From d8ec9ce76eb6486f71df53f1e1d50c566a46f4a1 Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Fri, 11 Nov 2016 15:33:13 +0100 Subject: [PATCH 01/16] Update Markdown to 7.x-1.5 --- .../markdown/includes/Markdown.inc.php | 10 +- .../contrib/markdown/includes/Markdown.php | 1274 ++++++++++------- .../markdown/includes/MarkdownExtra.inc.php | 10 +- .../markdown/includes/MarkdownExtra.php | 1186 ++++++++------- .../includes/MarkdownInterface.inc.php | 10 +- .../markdown/includes/MarkdownInterface.php | 60 +- .../modules/contrib/markdown/markdown.info | 6 +- 7 files changed, 1500 insertions(+), 1056 deletions(-) mode change 100644 => 100755 www7/sites/all/modules/contrib/markdown/includes/Markdown.inc.php mode change 100644 => 100755 www7/sites/all/modules/contrib/markdown/includes/Markdown.php mode change 100644 => 100755 www7/sites/all/modules/contrib/markdown/includes/MarkdownExtra.inc.php mode change 100644 => 100755 www7/sites/all/modules/contrib/markdown/includes/MarkdownExtra.php mode change 100644 => 100755 www7/sites/all/modules/contrib/markdown/includes/MarkdownInterface.inc.php mode change 100644 => 100755 www7/sites/all/modules/contrib/markdown/includes/MarkdownInterface.php diff --git a/www7/sites/all/modules/contrib/markdown/includes/Markdown.inc.php b/www7/sites/all/modules/contrib/markdown/includes/Markdown.inc.php old mode 100644 new mode 100755 index 8c281094c..e2bd3808e --- a/www7/sites/all/modules/contrib/markdown/includes/Markdown.inc.php +++ b/www7/sites/all/modules/contrib/markdown/includes/Markdown.inc.php @@ -1,10 +1,10 @@ -# -# Original Markdown -# Copyright (c) 2004-2006 John Gruber -# -# -namespace Michelf; - +/** + * Markdown - A text-to-HTML conversion tool for web writers + * + * @package php-markdown + * @author Michel Fortin + * @copyright 2004-2016 Michel Fortin + * @copyright (Original Markdown) 2004-2006 John Gruber + */ -# -# Markdown Parser Class -# +namespace Michelf; +/** + * Markdown Parser Class + */ class Markdown implements MarkdownInterface { - - ### Version ### - - const MARKDOWNLIB_VERSION = "1.6.0"; - - ### Simple Function Interface ### - + /** + * Define the package version + * @var string + */ + const MARKDOWNLIB_VERSION = "1.7.0"; + + /** + * Simple function interface - Initialize the parser and return the result + * of its transform method. This will work fine for derived classes too. + * + * @api + * + * @param string $text + * @return string + */ public static function defaultTransform($text) { - # - # Initialize the parser and return the result of its transform method. - # This will work fine for derived classes too. - # - # Take parser class on which this function was called. + // Take parser class on which this function was called. $parser_class = \get_called_class(); - # try to take parser from the static parser list + // Try to take parser from the static parser list static $parser_list; $parser =& $parser_list[$parser_class]; - # create the parser it not already set - if (!$parser) + // Create the parser it not already set + if (!$parser) { $parser = new $parser_class; + } - # Transform text using parser. + // Transform text using parser. return $parser->transform($text); } - ### Configuration Variables ### + /** + * Configuration variables + */ - # Change to ">" for HTML output. + /** + * Change to ">" for HTML output. + * @var string + */ public $empty_element_suffix = " />"; + + /** + * The width of indentation of the output markup + * @var int + */ public $tab_width = 4; - # Change to `true` to disallow markup or entities. - public $no_markup = false; + /** + * Change to `true` to disallow markup or entities. + * @var boolean + */ + public $no_markup = false; public $no_entities = false; - # Predefined urls and titles for reference links and images. - public $predef_urls = array(); + + /** + * Change to `true` to enable line breaks on \n without two trailling spaces + * @var boolean + */ + public $hard_wrap = false; + + /** + * Predefined URLs and titles for reference links and images. + * @var array + */ + public $predef_urls = array(); public $predef_titles = array(); - # Optional filter function for URLs + /** + * Optional filter function for URLs + * @var callable + */ public $url_filter_func = null; - # Optional header id="" generation callback function. + /** + * Optional header id="" generation callback function. + * @var callable + */ public $header_id_func = null; - # Optional function for converting code block content to HTML + /** + * Optional function for converting code block content to HTML + * @var callable + */ public $code_block_content_func = null; - # Class attribute to toggle "enhanced ordered list" behaviour - # setting this to true will allow ordered lists to start from the index - # number that is defined first. For example: - # 2. List item two - # 3. List item three - # - # becomes - #
    - #
  1. List item two
  2. - #
  3. List item three
  4. - #
+ /** + * Optional function for converting code span content to HTML. + * @var callable + */ + public $code_span_content_func = null; + + /** + * Class attribute to toggle "enhanced ordered list" behaviour + * setting this to true will allow ordered lists to start from the index + * number that is defined first. + * + * For example: + * 2. List item two + * 3. List item three + * + * Becomes: + *
    + *
  1. List item two
  2. + *
  3. List item three
  4. + *
+ * + * @var bool + */ public $enhanced_ordered_list = false; - ### Parser Implementation ### + /** + * Parser implementation + */ - # Regex to match balanced [brackets]. - # Needed to insert a maximum bracked depth while converting to PHP. + /** + * Regex to match balanced [brackets]. + * Needed to insert a maximum bracked depth while converting to PHP. + * @var int + */ protected $nested_brackets_depth = 6; protected $nested_brackets_re; - + protected $nested_url_parenthesis_depth = 4; protected $nested_url_parenthesis_re; - # Table of hash values for escaped characters: + /** + * Table of hash values for escaped characters: + * @var string + */ protected $escape_chars = '\`*_{}[]()>#+-.!'; protected $escape_chars_re; - + /** + * Constructor function. Initialize appropriate member variables. + * @return void + */ public function __construct() { - # - # Constructor function. Initialize appropriate member variables. - # $this->_initDetab(); $this->prepareItalicsAndBold(); @@ -113,51 +166,60 @@ public function __construct() { $this->escape_chars_re = '['.preg_quote($this->escape_chars).']'; - # Sort document, block, and span gamut in ascendent priority order. + // Sort document, block, and span gamut in ascendent priority order. asort($this->document_gamut); asort($this->block_gamut); asort($this->span_gamut); } - # Internal hashes used during transformation. - protected $urls = array(); - protected $titles = array(); + /** + * Internal hashes used during transformation. + * @var array + */ + protected $urls = array(); + protected $titles = array(); protected $html_hashes = array(); - # Status flag to avoid invalid nesting. + /** + * Status flag to avoid invalid nesting. + * @var boolean + */ protected $in_anchor = false; - + /** + * Called before the transformation process starts to setup parser states. + * @return void + */ protected function setup() { - # - # Called before the transformation process starts to setup parser - # states. - # - # Clear global hashes. - $this->urls = $this->predef_urls; - $this->titles = $this->predef_titles; + // Clear global hashes. + $this->urls = $this->predef_urls; + $this->titles = $this->predef_titles; $this->html_hashes = array(); - - $this->in_anchor = false; + $this->in_anchor = false; } + /** + * Called after the transformation process to clear any variable which may + * be taking up memory unnecessarly. + * @return void + */ protected function teardown() { - # - # Called after the transformation process to clear any variable - # which may be taking up memory unnecessarly. - # - $this->urls = array(); - $this->titles = array(); + $this->urls = array(); + $this->titles = array(); $this->html_hashes = array(); } - + /** + * Main function. Performs some preprocessing on the input text and pass + * it through the document gamut. + * + * @api + * + * @param string $text + * @return string + */ public function transform($text) { - # - # Main function. Performs some preprocessing on the input text - # and pass it through the document gamut. - # $this->setup(); # Remove UTF-8 BOM and marker character in input, if present. @@ -191,23 +253,28 @@ public function transform($text) { return $text . "\n"; } - + + /** + * Define the document gamut + * @var array + */ protected $document_gamut = array( - # Strip link definitions, store in hashes. + // Strip link definitions, store in hashes. "stripLinkDefinitions" => 20, - "runBasicBlockGamut" => 30, - ); - - + ); + + /** + * Strips link definitions from text, stores the URLs and titles in + * hash references + * @param string $text + * @return string + */ protected function stripLinkDefinitions($text) { - # - # Strips link definitions from text, stores the URLs and titles in - # hash references. - # + $less_than_tab = $this->tab_width - 1; - # Link defs are in the form: ^[id]: url "optional title" + // Link defs are in the form: ^[id]: url "optional title" $text = preg_replace_callback('{ ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 [ ]* @@ -231,43 +298,58 @@ protected function stripLinkDefinitions($text) { (?:\n+|\Z) }xm', array($this, '_stripLinkDefinitions_callback'), - $text); + $text + ); return $text; } + + /** + * The callback to strip link definitions + * @param array $matches + * @return string + */ protected function _stripLinkDefinitions_callback($matches) { $link_id = strtolower($matches[1]); $url = $matches[2] == '' ? $matches[3] : $matches[2]; $this->urls[$link_id] = $url; $this->titles[$link_id] =& $matches[4]; - return ''; # String that will replace the block + return ''; // String that will replace the block } - + /** + * Hashify HTML blocks + * @param string $text + * @return string + */ protected function hashHTMLBlocks($text) { - if ($this->no_markup) return $text; + if ($this->no_markup) { + return $text; + } $less_than_tab = $this->tab_width - 1; - # Hashify HTML blocks: - # We only want to do this for block-level HTML tags, such as headers, - # lists, and tables. That's because we still want to wrap

s around - # "paragraphs" that are wrapped in non-block-level tags, such as anchors, - # phrase emphasis, and spans. The list of tags we're looking for is - # hard-coded: - # - # * List "a" is made of tags which can be both inline or block-level. - # These will be treated block-level when the start tag is alone on - # its line, otherwise they're not matched here and will be taken as - # inline later. - # * List "b" is made of tags which are always block-level; - # + /** + * Hashify HTML blocks: + * + * We only want to do this for block-level HTML tags, such as headers, + * lists, and tables. That's because we still want to wrap

s around + * "paragraphs" that are wrapped in non-block-level tags, such as + * anchors, phrase emphasis, and spans. The list of tags we're looking + * for is hard-coded: + * + * * List "a" is made of tags which can be both inline or block-level. + * These will be treated block-level when the start tag is alone on + * its line, otherwise they're not matched here and will be taken as + * inline later. + * * List "b" is made of tags which are always block-level; + */ $block_tags_a_re = 'ins|del'; $block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'. 'script|noscript|style|form|fieldset|iframe|math|svg|'. 'article|section|nav|aside|hgroup|header|footer|'. 'figure'; - # Regular expression for the content of a block tag. + // Regular expression for the content of a block tag. $nested_tags_level = 4; $attr = ' (?> # optional tag attributes @@ -293,8 +375,8 @@ protected function hashHTMLBlocks($text) { (?> /> | - >', $nested_tags_level). # end of opening tag - '.*?'. # last level nested tag content + >', $nested_tags_level). // end of opening tag + '.*?'. // last level nested tag content str_repeat(' # closing nested tag ) @@ -305,17 +387,20 @@ protected function hashHTMLBlocks($text) { $nested_tags_level); $content2 = str_replace('\2', '\3', $content); - # First, look for nested blocks, e.g.: - #

- #
- # tags for inner block must be indented. - #
- #
- # - # The outermost tags must start at the left margin for this to match, and - # the inner nested divs must be indented. - # We need to do this before the next, more liberal match, because the next - # match will start at the first `
` and stop at the first `
`. + /** + * First, look for nested blocks, e.g.: + *
+ *
+ * tags for inner block must be indented. + *
+ *
+ * + * The outermost tags must start at the left margin for this to match, + * and the inner nested divs must be indented. + * We need to do this before the next, more liberal match, because the + * next match will start at the first `
` and stop at the + * first `
`. + */ $text = preg_replace_callback('{(?> (?> (?<=\n) # Starting on its own line @@ -378,94 +463,114 @@ protected function hashHTMLBlocks($text) { ) )}Sxmi', array($this, '_hashHTMLBlocks_callback'), - $text); + $text + ); return $text; } + + /** + * The callback for hashing HTML blocks + * @param string $matches + * @return string + */ protected function _hashHTMLBlocks_callback($matches) { $text = $matches[1]; $key = $this->hashBlock($text); return "\n\n$key\n\n"; } - + /** + * Called whenever a tag must be hashed when a function insert an atomic + * element in the text stream. Passing $text to through this function gives + * a unique text-token which will be reverted back when calling unhash. + * + * The $boundary argument specify what character should be used to surround + * the token. By convension, "B" is used for block elements that needs not + * to be wrapped into paragraph tags at the end, ":" is used for elements + * that are word separators and "X" is used in the general case. + * + * @param string $text + * @param string $boundary + * @return string + */ protected function hashPart($text, $boundary = 'X') { - # - # Called whenever a tag must be hashed when a function insert an atomic - # element in the text stream. Passing $text to through this function gives - # a unique text-token which will be reverted back when calling unhash. - # - # The $boundary argument specify what character should be used to surround - # the token. By convension, "B" is used for block elements that needs not - # to be wrapped into paragraph tags at the end, ":" is used for elements - # that are word separators and "X" is used in the general case. - # - # Swap back any tag hash found in $text so we do not have to `unhash` - # multiple times at the end. + // Swap back any tag hash found in $text so we do not have to `unhash` + // multiple times at the end. $text = $this->unhash($text); - # Then hash the block. + // Then hash the block. static $i = 0; $key = "$boundary\x1A" . ++$i . $boundary; $this->html_hashes[$key] = $text; - return $key; # String that will replace the tag. + return $key; // String that will replace the tag. } - + /** + * Shortcut function for hashPart with block-level boundaries. + * @param string $text + * @return string + */ protected function hashBlock($text) { - # - # Shortcut function for hashPart with block-level boundaries. - # return $this->hashPart($text, 'B'); } - + /** + * Define the block gamut - these are all the transformations that form + * block-level tags like paragraphs, headers, and list items. + * @var array + */ protected $block_gamut = array( - # - # These are all the transformations that form block-level - # tags like paragraphs, headers, and list items. - # "doHeaders" => 10, "doHorizontalRules" => 20, - "doLists" => 40, "doCodeBlocks" => 50, "doBlockQuotes" => 60, - ); - + ); + + /** + * Run block gamut tranformations. + * + * We need to escape raw HTML in Markdown source before doing anything + * else. This need to be done for each block, and not only at the + * begining in the Markdown function since hashed blocks can be part of + * list items and could have been indented. Indented blocks would have + * been seen as a code block in a previous pass of hashHTMLBlocks. + * + * @param string $text + * @return string + */ protected function runBlockGamut($text) { - # - # Run block gamut tranformations. - # - # We need to escape raw HTML in Markdown source before doing anything - # else. This need to be done for each block, and not only at the - # begining in the Markdown function since hashed blocks can be part of - # list items and could have been indented. Indented blocks would have - # been seen as a code block in a previous pass of hashHTMLBlocks. $text = $this->hashHTMLBlocks($text); - return $this->runBasicBlockGamut($text); } - + + /** + * Run block gamut tranformations, without hashing HTML blocks. This is + * useful when HTML blocks are known to be already hashed, like in the first + * whole-document pass. + * + * @param string $text + * @return string + */ protected function runBasicBlockGamut($text) { - # - # Run block gamut tranformations, without hashing HTML blocks. This is - # useful when HTML blocks are known to be already hashed, like in the first - # whole-document pass. - # + foreach ($this->block_gamut as $method => $priority) { $text = $this->$method($text); } - # Finally form paragraph and restore hashed blocks. + // Finally form paragraph and restore hashed blocks. $text = $this->formParagraphs($text); return $text; } - - + + /** + * Convert horizontal rules + * @param string $text + * @return string + */ protected function doHorizontalRules($text) { - # Do Horizontal Rules: return preg_replace( '{ ^[ ]{0,3} # Leading space @@ -478,66 +583,81 @@ protected function doHorizontalRules($text) { $ # End of line. }mx', "\n".$this->hashBlock("empty_element_suffix")."\n", - $text); + $text + ); } - + /** + * These are all the transformations that occur *within* block-level + * tags like paragraphs, headers, and list items. + * @var array + */ protected $span_gamut = array( - # - # These are all the transformations that occur *within* block-level - # tags like paragraphs, headers, and list items. - # - # Process character escapes, code spans, and inline HTML - # in one shot. + // Process character escapes, code spans, and inline HTML + // in one shot. "parseSpan" => -30, - - # Process anchor and image tags. Images must come first, - # because ![foo][f] looks like an anchor. + // Process anchor and image tags. Images must come first, + // because ![foo][f] looks like an anchor. "doImages" => 10, "doAnchors" => 20, - - # Make links out of things like `` - # Must come after doAnchors, because you can use < and > - # delimiters in inline links like [this](). + // Make links out of things like `` + // Must come after doAnchors, because you can use < and > + // delimiters in inline links like [this](). "doAutoLinks" => 30, "encodeAmpsAndAngles" => 40, - "doItalicsAndBold" => 50, "doHardBreaks" => 60, - ); + ); + /** + * Run span gamut transformations + * @param string $text + * @return string + */ protected function runSpanGamut($text) { - # - # Run span gamut tranformations. - # foreach ($this->span_gamut as $method => $priority) { $text = $this->$method($text); } return $text; } - - + + /** + * Do hard breaks + * @param string $text + * @return string + */ protected function doHardBreaks($text) { - # Do hard breaks: - return preg_replace_callback('/ {2,}\n/', - array($this, '_doHardBreaks_callback'), $text); + if ($this->hard_wrap) { + return preg_replace_callback('/ *\n/', + array($this, '_doHardBreaks_callback'), $text); + } else { + return preg_replace_callback('/ {2,}\n/', + array($this, '_doHardBreaks_callback'), $text); + } } + + /** + * Trigger part hashing for the hard break (callback method) + * @param array $matches + * @return string + */ protected function _doHardBreaks_callback($matches) { return $this->hashPart("empty_element_suffix\n"); } - + /** + * Turn Markdown link shortcuts into XHTML tags. + * @param string $text + * @return string + */ protected function doAnchors($text) { - # - # Turn Markdown link shortcuts into XHTML tags. - # - if ($this->in_anchor) return $text; + if ($this->in_anchor) { + return $text; + } $this->in_anchor = true; - # - # First, handle reference-style links: [link text] [id] - # + // First, handle reference-style links: [link text] [id] $text = preg_replace_callback('{ ( # wrap whole match in $1 \[ @@ -554,9 +674,7 @@ protected function doAnchors($text) { }xs', array($this, '_doAnchors_reference_callback'), $text); - # - # Next, inline-style links: [link text](url "optional title") - # + // Next, inline-style links: [link text](url "optional title") $text = preg_replace_callback('{ ( # wrap whole match in $1 \[ @@ -581,11 +699,9 @@ protected function doAnchors($text) { }xs', array($this, '_doAnchors_inline_callback'), $text); - # - # Last, handle reference-style shortcuts: [link text] - # These must come last in case you've also got [link text][1] - # or [link text](/foo) - # + // Last, handle reference-style shortcuts: [link text] + // These must come last in case you've also got [link text][1] + // or [link text](/foo) $text = preg_replace_callback('{ ( # wrap whole match in $1 \[ @@ -598,17 +714,23 @@ protected function doAnchors($text) { $this->in_anchor = false; return $text; } + + /** + * Callback method to parse referenced anchors + * @param string $matches + * @return string + */ protected function _doAnchors_reference_callback($matches) { $whole_match = $matches[1]; $link_text = $matches[2]; $link_id =& $matches[3]; if ($link_id == "") { - # for shortcut links like [this][] or [this]. + // for shortcut links like [this][] or [this]. $link_id = $link_text; } - # lower-case and turn embedded newlines into spaces + // lower-case and turn embedded newlines into spaces $link_id = strtolower($link_id); $link_id = preg_replace('{[ ]?\n}', ' ', $link_id); @@ -626,20 +748,26 @@ protected function _doAnchors_reference_callback($matches) { $link_text = $this->runSpanGamut($link_text); $result .= ">$link_text"; $result = $this->hashPart($result); - } - else { + } else { $result = $whole_match; } return $result; } + + /** + * Callback method to parse inline anchors + * @param string $matches + * @return string + */ protected function _doAnchors_inline_callback($matches) { $whole_match = $matches[1]; $link_text = $this->runSpanGamut($matches[2]); $url = $matches[3] == '' ? $matches[4] : $matches[3]; $title =& $matches[7]; - // if the URL was of the form it got caught by the HTML - // tag parser and hashed. Need to reverse the process before using the URL. + // If the URL was of the form it got caught by the HTML + // tag parser and hashed. Need to reverse the process before using + // the URL. $unhashed = $this->unhash($url); if ($unhashed != $url) $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); @@ -658,14 +786,13 @@ protected function _doAnchors_inline_callback($matches) { return $this->hashPart($result); } - + /** + * Turn Markdown image shortcuts into tags. + * @param string $text + * @return string + */ protected function doImages($text) { - # - # Turn Markdown image shortcuts into tags. - # - # - # First, handle reference-style labeled images: ![alt text][id] - # + // First, handle reference-style labeled images: ![alt text][id] $text = preg_replace_callback('{ ( # wrap whole match in $1 !\[ @@ -683,10 +810,8 @@ protected function doImages($text) { }xs', array($this, '_doImages_reference_callback'), $text); - # - # Next, handle inline images: ![alt text](url "optional title") - # Don't forget: encode * and _ - # + // Next, handle inline images: ![alt text](url "optional title") + // Don't forget: encode * and _ $text = preg_replace_callback('{ ( # wrap whole match in $1 !\[ @@ -714,13 +839,19 @@ protected function doImages($text) { return $text; } + + /** + * Callback to parse references image tags + * @param array $matches + * @return string + */ protected function _doImages_reference_callback($matches) { $whole_match = $matches[1]; $alt_text = $matches[2]; $link_id = strtolower($matches[3]); if ($link_id == "") { - $link_id = strtolower($alt_text); # for shortcut links like ![this][]. + $link_id = strtolower($alt_text); // for shortcut links like ![this][]. } $alt_text = $this->encodeAttribute($alt_text); @@ -734,14 +865,19 @@ protected function _doImages_reference_callback($matches) { } $result .= $this->empty_element_suffix; $result = $this->hashPart($result); - } - else { - # If there's no such link ID, leave intact: + } else { + // If there's no such link ID, leave intact: $result = $whole_match; } return $result; } + + /** + * Callback to parse inline image tags + * @param array $matches + * @return string + */ protected function _doImages_inline_callback($matches) { $whole_match = $matches[1]; $alt_text = $matches[2]; @@ -753,32 +889,38 @@ protected function _doImages_inline_callback($matches) { $result = "\"$alt_text\"";encodeAttribute($title); - $result .= " title=\"$title\""; # $title already quoted + $result .= " title=\"$title\""; // $title already quoted } $result .= $this->empty_element_suffix; return $this->hashPart($result); } - + /** + * Parse Markdown heading elements to HTML + * @param string $text + * @return string + */ protected function doHeaders($text) { - # Setext-style headers: - # Header 1 - # ======== - # - # Header 2 - # -------- - # + /** + * Setext-style headers: + * Header 1 + * ======== + * + * Header 2 + * -------- + */ $text = preg_replace_callback('{ ^(.+?)[ ]*\n(=+|-+)[ ]*\n+ }mx', array($this, '_doHeaders_callback_setext'), $text); - # atx-style headers: - # # Header 1 - # ## Header 2 - # ## Header 2 with closing hashes ## - # ... - # ###### Header 6 - # + /** + * atx-style headers: + * # Header 1 + * ## Header 2 + * ## Header 2 with closing hashes ## + * ... + * ###### Header 6 + */ $text = preg_replace_callback('{ ^(\#{1,6}) # $1 = string of #\'s [ ]* @@ -792,22 +934,33 @@ protected function doHeaders($text) { return $text; } + /** + * Setext header parsing callback + * @param array $matches + * @return string + */ protected function _doHeaders_callback_setext($matches) { - # Terrible hack to check we haven't found an empty list item. - if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1])) + // Terrible hack to check we haven't found an empty list item. + if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1])) { return $matches[0]; + } $level = $matches[2]{0} == '=' ? 1 : 2; - # id attribute generation + // ID attribute generation $idAtt = $this->_generateIdFromHeaderValue($matches[1]); $block = "".$this->runSpanGamut($matches[1]).""; return "\n" . $this->hashBlock($block) . "\n\n"; } - protected function _doHeaders_callback_atx($matches) { - # id attribute generation + /** + * ATX header parsing callback + * @param array $matches + * @return string + */ + protected function _doHeaders_callback_atx($matches) { + // ID attribute generation $idAtt = $this->_generateIdFromHeaderValue($matches[2]); $level = strlen($matches[1]); @@ -815,30 +968,37 @@ protected function _doHeaders_callback_atx($matches) { return "\n" . $this->hashBlock($block) . "\n\n"; } - protected function _generateIdFromHeaderValue($headerValue) { - - # if a header_id_func property is set, we can use it to automatically - # generate an id attribute. - # - # This method returns a string in the form id="foo", or an empty string - # otherwise. + /** + * If a header_id_func property is set, we can use it to automatically + * generate an id attribute. + * + * This method returns a string in the form id="foo", or an empty string + * otherwise. + * @param string $headerValue + * @return string + */ + protected function _generateIdFromHeaderValue($headerValue) { if (!is_callable($this->header_id_func)) { return ""; } + $idValue = call_user_func($this->header_id_func, $headerValue); - if (!$idValue) return ""; + if (!$idValue) { + return ""; + } return ' id="' . $this->encodeAttribute($idValue) . '"'; - } + /** + * Form HTML ordered (numbered) and unordered (bulleted) lists. + * @param string $text + * @return string + */ protected function doLists($text) { - # - # Form HTML ordered (numbered) and unordered (bulleted) lists. - # $less_than_tab = $this->tab_width - 1; - # Re-usable patterns to match list item bullets and number markers: + // Re-usable patterns to match list item bullets and number markers: $marker_ul_re = '[*+-]'; $marker_ol_re = '\d+[\.]'; @@ -848,7 +1008,7 @@ protected function doLists($text) { ); foreach ($markers_relist as $marker_re => $other_marker_re) { - # Re-usable pattern to match any entirel ul or ol list: + // Re-usable pattern to match any entirel ul or ol list: $whole_list_re = ' ( # $1 = whole list ( # $2 @@ -876,8 +1036,8 @@ protected function doLists($text) { ) '; // mx - # We use a different prefix before nested lists than top-level lists. - # See extended comment in _ProcessListItems(). + // We use a different prefix before nested lists than top-level lists. + //See extended comment in _ProcessListItems(). if ($this->list_level) { $text = preg_replace_callback('{ @@ -885,8 +1045,7 @@ protected function doLists($text) { '.$whole_list_re.' }mx', array($this, '_doLists_callback'), $text); - } - else { + } else { $text = preg_replace_callback('{ (?:(?<=\n)\n|\A\n?) # Must eat the newline '.$whole_list_re.' @@ -897,8 +1056,14 @@ protected function doLists($text) { return $text; } + + /** + * List parsing callback + * @param array $matches + * @return string + */ protected function _doLists_callback($matches) { - # Re-usable patterns to match list item bullets and number markers: + // Re-usable patterns to match list item bullets and number markers: $marker_ul_re = '[*+-]'; $marker_ol_re = '\d+[\.]'; $marker_any_re = "(?:$marker_ul_re|$marker_ol_re)"; @@ -914,7 +1079,7 @@ protected function _doLists_callback($matches) { $ol_start = 1; if ($this->enhanced_ordered_list) { - # Get the start number for ordered list. + // Get the start number for ordered list. if ($list_type == 'ol') { $ol_start_array = array(); $ol_start_check = preg_match("/$marker_ol_start_re/", $matches[4], $ol_start_array); @@ -932,37 +1097,45 @@ protected function _doLists_callback($matches) { return "\n". $result ."\n\n"; } + /** + * Nesting tracker for list levels + * @var integer + */ protected $list_level = 0; + /** + * Process the contents of a single ordered or unordered list, splitting it + * into individual list items. + * @param string $list_str + * @param string $marker_any_re + * @return string + */ protected function processListItems($list_str, $marker_any_re) { - # - # Process the contents of a single ordered or unordered list, splitting it - # into individual list items. - # - # The $this->list_level global keeps track of when we're inside a list. - # Each time we enter a list, we increment it; when we leave a list, - # we decrement. If it's zero, we're not in a list anymore. - # - # We do this because when we're not inside a list, we want to treat - # something like this: - # - # I recommend upgrading to version - # 8. Oops, now this line is treated - # as a sub-list. - # - # As a single paragraph, despite the fact that the second line starts - # with a digit-period-space sequence. - # - # Whereas when we're inside a list (or sub-list), that line will be - # treated as the start of a sub-list. What a kludge, huh? This is - # an aspect of Markdown's syntax that's hard to parse perfectly - # without resorting to mind-reading. Perhaps the solution is to - # change the syntax rules such that sub-lists must start with a - # starting cardinal number; e.g. "1." or "a.". - + /** + * The $this->list_level global keeps track of when we're inside a list. + * Each time we enter a list, we increment it; when we leave a list, + * we decrement. If it's zero, we're not in a list anymore. + * + * We do this because when we're not inside a list, we want to treat + * something like this: + * + * I recommend upgrading to version + * 8. Oops, now this line is treated + * as a sub-list. + * + * As a single paragraph, despite the fact that the second line starts + * with a digit-period-space sequence. + * + * Whereas when we're inside a list (or sub-list), that line will be + * treated as the start of a sub-list. What a kludge, huh? This is + * an aspect of Markdown's syntax that's hard to parse perfectly + * without resorting to mind-reading. Perhaps the solution is to + * change the syntax rules such that sub-lists must start with a + * starting cardinal number; e.g. "1." or "a.". + */ $this->list_level++; - # trim trailing blank lines: + // Trim trailing blank lines: $list_str = preg_replace("/\n{2,}\\z/", "\n", $list_str); $list_str = preg_replace_callback('{ @@ -980,6 +1153,12 @@ protected function processListItems($list_str, $marker_any_re) { $this->list_level--; return $list_str; } + + /** + * List item parsing callback + * @param array $matches + * @return string + */ protected function _processListItems_callback($matches) { $item = $matches[4]; $leading_line =& $matches[1]; @@ -990,25 +1169,24 @@ protected function _processListItems_callback($matches) { if ($leading_line || $tailing_blank_line || preg_match('/\n{2,}/', $item)) { - # Replace marker with the appropriate whitespace indentation + // Replace marker with the appropriate whitespace indentation $item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item; $item = $this->runBlockGamut($this->outdent($item)."\n"); - } - else { - # Recursion for sub-lists: + } else { + // Recursion for sub-lists: $item = $this->doLists($this->outdent($item)); - $item = preg_replace('/\n+$/', '', $item); - $item = $this->runSpanGamut($item); + $item = $this->formParagraphs($item, false); } return "
  • " . $item . "
  • \n"; } - + /** + * Process Markdown `
    ` blocks.
    +	 * @param  string $text
    +	 * @return string
    +	 */
     	protected function doCodeBlocks($text) {
    -	#
    -	#	Process Markdown `
    ` blocks.
    -	#
     		$text = preg_replace_callback('{
     				(?:\n\n|\A\n?)
     				(	            # $1 = the code block -- one or more lines, starting with a space/tab
    @@ -1023,6 +1201,12 @@ protected function doCodeBlocks($text) {
     
     		return $text;
     	}
    +
    +	/**
    +	 * Code block parsing callback
    +	 * @param  array $matches
    +	 * @return string
    +	 */
     	protected function _doCodeBlocks_callback($matches) {
     		$codeblock = $matches[1];
     
    @@ -1037,44 +1221,68 @@ protected function _doCodeBlocks_callback($matches) {
     		$codeblock = preg_replace('/\A\n+|\n+\z/', '', $codeblock);
     
     		$codeblock = "
    $codeblock\n
    "; - return "\n\n".$this->hashBlock($codeblock)."\n\n"; + return "\n\n" . $this->hashBlock($codeblock) . "\n\n"; } - + /** + * Create a code span markup for $code. Called from handleSpanToken. + * @param string $code + * @return string + */ protected function makeCodeSpan($code) { - # - # Create a code span markup for $code. Called from handleSpanToken. - # - $code = htmlspecialchars(trim($code), ENT_NOQUOTES); + if ($this->code_span_content_func) { + $code = call_user_func($this->code_span_content_func, $code); + } else { + $code = htmlspecialchars(trim($code), ENT_NOQUOTES); + } return $this->hashPart("$code"); } - + /** + * Define the emphasis operators with their regex matches + * @var array + */ protected $em_relist = array( '' => '(?:(? '(? '(? '(?:(? '(? '(? '(?:(? '(? '(?em_relist as $em => $em_re) { foreach ($this->strong_relist as $strong => $strong_re) { - # Construct list of allowed token expressions. + // Construct list of allowed token expressions. $token_relist = array(); if (isset($this->em_strong_relist["$em$strong"])) { $token_relist[] = $this->em_strong_relist["$em$strong"]; @@ -1082,13 +1290,18 @@ protected function prepareItalicsAndBold() { $token_relist[] = $em_re; $token_relist[] = $strong_re; - # Construct master expression from list. - $token_re = '{('. implode('|', $token_relist) .')}'; + // Construct master expression from list. + $token_re = '{(' . implode('|', $token_relist) . ')}'; $this->em_strong_prepared_relist["$em$strong"] = $token_re; } } } - + + /** + * Convert Markdown italics (emphasis) and bold (strong) to HTML + * @param string $text + * @return string + */ protected function doItalicsAndBold($text) { $token_stack = array(''); $text_stack = array(''); @@ -1097,24 +1310,20 @@ protected function doItalicsAndBold($text) { $tree_char_em = false; while (1) { - # - # Get prepared regular expression for seraching emphasis tokens - # in current context. - # + // Get prepared regular expression for seraching emphasis tokens + // in current context. $token_re = $this->em_strong_prepared_relist["$em$strong"]; - # - # Each loop iteration search for the next emphasis token. - # Each token is then passed to handleSpanToken. - # + // Each loop iteration search for the next emphasis token. + // Each token is then passed to handleSpanToken. $parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE); $text_stack[0] .= $parts[0]; $token =& $parts[1]; $text =& $parts[2]; if (empty($token)) { - # Reached end of text span: empty stack without emitting. - # any more emphasis. + // Reached end of text span: empty stack without emitting. + // any more emphasis. while ($token_stack[0]) { $text_stack[1] .= array_shift($token_stack); $text_stack[0] .= array_shift($text_stack); @@ -1124,9 +1333,9 @@ protected function doItalicsAndBold($text) { $token_len = strlen($token); if ($tree_char_em) { - # Reached closing marker while inside a three-char emphasis. + // Reached closing marker while inside a three-char emphasis. if ($token_len == 3) { - # Three-char closing marker, close em and strong. + // Three-char closing marker, close em and strong. array_shift($token_stack); $span = array_shift($text_stack); $span = $this->runSpanGamut($span); @@ -1135,21 +1344,21 @@ protected function doItalicsAndBold($text) { $em = ''; $strong = ''; } else { - # Other closing marker: close one em or strong and - # change current token state to match the other + // Other closing marker: close one em or strong and + // change current token state to match the other $token_stack[0] = str_repeat($token{0}, 3-$token_len); $tag = $token_len == 2 ? "strong" : "em"; $span = $text_stack[0]; $span = $this->runSpanGamut($span); $span = "<$tag>$span"; $text_stack[0] = $this->hashPart($span); - $$tag = ''; # $$tag stands for $em or $strong + $$tag = ''; // $$tag stands for $em or $strong } $tree_char_em = false; } else if ($token_len == 3) { if ($em) { - # Reached closing marker for both em and strong. - # Closing strong marker: + // Reached closing marker for both em and strong. + // Closing strong marker: for ($i = 0; $i < 2; ++$i) { $shifted_token = array_shift($token_stack); $tag = strlen($shifted_token) == 2 ? "strong" : "em"; @@ -1157,11 +1366,11 @@ protected function doItalicsAndBold($text) { $span = $this->runSpanGamut($span); $span = "<$tag>$span"; $text_stack[0] .= $this->hashPart($span); - $$tag = ''; # $$tag stands for $em or $strong + $$tag = ''; // $$tag stands for $em or $strong } } else { - # Reached opening three-char emphasis marker. Push on token - # stack; will be handled by the special condition above. + // Reached opening three-char emphasis marker. Push on token + // stack; will be handled by the special condition above. $em = $token{0}; $strong = "$em$em"; array_unshift($token_stack, $token); @@ -1170,12 +1379,12 @@ protected function doItalicsAndBold($text) { } } else if ($token_len == 2) { if ($strong) { - # Unwind any dangling emphasis marker: + // Unwind any dangling emphasis marker: if (strlen($token_stack[0]) == 1) { $text_stack[1] .= array_shift($token_stack); $text_stack[0] .= array_shift($text_stack); } - # Closing strong marker: + // Closing strong marker: array_shift($token_stack); $span = array_shift($text_stack); $span = $this->runSpanGamut($span); @@ -1188,10 +1397,10 @@ protected function doItalicsAndBold($text) { $strong = $token; } } else { - # Here $token_len == 1 + // Here $token_len == 1 if ($em) { if (strlen($token_stack[0]) == 1) { - # Closing emphasis marker: + // Closing emphasis marker: array_shift($token_stack); $span = array_shift($text_stack); $span = $this->runSpanGamut($span); @@ -1211,7 +1420,11 @@ protected function doItalicsAndBold($text) { return $text_stack[0]; } - + /** + * Parse Markdown blockquotes to HTML + * @param string $text + * @return string + */ protected function doBlockQuotes($text) { $text = preg_replace_callback('/ ( # Wrap whole match in $1 @@ -1227,51 +1440,64 @@ protected function doBlockQuotes($text) { return $text; } + + /** + * Blockquote parsing callback + * @param array $matches + * @return string + */ protected function _doBlockQuotes_callback($matches) { $bq = $matches[1]; - # trim one level of quoting - trim whitespace-only lines + // trim one level of quoting - trim whitespace-only lines $bq = preg_replace('/^[ ]*>[ ]?|^[ ]+$/m', '', $bq); - $bq = $this->runBlockGamut($bq); # recurse + $bq = $this->runBlockGamut($bq); // recurse $bq = preg_replace('/^/m', " ", $bq); - # These leading spaces cause problem with
     content, 
    -		# so we need to fix that:
    +		// These leading spaces cause problem with 
     content, 
    +		// so we need to fix that:
     		$bq = preg_replace_callback('{(\s*
    .+?
    )}sx', array($this, '_doBlockQuotes_callback2'), $bq); - return "\n". $this->hashBlock("
    \n$bq\n
    ")."\n\n"; + return "\n" . $this->hashBlock("
    \n$bq\n
    ") . "\n\n"; } + + /** + * Blockquote parsing callback + * @param array $matches + * @return string + */ protected function _doBlockQuotes_callback2($matches) { $pre = $matches[1]; $pre = preg_replace('/^ /m', '', $pre); return $pre; } - - protected function formParagraphs($text) { - # - # Params: - # $text - string to process with html

    tags - # - # Strip leading and trailing lines: + /** + * Parse paragraphs + * + * @param string $text String to process in paragraphs + * @param boolean $wrap_in_p Whether paragraphs should be wrapped in

    tags + * @return string + */ + protected function formParagraphs($text, $wrap_in_p = true) { + // Strip leading and trailing lines: $text = preg_replace('/\A\n+|\n+\z/', '', $text); $grafs = preg_split('/\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY); - # - # Wrap

    tags and unhashify HTML blocks - # + // Wrap

    tags and unhashify HTML blocks foreach ($grafs as $key => $value) { if (!preg_match('/^B\x1A[0-9]+B$/', $value)) { - # Is a paragraph. + // Is a paragraph. $value = $this->runSpanGamut($value); - $value = preg_replace('/^([ ]*)/', "

    ", $value); - $value .= "

    "; + if ($wrap_in_p) { + $value = preg_replace('/^([ ]*)/', "

    ", $value); + $value .= "

    "; + } $grafs[$key] = $this->unhash($value); - } - else { - # Is a block. - # Modify elements of @grafs in-place... + } else { + // Is a block. + // Modify elements of @grafs in-place... $graf = $value; $block = $this->html_hashes[$graf]; $graf = $block; @@ -1296,11 +1522,11 @@ protected function formParagraphs($text) { // { // list(, $div_open, , $div_content, $div_close) = $matches; // -// # We can't call Markdown(), because that resets the hash; -// # that initialization code should be pulled into its own sub, though. +// // We can't call Markdown(), because that resets the hash; +// // that initialization code should be pulled into its own sub, though. // $div_content = $this->hashHTMLBlocks($div_content); // -// # Run document gamut methods on the content. +// // Run document gamut methods on the content. // foreach ($this->document_gamut as $method => $priority) { // $div_content = $this->$method($div_content); // } @@ -1317,37 +1543,39 @@ protected function formParagraphs($text) { return implode("\n\n", $grafs); } - + /** + * Encode text for a double-quoted HTML attribute. This function + * is *not* suitable for attributes enclosed in single quotes. + * @param string $text + * @return string + */ protected function encodeAttribute($text) { - # - # Encode text for a double-quoted HTML attribute. This function - # is *not* suitable for attributes enclosed in single quotes. - # $text = $this->encodeAmpsAndAngles($text); $text = str_replace('"', '"', $text); return $text; } - + /** + * Encode text for a double-quoted HTML attribute containing a URL, + * applying the URL filter if set. Also generates the textual + * representation for the URL (removing mailto: or tel:) storing it in $text. + * This function is *not* suitable for attributes enclosed in single quotes. + * + * @param string $url + * @param string &$text Passed by reference + * @return string URL + */ protected function encodeURLAttribute($url, &$text = null) { - # - # Encode text for a double-quoted HTML attribute containing a URL, - # applying the URL filter if set. Also generates the textual - # representation for the URL (removing mailto: or tel:) storing it in $text. - # This function is *not* suitable for attributes enclosed in single quotes. - # - if ($this->url_filter_func) + if ($this->url_filter_func) { $url = call_user_func($this->url_filter_func, $url); + } - if (preg_match('{^mailto:}i', $url)) + if (preg_match('{^mailto:}i', $url)) { $url = $this->encodeEntityObfuscatedAttribute($url, $text, 7); - else if (preg_match('{^tel:}i', $url)) - { + } else if (preg_match('{^tel:}i', $url)) { $url = $this->encodeAttribute($url); $text = substr($url, 4); - } - else - { + } else { $url = $this->encodeAttribute($url); $text = $url; } @@ -1355,33 +1583,38 @@ protected function encodeURLAttribute($url, &$text = null) { return $url; } - + /** + * Smart processing for ampersands and angle brackets that need to + * be encoded. Valid character entities are left alone unless the + * no-entities mode is set. + * @param string $text + * @return string + */ protected function encodeAmpsAndAngles($text) { - # - # Smart processing for ampersands and angle brackets that need to - # be encoded. Valid character entities are left alone unless the - # no-entities mode is set. - # if ($this->no_entities) { $text = str_replace('&', '&', $text); } else { - # Ampersand-encoding based entirely on Nat Irons's Amputator - # MT plugin: + // Ampersand-encoding based entirely on Nat Irons's Amputator + // MT plugin: $text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/', '&', $text); } - # Encode remaining <'s + // Encode remaining <'s $text = str_replace('<', '<', $text); return $text; } - + /** + * Parse Markdown automatic links to anchor HTML tags + * @param string $text + * @return string + */ protected function doAutoLinks($text) { $text = preg_replace_callback('{<((https?|ftp|dict|tel):[^\'">\s]+)>}i', array($this, '_doAutoLinks_url_callback'), $text); - # Email addresses: + // Email addresses: $text = preg_replace_callback('{ < (?:mailto:)? @@ -1404,11 +1637,23 @@ protected function doAutoLinks($text) { return $text; } + + /** + * Parse URL callback + * @param array $matches + * @return string + */ protected function _doAutoLinks_url_callback($matches) { $url = $this->encodeURLAttribute($matches[1], $text); $link = "$text"; return $this->hashPart($link); } + + /** + * Parse email address callback + * @param array $matches + * @return string + */ protected function _doAutoLinks_email_callback($matches) { $addr = $matches[1]; $url = $this->encodeURLAttribute("mailto:$addr", $text); @@ -1416,42 +1661,52 @@ protected function _doAutoLinks_email_callback($matches) { return $this->hashPart($link); } - + /** + * Input: some text to obfuscate, e.g. "mailto:foo@example.com" + * + * Output: the same text but with most characters encoded as either a + * decimal or hex entity, in the hopes of foiling most address + * harvesting spam bots. E.g.: + * + * mailto:foo + * @example.co + * m + * + * Note: the additional output $tail is assigned the same value as the + * ouput, minus the number of characters specified by $head_length. + * + * Based by a filter by Matthew Wickline, posted to BBEdit-Talk. + * With some optimizations by Milian Wolff. Forced encoding of HTML + * attribute special characters by Allan Odgaard. + * + * @param string $text + * @param string &$tail + * @param integer $head_length + * @return string + */ protected function encodeEntityObfuscatedAttribute($text, &$tail = null, $head_length = 0) { - # - # Input: some text to obfuscate, e.g. "mailto:foo@example.com" - # - # Output: the same text but with most characters encoded as either a - # decimal or hex entity, in the hopes of foiling most address - # harvesting spam bots. E.g.: - # - # mailto:foo - # @example.co - # m - # - # Note: the additional output $tail is assigned the same value as the - # ouput, minus the number of characters specified by $head_length. - # - # Based by a filter by Matthew Wickline, posted to BBEdit-Talk. - # With some optimizations by Milian Wolff. Forced encoding of HTML - # attribute special characters by Allan Odgaard. - # - if ($text == "") return $tail = ""; + if ($text == "") { + return $tail = ""; + } $chars = preg_split('/(? $char) { $ord = ord($char); - # Ignore non-ascii chars. + // Ignore non-ascii chars. if ($ord < 128) { - $r = ($seed * (1 + $key)) % 100; # Pseudo-random function. - # roughly 10% raw, 45% hex, 45% dec - # '@' *must* be encoded. I insist. - # '"' and '>' have to be encoded inside the attribute - if ($r > 90 && strpos('@"&>', $char) === false) /* do nothing */; - else if ($r < 45) $chars[$key] = '&#x'.dechex($ord).';'; - else $chars[$key] = '&#'.$ord.';'; + $r = ($seed * (1 + $key)) % 100; // Pseudo-random function. + // roughly 10% raw, 45% hex, 45% dec + // '@' *must* be encoded. I insist. + // '"' and '>' have to be encoded inside the attribute + if ($r > 90 && strpos('@"&>', $char) === false) { + /* do nothing */ + } else if ($r < 45) { + $chars[$key] = '&#x'.dechex($ord).';'; + } else { + $chars[$key] = '&#'.$ord.';'; + } } } @@ -1461,12 +1716,13 @@ protected function encodeEntityObfuscatedAttribute($text, &$tail = null, $head_l return $text; } - + /** + * Take the string $str and parse it into tokens, hashing embeded HTML, + * escaped characters and handling code spans. + * @param string $str + * @return string + */ protected function parseSpan($str) { - # - # Take the string $str and parse it into tokens, hashing embeded HTML, - # escaped characters and handling code spans. - # $output = ''; $span_re = '{ @@ -1496,42 +1752,41 @@ protected function parseSpan($str) { }xs'; while (1) { - # - # Each loop iteration seach for either the next tag, the next - # openning code span marker, or the next escaped character. - # Each token is then passed to handleSpanToken. - # + // Each loop iteration seach for either the next tag, the next + // openning code span marker, or the next escaped character. + // Each token is then passed to handleSpanToken. $parts = preg_split($span_re, $str, 2, PREG_SPLIT_DELIM_CAPTURE); - # Create token from text preceding tag. + // Create token from text preceding tag. if ($parts[0] != "") { $output .= $parts[0]; } - # Check if we reach the end. + // Check if we reach the end. if (isset($parts[1])) { $output .= $this->handleSpanToken($parts[1], $parts[2]); $str = $parts[2]; - } - else { + } else { break; } } return $output; } - - + + /** + * Handle $token provided by parseSpan by determining its nature and + * returning the corresponding value that should replace it. + * @param string $token + * @param string &$str + * @return string + */ protected function handleSpanToken($token, &$str) { - # - # Handle $token provided by parseSpan by determining its nature and - # returning the corresponding value that should replace it. - # switch ($token{0}) { case "\\": return $this->hashPart("&#". ord($token{1}). ";"); case "`": - # Search for end marker in remaining text. + // Search for end marker in remaining text. if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm', $str, $matches)) { @@ -1539,78 +1794,103 @@ protected function handleSpanToken($token, &$str) { $codespan = $this->makeCodeSpan($matches[1]); return $this->hashPart($codespan); } - return $token; // return as text since no ending marker found. + return $token; // Return as text since no ending marker found. default: return $this->hashPart($token); } } - + /** + * Remove one level of line-leading tabs or spaces + * @param string $text + * @return string + */ protected function outdent($text) { - # - # Remove one level of line-leading tabs or spaces - # - return preg_replace('/^(\t|[ ]{1,'.$this->tab_width.'})/m', '', $text); + return preg_replace('/^(\t|[ ]{1,' . $this->tab_width . '})/m', '', $text); } - # String length function for detab. `_initDetab` will create a function to - # hanlde UTF-8 if the default function does not exist. + /** + * String length function for detab. `_initDetab` will create a function to + * handle UTF-8 if the default function does not exist. + * @var string + */ protected $utf8_strlen = 'mb_strlen'; - - protected function detab($text) { - # - # Replace tabs with the appropriate amount of space. - # - # For each line we separate the line in blocks delemited by - # tab characters. Then we reconstruct every line by adding the - # appropriate number of space between each blocks. - + + /** + * Replace tabs with the appropriate amount of spaces. + * + * For each line we separate the line in blocks delemited by tab characters. + * Then we reconstruct every line by adding the appropriate number of space + * between each blocks. + * + * @param string $text + * @return string + */ + protected function detab($text) { $text = preg_replace_callback('/^.*\t.*$/m', array($this, '_detab_callback'), $text); return $text; } + + /** + * Replace tabs callback + * @param string $matches + * @return string + */ protected function _detab_callback($matches) { $line = $matches[0]; - $strlen = $this->utf8_strlen; # strlen function for UTF-8. + $strlen = $this->utf8_strlen; // strlen function for UTF-8. - # Split in blocks. + // Split in blocks. $blocks = explode("\t", $line); - # Add each blocks to the line. + // Add each blocks to the line. $line = $blocks[0]; - unset($blocks[0]); # Do not add first block twice. + unset($blocks[0]); // Do not add first block twice. foreach ($blocks as $block) { - # Calculate amount of space, insert spaces, insert block. + // Calculate amount of space, insert spaces, insert block. $amount = $this->tab_width - $strlen($line, 'UTF-8') % $this->tab_width; $line .= str_repeat(" ", $amount) . $block; } return $line; } + + /** + * Check for the availability of the function in the `utf8_strlen` property + * (initially `mb_strlen`). If the function is not available, create a + * function that will loosely count the number of UTF-8 characters with a + * regular expression. + * @return void + */ protected function _initDetab() { - # - # Check for the availability of the function in the `utf8_strlen` property - # (initially `mb_strlen`). If the function is not available, create a - # function that will loosely count the number of UTF-8 characters with a - # regular expression. - # - if (function_exists($this->utf8_strlen)) return; + + if (function_exists($this->utf8_strlen)) { + return; + } + $this->utf8_strlen = create_function('$text', 'return preg_match_all( "/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/", $text, $m);'); } - + /** + * Swap back in all the tags hashed by _HashHTMLBlocks. + * @param string $text + * @return string + */ protected function unhash($text) { - # - # Swap back in all the tags hashed by _HashHTMLBlocks. - # return preg_replace_callback('/(.)\x1A[0-9]+\1/', array($this, '_unhash_callback'), $text); } + + /** + * Unhashing callback + * @param array $matches + * @return string + */ protected function _unhash_callback($matches) { return $this->html_hashes[$matches[0]]; } - } diff --git a/www7/sites/all/modules/contrib/markdown/includes/MarkdownExtra.inc.php b/www7/sites/all/modules/contrib/markdown/includes/MarkdownExtra.inc.php old mode 100644 new mode 100755 index e11b1ef97..d09bd7a48 --- a/www7/sites/all/modules/contrib/markdown/includes/MarkdownExtra.inc.php +++ b/www7/sites/all/modules/contrib/markdown/includes/MarkdownExtra.inc.php @@ -1,10 +1,10 @@ -# -# Original Markdown -# Copyright (c) 2004-2006 John Gruber -# -# -namespace Michelf; - +/** + * Markdown Extra - A text-to-HTML conversion tool for web writers + * + * @package php-markdown + * @author Michel Fortin + * @copyright 2004-2016 Michel Fortin + * @copyright (Original Markdown) 2004-2006 John Gruber + */ -# -# Markdown Extra Parser Class -# +namespace Michelf; +/** + * Markdown Extra Parser Class + */ class MarkdownExtra extends \Michelf\Markdown { - - ### Configuration Variables ### - - # Prefix for footnote ids. + /** + * Configuration variables + */ + + /** + * Prefix for footnote ids. + * @var string + */ public $fn_id_prefix = ""; - # Optional title attribute for footnote links and backlinks. - public $fn_link_title = ""; + /** + * Optional title attribute for footnote links and backlinks. + * @var string + */ + public $fn_link_title = ""; public $fn_backlink_title = ""; - # Optional class attribute for footnote links and backlinks. - public $fn_link_class = "footnote-ref"; + /** + * Optional class attribute for footnote links and backlinks. + * @var string + */ + public $fn_link_class = "footnote-ref"; public $fn_backlink_class = "footnote-backref"; - # Content to be displayed within footnote backlinks. The default is '↩'; - # the U+FE0E on the end is a Unicode variant selector used to prevent iOS - # from displaying the arrow character as an emoji. + /** + * Content to be displayed within footnote backlinks. The default is '↩'; + * the U+FE0E on the end is a Unicode variant selector used to prevent iOS + * from displaying the arrow character as an emoji. + * @var string + */ public $fn_backlink_html = '↩︎'; - # Class name for table cell alignment (%% replaced left/center/right) - # For instance: 'go-%%' becomes 'go-left' or 'go-right' or 'go-center' - # If empty, the align attribute is used instead of a class name. + /** + * Class name for table cell alignment (%% replaced left/center/right) + * For instance: 'go-%%' becomes 'go-left' or 'go-right' or 'go-center' + * If empty, the align attribute is used instead of a class name. + * @var string + */ public $table_align_class_tmpl = ''; - # Optional class prefix for fenced code block. + /** + * Optional class prefix for fenced code block. + * @var string + */ public $code_class_prefix = ""; - # Class attribute for code blocks goes on the `code` tag; - # setting this to true will put attributes on the `pre` tag instead. + + /** + * Class attribute for code blocks goes on the `code` tag; + * setting this to true will put attributes on the `pre` tag instead. + * @var boolean + */ public $code_attr_on_pre = false; - # Predefined abbreviations. + /** + * Predefined abbreviations. + * @var array + */ public $predef_abbr = array(); - ### Parser Implementation ### - + /** + * Parser implementation + */ + + /** + * Constructor function. Initialize the parser object. + * @return void + */ public function __construct() { - # - # Constructor function. Initialize the parser object. - # - # Add extra escapable characters before parent constructor - # initialize the table. + // Add extra escapable characters before parent constructor + // initialize the table. $this->escape_chars .= ':|'; - # Insert extra document, block, and span transformations. - # Parent constructor will do the sorting. + // Insert extra document, block, and span transformations. + // Parent constructor will do the sorting. $this->document_gamut += array( "doFencedCodeBlocks" => 5, "stripFootnotes" => 15, "stripAbbreviations" => 25, "appendFootnotes" => 50, - ); + ); $this->block_gamut += array( "doFencedCodeBlocks" => 5, "doTables" => 15, "doDefLists" => 45, - ); + ); $this->span_gamut += array( "doFootnotes" => 5, "doAbbreviations" => 70, - ); + ); $this->enhanced_ordered_list = true; parent::__construct(); } - # Extra variables used during extra transformations. + /** + * Extra variables used during extra transformations. + * @var array + */ protected $footnotes = array(); protected $footnotes_ordered = array(); protected $footnotes_ref_count = array(); protected $footnotes_numbers = array(); protected $abbr_desciptions = array(); + /** @var @string */ protected $abbr_word_re = ''; - # Give the current footnote number. + /** + * Give the current footnote number. + * @var integer + */ protected $footnote_counter = 1; - + /** + * Setting up Extra-specific variables. + */ protected function setup() { - # - # Setting up Extra-specific variables. - # parent::setup(); $this->footnotes = array(); @@ -117,11 +148,11 @@ protected function setup() { $this->abbr_desciptions[$abbr_word] = trim($abbr_desc); } } - + + /** + * Clearing Extra-specific variables. + */ protected function teardown() { - # - # Clearing Extra-specific variables. - # $this->footnotes = array(); $this->footnotes_ordered = array(); $this->footnotes_ref_count = array(); @@ -133,30 +164,45 @@ protected function teardown() { } - ### Extra Attribute Parser ### - - # Expression to use to catch attributes (includes the braces) + /** + * Extra attribute parser + */ + + /** + * Expression to use to catch attributes (includes the braces) + * @var string + */ protected $id_class_attr_catch_re = '\{((?>[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,})[ ]*\}'; - # Expression to use when parsing in a context when no capture is desired + + /** + * Expression to use when parsing in a context when no capture is desired + * @var string + */ protected $id_class_attr_nocatch_re = '\{(?>[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,}[ ]*\}'; + /** + * Parse attributes caught by the $this->id_class_attr_catch_re expression + * and return the HTML-formatted list of attributes. + * + * Currently supported attributes are .class and #id. + * + * In addition, this method also supports supplying a default Id value, + * which will be used to populate the id attribute in case it was not + * overridden. + * @param string $tag_name + * @param string $attr + * @param mixed $defaultIdValue + * @param array $classes + * @return string + */ protected function doExtraAttributes($tag_name, $attr, $defaultIdValue = null, $classes = array()) { - # - # Parse attributes caught by the $this->id_class_attr_catch_re expression - # and return the HTML-formatted list of attributes. - # - # Currently supported attributes are .class and #id. - # - # In addition, this method also supports supplying a default Id value, - # which will be used to populate the id attribute in case it was not - # overridden. if (empty($attr) && !$defaultIdValue && empty($classes)) return ""; - # Split on components + // Split on components preg_match_all('/[#.a-z][-_:a-zA-Z0-9=]+/', $attr, $matches); $elements = $matches[0]; - # handle classes and ids (only first id taken into account) + // Handle classes and IDs (only first ID taken into account) $attributes = array(); $id = false; foreach ($elements as $element) { @@ -172,7 +218,7 @@ protected function doExtraAttributes($tag_name, $attr, $defaultIdValue = null, $ if (!$id) $id = $defaultIdValue; - # compose attributes as string + // Compose attributes as string $attr_str = ""; if (!empty($id)) { $attr_str .= ' id="'.$this->encodeAttribute($id) .'"'; @@ -186,15 +232,16 @@ protected function doExtraAttributes($tag_name, $attr, $defaultIdValue = null, $ return $attr_str; } - + /** + * Strips link definitions from text, stores the URLs and titles in + * hash references. + * @param string $text + * @return string + */ protected function stripLinkDefinitions($text) { - # - # Strips link definitions from text, stores the URLs and titles in - # hash references. - # $less_than_tab = $this->tab_width - 1; - # Link defs are in the form: ^[id]: url "optional title" + // Link defs are in the form: ^[id]: url "optional title" $text = preg_replace_callback('{ ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 [ ]* @@ -222,91 +269,123 @@ protected function stripLinkDefinitions($text) { $text); return $text; } + + /** + * Strip link definition callback + * @param array $matches + * @return string + */ protected function _stripLinkDefinitions_callback($matches) { $link_id = strtolower($matches[1]); $url = $matches[2] == '' ? $matches[3] : $matches[2]; $this->urls[$link_id] = $url; $this->titles[$link_id] =& $matches[4]; $this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy =& $matches[5]); - return ''; # String that will replace the block + return ''; // String that will replace the block } - ### HTML Block Parser ### + /** + * HTML block parser + */ - # Tags that are always treated as block tags: + /** + * Tags that are always treated as block tags + * @var string + */ protected $block_tags_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption|figure'; - # Tags treated as block tags only if the opening tag is alone on its line: + /** + * Tags treated as block tags only if the opening tag is alone on its line + * @var string + */ protected $context_block_tags_re = 'script|noscript|style|ins|del|iframe|object|source|track|param|math|svg|canvas|audio|video'; - # Tags where markdown="1" default to span mode: + /** + * Tags where markdown="1" default to span mode: + * @var string + */ protected $contain_span_tags_re = 'p|h[1-6]|li|dd|dt|td|th|legend|address'; - # Tags which must not have their contents modified, no matter where - # they appear: + /** + * Tags which must not have their contents modified, no matter where + * they appear + * @var string + */ protected $clean_tags_re = 'script|style|math|svg'; - # Tags that do not need to be closed. + /** + * Tags that do not need to be closed. + * @var string + */ protected $auto_close_tags_re = 'hr|img|param|source|track'; - + /** + * Hashify HTML Blocks and "clean tags". + * + * We only want to do this for block-level HTML tags, such as headers, + * lists, and tables. That's because we still want to wrap

    s around + * "paragraphs" that are wrapped in non-block-level tags, such as anchors, + * phrase emphasis, and spans. The list of tags we're looking for is + * hard-coded. + * + * This works by calling _HashHTMLBlocks_InMarkdown, which then calls + * _HashHTMLBlocks_InHTML when it encounter block tags. When the markdown="1" + * attribute is found within a tag, _HashHTMLBlocks_InHTML calls back + * _HashHTMLBlocks_InMarkdown to handle the Markdown syntax within the tag. + * These two functions are calling each other. It's recursive! + * @param string $text + * @return string + */ protected function hashHTMLBlocks($text) { - # - # Hashify HTML Blocks and "clean tags". - # - # We only want to do this for block-level HTML tags, such as headers, - # lists, and tables. That's because we still want to wrap

    s around - # "paragraphs" that are wrapped in non-block-level tags, such as anchors, - # phrase emphasis, and spans. The list of tags we're looking for is - # hard-coded. - # - # This works by calling _HashHTMLBlocks_InMarkdown, which then calls - # _HashHTMLBlocks_InHTML when it encounter block tags. When the markdown="1" - # attribute is found within a tag, _HashHTMLBlocks_InHTML calls back - # _HashHTMLBlocks_InMarkdown to handle the Markdown syntax within the tag. - # These two functions are calling each other. It's recursive! - # - if ($this->no_markup) return $text; - - # - # Call the HTML-in-Markdown hasher. - # + if ($this->no_markup) { + return $text; + } + + // Call the HTML-in-Markdown hasher. list($text, ) = $this->_hashHTMLBlocks_inMarkdown($text); return $text; } + + /** + * Parse markdown text, calling _HashHTMLBlocks_InHTML for block tags. + * + * * $indent is the number of space to be ignored when checking for code + * blocks. This is important because if we don't take the indent into + * account, something like this (which looks right) won't work as expected: + * + *

    + *
    + * Hello World. <-- Is this a Markdown code block or text? + *
    <-- Is this a Markdown code block or a real tag? + *
    + * + * If you don't like this, just don't indent the tag on which + * you apply the markdown="1" attribute. + * + * * If $enclosing_tag_re is not empty, stops at the first unmatched closing + * tag with that name. Nested tags supported. + * + * * If $span is true, text inside must treated as span. So any double + * newline will be replaced by a single newline so that it does not create + * paragraphs. + * + * Returns an array of that form: ( processed text , remaining text ) + * + * @param string $text + * @param integer $indent + * @param string $enclosing_tag_re + * @param boolean $span + * @return array + */ protected function _hashHTMLBlocks_inMarkdown($text, $indent = 0, $enclosing_tag_re = '', $span = false) { - # - # Parse markdown text, calling _HashHTMLBlocks_InHTML for block tags. - # - # * $indent is the number of space to be ignored when checking for code - # blocks. This is important because if we don't take the indent into - # account, something like this (which looks right) won't work as expected: - # - #
    - #
    - # Hello World. <-- Is this a Markdown code block or text? - #
    <-- Is this a Markdown code block or a real tag? - #
    - # - # If you don't like this, just don't indent the tag on which - # you apply the markdown="1" attribute. - # - # * If $enclosing_tag_re is not empty, stops at the first unmatched closing - # tag with that name. Nested tags supported. - # - # * If $span is true, text inside must treated as span. So any double - # newline will be replaced by a single newline so that it does not create - # paragraphs. - # - # Returns an array of that form: ( processed text , remaining text ) - # + if ($text === '') return array('', ''); - # Regex to check for the presense of newlines around a block tag. + // Regex to check for the presense of newlines around a block tag. $newline_before_re = '/(?:^\n?|\n\n)*$/'; $newline_after_re = '{ @@ -315,16 +394,16 @@ protected function _hashHTMLBlocks_inMarkdown($text, $indent = 0, [ ]*\n # Must be followed by newline. }xs'; - # Regex to match any tag. + // Regex to match any tag. $block_tag_re = '{ ( # $2: Capture whole tag. # Tag name. - '.$this->block_tags_re.' | - '.$this->context_block_tags_re.' | - '.$this->clean_tags_re.' | - (?!\s)'.$enclosing_tag_re.' + ' . $this->block_tags_re . ' | + ' . $this->context_block_tags_re . ' | + ' . $this->clean_tags_re . ' | + (?!\s)'.$enclosing_tag_re . ' ) (?: (?=[\s"\'/a-zA-Z0-9]) # Allowed characters after tag name. @@ -341,25 +420,25 @@ protected function _hashHTMLBlocks_inMarkdown($text, $indent = 0, <\?.*?\?> | <%.*?%> # Processing instruction | # CData Block - '. ( !$span ? ' # If not in span. + ' . ( !$span ? ' # If not in span. | # Indented code block (?: ^[ ]*\n | ^ | \n[ ]*\n ) - [ ]{'.($indent+4).'}[^\n]* \n + [ ]{' . ($indent + 4) . '}[^\n]* \n (?> - (?: [ ]{'.($indent+4).'}[^\n]* | [ ]* ) \n + (?: [ ]{' . ($indent + 4) . '}[^\n]* | [ ]* ) \n )* | # Fenced code block marker (?<= ^ | \n ) - [ ]{0,'.($indent+3).'}(?:~{3,}|`{3,}) + [ ]{0,' . ($indent + 3) . '}(?:~{3,}|`{3,}) [ ]* (?: \.?[-_:a-zA-Z0-9]+ )? # standalone class name [ ]* - (?: '.$this->id_class_attr_nocatch_re.' )? # extra attributes + (?: ' . $this->id_class_attr_nocatch_re . ' )? # extra attributes [ ]* (?= \n ) - ' : '' ). ' # End (if not is span). + ' : '' ) . ' # End (if not is span). | # Code span marker # Note, this regex needs to go after backtick fenced @@ -370,141 +449,121 @@ protected function _hashHTMLBlocks_inMarkdown($text, $indent = 0, }xs'; - $depth = 0; # Current depth inside the tag tree. - $parsed = ""; # Parsed text that will be returned. + $depth = 0; // Current depth inside the tag tree. + $parsed = ""; // Parsed text that will be returned. - # - # Loop through every tag until we find the closing tag of the parent - # or loop until reaching the end of text if no parent tag specified. - # + // Loop through every tag until we find the closing tag of the parent + // or loop until reaching the end of text if no parent tag specified. do { - # - # Split the text using the first $tag_match pattern found. - # Text before pattern will be first in the array, text after - # pattern will be at the end, and between will be any catches made - # by the pattern. - # + // Split the text using the first $tag_match pattern found. + // Text before pattern will be first in the array, text after + // pattern will be at the end, and between will be any catches made + // by the pattern. $parts = preg_split($block_tag_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE); - # If in Markdown span mode, add a empty-string span-level hash - # after each newline to prevent triggering any block element. + // If in Markdown span mode, add a empty-string span-level hash + // after each newline to prevent triggering any block element. if ($span) { $void = $this->hashPart("", ':'); - $newline = "$void\n"; + $newline = "\n$void"; $parts[0] = $void . str_replace("\n", $newline, $parts[0]) . $void; } - $parsed .= $parts[0]; # Text before current tag. + $parsed .= $parts[0]; // Text before current tag. - # If end of $text has been reached. Stop loop. + // If end of $text has been reached. Stop loop. if (count($parts) < 3) { $text = ""; break; } - $tag = $parts[1]; # Tag to handle. - $text = $parts[2]; # Remaining text after current tag. - $tag_re = preg_quote($tag); # For use in a regular expression. + $tag = $parts[1]; // Tag to handle. + $text = $parts[2]; // Remaining text after current tag. + $tag_re = preg_quote($tag); // For use in a regular expression. - # - # Check for: Fenced code block marker. - # Note: need to recheck the whole tag to disambiguate backtick - # fences from code spans - # - if (preg_match('{^\n?([ ]{0,'.($indent+3).'})(~{3,}|`{3,})[ ]*(?:\.?[-_:a-zA-Z0-9]+)?[ ]*(?:'.$this->id_class_attr_nocatch_re.')?[ ]*\n?$}', $tag, $capture)) { - # Fenced code block marker: find matching end marker. - $fence_indent = strlen($capture[1]); # use captured indent in re - $fence_re = $capture[2]; # use captured fence in re - if (preg_match('{^(?>.*\n)*?[ ]{'.($fence_indent).'}'.$fence_re.'[ ]*(?:\n|$)}', $text, + // Check for: Fenced code block marker. + // Note: need to recheck the whole tag to disambiguate backtick + // fences from code spans + if (preg_match('{^\n?([ ]{0,' . ($indent + 3) . '})(~{3,}|`{3,})[ ]*(?:\.?[-_:a-zA-Z0-9]+)?[ ]*(?:' . $this->id_class_attr_nocatch_re . ')?[ ]*\n?$}', $tag, $capture)) { + // Fenced code block marker: find matching end marker. + $fence_indent = strlen($capture[1]); // use captured indent in re + $fence_re = $capture[2]; // use captured fence in re + if (preg_match('{^(?>.*\n)*?[ ]{' . ($fence_indent) . '}' . $fence_re . '[ ]*(?:\n|$)}', $text, $matches)) { - # End marker found: pass text unchanged until marker. + // End marker found: pass text unchanged until marker. $parsed .= $tag . $matches[0]; $text = substr($text, strlen($matches[0])); } else { - # No end marker: just skip it. + // No end marker: just skip it. $parsed .= $tag; } } - # - # Check for: Indented code block. - # + // Check for: Indented code block. else if ($tag{0} == "\n" || $tag{0} == " ") { - # Indented code block: pass it unchanged, will be handled - # later. + // Indented code block: pass it unchanged, will be handled + // later. $parsed .= $tag; } - # - # Check for: Code span marker - # Note: need to check this after backtick fenced code blocks - # + // Check for: Code span marker + // Note: need to check this after backtick fenced code blocks else if ($tag{0} == "`") { - # Find corresponding end marker. + // Find corresponding end marker. $tag_re = preg_quote($tag); - if (preg_match('{^(?>.+?|\n(?!\n))*?(?.+?|\n(?!\n))*?(?block_tags_re.')\b}', $tag) || - ( preg_match('{^<(?:'.$this->context_block_tags_re.')\b}', $tag) && + // Check for: Opening Block level tag or + // Opening Context Block tag (like ins and del) + // used as a block tag (tag is alone on it's line). + else if (preg_match('{^<(?:' . $this->block_tags_re . ')\b}', $tag) || + ( preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) && preg_match($newline_before_re, $parsed) && preg_match($newline_after_re, $text) ) ) { - # Need to parse tag and following text using the HTML parser. + // Need to parse tag and following text using the HTML parser. list($block_text, $text) = $this->_hashHTMLBlocks_inHTML($tag . $text, "hashBlock", true); - # Make sure it stays outside of any paragraph by adding newlines. + // Make sure it stays outside of any paragraph by adding newlines. $parsed .= "\n\n$block_text\n\n"; } - # - # Check for: Clean tag (like script, math) - # HTML Comments, processing instructions. - # - else if (preg_match('{^<(?:'.$this->clean_tags_re.')\b}', $tag) || + // Check for: Clean tag (like script, math) + // HTML Comments, processing instructions. + else if (preg_match('{^<(?:' . $this->clean_tags_re . ')\b}', $tag) || $tag{1} == '!' || $tag{1} == '?') { - # Need to parse tag and following text using the HTML parser. - # (don't check for markdown attribute) + // Need to parse tag and following text using the HTML parser. + // (don't check for markdown attribute) list($block_text, $text) = $this->_hashHTMLBlocks_inHTML($tag . $text, "hashClean", false); $parsed .= $block_text; } - # - # Check for: Tag with same name as enclosing tag. - # + // Check for: Tag with same name as enclosing tag. else if ($enclosing_tag_re !== '' && - # Same name as enclosing tag. - preg_match('{^) - # Comments and Processing Instructions. - # - if (preg_match('{^auto_close_tags_re.')\b}', $tag) || + // Check for: Auto-close tag (like
    ) + // Comments and Processing Instructions. + if (preg_match('{^auto_close_tags_re . ')\b}', $tag) || $tag{1} == '!' || $tag{1} == '?') { - # Just add the tag to the block as if it was text. + // Just add the tag to the block as if it was text. $block_text .= $tag; } else { - # - # Increase/decrease nested tag count. Only do so if - # the tag's name match base tag's. - # - if (preg_match('{^mode = $attr_m[2] . $attr_m[3]; $span_mode = $this->mode == 'span' || $this->mode != 'block' && - preg_match('{^<(?:'.$this->contain_span_tags_re.')\b}', $tag); + preg_match('{^<(?:' . $this->contain_span_tags_re . ')\b}', $tag); - # Calculate indent before tag. + // Calculate indent before tag. if (preg_match('/(?:^|\n)( *?)(?! ).*?$/', $block_text, $matches)) { $strlen = $this->utf8_strlen; $indent = $strlen($matches[1], 'UTF-8'); @@ -652,31 +702,31 @@ protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) { $indent = 0; } - # End preceding block with this tag. + // End preceding block with this tag. $block_text .= $tag; $parsed .= $this->$hash_method($block_text); - # Get enclosing tag name for the ParseMarkdown function. - # (This pattern makes $tag_name_re safe without quoting.) + // Get enclosing tag name for the ParseMarkdown function. + // (This pattern makes $tag_name_re safe without quoting.) preg_match('/^<([\w:$]*)\b/', $tag, $matches); $tag_name_re = $matches[1]; - # Parse the content using the HTML-in-Markdown parser. + // Parse the content using the HTML-in-Markdown parser. list ($block_text, $text) = $this->_hashHTMLBlocks_inMarkdown($text, $indent, $tag_name_re, $span_mode); - # Outdent markdown text. + // Outdent markdown text. if ($indent > 0) { $block_text = preg_replace("/^[ ]{1,$indent}/m", "", $block_text); } - # Append tag content to parsed text. + // Append tag content to parsed text. if (!$span_mode) $parsed .= "\n\n$block_text\n\n"; else $parsed .= "$block_text"; - # Start over with a new block. + // Start over with a new block. $block_text = ""; } else $block_text .= $tag; @@ -684,39 +734,39 @@ protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) { } while ($depth > 0); - # - # Hash last block text that wasn't processed inside the loop. - # + // Hash last block text that wasn't processed inside the loop. $parsed .= $this->$hash_method($block_text); return array($parsed, $text); } - + /** + * Called whenever a tag must be hashed when a function inserts a "clean" tag + * in $text, it passes through this function and is automaticaly escaped, + * blocking invalid nested overlap. + * @param string $text + * @return string + */ protected function hashClean($text) { - # - # Called whenever a tag must be hashed when a function inserts a "clean" tag - # in $text, it passes through this function and is automaticaly escaped, - # blocking invalid nested overlap. - # return $this->hashPart($text, 'C'); } - + /** + * Turn Markdown link shortcuts into XHTML tags. + * @param string $text + * @return string + */ protected function doAnchors($text) { - # - # Turn Markdown link shortcuts into XHTML tags. - # - if ($this->in_anchor) return $text; + if ($this->in_anchor) { + return $text; + } $this->in_anchor = true; - - # - # First, handle reference-style links: [link text] [id] - # + + // First, handle reference-style links: [link text] [id] $text = preg_replace_callback('{ ( # wrap whole match in $1 \[ - ('.$this->nested_brackets_re.') # link text = $2 + (' . $this->nested_brackets_re . ') # link text = $2 \] [ ]? # one optional space @@ -729,20 +779,18 @@ protected function doAnchors($text) { }xs', array($this, '_doAnchors_reference_callback'), $text); - # - # Next, inline-style links: [link text](url "optional title") - # + // Next, inline-style links: [link text](url "optional title") $text = preg_replace_callback('{ ( # wrap whole match in $1 \[ - ('.$this->nested_brackets_re.') # link text = $2 + (' . $this->nested_brackets_re . ') # link text = $2 \] \( # literal paren [ \n]* (?: <(.+?)> # href = $3 | - ('.$this->nested_url_parenthesis_re.') # href = $4 + (' . $this->nested_url_parenthesis_re . ') # href = $4 ) [ \n]* ( # $5 @@ -752,16 +800,14 @@ protected function doAnchors($text) { [ \n]* # ignore any spaces/tabs between closing quote and ) )? # title is optional \) - (?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes + (?:[ ]? ' . $this->id_class_attr_catch_re . ' )? # $8 = id/class attributes ) }xs', array($this, '_doAnchors_inline_callback'), $text); - # - # Last, handle reference-style shortcuts: [link text] - # These must come last in case you've also got [link text][1] - # or [link text](/foo) - # + // Last, handle reference-style shortcuts: [link text] + // These must come last in case you've also got [link text][1] + // or [link text](/foo) $text = preg_replace_callback('{ ( # wrap whole match in $1 \[ @@ -774,17 +820,23 @@ protected function doAnchors($text) { $this->in_anchor = false; return $text; } + + /** + * Callback for reference anchors + * @param array $matches + * @return string + */ protected function _doAnchors_reference_callback($matches) { $whole_match = $matches[1]; $link_text = $matches[2]; $link_id =& $matches[3]; if ($link_id == "") { - # for shortcut links like [this][] or [this]. + // for shortcut links like [this][] or [this]. $link_id = $link_text; } - # lower-case and turn embedded newlines into spaces + // lower-case and turn embedded newlines into spaces $link_id = strtolower($link_id); $link_id = preg_replace('{[ ]?\n}', ' ', $link_id); @@ -810,6 +862,12 @@ protected function _doAnchors_reference_callback($matches) { } return $result; } + + /** + * Callback for inline anchors + * @param array $matches + * @return string + */ protected function _doAnchors_inline_callback($matches) { $whole_match = $matches[1]; $link_text = $this->runSpanGamut($matches[2]); @@ -838,18 +896,17 @@ protected function _doAnchors_inline_callback($matches) { return $this->hashPart($result); } - + /** + * Turn Markdown image shortcuts into tags. + * @param string $text + * @return string + */ protected function doImages($text) { - # - # Turn Markdown image shortcuts into tags. - # - # - # First, handle reference-style labeled images: ![alt text][id] - # + // First, handle reference-style labeled images: ![alt text][id] $text = preg_replace_callback('{ ( # wrap whole match in $1 !\[ - ('.$this->nested_brackets_re.') # alt text = $2 + (' . $this->nested_brackets_re . ') # alt text = $2 \] [ ]? # one optional space @@ -863,14 +920,12 @@ protected function doImages($text) { }xs', array($this, '_doImages_reference_callback'), $text); - # - # Next, handle inline images: ![alt text](url "optional title") - # Don't forget: encode * and _ - # + // Next, handle inline images: ![alt text](url "optional title") + // Don't forget: encode * and _ $text = preg_replace_callback('{ ( # wrap whole match in $1 !\[ - ('.$this->nested_brackets_re.') # alt text = $2 + (' . $this->nested_brackets_re . ') # alt text = $2 \] \s? # One optional whitespace character \( # literal paren @@ -878,7 +933,7 @@ protected function doImages($text) { (?: <(\S*)> # src url = $3 | - ('.$this->nested_url_parenthesis_re.') # src url = $4 + (' . $this->nested_url_parenthesis_re . ') # src url = $4 ) [ \n]* ( # $5 @@ -888,20 +943,26 @@ protected function doImages($text) { [ \n]* )? # title is optional \) - (?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes + (?:[ ]? ' . $this->id_class_attr_catch_re . ' )? # $8 = id/class attributes ) }xs', array($this, '_doImages_inline_callback'), $text); return $text; } + + /** + * Callback for referenced images + * @param array $matches + * @return string + */ protected function _doImages_reference_callback($matches) { $whole_match = $matches[1]; $alt_text = $matches[2]; $link_id = strtolower($matches[3]); if ($link_id == "") { - $link_id = strtolower($alt_text); # for shortcut links like ![this][]. + $link_id = strtolower($alt_text); // for shortcut links like ![this][]. } $alt_text = $this->encodeAttribute($alt_text); @@ -919,12 +980,18 @@ protected function _doImages_reference_callback($matches) { $result = $this->hashPart($result); } else { - # If there's no such link ID, leave intact: + // If there's no such link ID, leave intact: $result = $whole_match; } return $result; } + + /** + * Callback for inline images + * @param array $matches + * @return string + */ protected function _doImages_inline_callback($matches) { $whole_match = $matches[1]; $alt_text = $matches[2]; @@ -937,7 +1004,7 @@ protected function _doImages_inline_callback($matches) { $result = "\"$alt_text\"";encodeAttribute($title); - $result .= " title=\"$title\""; # $title already quoted + $result .= " title=\"$title\""; // $title already quoted } $result .= $attr; $result .= $this->empty_element_suffix; @@ -945,40 +1012,41 @@ protected function _doImages_inline_callback($matches) { return $this->hashPart($result); } - + /** + * Process markdown headers. Redefined to add ID and class attribute support. + * @param string $text + * @return string + */ protected function doHeaders($text) { - # - # Redefined to add id and class attribute support. - # - # Setext-style headers: - # Header 1 {#header1} - # ======== - # - # Header 2 {#header2 .class1 .class2} - # -------- - # + // Setext-style headers: + // Header 1 {#header1} + // ======== + // + // Header 2 {#header2 .class1 .class2} + // -------- + // $text = preg_replace_callback( '{ (^.+?) # $1: Header text - (?:[ ]+ '.$this->id_class_attr_catch_re.' )? # $3 = id/class attributes + (?:[ ]+ ' . $this->id_class_attr_catch_re . ' )? # $3 = id/class attributes [ ]*\n(=+|-+)[ ]*\n+ # $3: Header footer }mx', array($this, '_doHeaders_callback_setext'), $text); - # atx-style headers: - # # Header 1 {#header1} - # ## Header 2 {#header2} - # ## Header 2 with closing hashes ## {#header3.class1.class2} - # ... - # ###### Header 6 {.class2} - # + // atx-style headers: + // # Header 1 {#header1} + // ## Header 2 {#header2} + // ## Header 2 with closing hashes ## {#header3.class1.class2} + // ... + // ###### Header 6 {.class2} + // $text = preg_replace_callback('{ ^(\#{1,6}) # $1 = string of #\'s [ ]* (.+?) # $2 = Header text [ ]* \#* # optional closing #\'s (not counted) - (?:[ ]+ '.$this->id_class_attr_catch_re.' )? # $3 = id/class attributes + (?:[ ]+ ' . $this->id_class_attr_catch_re . ' )? # $3 = id/class attributes [ ]* \n+ }xm', @@ -986,49 +1054,61 @@ protected function doHeaders($text) { return $text; } + + /** + * Callback for setext headers + * @param array $matches + * @return string + */ protected function _doHeaders_callback_setext($matches) { - if ($matches[3] == '-' && preg_match('{^- }', $matches[1])) + if ($matches[3] == '-' && preg_match('{^- }', $matches[1])) { return $matches[0]; + } $level = $matches[3]{0} == '=' ? 1 : 2; $defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[1]) : null; $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[2], $defaultId); - $block = "".$this->runSpanGamut($matches[1]).""; + $block = "" . $this->runSpanGamut($matches[1]) . ""; return "\n" . $this->hashBlock($block) . "\n\n"; } + + /** + * Callback for atx headers + * @param array $matches + * @return string + */ protected function _doHeaders_callback_atx($matches) { $level = strlen($matches[1]); $defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[2]) : null; $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[3], $defaultId); - $block = "".$this->runSpanGamut($matches[2]).""; + $block = "" . $this->runSpanGamut($matches[2]) . ""; return "\n" . $this->hashBlock($block) . "\n\n"; } - + /** + * Form HTML tables. + * @param string $text + * @return string + */ protected function doTables($text) { - # - # Form HTML tables. - # $less_than_tab = $this->tab_width - 1; - # - # Find tables with leading pipe. - # - # | Header 1 | Header 2 - # | -------- | -------- - # | Cell 1 | Cell 2 - # | Cell 3 | Cell 4 - # + // Find tables with leading pipe. + // + // | Header 1 | Header 2 + // | -------- | -------- + // | Cell 1 | Cell 2 + // | Cell 3 | Cell 4 $text = preg_replace_callback(' { ^ # Start of a line - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. + [ ]{0,' . $less_than_tab . '} # Allowed whitespace. [|] # Optional leading pipe (present) (.+) \n # $1: Header row (at least one pipe) - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. + [ ]{0,' . $less_than_tab . '} # Allowed whitespace. [|] ([ ]*[-:]+[-| :]*) \n # $2: Header underline ( # $3: Cells @@ -1040,22 +1120,20 @@ protected function doTables($text) { (?=\n|\Z) # Stop at final double newline. }xm', array($this, '_doTable_leadingPipe_callback'), $text); - - # - # Find tables without leading pipe. - # - # Header 1 | Header 2 - # -------- | -------- - # Cell 1 | Cell 2 - # Cell 3 | Cell 4 - # + + // Find tables without leading pipe. + // + // Header 1 | Header 2 + // -------- | -------- + // Cell 1 | Cell 2 + // Cell 3 | Cell 4 $text = preg_replace_callback(' { ^ # Start of a line - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. + [ ]{0,' . $less_than_tab . '} # Allowed whitespace. (\S.*[|].*) \n # $1: Header row (at least one pipe) - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. + [ ]{0,' . $less_than_tab . '} # Allowed whitespace. ([-:]+[ ]*[|][-| :]*) \n # $2: Header underline ( # $3: Cells @@ -1069,35 +1147,53 @@ protected function doTables($text) { return $text; } + + /** + * Callback for removing the leading pipe for each row + * @param array $matches + * @return string + */ protected function _doTable_leadingPipe_callback($matches) { $head = $matches[1]; $underline = $matches[2]; $content = $matches[3]; - - # Remove leading pipe for each row. + $content = preg_replace('/^ *[|]/m', '', $content); return $this->_doTable_callback(array($matches[0], $head, $underline, $content)); } + + /** + * Make the align attribute in a table + * @param string $alignname + * @return string + */ protected function _doTable_makeAlignAttr($alignname) { - if (empty($this->table_align_class_tmpl)) + if (empty($this->table_align_class_tmpl)) { return " align=\"$alignname\""; + } $classname = str_replace('%%', $alignname, $this->table_align_class_tmpl); return " class=\"$classname\""; } + + /** + * Calback for processing tables + * @param array $matches + * @return string + */ protected function _doTable_callback($matches) { $head = $matches[1]; $underline = $matches[2]; $content = $matches[3]; - # Remove any tailing pipes for each line. + // Remove any tailing pipes for each line. $head = preg_replace('/[|] *$/m', '', $head); $underline = preg_replace('/[|] *$/m', '', $underline); $content = preg_replace('/[|] *$/m', '', $content); - # Reading alignement from header underline. + // Reading alignement from header underline. $separators = preg_split('/ *[|] */', $underline); foreach ($separators as $n => $s) { if (preg_match('/^ *-+: *$/', $s)) @@ -1110,38 +1206,38 @@ protected function _doTable_callback($matches) { $attr[$n] = ''; } - # Parsing span elements, including code spans, character escapes, - # and inline HTML tags, so that pipes inside those gets ignored. + // Parsing span elements, including code spans, character escapes, + // and inline HTML tags, so that pipes inside those gets ignored. $head = $this->parseSpan($head); $headers = preg_split('/ *[|] */', $head); $col_count = count($headers); $attr = array_pad($attr, $col_count, ''); - # Write column headers. + // Write column headers. $text = "\n"; $text .= "\n"; $text .= "\n"; foreach ($headers as $n => $header) - $text .= " ".$this->runSpanGamut(trim($header))."\n"; + $text .= " " . $this->runSpanGamut(trim($header)) . "\n"; $text .= "\n"; $text .= "\n"; - # Split content by row. + // Split content by row. $rows = explode("\n", trim($content, "\n")); $text .= "\n"; foreach ($rows as $row) { - # Parsing span elements, including code spans, character escapes, - # and inline HTML tags, so that pipes inside those gets ignored. + // Parsing span elements, including code spans, character escapes, + // and inline HTML tags, so that pipes inside those gets ignored. $row = $this->parseSpan($row); - # Split row by cell. + // Split row by cell. $row_cells = preg_split('/ *[|] */', $row, $col_count); $row_cells = array_pad($row_cells, $col_count, ''); $text .= "\n"; foreach ($row_cells as $n => $cell) - $text .= " ".$this->runSpanGamut(trim($cell))."\n"; + $text .= " " . $this->runSpanGamut(trim($cell)) . "\n"; $text .= "\n"; } $text .= "\n"; @@ -1150,21 +1246,22 @@ protected function _doTable_callback($matches) { return $this->hashBlock($text) . "\n"; } - + /** + * Form HTML definition lists. + * @param string $text + * @return string + */ protected function doDefLists($text) { - # - # Form HTML definition lists. - # $less_than_tab = $this->tab_width - 1; - # Re-usable pattern to match any entire dl list: + // Re-usable pattern to match any entire dl list: $whole_list_re = '(?> ( # $1 = whole list ( # $2 - [ ]{0,'.$less_than_tab.'} + [ ]{0,' . $less_than_tab . '} ((?>.*\S.*\n)+) # $3 = defined term \n? - [ ]{0,'.$less_than_tab.'}:[ ]+ # colon starting definition + [ ]{0,' . $less_than_tab . '}:[ ]+ # colon starting definition ) (?s:.+?) ( # $4 @@ -1173,13 +1270,13 @@ protected function doDefLists($text) { \n{2,} (?=\S) (?! # Negative lookahead for another term - [ ]{0,'.$less_than_tab.'} + [ ]{0,' . $less_than_tab . '} (?: \S.*\n )+? # defined term \n? - [ ]{0,'.$less_than_tab.'}:[ ]+ # colon starting definition + [ ]{0,' . $less_than_tab . '}:[ ]+ # colon starting definition ) (?! # Negative lookahead for another definition - [ ]{0,'.$less_than_tab.'}:[ ]+ # colon starting definition + [ ]{0,' . $less_than_tab . '}:[ ]+ # colon starting definition ) ) ) @@ -1187,59 +1284,67 @@ protected function doDefLists($text) { $text = preg_replace_callback('{ (?>\A\n?|(?<=\n\n)) - '.$whole_list_re.' + ' . $whole_list_re . ' }mx', array($this, '_doDefLists_callback'), $text); return $text; } + + /** + * Callback for processing definition lists + * @param array $matches + * @return string + */ protected function _doDefLists_callback($matches) { - # Re-usable patterns to match list item bullets and number markers: + // Re-usable patterns to match list item bullets and number markers: $list = $matches[1]; - # Turn double returns into triple returns, so that we can make a - # paragraph for the last item in a list, if necessary: + // Turn double returns into triple returns, so that we can make a + // paragraph for the last item in a list, if necessary: $result = trim($this->processDefListItems($list)); $result = "
    \n" . $result . "\n
    "; return $this->hashBlock($result) . "\n\n"; } - + /** + * Process the contents of a single definition list, splitting it + * into individual term and definition list items. + * @param string $list_str + * @return string + */ protected function processDefListItems($list_str) { - # - # Process the contents of a single definition list, splitting it - # into individual term and definition list items. - # + $less_than_tab = $this->tab_width - 1; - # trim trailing blank lines: + // Trim trailing blank lines: $list_str = preg_replace("/\n{2,}\\z/", "\n", $list_str); - # Process definition terms. + // Process definition terms. $list_str = preg_replace_callback('{ - (?>\A\n?|\n\n+) # leading line - ( # definition terms = $1 - [ ]{0,'.$less_than_tab.'} # leading whitespace - (?!\:[ ]|[ ]) # negative lookahead for a definition - # mark (colon) or more whitespace. - (?> \S.* \n)+? # actual term (not whitespace). + (?>\A\n?|\n\n+) # leading line + ( # definition terms = $1 + [ ]{0,' . $less_than_tab . '} # leading whitespace + (?!\:[ ]|[ ]) # negative lookahead for a definition + # mark (colon) or more whitespace. + (?> \S.* \n)+? # actual term (not whitespace). ) - (?=\n?[ ]{0,3}:[ ]) # lookahead for following line feed - # with a definition mark. + (?=\n?[ ]{0,3}:[ ]) # lookahead for following line feed + # with a definition mark. }xm', array($this, '_processDefListItems_callback_dt'), $list_str); - # Process actual definitions. + // Process actual definitions. $list_str = preg_replace_callback('{ - \n(\n+)? # leading line = $1 - ( # marker space = $2 - [ ]{0,'.$less_than_tab.'} # whitespace before colon - \:[ ]+ # definition mark (colon) + \n(\n+)? # leading line = $1 + ( # marker space = $2 + [ ]{0,' . $less_than_tab . '} # whitespace before colon + \:[ ]+ # definition mark (colon) ) - ((?s:.+?)) # definition text = $3 - (?= \n+ # stop at next definition mark, - (?: # next term or end of text - [ ]{0,'.$less_than_tab.'} \:[ ] | + ((?s:.+?)) # definition text = $3 + (?= \n+ # stop at next definition mark, + (?: # next term or end of text + [ ]{0,' . $less_than_tab . '} \:[ ] |
    | \z ) ) @@ -1248,6 +1353,12 @@ protected function processDefListItems($list_str) { return $list_str; } + + /** + * Callback for
    elements in definition lists + * @param array $matches + * @return string + */ protected function _processDefListItems_callback_dt($matches) { $terms = explode("\n", trim($matches[1])); $text = ''; @@ -1257,13 +1368,19 @@ protected function _processDefListItems_callback_dt($matches) { } return $text . "\n"; } + + /** + * Callback for
    elements in definition lists + * @param array $matches + * @return string + */ protected function _processDefListItems_callback_dd($matches) { $leading_line = $matches[1]; $marker_space = $matches[2]; $def = $matches[3]; if ($leading_line || preg_match('/\n{2,}/', $def)) { - # Replace marker with the appropriate whitespace indentation + // Replace marker with the appropriate whitespace indentation $def = str_repeat(' ', strlen($marker_space)) . $def; $def = $this->runBlockGamut($this->outdent($def . "\n\n")); $def = "\n". $def ."\n"; @@ -1276,15 +1393,18 @@ protected function _processDefListItems_callback_dd($matches) { return "\n
    " . $def . "
    \n"; } - + /** + * Adding the fenced code block syntax to regular Markdown: + * + * ~~~ + * Code block + * ~~~ + * + * @param string $text + * @return string + */ protected function doFencedCodeBlocks($text) { - # - # Adding the fenced code block syntax to regular Markdown: - # - # ~~~ - # Code block - # ~~~ - # + $less_than_tab = $this->tab_width; $text = preg_replace_callback('{ @@ -1299,7 +1419,7 @@ protected function doFencedCodeBlocks($text) { )? [ ]* (?: - '.$this->id_class_attr_catch_re.' # 3: Extra attributes + ' . $this->id_class_attr_catch_re . ' # 3: Extra attributes )? [ ]* \n # Whitespace and newline following marker. @@ -1318,6 +1438,12 @@ protected function doFencedCodeBlocks($text) { return $text; } + + /** + * Callback to process fenced code blocks + * @param array $matches + * @return string + */ protected function _doFencedCodeBlocks_callback($matches) { $classname =& $matches[2]; $attrs =& $matches[3]; @@ -1336,7 +1462,7 @@ protected function _doFencedCodeBlocks_callback($matches) { if ($classname != "") { if ($classname{0} == '.') $classname = substr($classname, 1); - $classes[] = $this->code_class_prefix.$classname; + $classes[] = $this->code_class_prefix . $classname; } $attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs, null, $classes); $pre_attr_str = $this->code_attr_on_pre ? $attr_str : ''; @@ -1345,52 +1471,57 @@ protected function _doFencedCodeBlocks_callback($matches) { return "\n\n".$this->hashBlock($codeblock)."\n\n"; } + + /** + * Replace new lines in fenced code blocks + * @param array $matches + * @return string + */ protected function _doFencedCodeBlocks_newlines($matches) { return str_repeat("empty_element_suffix", strlen($matches[0])); } - - # - # Redefining emphasis markers so that emphasis by underscore does not - # work in the middle of a word. - # + /** + * Redefining emphasis markers so that emphasis by underscore does not + * work in the middle of a word. + * @var array + */ protected $em_relist = array( '' => '(?:(? '(? '(? '(?:(? '(? '(? '(?:(? '(? '(? tags - # - # Strip leading and trailing lines: + ); + + /** + * Parse text into paragraphs + * @param string $text String to process in paragraphs + * @param boolean $wrap_in_p Whether paragraphs should be wrapped in

    tags + * @return string HTML output + */ + protected function formParagraphs($text, $wrap_in_p = true) { + // Strip leading and trailing lines: $text = preg_replace('/\A\n+|\n+\z/', '', $text); - + $grafs = preg_split('/\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY); - # - # Wrap

    tags and unhashify HTML blocks - # + // Wrap

    tags and unhashify HTML blocks foreach ($grafs as $key => $value) { $value = trim($this->runSpanGamut($value)); - # Check if this should be enclosed in a paragraph. - # Clean tag hashes & block tag hashes are left alone. - $is_p = !preg_match('/^B\x1A[0-9]+B|^C\x1A[0-9]+C$/', $value); + // Check if this should be enclosed in a paragraph. + // Clean tag hashes & block tag hashes are left alone. + $is_p = $wrap_in_p && !preg_match('/^B\x1A[0-9]+B|^C\x1A[0-9]+C$/', $value); if ($is_p) { $value = "

    $value

    "; @@ -1398,28 +1529,28 @@ protected function formParagraphs($text) { $grafs[$key] = $value; } - # Join grafs in one text, then unhash HTML tags. + // Join grafs in one text, then unhash HTML tags. $text = implode("\n\n", $grafs); - # Finish by removing any tag hashes still present in $text. + // Finish by removing any tag hashes still present in $text. $text = $this->unhash($text); return $text; } - ### Footnotes - + /** + * Footnotes - Strips link definitions from text, stores the URLs and + * titles in hash references. + * @param string $text + * @return string + */ protected function stripFootnotes($text) { - # - # Strips link definitions from text, stores the URLs and titles in - # hash references. - # $less_than_tab = $this->tab_width - 1; - # Link defs are in the form: [^id]: url "optional title" + // Link defs are in the form: [^id]: url "optional title" $text = preg_replace_callback('{ - ^[ ]{0,'.$less_than_tab.'}\[\^(.+?)\][ ]?: # note_id = $1 + ^[ ]{0,' . $less_than_tab . '}\[\^(.+?)\][ ]?: # note_id = $1 [ ]* \n? # maybe *one* newline ( # text = $2 (no blank lines allowed) @@ -1437,36 +1568,44 @@ protected function stripFootnotes($text) { $text); return $text; } + + /** + * Callback for stripping footnotes + * @param array $matches + * @return string + */ protected function _stripFootnotes_callback($matches) { $note_id = $this->fn_id_prefix . $matches[1]; $this->footnotes[$note_id] = $this->outdent($matches[2]); - return ''; # String that will replace the block + return ''; // String that will replace the block } - + /** + * Replace footnote references in $text [^id] with a special text-token + * which will be replaced by the actual footnote marker in appendFootnotes. + * @param string $text + * @return string + */ protected function doFootnotes($text) { - # - # Replace footnote references in $text [^id] with a special text-token - # which will be replaced by the actual footnote marker in appendFootnotes. - # if (!$this->in_anchor) { $text = preg_replace('{\[\^(.+?)\]}', "F\x1Afn:\\1\x1A:", $text); } return $text; } - + /** + * Append footnote list to text + * @param string $text + * @return string + */ protected function appendFootnotes($text) { - # - # Append footnote list to text. - # $text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}', array($this, '_appendFootnotes_callback'), $text); if (!empty($this->footnotes_ordered)) { $text .= "\n\n"; $text .= "
    \n"; - $text .= "empty_element_suffix ."\n"; + $text .= "empty_element_suffix . "\n"; $text .= "
      \n\n"; $attr = ""; @@ -1491,7 +1630,7 @@ protected function appendFootnotes($text) { unset($this->footnotes_ref_count[$note_id]); unset($this->footnotes[$note_id]); - $footnote .= "\n"; # Need to append newline before parsing. + $footnote .= "\n"; // Need to append newline before parsing. $footnote = $this->runBlockGamut("$footnote\n"); $footnote = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}', array($this, '_appendFootnotes_callback'), $footnote); @@ -1499,12 +1638,12 @@ protected function appendFootnotes($text) { $attr = str_replace("%%", ++$num, $attr); $note_id = $this->encodeAttribute($note_id); - # Prepare backlink, multiple backlinks if multiple references + // Prepare backlink, multiple backlinks if multiple references $backlink = "$backlink_text"; for ($ref_num = 2; $ref_num <= $ref_count; ++$ref_num) { $backlink .= " $backlink_text"; } - # Add backlink to last paragraph; create new paragraph if needed. + // Add backlink to last paragraph; create new paragraph if needed. if (preg_match('{

      $}', $footnote)) { $footnote = substr($footnote, 0, -4) . " $backlink

      "; } else { @@ -1521,16 +1660,22 @@ protected function appendFootnotes($text) { } return $text; } + + /** + * Callback for appending footnotes + * @param array $matches + * @return string + */ protected function _appendFootnotes_callback($matches) { $node_id = $this->fn_id_prefix . $matches[1]; - # Create footnote marker only if it has a corresponding footnote *and* - # the footnote hasn't been used by another marker. + // Create footnote marker only if it has a corresponding footnote *and* + // the footnote hasn't been used by another marker. if (isset($this->footnotes[$node_id])) { $num =& $this->footnotes_numbers[$node_id]; if (!isset($num)) { - # Transfer footnote content to the ordered list and give it its - # number + // Transfer footnote content to the ordered list and give it its + // number $this->footnotes_ordered[$node_id] = $this->footnotes[$node_id]; $this->footnotes_ref_count[$node_id] = 1; $num = $this->footnote_counter++; @@ -1560,54 +1705,69 @@ protected function _appendFootnotes_callback($matches) { ""; } - return "[^".$matches[1]."]"; + return "[^" . $matches[1] . "]"; } - ### Abbreviations ### - + /** + * Abbreviations - strips abbreviations from text, stores titles in hash + * references. + * @param string $text + * @return string + */ protected function stripAbbreviations($text) { - # - # Strips abbreviations from text, stores titles in hash references. - # $less_than_tab = $this->tab_width - 1; - # Link defs are in the form: [id]*: url "optional title" + // Link defs are in the form: [id]*: url "optional title" $text = preg_replace_callback('{ - ^[ ]{0,'.$less_than_tab.'}\*\[(.+?)\][ ]?: # abbr_id = $1 + ^[ ]{0,' . $less_than_tab . '}\*\[(.+?)\][ ]?: # abbr_id = $1 (.*) # text = $2 (no blank lines allowed) }xm', array($this, '_stripAbbreviations_callback'), $text); return $text; } + + /** + * Callback for stripping abbreviations + * @param array $matches + * @return string + */ protected function _stripAbbreviations_callback($matches) { $abbr_word = $matches[1]; $abbr_desc = $matches[2]; - if ($this->abbr_word_re) + if ($this->abbr_word_re) { $this->abbr_word_re .= '|'; + } $this->abbr_word_re .= preg_quote($abbr_word); $this->abbr_desciptions[$abbr_word] = trim($abbr_desc); - return ''; # String that will replace the block + return ''; // String that will replace the block } - - + + /** + * Find defined abbreviations in text and wrap them in elements. + * @param string $text + * @return string + */ protected function doAbbreviations($text) { - # - # Find defined abbreviations in text and wrap them in elements. - # if ($this->abbr_word_re) { // cannot use the /x modifier because abbr_word_re may // contain significant spaces: - $text = preg_replace_callback('{'. - '(?abbr_word_re.')'. - '(?![\w\x1A])'. - '}', + $text = preg_replace_callback('{' . + '(?abbr_word_re . ')' . + '(?![\w\x1A])' . + '}', array($this, '_doAbbreviations_callback'), $text); } return $text; } + + /** + * Callback for processing abbreviations + * @param array $matches + * @return string + */ protected function _doAbbreviations_callback($matches) { $abbr = $matches[0]; if (isset($this->abbr_desciptions[$abbr])) { diff --git a/www7/sites/all/modules/contrib/markdown/includes/MarkdownInterface.inc.php b/www7/sites/all/modules/contrib/markdown/includes/MarkdownInterface.inc.php old mode 100644 new mode 100755 index a023ed4e3..c4e9ac7f6 --- a/www7/sites/all/modules/contrib/markdown/includes/MarkdownInterface.inc.php +++ b/www7/sites/all/modules/contrib/markdown/includes/MarkdownInterface.inc.php @@ -1,9 +1,9 @@ -# -# Original Markdown -# Copyright (c) 2004-2006 John Gruber -# -# -namespace Michelf; - +/** + * Markdown - A text-to-HTML conversion tool for web writers + * + * @package php-markdown + * @author Michel Fortin + * @copyright 2004-2016 Michel Fortin + * @copyright (Original Markdown) 2004-2006 John Gruber + */ -# -# Markdown Parser Interface -# +namespace Michelf; +/** + * Markdown Parser Interface + */ interface MarkdownInterface { + /** + * Initialize the parser and return the result of its transform method. + * This will work fine for derived classes too. + * + * @api + * + * @param string $text + * @return string + */ + public static function defaultTransform($text); - # - # Initialize the parser and return the result of its transform method. - # This will work fine for derived classes too. - # - public static function defaultTransform($text); - - # - # Main function. Performs some preprocessing on the input text - # and pass it through the document gamut. - # - public function transform($text); - + /** + * Main function. Performs some preprocessing on the input text + * and pass it through the document gamut. + * + * @api + * + * @param string $text + * @return string + */ + public function transform($text); } diff --git a/www7/sites/all/modules/contrib/markdown/markdown.info b/www7/sites/all/modules/contrib/markdown/markdown.info index 7fc366709..c46c32bcd 100644 --- a/www7/sites/all/modules/contrib/markdown/markdown.info +++ b/www7/sites/all/modules/contrib/markdown/markdown.info @@ -4,9 +4,9 @@ package = "Input filters" core = 7.x php = 5.3 -; Information added by Drupal.org packaging script on 2016-07-26 -version = "7.x-1.4" +; Information added by Drupal.org packaging script on 2016-11-04 +version = "7.x-1.5" core = "7.x" project = "markdown" -datestamp = "1469495340" +datestamp = "1478247850" From d5f202124c56a405dd5a470c37e9c7718b51b70b Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Fri, 11 Nov 2016 15:33:50 +0100 Subject: [PATCH 02/16] Update mailchimp to 7.x-4.7 --- .../all/modules/contrib/mailchimp/README.txt | 2 +- .../modules/contrib/mailchimp/composer.json | 6 +- .../contrib/mailchimp/mailchimp.api.php | 40 +++ .../modules/contrib/mailchimp/mailchimp.info | 6 +- .../contrib/mailchimp/mailchimp.module | 9 +- .../mailchimp_activity.info | 6 +- .../modules/mailchimp_automations/README.txt | 26 ++ .../includes/mailchimp_automations.admin.inc | 335 ++++++++++++++++++ .../includes/mailchimp_automations.entity.inc | 40 +++ .../mailchimp_automations.ui_controller.inc | 26 ++ .../mailchimp_automations.info | 17 + .../mailchimp_automations.install | 110 ++++++ .../mailchimp_automations.module | 227 ++++++++++++ .../mailchimp_campaign.info | 6 +- .../mailchimp_i18n/mailchimp_i18n.i18n.inc | 69 ++++ .../mailchimp_i18n/mailchimp_i18n.info | 14 + .../mailchimp_i18n/mailchimp_i18n.module | 53 +++ .../mailchimp_lists/mailchimp_lists.info | 6 +- .../mailchimp_lists/mailchimp_lists.module | 4 +- .../tests/mailchimp_lists.test | 2 +- .../includes/mailchimp_signup.admin.inc | 17 +- .../mailchimp_signup/mailchimp_signup.info | 6 +- .../mailchimp_signup/mailchimp_signup.install | 21 ++ .../mailchimp_signup/mailchimp_signup.module | 21 +- 24 files changed, 1015 insertions(+), 54 deletions(-) create mode 100644 www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/README.txt create mode 100644 www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/includes/mailchimp_automations.admin.inc create mode 100644 www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/includes/mailchimp_automations.entity.inc create mode 100644 www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/includes/mailchimp_automations.ui_controller.inc create mode 100644 www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/mailchimp_automations.info create mode 100644 www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/mailchimp_automations.install create mode 100644 www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/mailchimp_automations.module create mode 100644 www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_i18n/mailchimp_i18n.i18n.inc create mode 100644 www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_i18n/mailchimp_i18n.info create mode 100644 www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_i18n/mailchimp_i18n.module diff --git a/www7/sites/all/modules/contrib/mailchimp/README.txt b/www7/sites/all/modules/contrib/mailchimp/README.txt index 868455b35..ce3e166ae 100644 --- a/www7/sites/all/modules/contrib/mailchimp/README.txt +++ b/www7/sites/all/modules/contrib/mailchimp/README.txt @@ -92,7 +92,7 @@ MailChimp Library Installation The library has dependencies managed by Composer. If you would prefer not to use Composer, you can download the pre-built library package: - https://github.com/thinkshout/mailchimp-api-php/releases/download/v1.0.4/v1.0.4-package.zip + https://github.com/thinkshout/mailchimp-api-php/releases/download/v1.0.5/v1.0.5-package.zip To use Composer: diff --git a/www7/sites/all/modules/contrib/mailchimp/composer.json b/www7/sites/all/modules/contrib/mailchimp/composer.json index f0675322e..d9d428708 100644 --- a/www7/sites/all/modules/contrib/mailchimp/composer.json +++ b/www7/sites/all/modules/contrib/mailchimp/composer.json @@ -1,7 +1,7 @@ { - "name": "drupal/contrib/mailchimp", + "name": "drupal/mailchimp", "description": "Mailchimp integration for Drupal.", - "version": "7.x-4.4", + "version": "7.x-4.7", "homepage": "https://www.drupal.org/project/mailchimp", "license": "GNU-2.0+", "keywords": [ @@ -11,6 +11,6 @@ "php" ], "require": { - "thinkshout/mailchimp-api-php": ">=1.0.3" + "thinkshout/mailchimp-api-php": ">=1.0.5" } } diff --git a/www7/sites/all/modules/contrib/mailchimp/mailchimp.api.php b/www7/sites/all/modules/contrib/mailchimp/mailchimp.api.php index e1ff238cb..86b9e3e2e 100644 --- a/www7/sites/all/modules/contrib/mailchimp/mailchimp.api.php +++ b/www7/sites/all/modules/contrib/mailchimp/mailchimp.api.php @@ -68,3 +68,43 @@ function hook_mailchimp_unsubscribe_user($list_id, $email) { function hook_mailchimp_api_key_alter(&$api_key, $context) { } + +/** + * Alter the entity options list on the automations entity form. + * + * @param array $entity_type_options + * The full list of Drupal entities. + * @param string $automation_entity_label + * The label for the automation entity, if it exists. + */ +function hook_mailchimp_automations_entity_options(&$entity_type_options, $automation_entity_label) { + +} + +/** + * Alter mergevars before a workflow automation is triggered. + * + * @param array $merge_vars + * The merge vars that will be passed to MailChimp. + * @param object $automation_entity + * The MailchimpAutomationEntity object. + * @param object $wrapped_entity + * The EntityMetadataWrapper for the triggering entity. + */ +function hook_mailchimp_automations_mergevars_alter(&$merge_vars, $automation_entity, $wrapped_entity) { + +} + +/** + * Perform an action after a successful MailChimp workflow automation. + * + * @param object $automation_entity + * The MailchimpAutomationEntity object. + * @param string $email + * The email_property value from the MailchimpAutomationEntity. + * @param object $wrapped_entity + * The EntityMetadataWrapper for the triggering entity. + */ +function hook_mailchimp_automations_workflow_email_triggered($automation_entity, $email, $wrapped_entity) { + +} diff --git a/www7/sites/all/modules/contrib/mailchimp/mailchimp.info b/www7/sites/all/modules/contrib/mailchimp/mailchimp.info index d0c9eb2cb..e963f4d75 100644 --- a/www7/sites/all/modules/contrib/mailchimp/mailchimp.info +++ b/www7/sites/all/modules/contrib/mailchimp/mailchimp.info @@ -8,9 +8,9 @@ files[] = includes/mailchimp_exception.inc configure = admin/config/services/mailchimp -; Information added by Drupal.org packaging script on 2016-10-28 -version = "7.x-4.6" +; Information added by Drupal.org packaging script on 2016-11-08 +version = "7.x-4.7" core = "7.x" project = "mailchimp" -datestamp = "1477691643" +datestamp = "1478578147" diff --git a/www7/sites/all/modules/contrib/mailchimp/mailchimp.module b/www7/sites/all/modules/contrib/mailchimp/mailchimp.module index 0f50fe621..ac7739d60 100644 --- a/www7/sites/all/modules/contrib/mailchimp/mailchimp.module +++ b/www7/sites/all/modules/contrib/mailchimp/mailchimp.module @@ -21,7 +21,7 @@ function mailchimp_libraries_info() { $libraries['mailchimp'] = array( 'name' => 'MailChimp API', 'vendor url' => 'https://github.com/thinkshout/mailchimp-api-php', - 'download url' => 'https://github.com/thinkshout/mailchimp-api-php/archive/v1.0.3.zip', + 'download url' => 'https://github.com/thinkshout/mailchimp-api-php/archive/v1.0.5.zip', 'version arguments' => array( 'file' => 'composer.json', 'pattern' => '/"version": "([0-9a-zA-Z.-]+)"/', @@ -529,9 +529,8 @@ function mailchimp_subscribe_process($list_id, $email, $merge_vars = NULL, $inte $result->status = $e->getCode(); $result->message = $e->getMessage(); } - finally { - return $result; - } + + return $result; } /** @@ -807,7 +806,7 @@ function mailchimp_batch_update_members($list_id, $batch, $double_in = FALSE) { * @return bool * Indicates whether unsubscribe was successful. */ -function mailchimp_unsubscribe($list_id, $email, $delete = FALSE, $goodbye = FALSE, $notify = FALSE) { +function mailchimp_unsubscribe_member($list_id, $email, $delete = FALSE, $goodbye = FALSE, $notify = FALSE) { $result = FALSE; if (mailchimp_is_subscribed($list_id, $email)) { diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_activity/mailchimp_activity.info b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_activity/mailchimp_activity.info index 6b86255e0..41fe47a83 100644 --- a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_activity/mailchimp_activity.info +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_activity/mailchimp_activity.info @@ -9,9 +9,9 @@ dependencies[] = entity files[] = includes/mailchimp_activity.entity.inc files[] = includes/mailchimp_activity.ui_controller.inc -; Information added by Drupal.org packaging script on 2016-10-28 -version = "7.x-4.6" +; Information added by Drupal.org packaging script on 2016-11-08 +version = "7.x-4.7" core = "7.x" project = "mailchimp" -datestamp = "1477691643" +datestamp = "1478578147" diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/README.txt b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/README.txt new file mode 100644 index 000000000..d0cc6b7ad --- /dev/null +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/README.txt @@ -0,0 +1,26 @@ +Integrate your Drupal entities with MailChimp's workflow automation endpoints. + +## Installation + +1. Enable the MailChimp Automation module +2. Make sure you have a recent version of the MailChimp PHP API library, which includes the MailchimpAutomations API service. + +## Usage + +1. Define which entity types you want to show campaign activity for at +/admin/config/services/mailchimp/automations. + * Select a Drupal entity type. + * Select a bundle. + * Select the email entity property. + * Select the appropriate MailChimp List + * Select the appropriate MailChimp Workflow + * Select the appropriate MailChimp Workflow Email +2. Configure permissions for managing MailChimp Automations + +## Notes + +1. The "Import mailchimp automation entity" button on the Automations admin tab will +throw a PHP error due to a bug in Entity API. You can prevent this error by +applying the patch in https://drupal.org/comment/8648215#comment-8648215 to +the entity module. +2. See additional options in the mailchimp_automations.api.php file, such as passing merge variables to MailChimp. diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/includes/mailchimp_automations.admin.inc b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/includes/mailchimp_automations.admin.inc new file mode 100644 index 000000000..3f900d89d --- /dev/null +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/includes/mailchimp_automations.admin.inc @@ -0,0 +1,335 @@ +label .= ' (cloned)'; + $mailchimp_automations_entity->name = ''; + } + $entitynotnull = isset($mailchimp_automations_entity->mailchimp_automations_entity_id); + $form_state['mailchimp_automation'] = $mailchimp_automations_entity; + + $form['label'] = array( + '#title' => t('Label'), + '#type' => 'textfield', + '#default_value' => $entitynotnull ? $mailchimp_automations_entity->label : '', + '#description' => t('The human-readable name of this automation entity.'), + '#required' => TRUE, + '#weight' => -10, + ); + + $form['name'] = array( + '#title' => t('Name'), + '#type' => 'machine_name', + '#default_value' => $entitynotnull ? $mailchimp_automations_entity->name : '', + '#description' => t('machine name should only contain lowercase letters & underscores'), + '#disabled' => !empty($mailchimp_automations_entity->name), + '#required' => TRUE, + '#machine_name' => array( + 'exists' => 'mailchimp_automations_load_entities', + 'source' => array('label'), + ), + '#weight' => -9, + ); + + $form['drupal_entity'] = array( + '#title' => t('Drupal entity'), + '#type' => 'fieldset', + '#attributes' => array( + 'id' => array('mailchimp-automation-drupal-entity'), + ), + '#weight' => -8, + ); + // Prep the entity type list before creating the form item: + $entity_types = array('' => t('-- Select --')); + foreach (entity_get_info() as $entity_type => $info) { + // Ignore MailChimp entity types: + if (strpos($entity_type, 'mailchimp') === FALSE) { + $entity_types[$entity_type] = $info['label']; + } + } + $automation_entity_label = $entitynotnull ? $mailchimp_automations_entity->label : ''; + drupal_alter('mailchimp_automations_entity_options', $entity_types, $automation_entity_label); + asort($entity_types); + $form['drupal_entity']['entity_type'] = array( + '#title' => t('Entity type'), + '#type' => 'select', + '#options' => $entity_types, + '#default_value' => $entitynotnull ? $mailchimp_automations_entity->entity_type : 0, + '#required' => TRUE, + '#description' => t('Select an entity type to trigger a mailchimp automation.'), + '#ajax' => array( + 'callback' => 'mailchimp_automations_mapping_form_callback', + 'wrapper' => 'mailchimp-automation-drupal-entity', + ), + '#weight' => -8, + ); + + $form_entity_type = & $form_state['values']['entity_type']; + if (!$form_entity_type && $entitynotnull) { + $form_entity_type = $mailchimp_automations_entity->entity_type; + } + if ($form_entity_type) { + // Prep the bundle list before creating the form item: + $bundles = array('' => t('-- Select --')); + $info = entity_get_info($form_entity_type); + foreach ($info['bundles'] as $key => $bundle) { + $bundles[$key] = $bundle['label']; + } + asort($bundles); + $form['drupal_entity']['bundle'] = array( + '#title' => t('Entity bundle'), + '#type' => 'select', + '#required' => TRUE, + '#description' => t('Select a Drupal entity bundle with an email address to report on.'), + '#options' => $bundles, + '#default_value' => $entitynotnull ? $mailchimp_automations_entity->bundle : 0, + '#weight' => -7, + '#ajax' => array( + 'callback' => 'mailchimp_automations_mapping_form_callback', + 'wrapper' => 'mailchimp-automation-drupal-entity', + ), + ); + + $form_bundle = & $form_state['values']['bundle']; + if (!$form_bundle && $entitynotnull) { + $form_bundle = $mailchimp_automations_entity->bundle; + } + if ($form_bundle) { + // Prep the field & properties list before creating the form item: + $fields = mailchimp_automations_email_fieldmap_options($form_entity_type, $form_bundle); + $form['drupal_entity']['email_property'] = array( + '#title' => t('Email Property'), + '#type' => 'select', + '#required' => TRUE, + '#description' => t('Select the field which contains the email address'), + '#options' => $fields, + '#default_value' => $entitynotnull ? $mailchimp_automations_entity->email_property : 0, + '#maxlength' => 127, + '#weight' => -6, + '#ajax' => array( + 'callback' => 'mailchimp_automations_mapping_form_callback', + 'wrapper' => 'mailchimp-automation-drupal-entity', + ), + ); + + $form_email_property = & $form_state['values']['email_property']; + if (!$form_email_property && $entitynotnull) { + $form_email_property = $mailchimp_automations_entity->email_property; + } + if ($form_email_property) { + $mc_lists = mailchimp_get_lists(); + $options = array(t('-- Select --')); + foreach ($mc_lists as $list_id => $list) { + $options[$list_id] = $list->name; + } + if (!empty($options)) { + $form['drupal_entity']['list_id'] = array( + '#title' => t('MailChimp List'), + '#type' => 'select', + '#required' => TRUE, + '#description' => t('Select the list that you created in MailChimp.'), + '#options' => $options, + '#default_value' => $entitynotnull ? $mailchimp_automations_entity->list_id : 0, + '#maxlength' => 127, + '#weight' => -5, + '#ajax' => array( + 'callback' => 'mailchimp_automations_mapping_form_callback', + 'wrapper' => 'mailchimp-automation-drupal-entity', + ), + ); + } + else { + $msg = t('You must add at least one list in MailChimp for this functionality to work.'); + drupal_set_message($msg, 'error', FALSE); + } + + $form_list_id = & $form_state['values']['list_id']; + if (!$form_list_id && $entitynotnull) { + $form_list_id = $mailchimp_automations_entity->list_id; + } + if ($form_list_id) { + $automations = mailchimp_automations_get_automations(); + if (!empty($automations)) { + $automation_options = mailchimp_automations_options_list($automations); + $form['drupal_entity']['workflow_id'] = array( + '#title' => t('Workflow ID'), + '#type' => 'select', + '#required' => TRUE, + '#description' => t('Select the workflow automation that you created in MailChimp. Untitled workflows are not included.'), + '#options' => $automation_options, + '#default_value' => $entitynotnull ? $mailchimp_automations_entity->workflow_id : 0, + '#maxlength' => 127, + '#weight' => -4, + '#ajax' => array( + 'callback' => 'mailchimp_automations_mapping_form_callback', + 'wrapper' => 'mailchimp-automation-drupal-entity', + ), + ); + } + else { + $msg = t('You must add at least one workflow in MailChimp for this functionality to work.'); + drupal_set_message($msg, 'error', FALSE); + } + + $form_workflow_id = & $form_state['values']['workflow_id']; + if (!$form_workflow_id && $entitynotnull) { + $form_workflow_id = $mailchimp_automations_entity->workflow_id; + } + if ($form_workflow_id) { + // Once the workflow id is saved, add the workflow email options. + $emails = mailchimp_automations_get_emails_for_workflow($form_workflow_id); + if (!empty($emails)) { + array_unshift($emails, t('-- Select --')); + $form['drupal_entity']['workflow_email_id'] = array( + '#title' => t('Workflow Email ID'), + '#type' => 'select', + '#required' => TRUE, + '#description' => t('Select the workflow automation email that you created in MailChimp.'), + '#options' => $emails, + '#default_value' => $entitynotnull ? $mailchimp_automations_entity->workflow_email_id : 0, + '#maxlength' => 127, + '#weight' => -3, + ); + } + else { + $msg = t('You must add at least one workflow email in MailChimp for this functionality to work.'); + drupal_set_message($msg, 'error', FALSE); + } + } + } + } + } + } + + $form['actions'] = array('#type' => 'actions'); + $form['actions']['submit'] = array( + '#value' => t('Save Entity'), + '#type' => 'submit', + ); + + return $form; +} + +/** + * Creates the options array for the select menu. + */ +function mailchimp_automations_options_list($automations) { + $options = array(t('-- Select --')); + foreach ($automations as $workflow) { + $title = $workflow->settings->title; + if (!empty($title)) { + $options[$workflow->id] = $title; + } + } + return $options; +} + +/** + * Ajax callback for mailchimp_automations_mapping_form(). + */ +function mailchimp_automations_mapping_form_callback($form, &$form_state) { + return $form['drupal_entity']; +} + +/** + * Validation callback for mailchimp_automations_entity_form(). + */ +function mailchimp_automations_entity_form_validate($form, &$form_state) { + if ($form_state['submitted']) { + $extant_mc_entities = entity_load('mailchimp_automations_entity'); + $form_id = $form_state['mailchimp_automations_entity']->mailchimp_automations_entity_id; + $form_bundle = $form_state['values']['bundle']; + $form_entity_id = $form_state['values']['entity_type']; + foreach ($extant_mc_entities as $extant_ent) { + if ($form_bundle == $extant_ent->bundle && + $form_entity_id == $extant_ent->entity_type && + $form_id != $extant_ent->mailchimp_automations_entity_id) { + form_set_error( + 'bundle', + t('A MailChimp Automation Entity already exists for this Bundle. Either select a different Bundle or edit the !link for this bundle.', + array( + '!link' => l(t('existing MailChimp Automation Entity'), "admin/config/services/mailchimp/automations/manage/{$extant_ent->name}"), + ) + )); + } + } + } +} + +/** + * Submit handler for mailchimp_automations_entity_form(). + */ +function mailchimp_automations_entity_form_submit($form, &$form_state) { + $dummy_entity = entity_create($form_state['values']['entity_type'], array('type' => $form_state['values']['bundle'])); + $entity_info = entity_get_info($dummy_entity->type); + if (!empty($entity_info)) { + // Create empty entity ID field so entity_uri doesn't result in an error. + $entity_id_field = $entity_info['entity keys']['id']; + $dummy_entity->$entity_id_field = NULL; + } + $uri = entity_uri($form_state['values']['entity_type'], $dummy_entity); + $values = $form_state['values']; + if ($form_state['op'] == 'add' || $form_state['op'] == 'clone') { + $automation_entity = entity_create('mailchimp_automations_entity', $values); + } + else { + $automation_entity = $form_state['mailchimp_automations_entity']; + foreach ($values as $key => $val) { + $automation_entity->{$key} = $val; + } + } + $automation_entity->save(); + // Make sure the new items appear in the menus: + menu_rebuild(); + $form_state['redirect'] = 'admin/config/services/mailchimp/automations'; +} + +/** + * Return all possible Drupal properties for a given entity type. + * + * @param string $entity_type + * Name of entity whose properties to list. + * @param string $entity_bundle + * Optional entity bundle to get properties for. + * + * @return array + * List of entities that can be used as an #options list. + */ +function mailchimp_automations_email_fieldmap_options($entity_type, $entity_bundle = NULL) { + $options = array('' => t('-- Select --')); + + $properties = entity_get_all_property_info($entity_type); + if (isset($entity_bundle)) { + $info = entity_get_property_info($entity_type); + $properties = $info['properties']; + if (isset($info['bundles'][$entity_bundle])) { + $properties += $info['bundles'][$entity_bundle]['properties']; + } + } + + foreach ($properties as $key => $property) { + $type = isset($property['type']) ? entity_property_extract_innermost_type($property['type']) : 'text'; + $is_entity = ($type == 'entity') || (bool) entity_get_info($type); + // Leave entities out of this. + if (!$is_entity) { + if (isset($property['field']) && $property['field'] && !empty($property['property info'])) { + foreach ($property['property info'] as $sub_key => $sub_prop) { + $options[$property['label']][$key . ':' . $sub_key] = $sub_prop['label']; + } + } + else { + $options[$key] = $property['label']; + } + } + } + + return $options; +} diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/includes/mailchimp_automations.entity.inc b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/includes/mailchimp_automations.entity.inc new file mode 100644 index 000000000..1d4ecfb4c --- /dev/null +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/includes/mailchimp_automations.entity.inc @@ -0,0 +1,40 @@ + 'admin/config/services/mailchimp/automations/manage/' . $this->name, + 'options' => array( + 'entity_type' => $this->entityType, + 'entity' => $this, + ), + ); + } + +} diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/includes/mailchimp_automations.ui_controller.inc b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/includes/mailchimp_automations.ui_controller.inc new file mode 100644 index 000000000..2ed60febb --- /dev/null +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/includes/mailchimp_automations.ui_controller.inc @@ -0,0 +1,26 @@ +path]['description'] = 'Manage MailChimp Automation entity settings.'; + $items[$this->path]['type'] = MENU_LOCAL_TASK; + $items[$this->path]['access callback'] = 'mailchimp_automations_entity_access'; + $items[$this->path]['title'] = "Automations"; + $items[$this->path]['weight'] = 10; + return $items; + } + +} diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/mailchimp_automations.info b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/mailchimp_automations.info new file mode 100644 index 000000000..8355a2308 --- /dev/null +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/mailchimp_automations.info @@ -0,0 +1,17 @@ +name = MailChimp Automations +description = Add workflow automations for any entity with an email field. +package = MailChimp +core = 7.x + +dependencies[] = mailchimp +dependencies[] = entity + +files[] = includes/mailchimp_automations.entity.inc +files[] = includes/mailchimp_automations.ui_controller.inc + +; Information added by Drupal.org packaging script on 2016-11-08 +version = "7.x-4.7" +core = "7.x" +project = "mailchimp" +datestamp = "1478578147" + diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/mailchimp_automations.install b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/mailchimp_automations.install new file mode 100644 index 000000000..a491cf51a --- /dev/null +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/mailchimp_automations.install @@ -0,0 +1,110 @@ + 'MailChimp automation enabled entities.', + 'fields' => array( + 'mailchimp_automations_entity_id' => array( + 'type' => 'serial', + 'not null' => TRUE, + 'description' => 'Primary Key: Unique mailchimp_automations_entity entity ID.', + ), + 'name' => array( + 'description' => 'The machine-readable name of this mailchimp_automations_entity.', + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + ), + 'label' => array( + 'description' => 'The human-readable name of this mailchimp_automations_entity.', + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + ), + 'entity_type' => array( + 'description' => 'The Drupal entity type (e.g. "node", "user").', + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '', + ), + 'bundle' => array( + 'description' => 'The Drupal bundle (e.g. "page", "user")', + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '', + ), + 'email_property' => array( + 'description' => 'The property that contains the email address to send to mailchimp.', + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '', + ), + 'list_id' => array( + 'description' => 'The MailChimp automation list id.', + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '', + ), + 'workflow_id' => array( + 'description' => 'The MailChimp automation workflow id.', + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '', + ), + 'workflow_email_id' => array( + 'description' => 'The MailChimp automation workflow email id.', + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '', + ), + // The following fields are for supporting exportable status. + 'locked' => array( + 'description' => 'A boolean indicating whether the administrator may delete this mapping.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + 'size' => 'tiny', + ), + 'status' => array( + 'type' => 'int', + 'not null' => TRUE, + // Set the default to ENTITY_CUSTOM without using the constant as it is + // not safe to use it at this point. + 'default' => 0x01, + 'size' => 'tiny', + 'description' => 'The exportable status of the entity.', + ), + 'module' => array( + 'description' => 'The name of the providing module if the entity has been defined in code.', + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + 'primary key' => array('mailchimp_automations_entity_id'), + 'unique keys' => array( + 'name' => array('name'), + 'entity_type_bundle' => array( + 'entity_type', + 'bundle', + ), + ), + ); + + return $schema; +} diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/mailchimp_automations.module b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/mailchimp_automations.module new file mode 100644 index 000000000..3791747f0 --- /dev/null +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_automations/mailchimp_automations.module @@ -0,0 +1,227 @@ + array( + 'label' => t('MailChimp Automations Entity'), + 'plural label' => t('MailChimp Automations Entities'), + 'controller class' => 'EntityAPIControllerExportable', + 'entity class' => 'MailchimpAutomationsEntity', + 'base table' => 'mailchimp_automations_entity', + 'uri callback' => 'entity_class_uri', + 'fieldable' => FALSE, + 'exportable' => TRUE, + 'module' => 'mailchimp_automations', + 'entity keys' => array( + 'id' => 'mailchimp_automations_entity_id', + 'name' => 'name', + 'label' => 'label', + ), + // Enable the entity API's admin UI. + 'admin ui' => array( + 'path' => 'admin/config/services/mailchimp/automations', + 'file' => 'includes/mailchimp_automations.admin.inc', + 'controller class' => 'MailChimpAutomationUIController', + ), + 'label callback' => 'mailchimp_automations_entity_info_label', + 'access callback' => 'mailchimp_automations_entity_access', + ), + ); + + return $return; +} + +/** + * Entity label callback. + */ +function mailchimp_automations_entity_info_label($entity, $entity_type) { + return empty($entity) ? 'New MailChimp Automation' : $entity->label; +} + +/** + * Access callback for mailchimp_automations_entity. + */ +function mailchimp_automations_entity_access() { + return mailchimp_apikey_ready_access('administer mailchimp automations'); +} + +/** + * Implements hook_entity_insert(). + */ +function mailchimp_automations_entity_insert($entity, $type) { + $wrapper = entity_metadata_wrapper($type, $entity); + $bundle = $wrapper->getBundle(); + if ($automation_entity = mailchimp_automations_entity_automation($type, $bundle)) { + mailchimp_automations_trigger_workflow($automation_entity, $wrapper); + } +} + +/** + * Access callback for activity menu items. + */ +function mailchimp_automations_access(MailchimpAutomationsEntity $mailchimp_automations_entity) { + if (user_access('access mailchimp automations')) { + return TRUE; + } + return FALSE; +} + +/** + * Loads a single or multiple instances of MailchimpAutomationsEntity. + * + * @param string $name + * Optional name of the MailchimpAutomationsEntity instance to load. + * + * @return mixed + * Array of MailchimpAutomationsEntity instances or one instance if $name is set. + */ +function mailchimp_automations_load_entities($id = NULL) { + $types = entity_load_multiple_by_name('mailchimp_automations_entity', isset($id) ? array($id) : FALSE); + return isset($id) ? reset($types) : $types; +} + +/** + * Wrapper for MailchimpAutomations->getAutomations(). + * + * @param string $workflow_id + * The MailChimp workflow_id. + * + * @return array + * The workflow automations for the active MailChimp API account. + */ +function mailchimp_automations_get_automations() { + $mc_auto = mailchimp_get_api_object('MailchimpAutomations'); + $results = $mc_auto->getAutomations(); + return $results->automations; +} + +/** + * Wrapper for MailchimpAutomations->getWorkflow(). + * + * @param string $workflow_id + * The MailChimp workflow_id. + * + * @return array + * The $key is workflow_id and the $value is the + */ +function mailchimp_automations_get_automation($workflow_id) { + $mc_auto = mailchimp_get_api_object('MailchimpAutomations'); + $workflow = $mc_auto->getWorkflow($workflow_id); + $title = $worflow->settings->title; + if (!empty($title)) { + return array( + $workflow->id => $title, + ); + } + return NULL; +} + +/** + * Wrapper for MailchimpAutomations->getWorkflowEmails(). + * + * @param string $workflow_id + * The MailChimp workflow_id. + * + * @return array + * An array of email workflows associated with this automation. + */ +function mailchimp_automations_get_emails_for_workflow($workflow_id) { + $emails = array(); + $mc_auto = mailchimp_get_api_object('MailchimpAutomations'); + $results = $mc_auto->getWorkflowEmails($workflow_id); + $email_results = $results->emails; + foreach ($email_results as $email) { + $title = $email->settings->title; + if (!empty($title)) { + $emails[$email->id] = $title; + } + } + return $emails; +} + +/** + * Triggers a workflow automation via the MailChimp API. + * + * @param object $automation + * The MailchimpAutomationsEntity object from the database. + * @param EntityMetadataWrapper $wrapped_entity + * The wrapped entity that triggered the workflow automation. + */ +function mailchimp_automations_trigger_workflow($automation_entity, $wrapped_entity) { + $email_property_field = $automation_entity->email_property; + $email = $wrapped_entity->$email_property_field->value(); + if (!mailchimp_is_subscribed($automation_entity->list_id, $email)) { + $merge_vars = NULL; + drupal_alter('mailchimp_automations_mergevars', $merge_vars, $automation_entity, $wrapped_entity); + // Skip mailchimp_subscribe to avoid cron if set + $added = mailchimp_subscribe_process($automation_entity->list_id, $email, $merge_vars); + if (!$added) { + watchdog('mailchimp', 'An error occurred subscribing @email to list @list during a workflow @automation. The automation did not comlplete.', array( + '@automation' => $automation_entity->label, + '@email' => $email, + ), WATCHDOG_ERROR); + } + } + $mc_auto = mailchimp_get_api_object('MailchimpAutomations'); + try { + $result = $mc_auto->addWorkflowEmailSubscriber($automation_entity->workflow_id, $automation_entity->workflow_email_id, $email); + if ($result) { + module_invoke_all('mailchimp_automations_workflow_email_triggered', $automation_entity, $email, $wrapped_entity); + } + } + catch (Exception $e) { + watchdog('mailchimp', 'An error occurred triggering a workflow automation. Workflow: @automation, Email: @email. The automation did not successfully complete. "%message"', array( + '@automation' => $automation_entity->label, + '@email' => $email, + '%message' => $e->getMessage(), + ), WATCHDOG_ERROR); + } +} + +/** + * Queries to see if there is an existing automation entity + * + * @param string $type + * The entity type name + * @param string $bundle + * The Drupal bundle for the entity + * + * @return Object + * The mailchimp_automations_entity + */ +function mailchimp_automations_entity_automation($type, $bundle) { + $query = new EntityFieldQuery(); + + $query->entityCondition('entity_type', 'mailchimp_automations_entity') + ->propertyCondition('entity_type', $type) + ->propertyCondition('bundle', $bundle) + ->propertyCondition('status', 1); + + $result = $query->execute(); + if ($result) { + $entity_array = entity_load('mailchimp_automations_entity', array_keys($result['mailchimp_automations_entity'])); + return reset($entity_array); + } + return NULL; +} + +/** + * Implements hook_permission(). + */ +function mailchimp_automations_permission() { + $return = array(); + + $return['administer mailchimp automations'] = array( + 'title' => t('Administer MailChimp automation entities'), + 'description' => t('Add, Delete, and Configure MailChimp Automation entity settings.'), + ); + return $return; +} diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_campaign/mailchimp_campaign.info b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_campaign/mailchimp_campaign.info index 2f2202418..b70d6bf05 100644 --- a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_campaign/mailchimp_campaign.info +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_campaign/mailchimp_campaign.info @@ -13,9 +13,9 @@ files[] = tests/mailchimp_campaigns.test configure = admin/config/services/mailchimp/campaigns -; Information added by Drupal.org packaging script on 2016-10-28 -version = "7.x-4.6" +; Information added by Drupal.org packaging script on 2016-11-08 +version = "7.x-4.7" core = "7.x" project = "mailchimp" -datestamp = "1477691643" +datestamp = "1478578147" diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_i18n/mailchimp_i18n.i18n.inc b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_i18n/mailchimp_i18n.i18n.inc new file mode 100644 index 000000000..3188737be --- /dev/null +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_i18n/mailchimp_i18n.i18n.inc @@ -0,0 +1,69 @@ + t('Description'), + 'submit_button' => t('Submit Button Label'), + 'confirmation_message' => t('Confirmation Message'), + ); + + // Add in translations for all settings and mergefields. + foreach ($this->object->settings as $settings_key => $setting) { + if (is_array($setting)) { + $mergefields = array_filter($setting); + foreach ($mergefields as $tag => $mergefield_settings) { + $properties['mergefield:' . $tag] = array( + 'title' => $mergefield_settings->name, + 'string' => $mergefield_settings->name, + ); + } + } + if (isset($title_mapping[$settings_key])) { + $properties[$settings_key] = array( + 'title' => $title_mapping[$settings_key], + 'string' => $setting, + ); + } + } + + $strings[$this->get_textgroup()]['mailchimp_signup'][$this->object->name] += $properties; + return $strings; + } + +} diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_i18n/mailchimp_i18n.info b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_i18n/mailchimp_i18n.info new file mode 100644 index 000000000..9e70cc044 --- /dev/null +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_i18n/mailchimp_i18n.info @@ -0,0 +1,14 @@ +name = Mailchimp translation +description = Allows translating Mailchimp forms. +dependencies[] = i18n_string +package = Multilingual - Internationalization +core = 7.x + +files[] = mailchimp_i18n.i18n.inc + +; Information added by Drupal.org packaging script on 2016-11-08 +version = "7.x-4.7" +core = "7.x" +project = "mailchimp" +datestamp = "1478578147" + diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_i18n/mailchimp_i18n.module b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_i18n/mailchimp_i18n.module new file mode 100644 index 000000000..bf3a113c3 --- /dev/null +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_i18n/mailchimp_i18n.module @@ -0,0 +1,53 @@ +original->name != $mailchimp_signup->name) { + i18n_string_update_context("mailchimp_signup:mailchimp_signup:{$mailchimp_signup->original->name}:*", "mailchimp_signup:mailchimp_signup:{$mailchimp_signup->original->name->name}:*"); + } + i18n_string_object_update('mailchimp_signup', $mailchimp_signup); +} + +/** + * Implements hook_mailchimp_signup_delete(). + */ +function mailchimp_i18n_mailchimp_type_delete($mailchimp_signup) { + i18n_string_object_remove('mailchimp_signup', $mailchimp_signup); +} diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_lists/mailchimp_lists.info b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_lists/mailchimp_lists.info index a8d79b5de..e82ab992c 100644 --- a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_lists/mailchimp_lists.info +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_lists/mailchimp_lists.info @@ -11,9 +11,9 @@ configure = admin/config/services/mailchimp/lists files[] = tests/mailchimp_lists.test -; Information added by Drupal.org packaging script on 2016-10-28 -version = "7.x-4.6" +; Information added by Drupal.org packaging script on 2016-11-08 +version = "7.x-4.7" core = "7.x" project = "mailchimp" -datestamp = "1477691643" +datestamp = "1478578147" diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_lists/mailchimp_lists.module b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_lists/mailchimp_lists.module index 329131956..05bc8208f 100644 --- a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_lists/mailchimp_lists.module +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_lists/mailchimp_lists.module @@ -272,11 +272,11 @@ function mailchimp_lists_process_subscribe_form_choices($choices, $instance, $fi break; case 'unsubscribe': - $ret = mailchimp_unsubscribe($list_id, $email, FALSE); + $ret = mailchimp_unsubscribe_member($list_id, $email, FALSE); break; case 'remove': - $ret = mailchimp_unsubscribe($list_id, $email, TRUE); + $ret = mailchimp_unsubscribe_member($list_id, $email, TRUE); break; case 'update': diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_lists/tests/mailchimp_lists.test b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_lists/tests/mailchimp_lists.test index a976f268e..934969d29 100644 --- a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_lists/tests/mailchimp_lists.test +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_lists/tests/mailchimp_lists.test @@ -178,7 +178,7 @@ class MailchimpListsTestCase extends DrupalWebTestCase { $list_id = '57afe96172'; $email = 'test@example.org'; - $unsubscribed = mailchimp_unsubscribe($list_id, $email); + $unsubscribed = mailchimp_unsubscribe_member($list_id, $email); $this->assertTrue($unsubscribed, 'Tested user unsubscription.'); } diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/includes/mailchimp_signup.admin.inc b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/includes/mailchimp_signup.admin.inc index 1e3e1d9e0..81de9a834 100644 --- a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/includes/mailchimp_signup.admin.inc +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/includes/mailchimp_signup.admin.inc @@ -259,22 +259,7 @@ function mailchimp_signup_form_submit($form, &$form_state) { } } - // update i18n translation sources - $language = language_default('language'); - $t_strings = array('title', 'name', 'description'); - foreach($t_strings as $key){ - mailchimp_signup_tt("field:mailchimp_signup:form:$signup->mcs_id:$key", $form_state['values'][$key], $language, TRUE); - } - foreach ($mergefields as $id => $val) { - if ($val) { - mailchimp_signup_tt("field:mailchimp_signup:form:$signup->mcs_id:mergefield:$id", $val->name, $language, TRUE); - } - } - mailchimp_signup_tt("field:mailchimp_signup:form:$signup->mcs_id:confirmation_message", $form_state['values']['settings']['confirmation_message'], $language, TRUE); - mailchimp_signup_tt("field:mailchimp_signup:form:$signup->mcs_id:submit_button", $form_state['values']['settings']['submit_button'], $language, TRUE); - - drupal_set_message(t('Signup form @name has been saved.', - array('@name' => $signup->name))); + drupal_set_message(t('Signup form @name has been saved.', array('@name' => $signup->name))); $form_state['redirect'] = 'admin/config/services/mailchimp/signup'; } else { diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/mailchimp_signup.info b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/mailchimp_signup.info index 462609ed9..46e44014e 100644 --- a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/mailchimp_signup.info +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/mailchimp_signup.info @@ -10,9 +10,9 @@ configure = admin/config/services/mailchimp/signup files[] = includes/mailchimp_signup.entity.inc files[] = includes/mailchimp_signup.ui_controller.inc -; Information added by Drupal.org packaging script on 2016-10-28 -version = "7.x-4.6" +; Information added by Drupal.org packaging script on 2016-11-08 +version = "7.x-4.7" core = "7.x" project = "mailchimp" -datestamp = "1477691643" +datestamp = "1478578147" diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/mailchimp_signup.install b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/mailchimp_signup.install index e7105d701..5595d2305 100644 --- a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/mailchimp_signup.install +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/mailchimp_signup.install @@ -68,6 +68,9 @@ function mailchimp_signup_schema() { ), 'primary key' => array('mcs_id'), 'unique key' => array('name'), + 'indexes' => array( + 'name' => array('name'), + ), ); return $schema; @@ -97,6 +100,12 @@ function mailchimp_signup_update_7002(&$sandbox) { $sandbox['total'] = $record_count; $sandbox['processed'] = 0; + + if ($sandbox['total'] == 0) { + // No signup forms found; update not required. + $sandbox['#finished'] = 1; + return; + } } $limit = 10; @@ -171,3 +180,15 @@ function mailchimp_signup_update_7002(&$sandbox) { $sandbox['#finished'] = ($sandbox['processed'] / $sandbox['total']); } + +/** + * Add index for the field looked up by it's entity controller. + */ +function mailchimp_signup_update_7003(&$sandbox) { + if (db_index_exists('mailchimp_signup', 'name')) { + return t('Database index for name column of the mailchimp_signup table existed already.'); + } + db_add_index('mailchimp_signup', 'name', array('name')); + + return t('Database index added to the name column of the mailchimp_signup table.'); +} diff --git a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/mailchimp_signup.module b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/mailchimp_signup.module index 46eb684cf..ff9373097 100644 --- a/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/mailchimp_signup.module +++ b/www7/sites/all/modules/contrib/mailchimp/modules/mailchimp_signup/mailchimp_signup.module @@ -57,7 +57,7 @@ function mailchimp_signup_menu() { */ function mailchimp_signup_title($signup_id){ $signup = mailchimp_signup_load($signup_id); - return mailchimp_signup_tt("field:mailchimp_signup:form:$signup->mcs_id:title", $signup->title); + return $signup->getTranslation('title'); } /** @@ -102,7 +102,7 @@ function mailchimp_signup_block_view($delta = '') { $signup = mailchimp_signup_load($delta); if ($signup) { $block = array( - 'subject' => check_plain($signup->title), + 'subject' => check_plain($signup->getTranslation('title')), 'content' => drupal_get_form('mailchimp_signup_subscribe_block_' . $signup->name . '_form', $signup, 'mailchimp_signup_block'), ); } @@ -211,7 +211,7 @@ function mailchimp_signup_entity_info() { * Entity label callback. */ function mailchimp_signup_entity_info_label($entity, $entity_type) { - return empty($entity) ? 'New MailChimp Signup' : $entity->title; + return empty($entity) ? t('New MailChimp Signup') : $entity->getTranslation('title'); } /** @@ -261,10 +261,9 @@ function mailchimp_signup_forms($form_id, $args) { function mailchimp_signup_subscribe_form($form, &$form_state, $signup, $type) { $form['#attributes'] = array('class' => array('mailchimp-signup-subscribe-form')); $form['description'] = array( - '#markup' => mailchimp_signup_tt("field:mailchimp_signup:form:$signup->mcs_id:description", filter_xss($signup->settings['description'])), - + '#markup' => mailchimp_signup_tt("mailchimp_signup:mailchimp_signup:$signup->name:description", filter_xss($signup->settings['description'])), '#prefix' => '' + '#suffix' => '
    ', ); $form['mailchimp_lists'] = array('#tree' => TRUE); $lists = mailchimp_get_lists($signup->mc_lists); @@ -317,7 +316,7 @@ function mailchimp_signup_subscribe_form($form, &$form_state, $signup, $type) { ); foreach ($signup->settings['mergefields'] as $tag => $mergevar) { if (!empty($mergevar)) { - $mergevar->name = mailchimp_signup_tt("field:mailchimp_signup:form:$signup->mcs_id:mergefield:$tag", $mergevar->name); + $mergevar->name = mailchimp_signup_tt("mailchimp_signup:mailchimp_signup:$signup->name:mergefield:$tag", $mergevar->name); $form['mergevars'][$tag] = mailchimp_insert_drupal_form_tag($mergevar); if (empty($lists)) { $form['mergevars'][$tag]['#disabled'] = TRUE; @@ -329,7 +328,7 @@ function mailchimp_signup_subscribe_form($form, &$form_state, $signup, $type) { $form['actions']['submit'] = array( '#type' => 'submit', '#weight' => 10, - '#value' => mailchimp_signup_tt("field:mailchimp_signup:form:$signup->mcs_id:submit_button", $signup->settings['submit_button']), + '#value' => mailchimp_signup_tt("mailchimp_signup:mailchimp_signup:$signup->name:submit_button", $signup->settings['submit_button']), '#disabled' => (empty($lists)), ); @@ -391,7 +390,7 @@ function mailchimp_signup_subscribe_form_submit($form, &$form_state) { $result = mailchimp_subscribe($list_id, $email, $mergevars, $interests, $signup->settings['doublein']); // Let other modules act on the results in hook_form_alter. $form_state['mailchimp_results'] = $result; - if (empty($result)) { + if (empty($result) || ($result->success === FALSE)) { drupal_set_message(t('There was a problem with your newsletter signup to %list.', array( '%list' => $list_details[$list_id]->name, )), 'warning'); @@ -400,8 +399,8 @@ function mailchimp_signup_subscribe_form_submit($form, &$form_state) { $successes[] = $list_details[$list_id]->name; } } - if (count($successes) && isset($signup->settings['confirmation_message']) && strlen($signup->settings['confirmation_message'])) { - $message = mailchimp_signup_tt("field:mailchimp_signup:form:$signup->mcs_id:confirmation_message", check_plain($signup->settings['confirmation_message'])); + if (count($successes) && !empty($signup->settings['confirmation_message'])) { + $message = mailchimp_signup_tt("mailchimp_signup:mailchimp_signup:$signup->name:confirmation_message", check_plain($signup->settings['confirmation_message'])); drupal_set_message($message, 'status'); } if (!empty($signup->settings['destination'])) { From ea9456e5182e530ee5ba9c73f6de033582c05f4c Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Fri, 11 Nov 2016 15:34:13 +0100 Subject: [PATCH 03/16] Update mailchimp library to 1.0.5 --- www7/sites/all/libraries/mailchimp/README.md | 0 .../all/libraries/mailchimp/composer.json | 2 +- .../all/libraries/mailchimp/composer.lock | 14 +-- .../sites/all/libraries/mailchimp/phpunit.xml | 0 .../all/libraries/mailchimp/src/Mailchimp.php | 88 +++++++++++++-- .../mailchimp/src/MailchimpAPIException.php | 0 .../mailchimp/src/MailchimpAutomations.php | 0 .../mailchimp/src/MailchimpCURLClient.php | 104 ++++++++++++++++++ .../mailchimp/src/MailchimpCampaigns.php | 20 ++++ .../mailchimp/src/MailchimpEcommerce.php | 0 .../mailchimp/src/MailchimpLists.php | 0 .../mailchimp/src/MailchimpReports.php | 0 .../mailchimp/src/MailchimpTemplates.php | 0 .../tests/MailchimpAutomationsTest.php | 0 .../tests/MailchimpCampaignsTest.php | 13 +++ .../tests/MailchimpEcommerceTest.php | 0 .../mailchimp/tests/MailchimpListsTest.php | 0 .../mailchimp/tests/MailchimpReportsTest.php | 0 .../tests/MailchimpTemplatesTest.php | 0 .../mailchimp/tests/MailchimpTest.php | 2 +- .../libraries/mailchimp/tests/src/Client.php | 0 .../mailchimp/tests/src/Mailchimp.php | 2 +- .../tests/src/MailchimpAutomations.php | 2 +- .../tests/src/MailchimpCampaigns.php | 2 +- .../tests/src/MailchimpEcommerce.php | 2 +- .../mailchimp/tests/src/MailchimpLists.php | 2 +- .../mailchimp/tests/src/MailchimpReports.php | 2 +- .../tests/src/MailchimpTemplates.php | 2 +- .../mailchimp/tests/src/Response.php | 0 .../all/libraries/mailchimp/vendor/.DS_Store | Bin 10244 -> 0 bytes .../libraries/mailchimp/vendor/autoload.php | 2 +- .../vendor/composer/autoload_real.php | 14 +-- .../vendor/composer/autoload_static.php | 10 +- .../mailchimp/vendor/composer/installed.json | 12 +- .../mailchimp/vendor/symfony/yaml/Inline.php | 7 +- .../vendor/symfony/yaml/Tests/InlineTest.php | 17 ++- 36 files changed, 262 insertions(+), 57 deletions(-) mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/README.md mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/composer.json mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/phpunit.xml mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/src/Mailchimp.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/src/MailchimpAPIException.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/src/MailchimpAutomations.php create mode 100755 www7/sites/all/libraries/mailchimp/src/MailchimpCURLClient.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/src/MailchimpCampaigns.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/src/MailchimpEcommerce.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/src/MailchimpLists.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/src/MailchimpReports.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/src/MailchimpTemplates.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/MailchimpAutomationsTest.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/MailchimpCampaignsTest.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/MailchimpEcommerceTest.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/MailchimpListsTest.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/MailchimpReportsTest.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/MailchimpTemplatesTest.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/MailchimpTest.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/src/Client.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/src/Mailchimp.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/src/MailchimpAutomations.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/src/MailchimpCampaigns.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/src/MailchimpEcommerce.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/src/MailchimpLists.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/src/MailchimpReports.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/src/MailchimpTemplates.php mode change 100644 => 100755 www7/sites/all/libraries/mailchimp/tests/src/Response.php delete mode 100644 www7/sites/all/libraries/mailchimp/vendor/.DS_Store diff --git a/www7/sites/all/libraries/mailchimp/README.md b/www7/sites/all/libraries/mailchimp/README.md old mode 100644 new mode 100755 diff --git a/www7/sites/all/libraries/mailchimp/composer.json b/www7/sites/all/libraries/mailchimp/composer.json old mode 100644 new mode 100755 index 931a0d0e0..79b4b1f19 --- a/www7/sites/all/libraries/mailchimp/composer.json +++ b/www7/sites/all/libraries/mailchimp/composer.json @@ -1,6 +1,6 @@ { "name": "thinkshout/mailchimp-api-php", - "version": "1.0.4", + "version": "1.0.5", "type": "library", "description": "PHP library for v3 of the MailChimp API", "keywords": ["mailchimp", "mail"], diff --git a/www7/sites/all/libraries/mailchimp/composer.lock b/www7/sites/all/libraries/mailchimp/composer.lock index 79d3dfc02..ca3952e3d 100644 --- a/www7/sites/all/libraries/mailchimp/composer.lock +++ b/www7/sites/all/libraries/mailchimp/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "dad6886cc43404c70ead41dd05d6de87", - "content-hash": "9aa998075f9af2435f3ea45bd7d6bdef", + "hash": "c106041f6e7a25291f25dbecd6f0354e", + "content-hash": "eb5a420e156fad673a4d62ce4223f170", "packages": [ { "name": "guzzlehttp/guzzle", @@ -1237,16 +1237,16 @@ }, { "name": "symfony/yaml", - "version": "v3.1.5", + "version": "v3.1.6", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3" + "reference": "7ff51b06c6c3d5cc6686df69004a42c69df09e27" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/368b9738d4033c8b93454cb0dbd45d305135a6d3", - "reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3", + "url": "https://api.github.com/repos/symfony/yaml/zipball/7ff51b06c6c3d5cc6686df69004a42c69df09e27", + "reference": "7ff51b06c6c3d5cc6686df69004a42c69df09e27", "shasum": "" }, "require": { @@ -1282,7 +1282,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-09-25 08:27:07" + "time": "2016-10-24 18:41:13" }, { "name": "webmozart/assert", diff --git a/www7/sites/all/libraries/mailchimp/phpunit.xml b/www7/sites/all/libraries/mailchimp/phpunit.xml old mode 100644 new mode 100755 diff --git a/www7/sites/all/libraries/mailchimp/src/Mailchimp.php b/www7/sites/all/libraries/mailchimp/src/Mailchimp.php old mode 100644 new mode 100755 index 64ea38796..6da0ea66b --- a/www7/sites/all/libraries/mailchimp/src/Mailchimp.php +++ b/www7/sites/all/libraries/mailchimp/src/Mailchimp.php @@ -12,7 +12,7 @@ */ class Mailchimp { - const VERSION = '1.0.4'; + const VERSION = '1.0.5'; const DEFAULT_DATA_CENTER = 'us1'; const ERROR_CODE_BAD_REQUEST = 'BadRequest'; @@ -41,12 +41,19 @@ class Mailchimp { public $version = self::VERSION; /** - * The GuzzleHttp Client. + * The GuzzleHttp client. * * @var Client $client */ protected $client; + /** + * The cURL client. + * + * @var MailchimpCURLClient $curl_client + */ + protected $curl_client; + /** * The REST API endpoint. * @@ -87,6 +94,15 @@ class Mailchimp { */ private $batch_operations; + /** + * TRUE if cURL should be used instead of the default Guzzle library. + * + * Provides compatibility with PHP 5.4. + * + * @var boolean $use_curl + */ + private $use_curl; + /** * Mailchimp constructor. * @@ -94,10 +110,10 @@ class Mailchimp { * The MailChimp API key. * @param string $api_user * The MailChimp API username. - * @param int $timeout - * Maximum request time in seconds. + * @param array $http_options + * HTTP client options. */ - public function __construct($api_key, $api_user = 'apikey', $timeout = 10) { + public function __construct($api_key, $api_user = 'apikey', $http_options = []) { $this->api_key = $api_key; $this->api_user = $api_user; @@ -105,9 +121,29 @@ public function __construct($api_key, $api_user = 'apikey', $timeout = 10) { $this->endpoint = str_replace(Mailchimp::DEFAULT_DATA_CENTER, $dc, $this->endpoint); - $this->client = new Client([ - 'timeout' => $timeout, - ]); + // Handle deprecated 'timeout' argument. + if (is_int($http_options)) { + $http_options = [ + 'timeout' => $http_options, + ]; + } + + // Default timeout is 10 seconds. + $http_options += [ + 'timeout' => 10, + ]; + + // Use Guzzle HTTP client if PHP version is 5.5.0 or above. + // Use cURL otherwise. + $this->use_curl = version_compare(phpversion(), '5.5.0', '<'); + + if ($this->use_curl) { + $this->curl_client = new MailchimpCURLClient($http_options); + } + else { + $this->client = new Client($http_options); + } + } /** @@ -264,6 +300,20 @@ protected function request($method, $path, $tokens = NULL, $parameters = NULL, $ $options['headers']['X-Trigger-Error'] = $this->debug_error_code; } + if ($this->use_curl) { + return $this->handleRequestCURL($method, $this->endpoint . $path, $options, $parameters); + } + else { + return $this->handleRequest($method, $this->endpoint . $path, $options, $parameters); + } + } + + /** + * Makes a request to the MailChimp API using the Guzzle HTTP client. + * + * @see Mailchimp::request(). + */ + public function handleRequest($method, $uri = '', $options = [], $parameters) { if (!empty($parameters)) { if ($method == 'GET') { // Send parameters as query string parameters. @@ -276,11 +326,10 @@ protected function request($method, $path, $tokens = NULL, $parameters = NULL, $ } try { - $response = $this->client->request($method, $this->endpoint . $path, $options); + $response = $this->client->request($method, $uri, $options); $data = json_decode($response->getBody()); return $data; - } catch (RequestException $e) { $response = $e->getResponse(); @@ -295,6 +344,25 @@ protected function request($method, $path, $tokens = NULL, $parameters = NULL, $ } } + /** + * Makes a request to the MailChimp API using cURL. + * + * @see Mailchimp::request(). + */ + public function handleRequestCURL($method, $uri = '', $options = [], $parameters) { + try { + $response = $this->curl_client->request($method, $uri, $options, $parameters); + $data = json_decode($response); + + return $data; + } + catch (\Exception $e) { + $message = $e->getMessage(); + + throw new MailchimpAPIException($message, $e->getCode(), $e); + } + } + /** * Gets the ID of the data center associated with an API key. * diff --git a/www7/sites/all/libraries/mailchimp/src/MailchimpAPIException.php b/www7/sites/all/libraries/mailchimp/src/MailchimpAPIException.php old mode 100644 new mode 100755 diff --git a/www7/sites/all/libraries/mailchimp/src/MailchimpAutomations.php b/www7/sites/all/libraries/mailchimp/src/MailchimpAutomations.php old mode 100644 new mode 100755 diff --git a/www7/sites/all/libraries/mailchimp/src/MailchimpCURLClient.php b/www7/sites/all/libraries/mailchimp/src/MailchimpCURLClient.php new file mode 100755 index 000000000..7ce82bcab --- /dev/null +++ b/www7/sites/all/libraries/mailchimp/src/MailchimpCURLClient.php @@ -0,0 +1,104 @@ +config = $config; + } + + /** + * Makes a request to the MailChimp API using cURL. + * + * @param string $method + * The REST method to use when making the request. + * @param string $uri + * The API URI to request. + * @param array $options + * Request options. @see Mailchimp::request(). + * @param array $parameters + * Associative array of parameters to send in the request body. + * + * @return object + * + * @throws \Exception + */ + public function request($method, $uri = '', $options = [], $parameters = []) { + $ch = curl_init(); + + curl_setopt($ch, CURLOPT_TIMEOUT, $this->config['timeout']); + + // Set request headers. + $headers = []; + foreach ($options['headers'] as $header_name => $header_value) { + $headers[] = $header_name . ': ' . $header_value; + } + + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + + // Set request content. + switch ($method) { + case 'POST': + curl_setopt($ch, CURLOPT_POST, TRUE); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode((object) $parameters)); + break; + case 'GET': + $uri .= '?' . http_build_query($parameters); + break; + case 'PUT': + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode((object) $parameters)); + break; + case 'PATCH': + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode((object) $parameters)); + break; + case 'DELETE': + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); + break; + default: + // Throw exception for unsupported request method. + throw new \Exception('Unsupported HTTP request method: ' . $method); + break; + } + + curl_setopt($ch, CURLOPT_URL, $uri); + + // Get response as a string. + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $response = curl_exec($ch); + + // Handle errors. + $curl_error = ($response === FALSE) ? curl_error($ch) : NULL; + + // Close cURL connection. + curl_close($ch); + + if (!empty($curl_error)) { + throw new \Exception($curl_error); + } + + $response_data = json_decode($response); + if (isset($response_data->status) && ($response_data->status != 200)) { + throw new \Exception($response_data->detail); + } + + return $response; + } + +} diff --git a/www7/sites/all/libraries/mailchimp/src/MailchimpCampaigns.php b/www7/sites/all/libraries/mailchimp/src/MailchimpCampaigns.php old mode 100644 new mode 100755 index b00fa6eb0..b4cdcb04c --- a/www7/sites/all/libraries/mailchimp/src/MailchimpCampaigns.php +++ b/www7/sites/all/libraries/mailchimp/src/MailchimpCampaigns.php @@ -80,6 +80,26 @@ public function addCampaign($type, $recipients, $settings, $parameters = [], $ba return $this->request('POST', '/campaigns', NULL, $parameters, $batch); } + /** + * Gets the HTML, plain-text, and template content for a MailChimp campaign. + * + * @param string $campaign_id + * The ID of the campaign. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/content/#read-get_campaigns_campaign_id_content + */ + public function getCampaignContent($campaign_id, $parameters = []) { + $tokens = [ + 'campaign_id' => $campaign_id, + ]; + + return $this->request('GET', '/campaigns/{campaign_id}/content', $tokens, $parameters); + } + /** * Sets the HTML, plain-text, and template content for a MailChimp campaign. * diff --git a/www7/sites/all/libraries/mailchimp/src/MailchimpEcommerce.php b/www7/sites/all/libraries/mailchimp/src/MailchimpEcommerce.php old mode 100644 new mode 100755 diff --git a/www7/sites/all/libraries/mailchimp/src/MailchimpLists.php b/www7/sites/all/libraries/mailchimp/src/MailchimpLists.php old mode 100644 new mode 100755 diff --git a/www7/sites/all/libraries/mailchimp/src/MailchimpReports.php b/www7/sites/all/libraries/mailchimp/src/MailchimpReports.php old mode 100644 new mode 100755 diff --git a/www7/sites/all/libraries/mailchimp/src/MailchimpTemplates.php b/www7/sites/all/libraries/mailchimp/src/MailchimpTemplates.php old mode 100644 new mode 100755 diff --git a/www7/sites/all/libraries/mailchimp/tests/MailchimpAutomationsTest.php b/www7/sites/all/libraries/mailchimp/tests/MailchimpAutomationsTest.php old mode 100644 new mode 100755 diff --git a/www7/sites/all/libraries/mailchimp/tests/MailchimpCampaignsTest.php b/www7/sites/all/libraries/mailchimp/tests/MailchimpCampaignsTest.php old mode 100644 new mode 100755 index e29a820fb..5f432f0f0 --- a/www7/sites/all/libraries/mailchimp/tests/MailchimpCampaignsTest.php +++ b/www7/sites/all/libraries/mailchimp/tests/MailchimpCampaignsTest.php @@ -63,6 +63,19 @@ public function testAddCampaign() { $this->assertEquals($settings->from_name, $request_body->settings->from_name); } + /** + * Tests library functionality for getting campaign content. + */ + public function testGetCampaignContent() { + $campaign_id = '42694e9e57'; + + $mc = new MailchimpCampaigns(); + $mc->getCampaignContent($campaign_id); + + $this->assertEquals('GET', $mc->getClient()->method); + $this->assertEquals($mc->getEndpoint() . '/campaigns/' . $campaign_id . '/content', $mc->getClient()->uri); + } + /** * Tests library functionality for setting campaign content. */ diff --git a/www7/sites/all/libraries/mailchimp/tests/MailchimpEcommerceTest.php b/www7/sites/all/libraries/mailchimp/tests/MailchimpEcommerceTest.php old mode 100644 new mode 100755 diff --git a/www7/sites/all/libraries/mailchimp/tests/MailchimpListsTest.php b/www7/sites/all/libraries/mailchimp/tests/MailchimpListsTest.php old mode 100644 new mode 100755 diff --git a/www7/sites/all/libraries/mailchimp/tests/MailchimpReportsTest.php b/www7/sites/all/libraries/mailchimp/tests/MailchimpReportsTest.php old mode 100644 new mode 100755 diff --git a/www7/sites/all/libraries/mailchimp/tests/MailchimpTemplatesTest.php b/www7/sites/all/libraries/mailchimp/tests/MailchimpTemplatesTest.php old mode 100644 new mode 100755 diff --git a/www7/sites/all/libraries/mailchimp/tests/MailchimpTest.php b/www7/sites/all/libraries/mailchimp/tests/MailchimpTest.php old mode 100644 new mode 100755 index 049208457..56fd58f9b --- a/www7/sites/all/libraries/mailchimp/tests/MailchimpTest.php +++ b/www7/sites/all/libraries/mailchimp/tests/MailchimpTest.php @@ -25,7 +25,7 @@ public function testGetAccount() { */ public function testVersion() { $mc = new Mailchimp(); - $this->assertEquals($mc::VERSION, '1.0.4'); + $this->assertEquals($mc::VERSION, '1.0.5'); $this->assertEquals(json_decode(file_get_contents('composer.json'))->version, $mc::VERSION); } diff --git a/www7/sites/all/libraries/mailchimp/tests/src/Client.php b/www7/sites/all/libraries/mailchimp/tests/src/Client.php old mode 100644 new mode 100755 diff --git a/www7/sites/all/libraries/mailchimp/tests/src/Mailchimp.php b/www7/sites/all/libraries/mailchimp/tests/src/Mailchimp.php old mode 100644 new mode 100755 index 940744bc7..7121502ce --- a/www7/sites/all/libraries/mailchimp/tests/src/Mailchimp.php +++ b/www7/sites/all/libraries/mailchimp/tests/src/Mailchimp.php @@ -12,7 +12,7 @@ class Mailchimp extends \Mailchimp\Mailchimp { /** * @inheritdoc */ - public function __construct($api_key = 'apikey', $api_user = 'apikey', $timeout = 60) { + public function __construct($api_key = 'apikey', $api_user = 'apikey', $http_options = []) { $this->client = new Client(); } diff --git a/www7/sites/all/libraries/mailchimp/tests/src/MailchimpAutomations.php b/www7/sites/all/libraries/mailchimp/tests/src/MailchimpAutomations.php old mode 100644 new mode 100755 index 52be7f0df..9dbce10b7 --- a/www7/sites/all/libraries/mailchimp/tests/src/MailchimpAutomations.php +++ b/www7/sites/all/libraries/mailchimp/tests/src/MailchimpAutomations.php @@ -7,7 +7,7 @@ class MailchimpAutomations extends \Mailchimp\MailchimpAutomations { /** * @inheritdoc */ - public function __construct($api_key = 'apikey', $api_user = 'apikey', $timeout = 60) { + public function __construct($api_key = 'apikey', $api_user = 'apikey', $http_options = []) { $this->client = new Client(); } diff --git a/www7/sites/all/libraries/mailchimp/tests/src/MailchimpCampaigns.php b/www7/sites/all/libraries/mailchimp/tests/src/MailchimpCampaigns.php old mode 100644 new mode 100755 index 5126eade4..11875e60e --- a/www7/sites/all/libraries/mailchimp/tests/src/MailchimpCampaigns.php +++ b/www7/sites/all/libraries/mailchimp/tests/src/MailchimpCampaigns.php @@ -12,7 +12,7 @@ class MailchimpCampaigns extends \Mailchimp\MailchimpCampaigns { /** * @inheritdoc */ - public function __construct($api_key = 'apikey', $api_user = 'apikey', $timeout = 60) { + public function __construct($api_key = 'apikey', $api_user = 'apikey', $http_options = []) { $this->client = new Client(); } diff --git a/www7/sites/all/libraries/mailchimp/tests/src/MailchimpEcommerce.php b/www7/sites/all/libraries/mailchimp/tests/src/MailchimpEcommerce.php old mode 100644 new mode 100755 index d07fc4fee..af8671794 --- a/www7/sites/all/libraries/mailchimp/tests/src/MailchimpEcommerce.php +++ b/www7/sites/all/libraries/mailchimp/tests/src/MailchimpEcommerce.php @@ -35,7 +35,7 @@ class MailchimpEcommerce extends \Mailchimp\MailchimpEcommerce { /** * @inheritdoc */ - public function __construct($api_key = 'apikey', $api_user = 'apikey', $timeout = 60) { + public function __construct($api_key = 'apikey', $api_user = 'apikey', $http_options = []) { $this->client = new Client(); } diff --git a/www7/sites/all/libraries/mailchimp/tests/src/MailchimpLists.php b/www7/sites/all/libraries/mailchimp/tests/src/MailchimpLists.php old mode 100644 new mode 100755 index 649b28f1f..721680bc7 --- a/www7/sites/all/libraries/mailchimp/tests/src/MailchimpLists.php +++ b/www7/sites/all/libraries/mailchimp/tests/src/MailchimpLists.php @@ -12,7 +12,7 @@ class MailchimpLists extends \Mailchimp\MailchimpLists { /** * @inheritdoc */ - public function __construct($api_key = 'apikey', $api_user = 'apikey', $timeout = 60) { + public function __construct($api_key = 'apikey', $api_user = 'apikey', $http_options = []) { $this->client = new Client(); } diff --git a/www7/sites/all/libraries/mailchimp/tests/src/MailchimpReports.php b/www7/sites/all/libraries/mailchimp/tests/src/MailchimpReports.php old mode 100644 new mode 100755 index 02211ecfe..5b24ffcca --- a/www7/sites/all/libraries/mailchimp/tests/src/MailchimpReports.php +++ b/www7/sites/all/libraries/mailchimp/tests/src/MailchimpReports.php @@ -12,7 +12,7 @@ class MailchimpReports extends \Mailchimp\MailchimpReports { /** * @inheritdoc */ - public function __construct($api_key = 'apikey', $api_user = 'apikey', $timeout = 60) { + public function __construct($api_key = 'apikey', $api_user = 'apikey', $http_options = []) { $this->client = new Client(); } diff --git a/www7/sites/all/libraries/mailchimp/tests/src/MailchimpTemplates.php b/www7/sites/all/libraries/mailchimp/tests/src/MailchimpTemplates.php old mode 100644 new mode 100755 index 682361ff9..ba3076005 --- a/www7/sites/all/libraries/mailchimp/tests/src/MailchimpTemplates.php +++ b/www7/sites/all/libraries/mailchimp/tests/src/MailchimpTemplates.php @@ -12,7 +12,7 @@ class MailchimpTemplates extends \Mailchimp\MailchimpTemplates { /** * @inheritdoc */ - public function __construct($api_key = 'apikey', $api_user = 'apikey', $timeout = 60) { + public function __construct($api_key = 'apikey', $api_user = 'apikey', $http_options = []) { $this->client = new Client(); } diff --git a/www7/sites/all/libraries/mailchimp/tests/src/Response.php b/www7/sites/all/libraries/mailchimp/tests/src/Response.php old mode 100644 new mode 100755 diff --git a/www7/sites/all/libraries/mailchimp/vendor/.DS_Store b/www7/sites/all/libraries/mailchimp/vendor/.DS_Store deleted file mode 100644 index ad1013e89cffcffaa285745b7dd8f034d50a4329..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10244 zcmeHMv2GJV5S@(^>;xmIsjdJi4TzLz_|jv zKV;}^JJBwJ^;-unz65|>#oNB&HR=HGlSSK!b`h+1#h9UbaM9Jp62k>|+|L*e+lh7& zY;Y$R+{wk6U93=?pB;Xghm-3BYgbdi6sRk}wR;;i`|EgXh5xwhcKh>LPW0u@(-{wZHuAXaUvg(M ztd8c_e2a2KFviJ4NmCloq2%SBVcaVF8eTA586E>)!w9Z(rmA5otS`X`{wtruIDIhB z@f;3WRT?DxzXBxrCwRf1ex7)42}bY_TDNdsBj#09uVEzr2h4wi_K`(z@K-?nA>x>+ z8T77_L8_04W8*#YLLXa+MIBFxN5zSlZtieQH;_$O2T`FpvTJ}R!z(4pF5;}OMz+LL z#CPp`bNM_bBo1?zh!FY4nhVI9X%bU$Mq5rXy3TV~yW#?x9RVV8BS z${L9%!IDltUid5QqL0EV-VtoVccgW{YxeM2Fhz!sV3nO+FjGAG)4b@FWx?Sow?z<* zZy$7&5|A>M5}bk(fv$I$R}%pqVJW}DGCrWABw3K+BFF?SBRG0qA5USQjG-`35Q6oZ z-(J`0H5OzKyi07cd-#x0(p)fCJOq2!JOz6Nr9_~jY713CiAbDJdwvGiOaW8C6fgx$ z0aM_L6ljEbGd}-+bouZ9SH#YyH3dw8zoCFz?e2EBF;hHSug%G4?HT$@bZ(4W1nXUJ z@yGG7{x}~0@NxVmI%9qP5?^QXb*%oM@KYeG|1S=?`IuN# P(Me@4D(J?4T>t+DESk8l diff --git a/www7/sites/all/libraries/mailchimp/vendor/autoload.php b/www7/sites/all/libraries/mailchimp/vendor/autoload.php index ad3a0846e..49956a1ad 100644 --- a/www7/sites/all/libraries/mailchimp/vendor/autoload.php +++ b/www7/sites/all/libraries/mailchimp/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInit32c4efde83c48407db778b61f0349f1c::getLoader(); +return ComposerAutoloaderInit22c89fc07eb52a6ca68a4337a7f96853::getLoader(); diff --git a/www7/sites/all/libraries/mailchimp/vendor/composer/autoload_real.php b/www7/sites/all/libraries/mailchimp/vendor/composer/autoload_real.php index 5df0adbeb..dc5f420fb 100644 --- a/www7/sites/all/libraries/mailchimp/vendor/composer/autoload_real.php +++ b/www7/sites/all/libraries/mailchimp/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit32c4efde83c48407db778b61f0349f1c +class ComposerAutoloaderInit22c89fc07eb52a6ca68a4337a7f96853 { private static $loader; @@ -19,15 +19,15 @@ public static function getLoader() return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit32c4efde83c48407db778b61f0349f1c', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit22c89fc07eb52a6ca68a4337a7f96853', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit32c4efde83c48407db778b61f0349f1c', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit22c89fc07eb52a6ca68a4337a7f96853', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION'); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit32c4efde83c48407db778b61f0349f1c::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit22c89fc07eb52a6ca68a4337a7f96853::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,19 +48,19 @@ public static function getLoader() $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit32c4efde83c48407db778b61f0349f1c::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit22c89fc07eb52a6ca68a4337a7f96853::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire32c4efde83c48407db778b61f0349f1c($fileIdentifier, $file); + composerRequire22c89fc07eb52a6ca68a4337a7f96853($fileIdentifier, $file); } return $loader; } } -function composerRequire32c4efde83c48407db778b61f0349f1c($fileIdentifier, $file) +function composerRequire22c89fc07eb52a6ca68a4337a7f96853($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/www7/sites/all/libraries/mailchimp/vendor/composer/autoload_static.php b/www7/sites/all/libraries/mailchimp/vendor/composer/autoload_static.php index 6c56ba103..45365a8d4 100644 --- a/www7/sites/all/libraries/mailchimp/vendor/composer/autoload_static.php +++ b/www7/sites/all/libraries/mailchimp/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit32c4efde83c48407db778b61f0349f1c +class ComposerStaticInit22c89fc07eb52a6ca68a4337a7f96853 { public static $files = array ( 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php', @@ -542,10 +542,10 @@ class ComposerStaticInit32c4efde83c48407db778b61f0349f1c public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit32c4efde83c48407db778b61f0349f1c::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit32c4efde83c48407db778b61f0349f1c::$prefixDirsPsr4; - $loader->prefixesPsr0 = ComposerStaticInit32c4efde83c48407db778b61f0349f1c::$prefixesPsr0; - $loader->classMap = ComposerStaticInit32c4efde83c48407db778b61f0349f1c::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit22c89fc07eb52a6ca68a4337a7f96853::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit22c89fc07eb52a6ca68a4337a7f96853::$prefixDirsPsr4; + $loader->prefixesPsr0 = ComposerStaticInit22c89fc07eb52a6ca68a4337a7f96853::$prefixesPsr0; + $loader->classMap = ComposerStaticInit22c89fc07eb52a6ca68a4337a7f96853::$classMap; }, null, ClassLoader::class); } diff --git a/www7/sites/all/libraries/mailchimp/vendor/composer/installed.json b/www7/sites/all/libraries/mailchimp/vendor/composer/installed.json index 36c899259..152e9d943 100644 --- a/www7/sites/all/libraries/mailchimp/vendor/composer/installed.json +++ b/www7/sites/all/libraries/mailchimp/vendor/composer/installed.json @@ -230,23 +230,23 @@ }, { "name": "symfony/yaml", - "version": "v3.1.5", - "version_normalized": "3.1.5.0", + "version": "v3.1.6", + "version_normalized": "3.1.6.0", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3" + "reference": "7ff51b06c6c3d5cc6686df69004a42c69df09e27" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/368b9738d4033c8b93454cb0dbd45d305135a6d3", - "reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3", + "url": "https://api.github.com/repos/symfony/yaml/zipball/7ff51b06c6c3d5cc6686df69004a42c69df09e27", + "reference": "7ff51b06c6c3d5cc6686df69004a42c69df09e27", "shasum": "" }, "require": { "php": ">=5.5.9" }, - "time": "2016-09-25 08:27:07", + "time": "2016-10-24 18:41:13", "type": "library", "extra": { "branch-alias": { diff --git a/www7/sites/all/libraries/mailchimp/vendor/symfony/yaml/Inline.php b/www7/sites/all/libraries/mailchimp/vendor/symfony/yaml/Inline.php index 6853e5a0b..68ff14983 100644 --- a/www7/sites/all/libraries/mailchimp/vendor/symfony/yaml/Inline.php +++ b/www7/sites/all/libraries/mailchimp/vendor/symfony/yaml/Inline.php @@ -317,7 +317,7 @@ public static function parseScalar($scalar, $flags = 0, $delimiters = null, $str } if ($output && '%' === $output[0]) { - @trigger_error(sprintf('Not quoting the scalar "%s" starting with the "%%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.' , $output), E_USER_DEPRECATED); + @trigger_error(sprintf('Not quoting the scalar "%s" starting with the "%%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', $output), E_USER_DEPRECATED); } if ($evaluate) { @@ -606,7 +606,10 @@ private static function evaluateScalar($scalar, $flags, $references = array()) return (float) str_replace(',', '', $scalar); case preg_match(self::getTimestampRegex(), $scalar): if (Yaml::PARSE_DATETIME & $flags) { - return new \DateTime($scalar, new \DateTimeZone('UTC')); + $date = new \DateTime($scalar); + $date->setTimeZone(new \DateTimeZone('UTC')); + + return $date; } $timeZone = date_default_timezone_get(); diff --git a/www7/sites/all/libraries/mailchimp/vendor/symfony/yaml/Tests/InlineTest.php b/www7/sites/all/libraries/mailchimp/vendor/symfony/yaml/Tests/InlineTest.php index 859a03e80..d6d7790dd 100644 --- a/www7/sites/all/libraries/mailchimp/vendor/symfony/yaml/Tests/InlineTest.php +++ b/www7/sites/all/libraries/mailchimp/vendor/symfony/yaml/Tests/InlineTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Yaml\Tests; -use Symfony\Bridge\PhpUnit\ErrorAssert; use Symfony\Component\Yaml\Inline; use Symfony\Component\Yaml\Yaml; @@ -255,14 +254,12 @@ public function getScalarIndicators() /** * @group legacy - * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered + * @expectedDeprecation Not quoting the scalar "%bar " starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0. * throws \Symfony\Component\Yaml\Exception\ParseException in 4.0 */ public function testParseUnquotedScalarStartingWithPercentCharacter() { - ErrorAssert::assertDeprecationsAreTriggered('Not quoting the scalar "%foo " starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', function () { - Inline::parse('{ foo: %foo }'); - }); + Inline::parse('{ foo: %bar }'); } /** @@ -510,7 +507,7 @@ public function testParseTimestampAsDateTimeObject($yaml, $year, $month, $day, $ $expected = new \DateTime($yaml); $expected->setTimeZone(new \DateTimeZone('UTC')); $expected->setDate($year, $month, $day); - $expected->setTime($hour, $minute, $second); + @$expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second)); $this->assertEquals($expected, Inline::parse($yaml, Yaml::PARSE_DATETIME)); } @@ -518,9 +515,9 @@ public function testParseTimestampAsDateTimeObject($yaml, $year, $month, $day, $ public function getTimestampTests() { return array( - 'canonical' => array('2001-12-15T02:59:43.1Z', 2001, 12, 15, 2, 59, 43), - 'ISO-8601' => array('2001-12-15t21:59:43.10-05:00', 2001, 12, 16, 2, 59, 43), - 'spaced' => array('2001-12-15 21:59:43.10 -5', 2001, 12, 16, 2, 59, 43), + 'canonical' => array('2001-12-15T02:59:43.1Z', 2001, 12, 15, 2, 59, 43.1), + 'ISO-8601' => array('2001-12-15t21:59:43.10-05:00', 2001, 12, 16, 2, 59, 43.1), + 'spaced' => array('2001-12-15 21:59:43.10 -5', 2001, 12, 16, 2, 59, 43.1), 'date' => array('2001-12-15', 2001, 12, 15, 0, 0, 0), ); } @@ -533,7 +530,7 @@ public function testParseNestedTimestampListAsDateTimeObject($yaml, $year, $mont $expected = new \DateTime($yaml); $expected->setTimeZone(new \DateTimeZone('UTC')); $expected->setDate($year, $month, $day); - $expected->setTime($hour, $minute, $second); + @$expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second)); $expectedNested = array('nested' => array($expected)); $yamlNested = "{nested: [$yaml]}"; From 5979425594e1ef3dcab14010c76a72423f884a70 Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Sat, 19 Nov 2016 13:47:45 +0100 Subject: [PATCH 04/16] Update Core to 7.52. --- www7/includes/bootstrap.inc | 2 +- www7/includes/database/select.inc | 15 +++ www7/modules/aggregator/aggregator.info | 6 +- .../aggregator/tests/aggregator_test.info | 6 +- www7/modules/block/block.info | 6 +- www7/modules/block/tests/block_test.info | 6 +- .../block_test_theme/block_test_theme.info | 6 +- www7/modules/blog/blog.info | 6 +- www7/modules/book/book.info | 6 +- www7/modules/color/color.info | 6 +- www7/modules/comment/comment.info | 6 +- www7/modules/contact/contact.info | 6 +- www7/modules/contextual/contextual.info | 6 +- www7/modules/dashboard/dashboard.info | 6 +- www7/modules/dblog/dblog.info | 6 +- www7/modules/field/field.info | 6 +- .../field_sql_storage/field_sql_storage.info | 6 +- www7/modules/field/modules/list/list.info | 6 +- .../field/modules/list/tests/list_test.info | 6 +- www7/modules/field/modules/number/number.info | 6 +- .../field/modules/options/options.info | 6 +- www7/modules/field/modules/text/text.info | 6 +- www7/modules/field/tests/field_test.info | 6 +- www7/modules/field_ui/field_ui.info | 6 +- www7/modules/file/file.info | 6 +- www7/modules/file/tests/file_module_test.info | 6 +- www7/modules/filter/filter.info | 6 +- www7/modules/forum/forum.info | 6 +- www7/modules/help/help.info | 6 +- www7/modules/image/image.info | 6 +- .../image/tests/image_module_test.info | 6 +- www7/modules/locale/locale.info | 6 +- www7/modules/locale/tests/locale_test.info | 6 +- www7/modules/menu/menu.info | 6 +- www7/modules/node/node.info | 6 +- www7/modules/node/tests/node_access_test.info | 6 +- www7/modules/node/tests/node_test.info | 6 +- .../node/tests/node_test_exception.info | 6 +- www7/modules/openid/openid.info | 6 +- www7/modules/openid/tests/openid_test.info | 6 +- www7/modules/overlay/overlay.info | 6 +- www7/modules/path/path.info | 6 +- www7/modules/php/php.info | 6 +- www7/modules/poll/poll.info | 6 +- www7/modules/profile/profile.info | 6 +- www7/modules/rdf/rdf.info | 6 +- www7/modules/rdf/tests/rdf_test.info | 6 +- www7/modules/search/search.info | 6 +- .../search/tests/search_embedded_form.info | 6 +- .../search/tests/search_extra_type.info | 6 +- .../search/tests/search_node_tags.info | 6 +- www7/modules/shortcut/shortcut.info | 6 +- www7/modules/simpletest/simpletest.info | 6 +- .../simpletest/tests/actions_loop_test.info | 6 +- .../simpletest/tests/ajax_forms_test.info | 6 +- www7/modules/simpletest/tests/ajax_test.info | 6 +- www7/modules/simpletest/tests/batch_test.info | 6 +- .../modules/simpletest/tests/boot_test_1.info | 6 +- .../modules/simpletest/tests/boot_test_2.info | 6 +- .../modules/simpletest/tests/common_test.info | 6 +- .../tests/common_test_cron_helper.info | 6 +- .../simpletest/tests/database_test.info | 6 +- .../drupal_autoload_test.info | 6 +- ...drupal_system_listing_compatible_test.info | 6 +- ...upal_system_listing_incompatible_test.info | 6 +- .../simpletest/tests/entity_cache_test.info | 6 +- .../tests/entity_cache_test_dependency.info | 6 +- .../tests/entity_crud_hook_test.info | 6 +- .../tests/entity_query_access_test.info | 6 +- www7/modules/simpletest/tests/error_test.info | 6 +- www7/modules/simpletest/tests/file_test.info | 6 +- .../modules/simpletest/tests/filter_test.info | 6 +- www7/modules/simpletest/tests/form_test.info | 6 +- www7/modules/simpletest/tests/image_test.info | 6 +- www7/modules/simpletest/tests/menu_test.info | 6 +- .../modules/simpletest/tests/module_test.info | 6 +- www7/modules/simpletest/tests/path_test.info | 6 +- .../tests/psr_0_test/psr_0_test.info | 6 +- .../tests/psr_4_test/psr_4_test.info | 6 +- .../simpletest/tests/requirements1_test.info | 6 +- .../simpletest/tests/requirements2_test.info | 6 +- .../simpletest/tests/session_test.info | 6 +- .../tests/system_dependencies_test.info | 6 +- ...atible_core_version_dependencies_test.info | 6 +- ...system_incompatible_core_version_test.info | 6 +- ...ible_module_version_dependencies_test.info | 6 +- ...stem_incompatible_module_version_test.info | 6 +- .../tests/system_project_namespace_test.info | 6 +- .../modules/simpletest/tests/system_test.info | 6 +- .../simpletest/tests/taxonomy_test.info | 6 +- .../simpletest/tests/taxonomy_test.module | 30 +++++ www7/modules/simpletest/tests/theme_test.info | 6 +- .../themes/test_basetheme/test_basetheme.info | 6 +- .../themes/test_subtheme/test_subtheme.info | 6 +- .../tests/themes/test_theme/test_theme.info | 6 +- .../simpletest/tests/update_script_test.info | 6 +- .../simpletest/tests/update_test_1.info | 6 +- .../simpletest/tests/update_test_2.info | 6 +- .../simpletest/tests/update_test_3.info | 6 +- .../simpletest/tests/url_alter_test.info | 6 +- .../modules/simpletest/tests/xmlrpc_test.info | 6 +- www7/modules/statistics/statistics.info | 6 +- www7/modules/syslog/syslog.info | 6 +- www7/modules/system/system.info | 6 +- www7/modules/system/system.module | 2 +- .../modules/system/tests/cron_queue_test.info | 6 +- .../system/tests/system_cron_test.info | 6 +- www7/modules/taxonomy/taxonomy.info | 6 +- www7/modules/taxonomy/taxonomy.module | 8 +- www7/modules/taxonomy/taxonomy.pages.inc | 2 +- www7/modules/taxonomy/taxonomy.test | 110 ++++++++++++++++++ www7/modules/toolbar/toolbar.info | 6 +- www7/modules/tracker/tracker.info | 6 +- .../translation/tests/translation_test.info | 6 +- www7/modules/translation/translation.info | 6 +- www7/modules/trigger/tests/trigger_test.info | 6 +- www7/modules/trigger/trigger.info | 6 +- .../modules/update/tests/aaa_update_test.info | 6 +- .../modules/update/tests/bbb_update_test.info | 6 +- .../modules/update/tests/ccc_update_test.info | 6 +- .../update_test_admintheme.info | 6 +- .../update_test_basetheme.info | 6 +- .../update_test_subtheme.info | 6 +- www7/modules/update/tests/update_test.info | 6 +- www7/modules/update/update.info | 6 +- www7/modules/user/tests/user_form_test.info | 6 +- www7/modules/user/user.info | 6 +- www7/profiles/minimal/minimal.info | 6 +- www7/profiles/standard/standard.info | 6 +- ...drupal_system_listing_compatible_test.info | 6 +- ...upal_system_listing_incompatible_test.info | 6 +- www7/profiles/testing/testing.info | 6 +- www7/themes/bartik/bartik.info | 6 +- www7/themes/garland/garland.info | 6 +- www7/themes/seven/seven.info | 6 +- www7/themes/stark/stark.info | 6 +- 136 files changed, 549 insertions(+), 394 deletions(-) diff --git a/www7/includes/bootstrap.inc b/www7/includes/bootstrap.inc index 3c41c69ff..8ff737954 100644 --- a/www7/includes/bootstrap.inc +++ b/www7/includes/bootstrap.inc @@ -8,7 +8,7 @@ /** * The current system version. */ -define('VERSION', '7.51'); +define('VERSION', '7.52'); /** * Core API compatibility. diff --git a/www7/includes/database/select.inc b/www7/includes/database/select.inc index 3abd205c9..8d84460e8 100644 --- a/www7/includes/database/select.inc +++ b/www7/includes/database/select.inc @@ -1231,6 +1231,21 @@ class SelectQuery extends Query implements SelectQueryInterface { // Modules may alter all queries or only those having a particular tag. if (isset($this->alterTags)) { + // Many contrib modules assume that query tags used for access-checking + // purposes follow the pattern $entity_type . '_access'. But this is + // not the case for taxonomy terms, since core used to add term_access + // instead of taxonomy_term_access to its queries. Provide backwards + // compatibility by adding both tags here instead of attempting to fix + // all contrib modules in a coordinated effort. + // TODO: + // - Extract this mechanism into a hook as part of a public (non-security) + // issue. + // - Emit E_USER_DEPRECATED if term_access is used. + // https://www.drupal.org/node/2575081 + $term_access_tags = array('term_access' => 1, 'taxonomy_term_access' => 1); + if (array_intersect_key($this->alterTags, $term_access_tags)) { + $this->alterTags += $term_access_tags; + } $hooks = array('query'); foreach ($this->alterTags as $tag => $value) { $hooks[] = 'query_' . $tag; diff --git a/www7/modules/aggregator/aggregator.info b/www7/modules/aggregator/aggregator.info index 524117027..7a1d0845d 100644 --- a/www7/modules/aggregator/aggregator.info +++ b/www7/modules/aggregator/aggregator.info @@ -7,8 +7,8 @@ files[] = aggregator.test configure = admin/config/services/aggregator/settings stylesheets[all][] = aggregator.css -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/aggregator/tests/aggregator_test.info b/www7/modules/aggregator/tests/aggregator_test.info index f3194fe86..3dc5c15c8 100644 --- a/www7/modules/aggregator/tests/aggregator_test.info +++ b/www7/modules/aggregator/tests/aggregator_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/block/block.info b/www7/modules/block/block.info index be55e090b..e30172c5e 100644 --- a/www7/modules/block/block.info +++ b/www7/modules/block/block.info @@ -6,8 +6,8 @@ core = 7.x files[] = block.test configure = admin/structure/block -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/block/tests/block_test.info b/www7/modules/block/tests/block_test.info index 2bb8d0339..533997190 100644 --- a/www7/modules/block/tests/block_test.info +++ b/www7/modules/block/tests/block_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/block/tests/themes/block_test_theme/block_test_theme.info b/www7/modules/block/tests/themes/block_test_theme/block_test_theme.info index 18a70cf83..c9ae187b0 100644 --- a/www7/modules/block/tests/themes/block_test_theme/block_test_theme.info +++ b/www7/modules/block/tests/themes/block_test_theme/block_test_theme.info @@ -13,8 +13,8 @@ regions[footer] = Footer regions[highlighted] = Highlighted regions[help] = Help -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/blog/blog.info b/www7/modules/blog/blog.info index e4d074444..0f99752ff 100644 --- a/www7/modules/blog/blog.info +++ b/www7/modules/blog/blog.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = blog.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/book/book.info b/www7/modules/book/book.info index 68eb2f86c..e9ccf68a5 100644 --- a/www7/modules/book/book.info +++ b/www7/modules/book/book.info @@ -7,8 +7,8 @@ files[] = book.test configure = admin/content/book/settings stylesheets[all][] = book.css -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/color/color.info b/www7/modules/color/color.info index 1bc59cbf8..83b2ef9b6 100644 --- a/www7/modules/color/color.info +++ b/www7/modules/color/color.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = color.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/comment/comment.info b/www7/modules/comment/comment.info index 367d1e0e5..3fc458ffe 100644 --- a/www7/modules/comment/comment.info +++ b/www7/modules/comment/comment.info @@ -9,8 +9,8 @@ files[] = comment.test configure = admin/content/comment stylesheets[all][] = comment.css -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/contact/contact.info b/www7/modules/contact/contact.info index 3dbb788d4..e846110f8 100644 --- a/www7/modules/contact/contact.info +++ b/www7/modules/contact/contact.info @@ -6,8 +6,8 @@ core = 7.x files[] = contact.test configure = admin/structure/contact -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/contextual/contextual.info b/www7/modules/contextual/contextual.info index a6d3e2df4..e398956ee 100644 --- a/www7/modules/contextual/contextual.info +++ b/www7/modules/contextual/contextual.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = contextual.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/dashboard/dashboard.info b/www7/modules/dashboard/dashboard.info index e71792f45..402928aaf 100644 --- a/www7/modules/dashboard/dashboard.info +++ b/www7/modules/dashboard/dashboard.info @@ -7,8 +7,8 @@ files[] = dashboard.test dependencies[] = block configure = admin/dashboard/customize -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/dblog/dblog.info b/www7/modules/dblog/dblog.info index 724ca7245..01e9a9a04 100644 --- a/www7/modules/dblog/dblog.info +++ b/www7/modules/dblog/dblog.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = dblog.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/field/field.info b/www7/modules/field/field.info index d318cf132..94a94ba89 100644 --- a/www7/modules/field/field.info +++ b/www7/modules/field/field.info @@ -11,8 +11,8 @@ dependencies[] = field_sql_storage required = TRUE stylesheets[all][] = theme/field.css -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/field/modules/field_sql_storage/field_sql_storage.info b/www7/modules/field/modules/field_sql_storage/field_sql_storage.info index f5e5f965e..c46e029b5 100644 --- a/www7/modules/field/modules/field_sql_storage/field_sql_storage.info +++ b/www7/modules/field/modules/field_sql_storage/field_sql_storage.info @@ -7,8 +7,8 @@ dependencies[] = field files[] = field_sql_storage.test required = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/field/modules/list/list.info b/www7/modules/field/modules/list/list.info index 9c406945f..4904441a5 100644 --- a/www7/modules/field/modules/list/list.info +++ b/www7/modules/field/modules/list/list.info @@ -7,8 +7,8 @@ dependencies[] = field dependencies[] = options files[] = tests/list.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/field/modules/list/tests/list_test.info b/www7/modules/field/modules/list/tests/list_test.info index 58ad667c5..2e5122360 100644 --- a/www7/modules/field/modules/list/tests/list_test.info +++ b/www7/modules/field/modules/list/tests/list_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/field/modules/number/number.info b/www7/modules/field/modules/number/number.info index 3da7cc80b..ef5985b3f 100644 --- a/www7/modules/field/modules/number/number.info +++ b/www7/modules/field/modules/number/number.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = number.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/field/modules/options/options.info b/www7/modules/field/modules/options/options.info index 289d4d3a8..63b916328 100644 --- a/www7/modules/field/modules/options/options.info +++ b/www7/modules/field/modules/options/options.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = options.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/field/modules/text/text.info b/www7/modules/field/modules/text/text.info index 5bd220296..c70494760 100644 --- a/www7/modules/field/modules/text/text.info +++ b/www7/modules/field/modules/text/text.info @@ -7,8 +7,8 @@ dependencies[] = field files[] = text.test required = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/field/tests/field_test.info b/www7/modules/field/tests/field_test.info index 4a22cda6d..166da2e68 100644 --- a/www7/modules/field/tests/field_test.info +++ b/www7/modules/field/tests/field_test.info @@ -6,8 +6,8 @@ files[] = field_test.entity.inc version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/field_ui/field_ui.info b/www7/modules/field_ui/field_ui.info index 91b250cc3..017e1b19b 100644 --- a/www7/modules/field_ui/field_ui.info +++ b/www7/modules/field_ui/field_ui.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = field_ui.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/file/file.info b/www7/modules/file/file.info index 2e5b7a2ff..e19955325 100644 --- a/www7/modules/file/file.info +++ b/www7/modules/file/file.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = tests/file.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/file/tests/file_module_test.info b/www7/modules/file/tests/file_module_test.info index cdb1561d7..c4d0d6823 100644 --- a/www7/modules/file/tests/file_module_test.info +++ b/www7/modules/file/tests/file_module_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/filter/filter.info b/www7/modules/filter/filter.info index 6b69921af..e8a9e3b9f 100644 --- a/www7/modules/filter/filter.info +++ b/www7/modules/filter/filter.info @@ -7,8 +7,8 @@ files[] = filter.test required = TRUE configure = admin/config/content/formats -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/forum/forum.info b/www7/modules/forum/forum.info index 39250e441..62b9a1bee 100644 --- a/www7/modules/forum/forum.info +++ b/www7/modules/forum/forum.info @@ -9,8 +9,8 @@ files[] = forum.test configure = admin/structure/forum stylesheets[all][] = forum.css -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/help/help.info b/www7/modules/help/help.info index 3b4812217..e930ed6c1 100644 --- a/www7/modules/help/help.info +++ b/www7/modules/help/help.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = help.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/image/image.info b/www7/modules/image/image.info index 0b14b66ae..7d9543b87 100644 --- a/www7/modules/image/image.info +++ b/www7/modules/image/image.info @@ -7,8 +7,8 @@ dependencies[] = file files[] = image.test configure = admin/config/media/image-styles -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/image/tests/image_module_test.info b/www7/modules/image/tests/image_module_test.info index d2131dd28..20c6bcca1 100644 --- a/www7/modules/image/tests/image_module_test.info +++ b/www7/modules/image/tests/image_module_test.info @@ -6,8 +6,8 @@ core = 7.x files[] = image_module_test.module hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/locale/locale.info b/www7/modules/locale/locale.info index 6e0579483..c239cc9d6 100644 --- a/www7/modules/locale/locale.info +++ b/www7/modules/locale/locale.info @@ -6,8 +6,8 @@ core = 7.x files[] = locale.test configure = admin/config/regional/language -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/locale/tests/locale_test.info b/www7/modules/locale/tests/locale_test.info index 5ea5dbc49..815ffefd3 100644 --- a/www7/modules/locale/tests/locale_test.info +++ b/www7/modules/locale/tests/locale_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/menu/menu.info b/www7/modules/menu/menu.info index 2c4681ceb..0f63c2925 100644 --- a/www7/modules/menu/menu.info +++ b/www7/modules/menu/menu.info @@ -6,8 +6,8 @@ core = 7.x files[] = menu.test configure = admin/structure/menu -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/node/node.info b/www7/modules/node/node.info index 63a0c4bea..7942549f7 100644 --- a/www7/modules/node/node.info +++ b/www7/modules/node/node.info @@ -9,8 +9,8 @@ required = TRUE configure = admin/structure/types stylesheets[all][] = node.css -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/node/tests/node_access_test.info b/www7/modules/node/tests/node_access_test.info index 7354c045b..ec9b98279 100644 --- a/www7/modules/node/tests/node_access_test.info +++ b/www7/modules/node/tests/node_access_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/node/tests/node_test.info b/www7/modules/node/tests/node_test.info index afc1a9e23..7ada6a78c 100644 --- a/www7/modules/node/tests/node_test.info +++ b/www7/modules/node/tests/node_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/node/tests/node_test_exception.info b/www7/modules/node/tests/node_test_exception.info index 7d0eb6017..7a3d5db81 100644 --- a/www7/modules/node/tests/node_test_exception.info +++ b/www7/modules/node/tests/node_test_exception.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/openid/openid.info b/www7/modules/openid/openid.info index cc25d8149..2552fdf2e 100644 --- a/www7/modules/openid/openid.info +++ b/www7/modules/openid/openid.info @@ -5,8 +5,8 @@ package = Core core = 7.x files[] = openid.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/openid/tests/openid_test.info b/www7/modules/openid/tests/openid_test.info index 922fdcc51..620aabdfd 100644 --- a/www7/modules/openid/tests/openid_test.info +++ b/www7/modules/openid/tests/openid_test.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = openid hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/overlay/overlay.info b/www7/modules/overlay/overlay.info index 63ca90f1e..3e3380949 100644 --- a/www7/modules/overlay/overlay.info +++ b/www7/modules/overlay/overlay.info @@ -4,8 +4,8 @@ package = Core version = VERSION core = 7.x -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/path/path.info b/www7/modules/path/path.info index 9f4503b47..dc612fd2f 100644 --- a/www7/modules/path/path.info +++ b/www7/modules/path/path.info @@ -6,8 +6,8 @@ core = 7.x files[] = path.test configure = admin/config/search/path -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/php/php.info b/www7/modules/php/php.info index a977a9a61..5a1e90557 100644 --- a/www7/modules/php/php.info +++ b/www7/modules/php/php.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = php.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/poll/poll.info b/www7/modules/poll/poll.info index 67158a141..2e8aaf6b1 100644 --- a/www7/modules/poll/poll.info +++ b/www7/modules/poll/poll.info @@ -6,8 +6,8 @@ core = 7.x files[] = poll.test stylesheets[all][] = poll.css -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/profile/profile.info b/www7/modules/profile/profile.info index 61f6f4d0d..24fa7a0ac 100644 --- a/www7/modules/profile/profile.info +++ b/www7/modules/profile/profile.info @@ -11,8 +11,8 @@ configure = admin/config/people/profile ; See user_system_info_alter(). hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/rdf/rdf.info b/www7/modules/rdf/rdf.info index b0d4a645d..bb859054a 100644 --- a/www7/modules/rdf/rdf.info +++ b/www7/modules/rdf/rdf.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = rdf.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/rdf/tests/rdf_test.info b/www7/modules/rdf/tests/rdf_test.info index 898fdf599..a676e1607 100644 --- a/www7/modules/rdf/tests/rdf_test.info +++ b/www7/modules/rdf/tests/rdf_test.info @@ -6,8 +6,8 @@ core = 7.x hidden = TRUE dependencies[] = blog -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/search/search.info b/www7/modules/search/search.info index 389d28473..df0c7f467 100644 --- a/www7/modules/search/search.info +++ b/www7/modules/search/search.info @@ -8,8 +8,8 @@ files[] = search.test configure = admin/config/search/settings stylesheets[all][] = search.css -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/search/tests/search_embedded_form.info b/www7/modules/search/tests/search_embedded_form.info index b9c5c22b7..ce0769d23 100644 --- a/www7/modules/search/tests/search_embedded_form.info +++ b/www7/modules/search/tests/search_embedded_form.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/search/tests/search_extra_type.info b/www7/modules/search/tests/search_extra_type.info index b409794d9..3fcfea64d 100644 --- a/www7/modules/search/tests/search_extra_type.info +++ b/www7/modules/search/tests/search_extra_type.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/search/tests/search_node_tags.info b/www7/modules/search/tests/search_node_tags.info index 687269aeb..2c8b9db55 100644 --- a/www7/modules/search/tests/search_node_tags.info +++ b/www7/modules/search/tests/search_node_tags.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/shortcut/shortcut.info b/www7/modules/shortcut/shortcut.info index c5a7b28ec..54957d391 100644 --- a/www7/modules/shortcut/shortcut.info +++ b/www7/modules/shortcut/shortcut.info @@ -6,8 +6,8 @@ core = 7.x files[] = shortcut.test configure = admin/config/user-interface/shortcut -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/simpletest.info b/www7/modules/simpletest/simpletest.info index 188d9ef34..8175a63c4 100644 --- a/www7/modules/simpletest/simpletest.info +++ b/www7/modules/simpletest/simpletest.info @@ -57,8 +57,8 @@ files[] = tests/upgrade/update.trigger.test files[] = tests/upgrade/update.field.test files[] = tests/upgrade/update.user.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/actions_loop_test.info b/www7/modules/simpletest/tests/actions_loop_test.info index 977bbe070..f07a631b3 100644 --- a/www7/modules/simpletest/tests/actions_loop_test.info +++ b/www7/modules/simpletest/tests/actions_loop_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/ajax_forms_test.info b/www7/modules/simpletest/tests/ajax_forms_test.info index 824c2666f..7b1491e6f 100644 --- a/www7/modules/simpletest/tests/ajax_forms_test.info +++ b/www7/modules/simpletest/tests/ajax_forms_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/ajax_test.info b/www7/modules/simpletest/tests/ajax_test.info index 8d3dae7f6..b5d7478bc 100644 --- a/www7/modules/simpletest/tests/ajax_test.info +++ b/www7/modules/simpletest/tests/ajax_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/batch_test.info b/www7/modules/simpletest/tests/batch_test.info index 07c8bd479..bb90c8e23 100644 --- a/www7/modules/simpletest/tests/batch_test.info +++ b/www7/modules/simpletest/tests/batch_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/boot_test_1.info b/www7/modules/simpletest/tests/boot_test_1.info index 474c4c450..475e72bec 100644 --- a/www7/modules/simpletest/tests/boot_test_1.info +++ b/www7/modules/simpletest/tests/boot_test_1.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/boot_test_2.info b/www7/modules/simpletest/tests/boot_test_2.info index ded72c566..452913ed5 100644 --- a/www7/modules/simpletest/tests/boot_test_2.info +++ b/www7/modules/simpletest/tests/boot_test_2.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/common_test.info b/www7/modules/simpletest/tests/common_test.info index c324d8a76..10ef71ecd 100644 --- a/www7/modules/simpletest/tests/common_test.info +++ b/www7/modules/simpletest/tests/common_test.info @@ -7,8 +7,8 @@ stylesheets[all][] = common_test.css stylesheets[print][] = common_test.print.css hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/common_test_cron_helper.info b/www7/modules/simpletest/tests/common_test_cron_helper.info index 619b87e2c..4a17eaeb8 100644 --- a/www7/modules/simpletest/tests/common_test_cron_helper.info +++ b/www7/modules/simpletest/tests/common_test_cron_helper.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/database_test.info b/www7/modules/simpletest/tests/database_test.info index 34571d0c8..4414602d0 100644 --- a/www7/modules/simpletest/tests/database_test.info +++ b/www7/modules/simpletest/tests/database_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.info b/www7/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.info index 910d27a7b..beb90c192 100644 --- a/www7/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.info +++ b/www7/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.info @@ -7,8 +7,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info b/www7/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info index 3276127c9..501574b02 100644 --- a/www7/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info +++ b/www7/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info b/www7/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info index e3603834d..e64ee615b 100644 --- a/www7/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info +++ b/www7/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/entity_cache_test.info b/www7/modules/simpletest/tests/entity_cache_test.info index b7dc76bbd..18ee1a7d9 100644 --- a/www7/modules/simpletest/tests/entity_cache_test.info +++ b/www7/modules/simpletest/tests/entity_cache_test.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = entity_cache_test_dependency hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/entity_cache_test_dependency.info b/www7/modules/simpletest/tests/entity_cache_test_dependency.info index b26436e63..16c9913f0 100644 --- a/www7/modules/simpletest/tests/entity_cache_test_dependency.info +++ b/www7/modules/simpletest/tests/entity_cache_test_dependency.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/entity_crud_hook_test.info b/www7/modules/simpletest/tests/entity_crud_hook_test.info index 0b0f44b7b..655c13185 100644 --- a/www7/modules/simpletest/tests/entity_crud_hook_test.info +++ b/www7/modules/simpletest/tests/entity_crud_hook_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/entity_query_access_test.info b/www7/modules/simpletest/tests/entity_query_access_test.info index 7ac6759e5..41e7e5855 100644 --- a/www7/modules/simpletest/tests/entity_query_access_test.info +++ b/www7/modules/simpletest/tests/entity_query_access_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/error_test.info b/www7/modules/simpletest/tests/error_test.info index a771b6fd2..37d97fc8b 100644 --- a/www7/modules/simpletest/tests/error_test.info +++ b/www7/modules/simpletest/tests/error_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/file_test.info b/www7/modules/simpletest/tests/file_test.info index 605af1d82..fb6b77a2a 100644 --- a/www7/modules/simpletest/tests/file_test.info +++ b/www7/modules/simpletest/tests/file_test.info @@ -6,8 +6,8 @@ core = 7.x files[] = file_test.module hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/filter_test.info b/www7/modules/simpletest/tests/filter_test.info index 9e0a59898..cbaebf5b5 100644 --- a/www7/modules/simpletest/tests/filter_test.info +++ b/www7/modules/simpletest/tests/filter_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/form_test.info b/www7/modules/simpletest/tests/form_test.info index 75ee2ea1d..30bcdfa91 100644 --- a/www7/modules/simpletest/tests/form_test.info +++ b/www7/modules/simpletest/tests/form_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/image_test.info b/www7/modules/simpletest/tests/image_test.info index 4f2918867..369386d4b 100644 --- a/www7/modules/simpletest/tests/image_test.info +++ b/www7/modules/simpletest/tests/image_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/menu_test.info b/www7/modules/simpletest/tests/menu_test.info index 68a1386b6..e1f9af325 100644 --- a/www7/modules/simpletest/tests/menu_test.info +++ b/www7/modules/simpletest/tests/menu_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/module_test.info b/www7/modules/simpletest/tests/module_test.info index 6cd6c3d5c..384d90e86 100644 --- a/www7/modules/simpletest/tests/module_test.info +++ b/www7/modules/simpletest/tests/module_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/path_test.info b/www7/modules/simpletest/tests/path_test.info index b2acd4f3e..82fa3d8c2 100644 --- a/www7/modules/simpletest/tests/path_test.info +++ b/www7/modules/simpletest/tests/path_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/psr_0_test/psr_0_test.info b/www7/modules/simpletest/tests/psr_0_test/psr_0_test.info index b07bc7dd0..1b96bb10f 100644 --- a/www7/modules/simpletest/tests/psr_0_test/psr_0_test.info +++ b/www7/modules/simpletest/tests/psr_0_test/psr_0_test.info @@ -5,8 +5,8 @@ core = 7.x hidden = TRUE package = Testing -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/psr_4_test/psr_4_test.info b/www7/modules/simpletest/tests/psr_4_test/psr_4_test.info index b7324bee3..ad58c5488 100644 --- a/www7/modules/simpletest/tests/psr_4_test/psr_4_test.info +++ b/www7/modules/simpletest/tests/psr_4_test/psr_4_test.info @@ -5,8 +5,8 @@ core = 7.x hidden = TRUE package = Testing -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/requirements1_test.info b/www7/modules/simpletest/tests/requirements1_test.info index b6f775aad..d53acae1d 100644 --- a/www7/modules/simpletest/tests/requirements1_test.info +++ b/www7/modules/simpletest/tests/requirements1_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/requirements2_test.info b/www7/modules/simpletest/tests/requirements2_test.info index c4fa4da4f..5931142ec 100644 --- a/www7/modules/simpletest/tests/requirements2_test.info +++ b/www7/modules/simpletest/tests/requirements2_test.info @@ -7,8 +7,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/session_test.info b/www7/modules/simpletest/tests/session_test.info index da76cac23..cac226fca 100644 --- a/www7/modules/simpletest/tests/session_test.info +++ b/www7/modules/simpletest/tests/session_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/system_dependencies_test.info b/www7/modules/simpletest/tests/system_dependencies_test.info index e5fa625d4..b54d4195a 100644 --- a/www7/modules/simpletest/tests/system_dependencies_test.info +++ b/www7/modules/simpletest/tests/system_dependencies_test.info @@ -6,8 +6,8 @@ core = 7.x hidden = TRUE dependencies[] = _missing_dependency -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.info b/www7/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.info index 4c0fd9edb..6872a334c 100644 --- a/www7/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.info +++ b/www7/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.info @@ -6,8 +6,8 @@ core = 7.x hidden = TRUE dependencies[] = system_incompatible_core_version_test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/system_incompatible_core_version_test.info b/www7/modules/simpletest/tests/system_incompatible_core_version_test.info index 01d0bdaf6..0be297c7e 100644 --- a/www7/modules/simpletest/tests/system_incompatible_core_version_test.info +++ b/www7/modules/simpletest/tests/system_incompatible_core_version_test.info @@ -5,8 +5,8 @@ version = VERSION core = 5.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.info b/www7/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.info index d453ed149..011bad3be 100644 --- a/www7/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.info +++ b/www7/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.info @@ -7,8 +7,8 @@ hidden = TRUE ; system_incompatible_module_version_test declares version 1.0 dependencies[] = system_incompatible_module_version_test (>2.0) -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/system_incompatible_module_version_test.info b/www7/modules/simpletest/tests/system_incompatible_module_version_test.info index 9e59bc818..18e48dd25 100644 --- a/www7/modules/simpletest/tests/system_incompatible_module_version_test.info +++ b/www7/modules/simpletest/tests/system_incompatible_module_version_test.info @@ -5,8 +5,8 @@ version = 1.0 core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/system_project_namespace_test.info b/www7/modules/simpletest/tests/system_project_namespace_test.info index 3a51de4e6..2dd024d12 100644 --- a/www7/modules/simpletest/tests/system_project_namespace_test.info +++ b/www7/modules/simpletest/tests/system_project_namespace_test.info @@ -6,8 +6,8 @@ core = 7.x hidden = TRUE dependencies[] = drupal:filter -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/system_test.info b/www7/modules/simpletest/tests/system_test.info index 7ea5e2730..edbf8e580 100644 --- a/www7/modules/simpletest/tests/system_test.info +++ b/www7/modules/simpletest/tests/system_test.info @@ -6,8 +6,8 @@ core = 7.x files[] = system_test.module hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/taxonomy_test.info b/www7/modules/simpletest/tests/taxonomy_test.info index d5e12357f..39314e3e6 100644 --- a/www7/modules/simpletest/tests/taxonomy_test.info +++ b/www7/modules/simpletest/tests/taxonomy_test.info @@ -6,8 +6,8 @@ core = 7.x hidden = TRUE dependencies[] = taxonomy -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/taxonomy_test.module b/www7/modules/simpletest/tests/taxonomy_test.module index f82950c30..f41443801 100644 --- a/www7/modules/simpletest/tests/taxonomy_test.module +++ b/www7/modules/simpletest/tests/taxonomy_test.module @@ -109,3 +109,33 @@ function taxonomy_test_get_antonym($tid) { ->execute() ->fetchField(); } + +/** + * Implements hook_query_alter(). + */ +function taxonomy_test_query_alter(QueryAlterableInterface $query) { + $value = variable_get(__FUNCTION__); + if (isset($value)) { + variable_set(__FUNCTION__, ++$value); + } +} + +/** + * Implements hook_query_TAG_alter(). + */ +function taxonomy_test_query_term_access_alter(QueryAlterableInterface $query) { + $value = variable_get(__FUNCTION__); + if (isset($value)) { + variable_set(__FUNCTION__, ++$value); + } +} + +/** + * Implements hook_query_TAG_alter(). + */ +function taxonomy_test_query_taxonomy_term_access_alter(QueryAlterableInterface $query) { + $value = variable_get(__FUNCTION__); + if (isset($value)) { + variable_set(__FUNCTION__, ++$value); + } +} diff --git a/www7/modules/simpletest/tests/theme_test.info b/www7/modules/simpletest/tests/theme_test.info index 57fc7f4a0..479536327 100644 --- a/www7/modules/simpletest/tests/theme_test.info +++ b/www7/modules/simpletest/tests/theme_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/themes/test_basetheme/test_basetheme.info b/www7/modules/simpletest/tests/themes/test_basetheme/test_basetheme.info index e473e69c7..9ca6b9b57 100644 --- a/www7/modules/simpletest/tests/themes/test_basetheme/test_basetheme.info +++ b/www7/modules/simpletest/tests/themes/test_basetheme/test_basetheme.info @@ -6,8 +6,8 @@ hidden = TRUE settings[basetheme_only] = base theme value settings[subtheme_override] = base theme value -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/themes/test_subtheme/test_subtheme.info b/www7/modules/simpletest/tests/themes/test_subtheme/test_subtheme.info index 2527b611a..19c94a3db 100644 --- a/www7/modules/simpletest/tests/themes/test_subtheme/test_subtheme.info +++ b/www7/modules/simpletest/tests/themes/test_subtheme/test_subtheme.info @@ -6,8 +6,8 @@ hidden = TRUE settings[subtheme_override] = subtheme value -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/themes/test_theme/test_theme.info b/www7/modules/simpletest/tests/themes/test_theme/test_theme.info index b11f6c14d..d6695e526 100644 --- a/www7/modules/simpletest/tests/themes/test_theme/test_theme.info +++ b/www7/modules/simpletest/tests/themes/test_theme/test_theme.info @@ -17,8 +17,8 @@ stylesheets[all][] = system.base.css settings[theme_test_setting] = default value -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/update_script_test.info b/www7/modules/simpletest/tests/update_script_test.info index f0ada8870..67519996c 100644 --- a/www7/modules/simpletest/tests/update_script_test.info +++ b/www7/modules/simpletest/tests/update_script_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/update_test_1.info b/www7/modules/simpletest/tests/update_test_1.info index 79b2a83bb..11091c29f 100644 --- a/www7/modules/simpletest/tests/update_test_1.info +++ b/www7/modules/simpletest/tests/update_test_1.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/update_test_2.info b/www7/modules/simpletest/tests/update_test_2.info index 79b2a83bb..11091c29f 100644 --- a/www7/modules/simpletest/tests/update_test_2.info +++ b/www7/modules/simpletest/tests/update_test_2.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/update_test_3.info b/www7/modules/simpletest/tests/update_test_3.info index 79b2a83bb..11091c29f 100644 --- a/www7/modules/simpletest/tests/update_test_3.info +++ b/www7/modules/simpletest/tests/update_test_3.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/url_alter_test.info b/www7/modules/simpletest/tests/url_alter_test.info index 4a6d21561..464056b1e 100644 --- a/www7/modules/simpletest/tests/url_alter_test.info +++ b/www7/modules/simpletest/tests/url_alter_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/simpletest/tests/xmlrpc_test.info b/www7/modules/simpletest/tests/xmlrpc_test.info index 28f96bb0e..166cb8010 100644 --- a/www7/modules/simpletest/tests/xmlrpc_test.info +++ b/www7/modules/simpletest/tests/xmlrpc_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/statistics/statistics.info b/www7/modules/statistics/statistics.info index bcabcf030..cc4e88e19 100644 --- a/www7/modules/statistics/statistics.info +++ b/www7/modules/statistics/statistics.info @@ -6,8 +6,8 @@ core = 7.x files[] = statistics.test configure = admin/config/system/statistics -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/syslog/syslog.info b/www7/modules/syslog/syslog.info index 91bd74f20..3739d035e 100644 --- a/www7/modules/syslog/syslog.info +++ b/www7/modules/syslog/syslog.info @@ -6,8 +6,8 @@ core = 7.x files[] = syslog.test configure = admin/config/development/logging -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/system/system.info b/www7/modules/system/system.info index d637f1c51..365315786 100644 --- a/www7/modules/system/system.info +++ b/www7/modules/system/system.info @@ -12,8 +12,8 @@ files[] = system.test required = TRUE configure = admin/config/system -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/system/system.module b/www7/modules/system/system.module index 59087c884..ae7c43234 100644 --- a/www7/modules/system/system.module +++ b/www7/modules/system/system.module @@ -2883,7 +2883,7 @@ function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, // Prepare cancel link. if (isset($_GET['destination'])) { - $options = drupal_parse_url(urldecode($_GET['destination'])); + $options = drupal_parse_url($_GET['destination']); } elseif (is_array($path)) { $options = $path; diff --git a/www7/modules/system/tests/cron_queue_test.info b/www7/modules/system/tests/cron_queue_test.info index 03b322416..8da518319 100644 --- a/www7/modules/system/tests/cron_queue_test.info +++ b/www7/modules/system/tests/cron_queue_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/system/tests/system_cron_test.info b/www7/modules/system/tests/system_cron_test.info index 4f7a2da23..824d8a18e 100644 --- a/www7/modules/system/tests/system_cron_test.info +++ b/www7/modules/system/tests/system_cron_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/taxonomy/taxonomy.info b/www7/modules/taxonomy/taxonomy.info index 9bbba1616..f6ffb6334 100644 --- a/www7/modules/taxonomy/taxonomy.info +++ b/www7/modules/taxonomy/taxonomy.info @@ -8,8 +8,8 @@ files[] = taxonomy.module files[] = taxonomy.test configure = admin/structure/taxonomy -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/taxonomy/taxonomy.module b/www7/modules/taxonomy/taxonomy.module index 554d6d2ab..981649d2a 100644 --- a/www7/modules/taxonomy/taxonomy.module +++ b/www7/modules/taxonomy/taxonomy.module @@ -1023,7 +1023,7 @@ function taxonomy_get_parents($tid) { $query->join('taxonomy_term_hierarchy', 'h', 'h.parent = t.tid'); $query->addField('t', 'tid'); $query->condition('h.tid', $tid); - $query->addTag('term_access'); + $query->addTag('taxonomy_term_access'); $query->orderBy('t.weight'); $query->orderBy('t.name'); $tids = $query->execute()->fetchCol(); @@ -1081,7 +1081,7 @@ function taxonomy_get_children($tid, $vid = 0) { if ($vid) { $query->condition('t.vid', $vid); } - $query->addTag('term_access'); + $query->addTag('taxonomy_term_access'); $query->orderBy('t.weight'); $query->orderBy('t.name'); $tids = $query->execute()->fetchCol(); @@ -1129,7 +1129,7 @@ function taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $load_entities $query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid'); $result = $query ->addTag('translatable') - ->addTag('term_access') + ->addTag('taxonomy_term_access') ->fields('t') ->fields('h', array('parent')) ->condition('t.vid', $vid) @@ -1249,7 +1249,7 @@ class TaxonomyTermController extends DrupalDefaultEntityController { protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) { $query = parent::buildQuery($ids, $conditions, $revision_id); $query->addTag('translatable'); - $query->addTag('term_access'); + $query->addTag('taxonomy_term_access'); // When name is passed as a condition use LIKE. if (isset($conditions['name'])) { $query_conditions = &$query->conditions(); diff --git a/www7/modules/taxonomy/taxonomy.pages.inc b/www7/modules/taxonomy/taxonomy.pages.inc index 975ff1203..38b24b3b4 100644 --- a/www7/modules/taxonomy/taxonomy.pages.inc +++ b/www7/modules/taxonomy/taxonomy.pages.inc @@ -150,7 +150,7 @@ function taxonomy_autocomplete($field_name = '', $tags_typed = '') { $query = db_select('taxonomy_term_data', 't'); $query->addTag('translatable'); - $query->addTag('term_access'); + $query->addTag('taxonomy_term_access'); // Do not select already entered terms. if (!empty($tags_typed)) { diff --git a/www7/modules/taxonomy/taxonomy.test b/www7/modules/taxonomy/taxonomy.test index e9dac1ec9..a4b7ee833 100644 --- a/www7/modules/taxonomy/taxonomy.test +++ b/www7/modules/taxonomy/taxonomy.test @@ -1983,3 +1983,113 @@ class TaxonomyEFQTestCase extends TaxonomyWebTestCase { } } + +/** + * Tests that appropriate query tags are added. + */ +class TaxonomyQueryAlterTestCase extends TaxonomyWebTestCase { + public static function getInfo() { + return array( + 'name' => 'Taxonomy query tags', + 'description' => 'Verifies that taxonomy_term_access tags are added to queries.', + 'group' => 'Taxonomy', + ); + } + + public function setUp() { + parent::setUp('taxonomy_test'); + } + + /** + * Tests that appropriate tags are added when querying the database. + */ + public function testTaxonomyQueryAlter() { + // Create a new vocabulary and add a few terms to it. + $vocabulary = $this->createVocabulary(); + $terms = array(); + for ($i = 0; $i < 5; $i++) { + $terms[$i] = $this->createTerm($vocabulary); + } + + // Set up hierarchy. Term 2 is a child of 1. + $terms[2]->parent = array($terms[1]->tid); + taxonomy_term_save($terms[2]); + + $this->setupQueryTagTestHooks(); + $loaded_term = taxonomy_term_load($terms[0]->tid); + $this->assertEqual($loaded_term->tid, $terms[0]->tid, 'First term was loaded'); + $this->assertQueryTagTestResult(1, 'taxonomy_term_load()'); + + $this->setupQueryTagTestHooks(); + $loaded_terms = taxonomy_get_tree($vocabulary->vid); + $this->assertEqual(count($loaded_terms), count($terms), 'All terms were loaded'); + $this->assertQueryTagTestResult(1, 'taxonomy_get_tree()'); + + $this->setupQueryTagTestHooks(); + $loaded_terms = taxonomy_get_parents($terms[2]->tid); + $this->assertEqual(count($loaded_terms), 1, 'All parent terms were loaded'); + $this->assertQueryTagTestResult(2, 'taxonomy_get_parents()'); + + $this->setupQueryTagTestHooks(); + $loaded_terms = taxonomy_get_children($terms[1]->tid); + $this->assertEqual(count($loaded_terms), 1, 'All child terms were loaded'); + $this->assertQueryTagTestResult(2, 'taxonomy_get_children()'); + + $this->setupQueryTagTestHooks(); + $query = db_select('taxonomy_term_data', 't'); + $query->addField('t', 'tid'); + $query->addTag('taxonomy_term_access'); + $tids = $query->execute()->fetchCol(); + $this->assertEqual(count($tids), count($terms), 'All term IDs were retrieved'); + $this->assertQueryTagTestResult(1, 'custom db_select() with taxonomy_term_access tag (preferred)'); + + $this->setupQueryTagTestHooks(); + $query = db_select('taxonomy_term_data', 't'); + $query->addField('t', 'tid'); + $query->addTag('term_access'); + $tids = $query->execute()->fetchCol(); + $this->assertEqual(count($tids), count($terms), 'All term IDs were retrieved'); + $this->assertQueryTagTestResult(1, 'custom db_select() with term_access tag (deprecated)'); + + $this->setupQueryTagTestHooks(); + $query = new EntityFieldQuery(); + $query->entityCondition('entity_type', 'taxonomy_term'); + $query->addTag('taxonomy_term_access'); + $result = $query->execute(); + $this->assertEqual(count($result['taxonomy_term']), count($terms), 'All term IDs were retrieved'); + $this->assertQueryTagTestResult(1, 'custom EntityFieldQuery with taxonomy_term_access tag (preferred)'); + + $this->setupQueryTagTestHooks(); + $query = new EntityFieldQuery(); + $query->entityCondition('entity_type', 'taxonomy_term'); + $query->addTag('term_access'); + $result = $query->execute(); + $this->assertEqual(count($result['taxonomy_term']), count($terms), 'All term IDs were retrieved'); + $this->assertQueryTagTestResult(1, 'custom EntityFieldQuery with term_access tag (deprecated)'); + } + + /** + * Sets up the hooks in the test module. + */ + protected function setupQueryTagTestHooks() { + taxonomy_terms_static_reset(); + variable_set('taxonomy_test_query_alter', 0); + variable_set('taxonomy_test_query_term_access_alter', 0); + variable_set('taxonomy_test_query_taxonomy_term_access_alter', 0); + } + + /** + * Verifies invocation of the hooks in the test module. + * + * @param int $expected_invocations + * The number of times the hooks are expected to have been invoked. + * @param string $method + * A string describing the invoked function which generated the query. + */ + protected function assertQueryTagTestResult($expected_invocations, $method) { + $this->assertIdentical($expected_invocations, variable_get('taxonomy_test_query_alter'), 'hook_query_alter() invoked when executing ' . $method); + $this->assertIdentical($expected_invocations, variable_get('taxonomy_test_query_term_access_alter'), 'Deprecated hook_query_term_access_alter() invoked when executing ' . $method); + $this->assertIdentical($expected_invocations, variable_get('taxonomy_test_query_taxonomy_term_access_alter'), 'Preferred hook_query_taxonomy_term_access_alter() invoked when executing ' . $method); + } + +} diff --git a/www7/modules/toolbar/toolbar.info b/www7/modules/toolbar/toolbar.info index 3ce4e98ed..19c33f14d 100644 --- a/www7/modules/toolbar/toolbar.info +++ b/www7/modules/toolbar/toolbar.info @@ -4,8 +4,8 @@ core = 7.x package = Core version = VERSION -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/tracker/tracker.info b/www7/modules/tracker/tracker.info index eca56149b..d81d72bb9 100644 --- a/www7/modules/tracker/tracker.info +++ b/www7/modules/tracker/tracker.info @@ -6,8 +6,8 @@ version = VERSION core = 7.x files[] = tracker.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/translation/tests/translation_test.info b/www7/modules/translation/tests/translation_test.info index 0f2de51d1..a0cfc5628 100644 --- a/www7/modules/translation/tests/translation_test.info +++ b/www7/modules/translation/tests/translation_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/translation/translation.info b/www7/modules/translation/translation.info index 3f36bfc86..0836a7ba4 100644 --- a/www7/modules/translation/translation.info +++ b/www7/modules/translation/translation.info @@ -6,8 +6,8 @@ version = VERSION core = 7.x files[] = translation.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/trigger/tests/trigger_test.info b/www7/modules/trigger/tests/trigger_test.info index 68ade94af..ae4dcc52a 100644 --- a/www7/modules/trigger/tests/trigger_test.info +++ b/www7/modules/trigger/tests/trigger_test.info @@ -4,8 +4,8 @@ package = Testing core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/trigger/trigger.info b/www7/modules/trigger/trigger.info index 72be9cc68..0d557a691 100644 --- a/www7/modules/trigger/trigger.info +++ b/www7/modules/trigger/trigger.info @@ -6,8 +6,8 @@ core = 7.x files[] = trigger.test configure = admin/structure/trigger -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/update/tests/aaa_update_test.info b/www7/modules/update/tests/aaa_update_test.info index 2f14b29d5..240dfc159 100644 --- a/www7/modules/update/tests/aaa_update_test.info +++ b/www7/modules/update/tests/aaa_update_test.info @@ -4,8 +4,8 @@ package = Testing core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/update/tests/bbb_update_test.info b/www7/modules/update/tests/bbb_update_test.info index 900d0689a..7844301b9 100644 --- a/www7/modules/update/tests/bbb_update_test.info +++ b/www7/modules/update/tests/bbb_update_test.info @@ -4,8 +4,8 @@ package = Testing core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/update/tests/ccc_update_test.info b/www7/modules/update/tests/ccc_update_test.info index 51dc859ee..e7993c279 100644 --- a/www7/modules/update/tests/ccc_update_test.info +++ b/www7/modules/update/tests/ccc_update_test.info @@ -4,8 +4,8 @@ package = Testing core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/update/tests/themes/update_test_admintheme/update_test_admintheme.info b/www7/modules/update/tests/themes/update_test_admintheme/update_test_admintheme.info index cc3e3c5e5..446e25d21 100644 --- a/www7/modules/update/tests/themes/update_test_admintheme/update_test_admintheme.info +++ b/www7/modules/update/tests/themes/update_test_admintheme/update_test_admintheme.info @@ -3,8 +3,8 @@ description = Test theme which is used as admin theme. core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info b/www7/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info index e8f2bfd55..b689b1b65 100644 --- a/www7/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info +++ b/www7/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info @@ -3,8 +3,8 @@ description = Test theme which acts as a base theme for other test subthemes. core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info b/www7/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info index ae70713d7..38c0cfd10 100644 --- a/www7/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info +++ b/www7/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info @@ -4,8 +4,8 @@ core = 7.x base theme = update_test_basetheme hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/update/tests/update_test.info b/www7/modules/update/tests/update_test.info index 8cd643b19..14cd90f94 100644 --- a/www7/modules/update/tests/update_test.info +++ b/www7/modules/update/tests/update_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/update/update.info b/www7/modules/update/update.info index d4477d893..56759d223 100644 --- a/www7/modules/update/update.info +++ b/www7/modules/update/update.info @@ -6,8 +6,8 @@ core = 7.x files[] = update.test configure = admin/reports/updates/settings -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/user/tests/user_form_test.info b/www7/modules/user/tests/user_form_test.info index 57d8fd04f..4f2d8b347 100644 --- a/www7/modules/user/tests/user_form_test.info +++ b/www7/modules/user/tests/user_form_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/modules/user/user.info b/www7/modules/user/user.info index 44d2fd255..ddc243bdc 100644 --- a/www7/modules/user/user.info +++ b/www7/modules/user/user.info @@ -9,8 +9,8 @@ required = TRUE configure = admin/config/people stylesheets[all][] = user.css -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/profiles/minimal/minimal.info b/www7/profiles/minimal/minimal.info index bb30cdc81..41139c8e5 100644 --- a/www7/profiles/minimal/minimal.info +++ b/www7/profiles/minimal/minimal.info @@ -5,8 +5,8 @@ core = 7.x dependencies[] = block dependencies[] = dblog -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/profiles/standard/standard.info b/www7/profiles/standard/standard.info index effe3959a..fbb26da53 100644 --- a/www7/profiles/standard/standard.info +++ b/www7/profiles/standard/standard.info @@ -24,8 +24,8 @@ dependencies[] = field_ui dependencies[] = file dependencies[] = rdf -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info b/www7/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info index d4d12484e..344e798b7 100644 --- a/www7/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info +++ b/www7/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info @@ -6,8 +6,8 @@ core = 7.x hidden = TRUE files[] = drupal_system_listing_compatible_test.test -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info b/www7/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info index 7469d2f10..4220613bf 100644 --- a/www7/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info +++ b/www7/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info @@ -8,8 +8,8 @@ version = VERSION core = 6.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/profiles/testing/testing.info b/www7/profiles/testing/testing.info index 937c48e2c..6b29a17e5 100644 --- a/www7/profiles/testing/testing.info +++ b/www7/profiles/testing/testing.info @@ -4,8 +4,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/themes/bartik/bartik.info b/www7/themes/bartik/bartik.info index b2a0a40c6..0ae697c08 100644 --- a/www7/themes/bartik/bartik.info +++ b/www7/themes/bartik/bartik.info @@ -34,8 +34,8 @@ regions[footer] = Footer settings[shortcut_module_link] = 0 -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/themes/garland/garland.info b/www7/themes/garland/garland.info index 24e56757e..c2f00d499 100644 --- a/www7/themes/garland/garland.info +++ b/www7/themes/garland/garland.info @@ -7,8 +7,8 @@ stylesheets[all][] = style.css stylesheets[print][] = print.css settings[garland_width] = fluid -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/themes/seven/seven.info b/www7/themes/seven/seven.info index 479d04a1e..db30d4154 100644 --- a/www7/themes/seven/seven.info +++ b/www7/themes/seven/seven.info @@ -13,8 +13,8 @@ regions[page_bottom] = Page bottom regions[sidebar_first] = First sidebar regions_hidden[] = sidebar_first -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" diff --git a/www7/themes/stark/stark.info b/www7/themes/stark/stark.info index 1a47c4cc8..afa8ee8f1 100644 --- a/www7/themes/stark/stark.info +++ b/www7/themes/stark/stark.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x stylesheets[all][] = layout.css -; Information added by Drupal.org packaging script on 2016-10-05 -version = "7.51" +; Information added by Drupal.org packaging script on 2016-11-16 +version = "7.52" project = "drupal" -datestamp = "1475694174" +datestamp = "1479322922" From 88df478e1cebd0f2373763e926d1e5c562635652 Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Sat, 10 Dec 2016 11:45:14 +0100 Subject: [PATCH 05/16] Update core to 7.53 --- www7/includes/bootstrap.inc | 2 +- www7/misc/tabledrag.js | 12 ++++++++++-- www7/modules/aggregator/aggregator.info | 6 +++--- www7/modules/aggregator/tests/aggregator_test.info | 6 +++--- www7/modules/block/block.info | 6 +++--- www7/modules/block/tests/block_test.info | 6 +++--- .../themes/block_test_theme/block_test_theme.info | 6 +++--- www7/modules/blog/blog.info | 6 +++--- www7/modules/book/book.info | 6 +++--- www7/modules/color/color.info | 6 +++--- www7/modules/comment/comment.info | 6 +++--- www7/modules/contact/contact.info | 6 +++--- www7/modules/contextual/contextual.info | 6 +++--- www7/modules/dashboard/dashboard.info | 6 +++--- www7/modules/dblog/dblog.info | 6 +++--- www7/modules/field/field.info | 6 +++--- .../modules/field_sql_storage/field_sql_storage.info | 6 +++--- www7/modules/field/modules/list/list.info | 6 +++--- www7/modules/field/modules/list/tests/list_test.info | 6 +++--- www7/modules/field/modules/number/number.info | 6 +++--- www7/modules/field/modules/options/options.info | 6 +++--- www7/modules/field/modules/text/text.info | 6 +++--- www7/modules/field/tests/field_test.info | 6 +++--- www7/modules/field_ui/field_ui.info | 6 +++--- www7/modules/file/file.info | 6 +++--- www7/modules/file/tests/file_module_test.info | 6 +++--- www7/modules/filter/filter.info | 6 +++--- www7/modules/forum/forum.info | 6 +++--- www7/modules/help/help.info | 6 +++--- www7/modules/image/image.info | 6 +++--- www7/modules/image/tests/image_module_test.info | 6 +++--- www7/modules/locale/locale.info | 6 +++--- www7/modules/locale/tests/locale_test.info | 6 +++--- www7/modules/menu/menu.info | 6 +++--- www7/modules/node/node.info | 6 +++--- www7/modules/node/tests/node_access_test.info | 6 +++--- www7/modules/node/tests/node_test.info | 6 +++--- www7/modules/node/tests/node_test_exception.info | 6 +++--- www7/modules/openid/openid.info | 6 +++--- www7/modules/openid/tests/openid_test.info | 6 +++--- www7/modules/overlay/overlay.info | 6 +++--- www7/modules/path/path.info | 6 +++--- www7/modules/php/php.info | 6 +++--- www7/modules/poll/poll.info | 6 +++--- www7/modules/profile/profile.info | 6 +++--- www7/modules/rdf/rdf.info | 6 +++--- www7/modules/rdf/tests/rdf_test.info | 6 +++--- www7/modules/search/search.info | 6 +++--- www7/modules/search/tests/search_embedded_form.info | 6 +++--- www7/modules/search/tests/search_extra_type.info | 6 +++--- www7/modules/search/tests/search_node_tags.info | 6 +++--- www7/modules/shortcut/shortcut.info | 6 +++--- www7/modules/simpletest/simpletest.info | 6 +++--- www7/modules/simpletest/tests/actions_loop_test.info | 6 +++--- www7/modules/simpletest/tests/ajax_forms_test.info | 6 +++--- www7/modules/simpletest/tests/ajax_test.info | 6 +++--- www7/modules/simpletest/tests/batch_test.info | 6 +++--- www7/modules/simpletest/tests/boot_test_1.info | 6 +++--- www7/modules/simpletest/tests/boot_test_2.info | 6 +++--- www7/modules/simpletest/tests/common_test.info | 6 +++--- .../simpletest/tests/common_test_cron_helper.info | 6 +++--- www7/modules/simpletest/tests/database_test.info | 6 +++--- .../drupal_autoload_test/drupal_autoload_test.info | 6 +++--- .../drupal_system_listing_compatible_test.info | 6 +++--- .../drupal_system_listing_incompatible_test.info | 6 +++--- www7/modules/simpletest/tests/entity_cache_test.info | 6 +++--- .../tests/entity_cache_test_dependency.info | 6 +++--- .../simpletest/tests/entity_crud_hook_test.info | 6 +++--- .../simpletest/tests/entity_query_access_test.info | 6 +++--- www7/modules/simpletest/tests/error_test.info | 6 +++--- www7/modules/simpletest/tests/file_test.info | 6 +++--- www7/modules/simpletest/tests/filter_test.info | 6 +++--- www7/modules/simpletest/tests/form_test.info | 6 +++--- www7/modules/simpletest/tests/image_test.info | 6 +++--- www7/modules/simpletest/tests/menu_test.info | 6 +++--- www7/modules/simpletest/tests/module_test.info | 6 +++--- www7/modules/simpletest/tests/path_test.info | 6 +++--- .../simpletest/tests/psr_0_test/psr_0_test.info | 6 +++--- .../simpletest/tests/psr_4_test/psr_4_test.info | 6 +++--- .../modules/simpletest/tests/requirements1_test.info | 6 +++--- .../modules/simpletest/tests/requirements2_test.info | 6 +++--- www7/modules/simpletest/tests/session_test.info | 6 +++--- .../simpletest/tests/system_dependencies_test.info | 6 +++--- ..._incompatible_core_version_dependencies_test.info | 6 +++--- .../tests/system_incompatible_core_version_test.info | 6 +++--- ...ncompatible_module_version_dependencies_test.info | 6 +++--- .../system_incompatible_module_version_test.info | 6 +++--- .../tests/system_project_namespace_test.info | 6 +++--- www7/modules/simpletest/tests/system_test.info | 6 +++--- www7/modules/simpletest/tests/taxonomy_test.info | 6 +++--- www7/modules/simpletest/tests/theme_test.info | 6 +++--- .../tests/themes/test_basetheme/test_basetheme.info | 6 +++--- .../tests/themes/test_subtheme/test_subtheme.info | 6 +++--- .../tests/themes/test_theme/test_theme.info | 6 +++--- .../modules/simpletest/tests/update_script_test.info | 6 +++--- www7/modules/simpletest/tests/update_test_1.info | 6 +++--- www7/modules/simpletest/tests/update_test_2.info | 6 +++--- www7/modules/simpletest/tests/update_test_3.info | 6 +++--- www7/modules/simpletest/tests/url_alter_test.info | 6 +++--- www7/modules/simpletest/tests/xmlrpc_test.info | 6 +++--- www7/modules/statistics/statistics.info | 6 +++--- www7/modules/syslog/syslog.info | 6 +++--- www7/modules/system/system.info | 6 +++--- www7/modules/system/tests/cron_queue_test.info | 6 +++--- www7/modules/system/tests/system_cron_test.info | 6 +++--- www7/modules/taxonomy/taxonomy.info | 6 +++--- www7/modules/toolbar/toolbar.info | 6 +++--- www7/modules/tracker/tracker.info | 6 +++--- www7/modules/translation/tests/translation_test.info | 6 +++--- www7/modules/translation/translation.info | 6 +++--- www7/modules/trigger/tests/trigger_test.info | 6 +++--- www7/modules/trigger/trigger.info | 6 +++--- www7/modules/update/tests/aaa_update_test.info | 6 +++--- www7/modules/update/tests/bbb_update_test.info | 6 +++--- www7/modules/update/tests/ccc_update_test.info | 6 +++--- .../update_test_admintheme.info | 6 +++--- .../update_test_basetheme/update_test_basetheme.info | 6 +++--- .../update_test_subtheme/update_test_subtheme.info | 6 +++--- www7/modules/update/tests/update_test.info | 6 +++--- www7/modules/update/update.info | 6 +++--- www7/modules/user/tests/user_form_test.info | 6 +++--- www7/modules/user/user.info | 6 +++--- www7/profiles/minimal/minimal.info | 6 +++--- www7/profiles/standard/standard.info | 6 +++--- .../drupal_system_listing_compatible_test.info | 6 +++--- .../drupal_system_listing_incompatible_test.info | 6 +++--- www7/profiles/testing/testing.info | 6 +++--- www7/themes/bartik/bartik.info | 6 +++--- www7/themes/garland/garland.info | 6 +++--- www7/themes/seven/seven.info | 6 +++--- www7/themes/stark/stark.info | 6 +++--- 131 files changed, 398 insertions(+), 390 deletions(-) diff --git a/www7/includes/bootstrap.inc b/www7/includes/bootstrap.inc index 8ff737954..ed6d864c8 100644 --- a/www7/includes/bootstrap.inc +++ b/www7/includes/bootstrap.inc @@ -8,7 +8,7 @@ /** * The current system version. */ -define('VERSION', '7.52'); +define('VERSION', '7.53'); /** * Core API compatibility. diff --git a/www7/misc/tabledrag.js b/www7/misc/tabledrag.js index 4e07784c7..7ea88b607 100644 --- a/www7/misc/tabledrag.js +++ b/www7/misc/tabledrag.js @@ -580,12 +580,20 @@ Drupal.tableDrag.prototype.dropRow = function (event, self) { * Get the mouse coordinates from the event (allowing for browser differences). */ Drupal.tableDrag.prototype.mouseCoords = function (event) { + // Complete support for pointer events was only introduced to jQuery in + // version 1.11.1; between versions 1.7 and 1.11.0 pointer events have the + // clientX and clientY properties undefined. In those cases, the properties + // must be retrieved from the event.originalEvent object instead. + var clientX = event.clientX || event.originalEvent.clientX; + var clientY = event.clientY || event.originalEvent.clientY; + if (event.pageX || event.pageY) { return { x: event.pageX, y: event.pageY }; } + return { - x: event.clientX + document.body.scrollLeft - document.body.clientLeft, - y: event.clientY + document.body.scrollTop - document.body.clientTop + x: clientX + document.body.scrollLeft - document.body.clientLeft, + y: clientY + document.body.scrollTop - document.body.clientTop }; }; diff --git a/www7/modules/aggregator/aggregator.info b/www7/modules/aggregator/aggregator.info index 7a1d0845d..b75823524 100644 --- a/www7/modules/aggregator/aggregator.info +++ b/www7/modules/aggregator/aggregator.info @@ -7,8 +7,8 @@ files[] = aggregator.test configure = admin/config/services/aggregator/settings stylesheets[all][] = aggregator.css -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/aggregator/tests/aggregator_test.info b/www7/modules/aggregator/tests/aggregator_test.info index 3dc5c15c8..8418e88bd 100644 --- a/www7/modules/aggregator/tests/aggregator_test.info +++ b/www7/modules/aggregator/tests/aggregator_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/block/block.info b/www7/modules/block/block.info index e30172c5e..8ecff8ad0 100644 --- a/www7/modules/block/block.info +++ b/www7/modules/block/block.info @@ -6,8 +6,8 @@ core = 7.x files[] = block.test configure = admin/structure/block -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/block/tests/block_test.info b/www7/modules/block/tests/block_test.info index 533997190..514b33b11 100644 --- a/www7/modules/block/tests/block_test.info +++ b/www7/modules/block/tests/block_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/block/tests/themes/block_test_theme/block_test_theme.info b/www7/modules/block/tests/themes/block_test_theme/block_test_theme.info index c9ae187b0..8e6826cb5 100644 --- a/www7/modules/block/tests/themes/block_test_theme/block_test_theme.info +++ b/www7/modules/block/tests/themes/block_test_theme/block_test_theme.info @@ -13,8 +13,8 @@ regions[footer] = Footer regions[highlighted] = Highlighted regions[help] = Help -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/blog/blog.info b/www7/modules/blog/blog.info index 0f99752ff..a3989510c 100644 --- a/www7/modules/blog/blog.info +++ b/www7/modules/blog/blog.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = blog.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/book/book.info b/www7/modules/book/book.info index e9ccf68a5..9575ff64e 100644 --- a/www7/modules/book/book.info +++ b/www7/modules/book/book.info @@ -7,8 +7,8 @@ files[] = book.test configure = admin/content/book/settings stylesheets[all][] = book.css -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/color/color.info b/www7/modules/color/color.info index 83b2ef9b6..3ecf3752f 100644 --- a/www7/modules/color/color.info +++ b/www7/modules/color/color.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = color.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/comment/comment.info b/www7/modules/comment/comment.info index 3fc458ffe..749da0d00 100644 --- a/www7/modules/comment/comment.info +++ b/www7/modules/comment/comment.info @@ -9,8 +9,8 @@ files[] = comment.test configure = admin/content/comment stylesheets[all][] = comment.css -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/contact/contact.info b/www7/modules/contact/contact.info index e846110f8..6279557a2 100644 --- a/www7/modules/contact/contact.info +++ b/www7/modules/contact/contact.info @@ -6,8 +6,8 @@ core = 7.x files[] = contact.test configure = admin/structure/contact -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/contextual/contextual.info b/www7/modules/contextual/contextual.info index e398956ee..3a670c0ce 100644 --- a/www7/modules/contextual/contextual.info +++ b/www7/modules/contextual/contextual.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = contextual.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/dashboard/dashboard.info b/www7/modules/dashboard/dashboard.info index 402928aaf..ceb38247c 100644 --- a/www7/modules/dashboard/dashboard.info +++ b/www7/modules/dashboard/dashboard.info @@ -7,8 +7,8 @@ files[] = dashboard.test dependencies[] = block configure = admin/dashboard/customize -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/dblog/dblog.info b/www7/modules/dblog/dblog.info index 01e9a9a04..e9edca59c 100644 --- a/www7/modules/dblog/dblog.info +++ b/www7/modules/dblog/dblog.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = dblog.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/field/field.info b/www7/modules/field/field.info index 94a94ba89..2157d242e 100644 --- a/www7/modules/field/field.info +++ b/www7/modules/field/field.info @@ -11,8 +11,8 @@ dependencies[] = field_sql_storage required = TRUE stylesheets[all][] = theme/field.css -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/field/modules/field_sql_storage/field_sql_storage.info b/www7/modules/field/modules/field_sql_storage/field_sql_storage.info index c46e029b5..13bf2640f 100644 --- a/www7/modules/field/modules/field_sql_storage/field_sql_storage.info +++ b/www7/modules/field/modules/field_sql_storage/field_sql_storage.info @@ -7,8 +7,8 @@ dependencies[] = field files[] = field_sql_storage.test required = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/field/modules/list/list.info b/www7/modules/field/modules/list/list.info index 4904441a5..658433a45 100644 --- a/www7/modules/field/modules/list/list.info +++ b/www7/modules/field/modules/list/list.info @@ -7,8 +7,8 @@ dependencies[] = field dependencies[] = options files[] = tests/list.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/field/modules/list/tests/list_test.info b/www7/modules/field/modules/list/tests/list_test.info index 2e5122360..a15b62b18 100644 --- a/www7/modules/field/modules/list/tests/list_test.info +++ b/www7/modules/field/modules/list/tests/list_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/field/modules/number/number.info b/www7/modules/field/modules/number/number.info index ef5985b3f..104e32a28 100644 --- a/www7/modules/field/modules/number/number.info +++ b/www7/modules/field/modules/number/number.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = number.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/field/modules/options/options.info b/www7/modules/field/modules/options/options.info index 63b916328..d3198a3af 100644 --- a/www7/modules/field/modules/options/options.info +++ b/www7/modules/field/modules/options/options.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = options.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/field/modules/text/text.info b/www7/modules/field/modules/text/text.info index c70494760..54cc28d6d 100644 --- a/www7/modules/field/modules/text/text.info +++ b/www7/modules/field/modules/text/text.info @@ -7,8 +7,8 @@ dependencies[] = field files[] = text.test required = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/field/tests/field_test.info b/www7/modules/field/tests/field_test.info index 166da2e68..7c0e5b7d5 100644 --- a/www7/modules/field/tests/field_test.info +++ b/www7/modules/field/tests/field_test.info @@ -6,8 +6,8 @@ files[] = field_test.entity.inc version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/field_ui/field_ui.info b/www7/modules/field_ui/field_ui.info index 017e1b19b..5df082c9c 100644 --- a/www7/modules/field_ui/field_ui.info +++ b/www7/modules/field_ui/field_ui.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = field_ui.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/file/file.info b/www7/modules/file/file.info index e19955325..4bf081217 100644 --- a/www7/modules/file/file.info +++ b/www7/modules/file/file.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = tests/file.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/file/tests/file_module_test.info b/www7/modules/file/tests/file_module_test.info index c4d0d6823..a6ad129a5 100644 --- a/www7/modules/file/tests/file_module_test.info +++ b/www7/modules/file/tests/file_module_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/filter/filter.info b/www7/modules/filter/filter.info index e8a9e3b9f..a513f5fcf 100644 --- a/www7/modules/filter/filter.info +++ b/www7/modules/filter/filter.info @@ -7,8 +7,8 @@ files[] = filter.test required = TRUE configure = admin/config/content/formats -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/forum/forum.info b/www7/modules/forum/forum.info index 62b9a1bee..74cc2d038 100644 --- a/www7/modules/forum/forum.info +++ b/www7/modules/forum/forum.info @@ -9,8 +9,8 @@ files[] = forum.test configure = admin/structure/forum stylesheets[all][] = forum.css -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/help/help.info b/www7/modules/help/help.info index e930ed6c1..062b30e60 100644 --- a/www7/modules/help/help.info +++ b/www7/modules/help/help.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = help.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/image/image.info b/www7/modules/image/image.info index 7d9543b87..47fb5a5ad 100644 --- a/www7/modules/image/image.info +++ b/www7/modules/image/image.info @@ -7,8 +7,8 @@ dependencies[] = file files[] = image.test configure = admin/config/media/image-styles -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/image/tests/image_module_test.info b/www7/modules/image/tests/image_module_test.info index 20c6bcca1..f9f3f484f 100644 --- a/www7/modules/image/tests/image_module_test.info +++ b/www7/modules/image/tests/image_module_test.info @@ -6,8 +6,8 @@ core = 7.x files[] = image_module_test.module hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/locale/locale.info b/www7/modules/locale/locale.info index c239cc9d6..520d4ecdf 100644 --- a/www7/modules/locale/locale.info +++ b/www7/modules/locale/locale.info @@ -6,8 +6,8 @@ core = 7.x files[] = locale.test configure = admin/config/regional/language -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/locale/tests/locale_test.info b/www7/modules/locale/tests/locale_test.info index 815ffefd3..b51de9f38 100644 --- a/www7/modules/locale/tests/locale_test.info +++ b/www7/modules/locale/tests/locale_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/menu/menu.info b/www7/modules/menu/menu.info index 0f63c2925..9c6a8d19e 100644 --- a/www7/modules/menu/menu.info +++ b/www7/modules/menu/menu.info @@ -6,8 +6,8 @@ core = 7.x files[] = menu.test configure = admin/structure/menu -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/node/node.info b/www7/modules/node/node.info index 7942549f7..a8c61fb37 100644 --- a/www7/modules/node/node.info +++ b/www7/modules/node/node.info @@ -9,8 +9,8 @@ required = TRUE configure = admin/structure/types stylesheets[all][] = node.css -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/node/tests/node_access_test.info b/www7/modules/node/tests/node_access_test.info index ec9b98279..7ba4455b4 100644 --- a/www7/modules/node/tests/node_access_test.info +++ b/www7/modules/node/tests/node_access_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/node/tests/node_test.info b/www7/modules/node/tests/node_test.info index 7ada6a78c..67de1b368 100644 --- a/www7/modules/node/tests/node_test.info +++ b/www7/modules/node/tests/node_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/node/tests/node_test_exception.info b/www7/modules/node/tests/node_test_exception.info index 7a3d5db81..387ccde26 100644 --- a/www7/modules/node/tests/node_test_exception.info +++ b/www7/modules/node/tests/node_test_exception.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/openid/openid.info b/www7/modules/openid/openid.info index 2552fdf2e..f1d0a5a54 100644 --- a/www7/modules/openid/openid.info +++ b/www7/modules/openid/openid.info @@ -5,8 +5,8 @@ package = Core core = 7.x files[] = openid.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/openid/tests/openid_test.info b/www7/modules/openid/tests/openid_test.info index 620aabdfd..485202676 100644 --- a/www7/modules/openid/tests/openid_test.info +++ b/www7/modules/openid/tests/openid_test.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = openid hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/overlay/overlay.info b/www7/modules/overlay/overlay.info index 3e3380949..dd1f3f4b7 100644 --- a/www7/modules/overlay/overlay.info +++ b/www7/modules/overlay/overlay.info @@ -4,8 +4,8 @@ package = Core version = VERSION core = 7.x -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/path/path.info b/www7/modules/path/path.info index dc612fd2f..f17fdaf16 100644 --- a/www7/modules/path/path.info +++ b/www7/modules/path/path.info @@ -6,8 +6,8 @@ core = 7.x files[] = path.test configure = admin/config/search/path -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/php/php.info b/www7/modules/php/php.info index 5a1e90557..0247be60d 100644 --- a/www7/modules/php/php.info +++ b/www7/modules/php/php.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = php.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/poll/poll.info b/www7/modules/poll/poll.info index 2e8aaf6b1..c47342616 100644 --- a/www7/modules/poll/poll.info +++ b/www7/modules/poll/poll.info @@ -6,8 +6,8 @@ core = 7.x files[] = poll.test stylesheets[all][] = poll.css -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/profile/profile.info b/www7/modules/profile/profile.info index 24fa7a0ac..dfa174c59 100644 --- a/www7/modules/profile/profile.info +++ b/www7/modules/profile/profile.info @@ -11,8 +11,8 @@ configure = admin/config/people/profile ; See user_system_info_alter(). hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/rdf/rdf.info b/www7/modules/rdf/rdf.info index bb859054a..44f04bd00 100644 --- a/www7/modules/rdf/rdf.info +++ b/www7/modules/rdf/rdf.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = rdf.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/rdf/tests/rdf_test.info b/www7/modules/rdf/tests/rdf_test.info index a676e1607..8195c999e 100644 --- a/www7/modules/rdf/tests/rdf_test.info +++ b/www7/modules/rdf/tests/rdf_test.info @@ -6,8 +6,8 @@ core = 7.x hidden = TRUE dependencies[] = blog -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/search/search.info b/www7/modules/search/search.info index df0c7f467..a092ea9eb 100644 --- a/www7/modules/search/search.info +++ b/www7/modules/search/search.info @@ -8,8 +8,8 @@ files[] = search.test configure = admin/config/search/settings stylesheets[all][] = search.css -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/search/tests/search_embedded_form.info b/www7/modules/search/tests/search_embedded_form.info index ce0769d23..6423cef53 100644 --- a/www7/modules/search/tests/search_embedded_form.info +++ b/www7/modules/search/tests/search_embedded_form.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/search/tests/search_extra_type.info b/www7/modules/search/tests/search_extra_type.info index 3fcfea64d..0ae00a58d 100644 --- a/www7/modules/search/tests/search_extra_type.info +++ b/www7/modules/search/tests/search_extra_type.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/search/tests/search_node_tags.info b/www7/modules/search/tests/search_node_tags.info index 2c8b9db55..b2cc66ab3 100644 --- a/www7/modules/search/tests/search_node_tags.info +++ b/www7/modules/search/tests/search_node_tags.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/shortcut/shortcut.info b/www7/modules/shortcut/shortcut.info index 54957d391..c12f11e47 100644 --- a/www7/modules/shortcut/shortcut.info +++ b/www7/modules/shortcut/shortcut.info @@ -6,8 +6,8 @@ core = 7.x files[] = shortcut.test configure = admin/config/user-interface/shortcut -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/simpletest.info b/www7/modules/simpletest/simpletest.info index 8175a63c4..d613ff2dc 100644 --- a/www7/modules/simpletest/simpletest.info +++ b/www7/modules/simpletest/simpletest.info @@ -57,8 +57,8 @@ files[] = tests/upgrade/update.trigger.test files[] = tests/upgrade/update.field.test files[] = tests/upgrade/update.user.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/actions_loop_test.info b/www7/modules/simpletest/tests/actions_loop_test.info index f07a631b3..71cd14f31 100644 --- a/www7/modules/simpletest/tests/actions_loop_test.info +++ b/www7/modules/simpletest/tests/actions_loop_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/ajax_forms_test.info b/www7/modules/simpletest/tests/ajax_forms_test.info index 7b1491e6f..c9d9cb6d6 100644 --- a/www7/modules/simpletest/tests/ajax_forms_test.info +++ b/www7/modules/simpletest/tests/ajax_forms_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/ajax_test.info b/www7/modules/simpletest/tests/ajax_test.info index b5d7478bc..f572a0056 100644 --- a/www7/modules/simpletest/tests/ajax_test.info +++ b/www7/modules/simpletest/tests/ajax_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/batch_test.info b/www7/modules/simpletest/tests/batch_test.info index bb90c8e23..dc2aae563 100644 --- a/www7/modules/simpletest/tests/batch_test.info +++ b/www7/modules/simpletest/tests/batch_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/boot_test_1.info b/www7/modules/simpletest/tests/boot_test_1.info index 475e72bec..85a5ea65c 100644 --- a/www7/modules/simpletest/tests/boot_test_1.info +++ b/www7/modules/simpletest/tests/boot_test_1.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/boot_test_2.info b/www7/modules/simpletest/tests/boot_test_2.info index 452913ed5..0bc815c72 100644 --- a/www7/modules/simpletest/tests/boot_test_2.info +++ b/www7/modules/simpletest/tests/boot_test_2.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/common_test.info b/www7/modules/simpletest/tests/common_test.info index 10ef71ecd..7d4668001 100644 --- a/www7/modules/simpletest/tests/common_test.info +++ b/www7/modules/simpletest/tests/common_test.info @@ -7,8 +7,8 @@ stylesheets[all][] = common_test.css stylesheets[print][] = common_test.print.css hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/common_test_cron_helper.info b/www7/modules/simpletest/tests/common_test_cron_helper.info index 4a17eaeb8..55dbd67a3 100644 --- a/www7/modules/simpletest/tests/common_test_cron_helper.info +++ b/www7/modules/simpletest/tests/common_test_cron_helper.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/database_test.info b/www7/modules/simpletest/tests/database_test.info index 4414602d0..0e31a2266 100644 --- a/www7/modules/simpletest/tests/database_test.info +++ b/www7/modules/simpletest/tests/database_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.info b/www7/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.info index beb90c192..18044661f 100644 --- a/www7/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.info +++ b/www7/modules/simpletest/tests/drupal_autoload_test/drupal_autoload_test.info @@ -7,8 +7,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info b/www7/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info index 501574b02..2b8c34c6c 100644 --- a/www7/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info +++ b/www7/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info b/www7/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info index e64ee615b..ce9e19182 100644 --- a/www7/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info +++ b/www7/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/entity_cache_test.info b/www7/modules/simpletest/tests/entity_cache_test.info index 18ee1a7d9..eb38854ea 100644 --- a/www7/modules/simpletest/tests/entity_cache_test.info +++ b/www7/modules/simpletest/tests/entity_cache_test.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = entity_cache_test_dependency hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/entity_cache_test_dependency.info b/www7/modules/simpletest/tests/entity_cache_test_dependency.info index 16c9913f0..0c4335466 100644 --- a/www7/modules/simpletest/tests/entity_cache_test_dependency.info +++ b/www7/modules/simpletest/tests/entity_cache_test_dependency.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/entity_crud_hook_test.info b/www7/modules/simpletest/tests/entity_crud_hook_test.info index 655c13185..bb99125c0 100644 --- a/www7/modules/simpletest/tests/entity_crud_hook_test.info +++ b/www7/modules/simpletest/tests/entity_crud_hook_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/entity_query_access_test.info b/www7/modules/simpletest/tests/entity_query_access_test.info index 41e7e5855..7ab70ddc9 100644 --- a/www7/modules/simpletest/tests/entity_query_access_test.info +++ b/www7/modules/simpletest/tests/entity_query_access_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/error_test.info b/www7/modules/simpletest/tests/error_test.info index 37d97fc8b..d01fea3f8 100644 --- a/www7/modules/simpletest/tests/error_test.info +++ b/www7/modules/simpletest/tests/error_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/file_test.info b/www7/modules/simpletest/tests/file_test.info index fb6b77a2a..6f8d7529d 100644 --- a/www7/modules/simpletest/tests/file_test.info +++ b/www7/modules/simpletest/tests/file_test.info @@ -6,8 +6,8 @@ core = 7.x files[] = file_test.module hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/filter_test.info b/www7/modules/simpletest/tests/filter_test.info index cbaebf5b5..315b04721 100644 --- a/www7/modules/simpletest/tests/filter_test.info +++ b/www7/modules/simpletest/tests/filter_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/form_test.info b/www7/modules/simpletest/tests/form_test.info index 30bcdfa91..c2b36e785 100644 --- a/www7/modules/simpletest/tests/form_test.info +++ b/www7/modules/simpletest/tests/form_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/image_test.info b/www7/modules/simpletest/tests/image_test.info index 369386d4b..a6efccb62 100644 --- a/www7/modules/simpletest/tests/image_test.info +++ b/www7/modules/simpletest/tests/image_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/menu_test.info b/www7/modules/simpletest/tests/menu_test.info index e1f9af325..92e04302b 100644 --- a/www7/modules/simpletest/tests/menu_test.info +++ b/www7/modules/simpletest/tests/menu_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/module_test.info b/www7/modules/simpletest/tests/module_test.info index 384d90e86..d8eeddfbd 100644 --- a/www7/modules/simpletest/tests/module_test.info +++ b/www7/modules/simpletest/tests/module_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/path_test.info b/www7/modules/simpletest/tests/path_test.info index 82fa3d8c2..c2f07a0d9 100644 --- a/www7/modules/simpletest/tests/path_test.info +++ b/www7/modules/simpletest/tests/path_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/psr_0_test/psr_0_test.info b/www7/modules/simpletest/tests/psr_0_test/psr_0_test.info index 1b96bb10f..3f0ce9709 100644 --- a/www7/modules/simpletest/tests/psr_0_test/psr_0_test.info +++ b/www7/modules/simpletest/tests/psr_0_test/psr_0_test.info @@ -5,8 +5,8 @@ core = 7.x hidden = TRUE package = Testing -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/psr_4_test/psr_4_test.info b/www7/modules/simpletest/tests/psr_4_test/psr_4_test.info index ad58c5488..53abc66f2 100644 --- a/www7/modules/simpletest/tests/psr_4_test/psr_4_test.info +++ b/www7/modules/simpletest/tests/psr_4_test/psr_4_test.info @@ -5,8 +5,8 @@ core = 7.x hidden = TRUE package = Testing -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/requirements1_test.info b/www7/modules/simpletest/tests/requirements1_test.info index d53acae1d..6a3a6f8e3 100644 --- a/www7/modules/simpletest/tests/requirements1_test.info +++ b/www7/modules/simpletest/tests/requirements1_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/requirements2_test.info b/www7/modules/simpletest/tests/requirements2_test.info index 5931142ec..b9738f957 100644 --- a/www7/modules/simpletest/tests/requirements2_test.info +++ b/www7/modules/simpletest/tests/requirements2_test.info @@ -7,8 +7,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/session_test.info b/www7/modules/simpletest/tests/session_test.info index cac226fca..20b846cf0 100644 --- a/www7/modules/simpletest/tests/session_test.info +++ b/www7/modules/simpletest/tests/session_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/system_dependencies_test.info b/www7/modules/simpletest/tests/system_dependencies_test.info index b54d4195a..1e74f9dee 100644 --- a/www7/modules/simpletest/tests/system_dependencies_test.info +++ b/www7/modules/simpletest/tests/system_dependencies_test.info @@ -6,8 +6,8 @@ core = 7.x hidden = TRUE dependencies[] = _missing_dependency -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.info b/www7/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.info index 6872a334c..d918475f5 100644 --- a/www7/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.info +++ b/www7/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.info @@ -6,8 +6,8 @@ core = 7.x hidden = TRUE dependencies[] = system_incompatible_core_version_test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/system_incompatible_core_version_test.info b/www7/modules/simpletest/tests/system_incompatible_core_version_test.info index 0be297c7e..1a8adc4a3 100644 --- a/www7/modules/simpletest/tests/system_incompatible_core_version_test.info +++ b/www7/modules/simpletest/tests/system_incompatible_core_version_test.info @@ -5,8 +5,8 @@ version = VERSION core = 5.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.info b/www7/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.info index 011bad3be..b081db4e7 100644 --- a/www7/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.info +++ b/www7/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.info @@ -7,8 +7,8 @@ hidden = TRUE ; system_incompatible_module_version_test declares version 1.0 dependencies[] = system_incompatible_module_version_test (>2.0) -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/system_incompatible_module_version_test.info b/www7/modules/simpletest/tests/system_incompatible_module_version_test.info index 18e48dd25..804408618 100644 --- a/www7/modules/simpletest/tests/system_incompatible_module_version_test.info +++ b/www7/modules/simpletest/tests/system_incompatible_module_version_test.info @@ -5,8 +5,8 @@ version = 1.0 core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/system_project_namespace_test.info b/www7/modules/simpletest/tests/system_project_namespace_test.info index 2dd024d12..d248a0992 100644 --- a/www7/modules/simpletest/tests/system_project_namespace_test.info +++ b/www7/modules/simpletest/tests/system_project_namespace_test.info @@ -6,8 +6,8 @@ core = 7.x hidden = TRUE dependencies[] = drupal:filter -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/system_test.info b/www7/modules/simpletest/tests/system_test.info index edbf8e580..f99edb186 100644 --- a/www7/modules/simpletest/tests/system_test.info +++ b/www7/modules/simpletest/tests/system_test.info @@ -6,8 +6,8 @@ core = 7.x files[] = system_test.module hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/taxonomy_test.info b/www7/modules/simpletest/tests/taxonomy_test.info index 39314e3e6..1dffb58cf 100644 --- a/www7/modules/simpletest/tests/taxonomy_test.info +++ b/www7/modules/simpletest/tests/taxonomy_test.info @@ -6,8 +6,8 @@ core = 7.x hidden = TRUE dependencies[] = taxonomy -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/theme_test.info b/www7/modules/simpletest/tests/theme_test.info index 479536327..ab7d0b709 100644 --- a/www7/modules/simpletest/tests/theme_test.info +++ b/www7/modules/simpletest/tests/theme_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/themes/test_basetheme/test_basetheme.info b/www7/modules/simpletest/tests/themes/test_basetheme/test_basetheme.info index 9ca6b9b57..ea39d8e95 100644 --- a/www7/modules/simpletest/tests/themes/test_basetheme/test_basetheme.info +++ b/www7/modules/simpletest/tests/themes/test_basetheme/test_basetheme.info @@ -6,8 +6,8 @@ hidden = TRUE settings[basetheme_only] = base theme value settings[subtheme_override] = base theme value -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/themes/test_subtheme/test_subtheme.info b/www7/modules/simpletest/tests/themes/test_subtheme/test_subtheme.info index 19c94a3db..60bb4e5c3 100644 --- a/www7/modules/simpletest/tests/themes/test_subtheme/test_subtheme.info +++ b/www7/modules/simpletest/tests/themes/test_subtheme/test_subtheme.info @@ -6,8 +6,8 @@ hidden = TRUE settings[subtheme_override] = subtheme value -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/themes/test_theme/test_theme.info b/www7/modules/simpletest/tests/themes/test_theme/test_theme.info index d6695e526..0370bc6a7 100644 --- a/www7/modules/simpletest/tests/themes/test_theme/test_theme.info +++ b/www7/modules/simpletest/tests/themes/test_theme/test_theme.info @@ -17,8 +17,8 @@ stylesheets[all][] = system.base.css settings[theme_test_setting] = default value -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/update_script_test.info b/www7/modules/simpletest/tests/update_script_test.info index 67519996c..af18d1190 100644 --- a/www7/modules/simpletest/tests/update_script_test.info +++ b/www7/modules/simpletest/tests/update_script_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/update_test_1.info b/www7/modules/simpletest/tests/update_test_1.info index 11091c29f..b64ad361f 100644 --- a/www7/modules/simpletest/tests/update_test_1.info +++ b/www7/modules/simpletest/tests/update_test_1.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/update_test_2.info b/www7/modules/simpletest/tests/update_test_2.info index 11091c29f..b64ad361f 100644 --- a/www7/modules/simpletest/tests/update_test_2.info +++ b/www7/modules/simpletest/tests/update_test_2.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/update_test_3.info b/www7/modules/simpletest/tests/update_test_3.info index 11091c29f..b64ad361f 100644 --- a/www7/modules/simpletest/tests/update_test_3.info +++ b/www7/modules/simpletest/tests/update_test_3.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/url_alter_test.info b/www7/modules/simpletest/tests/url_alter_test.info index 464056b1e..f7924d300 100644 --- a/www7/modules/simpletest/tests/url_alter_test.info +++ b/www7/modules/simpletest/tests/url_alter_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/simpletest/tests/xmlrpc_test.info b/www7/modules/simpletest/tests/xmlrpc_test.info index 166cb8010..cbc93637b 100644 --- a/www7/modules/simpletest/tests/xmlrpc_test.info +++ b/www7/modules/simpletest/tests/xmlrpc_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/statistics/statistics.info b/www7/modules/statistics/statistics.info index cc4e88e19..03d8a30f5 100644 --- a/www7/modules/statistics/statistics.info +++ b/www7/modules/statistics/statistics.info @@ -6,8 +6,8 @@ core = 7.x files[] = statistics.test configure = admin/config/system/statistics -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/syslog/syslog.info b/www7/modules/syslog/syslog.info index 3739d035e..00ad4ff74 100644 --- a/www7/modules/syslog/syslog.info +++ b/www7/modules/syslog/syslog.info @@ -6,8 +6,8 @@ core = 7.x files[] = syslog.test configure = admin/config/development/logging -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/system/system.info b/www7/modules/system/system.info index 365315786..5aa40c950 100644 --- a/www7/modules/system/system.info +++ b/www7/modules/system/system.info @@ -12,8 +12,8 @@ files[] = system.test required = TRUE configure = admin/config/system -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/system/tests/cron_queue_test.info b/www7/modules/system/tests/cron_queue_test.info index 8da518319..13fefda3f 100644 --- a/www7/modules/system/tests/cron_queue_test.info +++ b/www7/modules/system/tests/cron_queue_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/system/tests/system_cron_test.info b/www7/modules/system/tests/system_cron_test.info index 824d8a18e..ed37d1099 100644 --- a/www7/modules/system/tests/system_cron_test.info +++ b/www7/modules/system/tests/system_cron_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/taxonomy/taxonomy.info b/www7/modules/taxonomy/taxonomy.info index f6ffb6334..bd613c4b8 100644 --- a/www7/modules/taxonomy/taxonomy.info +++ b/www7/modules/taxonomy/taxonomy.info @@ -8,8 +8,8 @@ files[] = taxonomy.module files[] = taxonomy.test configure = admin/structure/taxonomy -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/toolbar/toolbar.info b/www7/modules/toolbar/toolbar.info index 19c33f14d..3b0675fa3 100644 --- a/www7/modules/toolbar/toolbar.info +++ b/www7/modules/toolbar/toolbar.info @@ -4,8 +4,8 @@ core = 7.x package = Core version = VERSION -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/tracker/tracker.info b/www7/modules/tracker/tracker.info index d81d72bb9..2b643cdaf 100644 --- a/www7/modules/tracker/tracker.info +++ b/www7/modules/tracker/tracker.info @@ -6,8 +6,8 @@ version = VERSION core = 7.x files[] = tracker.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/translation/tests/translation_test.info b/www7/modules/translation/tests/translation_test.info index a0cfc5628..1976f1c17 100644 --- a/www7/modules/translation/tests/translation_test.info +++ b/www7/modules/translation/tests/translation_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/translation/translation.info b/www7/modules/translation/translation.info index 0836a7ba4..6b3a2f176 100644 --- a/www7/modules/translation/translation.info +++ b/www7/modules/translation/translation.info @@ -6,8 +6,8 @@ version = VERSION core = 7.x files[] = translation.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/trigger/tests/trigger_test.info b/www7/modules/trigger/tests/trigger_test.info index ae4dcc52a..8ee061493 100644 --- a/www7/modules/trigger/tests/trigger_test.info +++ b/www7/modules/trigger/tests/trigger_test.info @@ -4,8 +4,8 @@ package = Testing core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/trigger/trigger.info b/www7/modules/trigger/trigger.info index 0d557a691..517536de8 100644 --- a/www7/modules/trigger/trigger.info +++ b/www7/modules/trigger/trigger.info @@ -6,8 +6,8 @@ core = 7.x files[] = trigger.test configure = admin/structure/trigger -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/update/tests/aaa_update_test.info b/www7/modules/update/tests/aaa_update_test.info index 240dfc159..9c69bde64 100644 --- a/www7/modules/update/tests/aaa_update_test.info +++ b/www7/modules/update/tests/aaa_update_test.info @@ -4,8 +4,8 @@ package = Testing core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/update/tests/bbb_update_test.info b/www7/modules/update/tests/bbb_update_test.info index 7844301b9..7327e7f05 100644 --- a/www7/modules/update/tests/bbb_update_test.info +++ b/www7/modules/update/tests/bbb_update_test.info @@ -4,8 +4,8 @@ package = Testing core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/update/tests/ccc_update_test.info b/www7/modules/update/tests/ccc_update_test.info index e7993c279..3a876fc37 100644 --- a/www7/modules/update/tests/ccc_update_test.info +++ b/www7/modules/update/tests/ccc_update_test.info @@ -4,8 +4,8 @@ package = Testing core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/update/tests/themes/update_test_admintheme/update_test_admintheme.info b/www7/modules/update/tests/themes/update_test_admintheme/update_test_admintheme.info index 446e25d21..00c1dd6b7 100644 --- a/www7/modules/update/tests/themes/update_test_admintheme/update_test_admintheme.info +++ b/www7/modules/update/tests/themes/update_test_admintheme/update_test_admintheme.info @@ -3,8 +3,8 @@ description = Test theme which is used as admin theme. core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info b/www7/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info index b689b1b65..6a858fd96 100644 --- a/www7/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info +++ b/www7/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info @@ -3,8 +3,8 @@ description = Test theme which acts as a base theme for other test subthemes. core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info b/www7/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info index 38c0cfd10..b579bb514 100644 --- a/www7/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info +++ b/www7/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info @@ -4,8 +4,8 @@ core = 7.x base theme = update_test_basetheme hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/update/tests/update_test.info b/www7/modules/update/tests/update_test.info index 14cd90f94..657b2c1c6 100644 --- a/www7/modules/update/tests/update_test.info +++ b/www7/modules/update/tests/update_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/update/update.info b/www7/modules/update/update.info index 56759d223..1efa370b8 100644 --- a/www7/modules/update/update.info +++ b/www7/modules/update/update.info @@ -6,8 +6,8 @@ core = 7.x files[] = update.test configure = admin/reports/updates/settings -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/user/tests/user_form_test.info b/www7/modules/user/tests/user_form_test.info index 4f2d8b347..921bd89ea 100644 --- a/www7/modules/user/tests/user_form_test.info +++ b/www7/modules/user/tests/user_form_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/modules/user/user.info b/www7/modules/user/user.info index ddc243bdc..2136902b6 100644 --- a/www7/modules/user/user.info +++ b/www7/modules/user/user.info @@ -9,8 +9,8 @@ required = TRUE configure = admin/config/people stylesheets[all][] = user.css -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/profiles/minimal/minimal.info b/www7/profiles/minimal/minimal.info index 41139c8e5..ebc9f1292 100644 --- a/www7/profiles/minimal/minimal.info +++ b/www7/profiles/minimal/minimal.info @@ -5,8 +5,8 @@ core = 7.x dependencies[] = block dependencies[] = dblog -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/profiles/standard/standard.info b/www7/profiles/standard/standard.info index fbb26da53..bc743d503 100644 --- a/www7/profiles/standard/standard.info +++ b/www7/profiles/standard/standard.info @@ -24,8 +24,8 @@ dependencies[] = field_ui dependencies[] = file dependencies[] = rdf -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info b/www7/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info index 344e798b7..f0f43f339 100644 --- a/www7/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info +++ b/www7/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info @@ -6,8 +6,8 @@ core = 7.x hidden = TRUE files[] = drupal_system_listing_compatible_test.test -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info b/www7/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info index 4220613bf..174343501 100644 --- a/www7/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info +++ b/www7/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info @@ -8,8 +8,8 @@ version = VERSION core = 6.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/profiles/testing/testing.info b/www7/profiles/testing/testing.info index 6b29a17e5..020330eb0 100644 --- a/www7/profiles/testing/testing.info +++ b/www7/profiles/testing/testing.info @@ -4,8 +4,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/themes/bartik/bartik.info b/www7/themes/bartik/bartik.info index 0ae697c08..007d0a530 100644 --- a/www7/themes/bartik/bartik.info +++ b/www7/themes/bartik/bartik.info @@ -34,8 +34,8 @@ regions[footer] = Footer settings[shortcut_module_link] = 0 -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/themes/garland/garland.info b/www7/themes/garland/garland.info index c2f00d499..009201413 100644 --- a/www7/themes/garland/garland.info +++ b/www7/themes/garland/garland.info @@ -7,8 +7,8 @@ stylesheets[all][] = style.css stylesheets[print][] = print.css settings[garland_width] = fluid -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/themes/seven/seven.info b/www7/themes/seven/seven.info index db30d4154..85e22afd1 100644 --- a/www7/themes/seven/seven.info +++ b/www7/themes/seven/seven.info @@ -13,8 +13,8 @@ regions[page_bottom] = Page bottom regions[sidebar_first] = First sidebar regions_hidden[] = sidebar_first -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" diff --git a/www7/themes/stark/stark.info b/www7/themes/stark/stark.info index afa8ee8f1..651c4fa7d 100644 --- a/www7/themes/stark/stark.info +++ b/www7/themes/stark/stark.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x stylesheets[all][] = layout.css -; Information added by Drupal.org packaging script on 2016-11-16 -version = "7.52" +; Information added by Drupal.org packaging script on 2016-12-07 +version = "7.53" project = "drupal" -datestamp = "1479322922" +datestamp = "1481152423" From c1091f917c23c8301454476a3390a1e8c345829d Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Sat, 10 Dec 2016 11:45:39 +0100 Subject: [PATCH 06/16] Update metatag to 7.x-1.18 --- .../all/modules/contrib/metatag/CHANGELOG.txt | 70 ++++ .../all/modules/contrib/metatag/README.txt | 9 +- .../modules/contrib/metatag/metatag.admin.inc | 102 +++++- .../all/modules/contrib/metatag/metatag.inc | 10 +- .../all/modules/contrib/metatag/metatag.info | 78 ++-- .../modules/contrib/metatag/metatag.install | 340 ++++++++++++++++-- .../contrib/metatag/metatag.metatag.inc | 28 +- .../modules/contrib/metatag/metatag.module | 225 ++++++++---- .../contrib/metatag/metatag.search_api.inc | 88 ++--- .../contrib/metatag/metatag.tokens.inc | 8 +- .../metatag_app_links/metatag_app_links.info | 7 +- .../tests/metatag_app_links.tags.test | 58 +++ .../metatag_context/metatag_context.info | 6 +- .../tests/metatag_context.i18n.test | 8 +- .../tests/metatag_context.test | 3 + .../tests/metatag_context_tests.info | 6 +- .../metatag/metatag_dc/metatag_dc.info | 7 +- .../metatag_dc/tests/metatag_dc.tags.test | 70 ++++ .../metatag_dc_advanced.info | 7 +- .../tests/metatag_dc_advanced.tags.test | 74 ++++ .../metatag/metatag_devel/metatag_devel.info | 6 +- .../metatag_facebook/metatag_facebook.info | 7 +- .../tests/metatag_facebook.tags.test | 37 ++ .../metatag_favicons/metatag_favicons.info | 7 +- .../tests/metatag_favicons.tags.test | 56 +++ .../metatag/metatag_google_cse/README.txt | 22 ++ .../metatag_google_cse.info | 16 + .../metatag_google_cse.install | 5 + .../metatag_google_cse.metatag.inc | 61 ++++ .../metatag_google_cse.module | 47 +++ .../tests/metatag_google_cse.tags.test | 42 +++ .../tests/metatag_google_cse.test | 47 +++ .../metatag_google_plus.info | 7 +- .../metatag_google_plus.metatag.inc | 22 +- .../tests/metatag_google_plus.tags.test | 61 ++++ .../metatag_hreflang/metatag_hreflang.info | 13 +- .../metatag_hreflang/metatag_hreflang.install | 34 ++ .../metatag_hreflang.metatag.inc | 2 +- .../metatag_hreflang/metatag_hreflang.module | 30 +- .../metatag_hreflang.tokens.inc | 23 ++ .../tests/metatag_hreflang.tags.test | 79 ++++ ...atag_hreflang.with_entity_translation.test | 248 ++++++++++++- .../metatag_importer/metatag_importer.info | 6 +- .../metatag_importer.page_title.inc | 4 +- .../contrib/metatag/metatag_mobile/README.txt | 1 + .../metatag_mobile/metatag_mobile.info | 7 +- .../metatag_mobile/metatag_mobile.metatag.inc | 91 +++-- .../metatag_mobile/metatag_mobile.module | 22 ++ .../tests/metatag_mobile.tags.test | 68 ++++ .../metatag_opengraph/metatag_opengraph.info | 7 +- .../metatag_opengraph.install | 4 +- .../tests/metatag_opengraph.tags.test | 133 +++++++ .../metatag_opengraph_products.info | 7 +- .../metatag_opengraph_products.tags.test | 60 ++++ .../metatag_panels/metatag_panels.info | 6 +- .../tests/metatag_panels.i18n.test | 8 +- .../metatag_panels/tests/metatag_panels.test | 1 + .../tests/metatag_panels_tests.info | 6 +- .../metatag_twitter_cards.info | 7 +- .../metatag_twitter_cards.install | 4 +- .../metatag_twitter_cards.metatag.inc | 2 +- .../tests/metatag_twitter_cards.tags.test | 90 +++++ .../metatag_verification.info | 7 +- .../metatag_verification.install | 25 ++ .../metatag_verification.metatag.inc | 12 - .../tests/metatag_verification.tags.test | 40 +++ .../metatag/metatag_views/metatag_views.info | 6 +- .../tests/metatag_views.i18n.test | 7 +- .../tests/metatag_views_tests.info | 6 +- .../metatag/tests/metatag.bulk_revert.test | 51 +++ .../tests/metatag.core_tag_removal.test | 3 +- .../contrib/metatag/tests/metatag.helper.test | 127 ++++--- .../contrib/metatag/tests/metatag.image.test | 67 +++- .../contrib/metatag/tests/metatag.locale.test | 10 +- .../contrib/metatag/tests/metatag.node.test | 189 +++++++--- ..._node.test => metatag.node.with_i18n.test} | 12 +- .../tests/metatag.string_handling.test | 18 +- .../metatag.string_handling_with_i18n.test | 1 + .../contrib/metatag/tests/metatag.tags.test | 138 +++++++ .../metatag/tests/metatag.tags_helper.test | 94 +++++ .../contrib/metatag/tests/metatag.term.test | 15 +- .../metatag/tests/metatag.term.with_i18n.test | 113 ++++++ .../contrib/metatag/tests/metatag.unit.test | 1 + .../contrib/metatag/tests/metatag.user.test | 24 +- .../tests/metatag.with_i18n_config.test | 8 +- .../tests/metatag.with_i18n_disabled.test | 8 +- .../tests/metatag.with_i18n_output.test | 8 +- .../metatag/tests/metatag.with_me.test | 69 ++++ .../metatag/tests/metatag.with_media.test | 1 + .../metatag/tests/metatag.with_panels.test | 9 +- .../metatag/tests/metatag.with_profile2.test | 5 +- .../tests/metatag.with_search_api.test | 3 + .../metatag/tests/metatag.with_views.test | 17 +- .../contrib/metatag/tests/metatag.xss.test | 195 ++++++++++ .../metatag/tests/metatag_search_test.info | 6 +- .../contrib/metatag/tests/metatag_test.info | 6 +- 96 files changed, 3373 insertions(+), 538 deletions(-) create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.tags.test create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_dc/tests/metatag_dc.tags.test create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_dc_advanced/tests/metatag_dc_advanced.tags.test create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_facebook/tests/metatag_facebook.tags.test create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.tags.test create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_google_cse/README.txt create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.info create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.install create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.metatag.inc create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.module create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.tags.test create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.test create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.tags.test create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.tags.test create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.tags.test create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.tags.test create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.tags.test create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.tags.test create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.install create mode 100644 www7/sites/all/modules/contrib/metatag/metatag_verification/tests/metatag_verification.tags.test create mode 100644 www7/sites/all/modules/contrib/metatag/tests/metatag.bulk_revert.test rename www7/sites/all/modules/contrib/metatag/tests/{metatag.with_i18n_node.test => metatag.node.with_i18n.test} (92%) create mode 100644 www7/sites/all/modules/contrib/metatag/tests/metatag.tags.test create mode 100644 www7/sites/all/modules/contrib/metatag/tests/metatag.tags_helper.test create mode 100644 www7/sites/all/modules/contrib/metatag/tests/metatag.term.with_i18n.test create mode 100644 www7/sites/all/modules/contrib/metatag/tests/metatag.with_me.test create mode 100644 www7/sites/all/modules/contrib/metatag/tests/metatag.xss.test diff --git a/www7/sites/all/modules/contrib/metatag/CHANGELOG.txt b/www7/sites/all/modules/contrib/metatag/CHANGELOG.txt index eea25c29a..20d4be896 100644 --- a/www7/sites/all/modules/contrib/metatag/CHANGELOG.txt +++ b/www7/sites/all/modules/contrib/metatag/CHANGELOG.txt @@ -1,3 +1,73 @@ +Metatag 7.x-1.18, 2016-11-30 +---------------------------- +#2761817 by DamienMcKenna: Fixed metatag_update_replace_config() so it isn't + hardcoded to only work with og:video. +#2759843 by DamienMcKenna: Removed the Alexa verification tag. +#2759855 by DamienMcKenna: Removed the Yahoo verification tag. +By DamienMcKenna: Clear Metatag's caches after deleting or renaming a meta tag. +#2763499 by DamienMcKenna: Don't use entity_load() when saving Metatag data, + it can cause anomolies. +#2750705 by jalpesh, susannecoates: Updated description of the Google Play app + ID meta tag. +#2771603 by FeyP: Fixed incorrect argument name to metatag_metatag_save(). +#2745177 by DamienMcKenna: Tests to confirm each meta tag can be filled in and + added to the global settings. +#2773839 by DamienMcKenna: Remove 'metatag_ui' from the {system} table. +#2773465 by DamienMcKenna: Because Page Title is now fully deprecated, promote + converting its settings and uninstalling it. +#1944862 by FeyP, DamienMcKenna: Allow control over which meta tags and + languages are reverted on the Bulk Revert page. +#2766315 by recrit, DamienMcKenna: metatag_entity_type_enable() would + incorrectly change settings in certain circumstances. +#2774859 by DamienMcKenna: Refactored main tests to not use the submodules by + default. +#2678896 by nmalinoski: Fixed redundant t() calls to fix double translation. +#2787189 by DamienMcKenna: Added some tests to confirm that the different node + preview options don't interfere with saving meta tag values. +By DamienMcKenna: Added a Known Issue for problems with Entity Token. +#2790967 by DamienMcKenna: Added tests for taxonomy term config translations + using i18n. +#2795255 by lazysoundsystem: 'disabled' was misspelled. +By DamienMcKenna: Updated the description of content-language to clarify its + usage and the fact that Bing may still use it. +#1865228 by DamienMcKenna: Moved Author meta tag to GooglePlus submodule. +#1343914 by DamienMcKenna: Moved Publisher meta tag to GooglePlus submodule. +#2784879 by sorinb, DamienMcKenna: Change metatag_update_7108 to use a sandbox. +#2791963 by ttkaminski, DamienMcKenna: Don't change protocol-relative URLs in + image values. +#2797069 by Internet, DamienMcKenna: Corrected the URL to Wikipedia's ICBM page. +#2799317 by mdooley: Use a static date example for the Expires meta tag's + description to avoid flooding the {locales_source} table. +#2800479 by DamienMcKenna, david.gil: Avoid showing errors if Search API is not + installed. +By DamienMcKenna: Slight reordering of the main info file. +#2663208 by DamienMcKenna, geertvd: Don't load meta tags on the /user/me page, + avoid problems when the Me module is installed. +#2813429 by DamienMcKenna: Added tests for metatag_mobile. +#2813427 by DamienMcKenna: Added support for the amphtml link tag. +#2811735 by Stevel, DamienMcKenna: Added dependencies to all tests so that tests + will only be listed if those dependencies are also available. +By stimalsina: Minor improvements to the amphtml meta tag's description. +#2823367 by DamienMcKenna: Fixed tests after internal API change in Media. +#2826023 by renatog, DamienMcKenna, gfcamilo: Coding standards fixes for + metatag.module. +#2831030 by prince_zyxware: Fixed some minor coding standard bugs, spacing + issues. +#2759461 by DamienMcKenna: hreflang=x-default is no longer removed when another + hreflang meta tag has the same URL, instead the other tag is removed as it + was supposed to be. Added a new [node:url-original] token for showing the + URL for the source node for translations; updated the default value for + the hreflang=x-default meta tag to use the new token instead of + [node:source:url]. Updates to many tests to allow these changes. +#2532588 by cebasqueira, renatog, DamienMcKenna: Added new meta tags for Google + CSE. +#2796701 by DrupalDano, DamienMcKenna: Some XSS tests for meta tag handling. +#2831073 by DamienMcKenna: Added Workbench Moderation as a test dependency, for + future use. +#2831822 by DamienMcKenna: Added support for the handheld mobile alternate link + tag, supported by Google. + + Metatag 7.x-1.17, 2016-06-30 ---------------------------- #2748627 by jalpesh: Corrected twitter:app:id:googleplay description. diff --git a/www7/sites/all/modules/contrib/metatag/README.txt b/www7/sites/all/modules/contrib/metatag/README.txt index 19a94e49e..791f5286a 100644 --- a/www7/sites/all/modules/contrib/metatag/README.txt +++ b/www7/sites/all/modules/contrib/metatag/README.txt @@ -293,7 +293,10 @@ Troubleshooting / known issues * Versions of Drupal older than v7.17 were missing necessary functionality for taxonomy term pages to work correctly. * Using Metatag with values assigned for the page title and the Page Title - module simultaneously can cause conflicts and unexpected results. + module simultaneously can cause conflicts and unexpected results. It is + strongly recommended to convert the Page Title settings to Metatag and just + uninstall Page Title entirely. See https://www.drupal.org/node/2774833 for + further details. * When customizing the meta tags for user pages, it is strongly recommended to not use the [current-user] tokens, these pertain to the person *viewing* the page and not e.g., the person who authored a page. @@ -311,6 +314,10 @@ Troubleshooting / known issues recommended to disable the "Force language neutral aliases" setting on the Admin Language settings page, i.e. set the "admin_language_force_neutral" variable to FALSE. Failing to do so can lead to data loss in Metatag. +* If Entity Token is installed (a dependency for Rules, Commerce and others) it + is possible that the token browser may not work correctly and may either + timeout or give an error instead of a browsable list of tokens. This is a + limitation of the token browser. Related modules diff --git a/www7/sites/all/modules/contrib/metatag/metatag.admin.inc b/www7/sites/all/modules/contrib/metatag/metatag.admin.inc index 0f707846d..8ab44655f 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag.admin.inc +++ b/www7/sites/all/modules/contrib/metatag/metatag.admin.inc @@ -342,7 +342,7 @@ function metatag_config_disable($config) { ctools_export_crud_disable('metatag_config', $config); $label = metatag_config_instance_label($config->instance); - drupal_set_message(t('The meta tag defaults for @label have been disabed.', array('@label' => $label))); + drupal_set_message(t('The meta tag defaults for @label have been disabled.', array('@label' => $label))); drupal_goto(); } @@ -391,8 +391,7 @@ function metatag_bulk_revert_form() { foreach (entity_get_info() as $entity_type => $entity_info) { foreach (array_keys($entity_info['bundles']) as $bundle) { if (metatag_entity_supports_metatags($entity_type, $bundle)) { - $options[$entity_type . ':' . $bundle] = - $entity_info['label'] . ': ' . $entity_info['bundles'][$bundle]['label']; + $options[$entity_type . ':' . $bundle] = $entity_info['label'] . ': ' . $entity_info['bundles'][$bundle]['label']; } } } @@ -406,6 +405,41 @@ function metatag_bulk_revert_form() { '#description' => t('All meta tags will be removed for all content of the selected entities.'), ); + $metatags = metatag_get_info(); + $options = array(); + foreach ($metatags['tags'] as $tag_name => $tag) { + $options[$tag_name] = t('@group_label: @tag_label', array( + '@group_label' => $metatags['groups'][$tag['group']]['label'], + '@tag_label' => $tag['label'], + )); + } + + if (count($options) > 0) { + $form['tags'] = array( + '#type' => 'checkboxes', + '#required' => FALSE, + '#title' => t('Select the tags to revert'), + '#description' => t('If you select any tags, only those tags will be reverted.'), + '#options' => $options, + ); + } + + $languages = language_list(); + $options = array( + LANGUAGE_NONE => t('Language neutral'), + ); + foreach ($languages as $language) { + $options[$language->language] = $language->name; + } + + $form['languages'] = array( + '#type' => 'checkboxes', + '#required' => FALSE, + '#title' => t('Select the languages to revert'), + '#description' => t('If you select any languages, only tags for those languages will be reverted.'), + '#options' => $options, + ); + $form['submit'] = array( '#type' => 'submit', '#value' => t('Revert'), @@ -428,10 +462,13 @@ function metatag_bulk_revert_form_submit($form, &$form_state) { 'file' => drupal_get_path('module', 'metatag') . '/metatag.admin.inc', ); + $tags = isset($form_state['values']['tags']) ? array_filter($form_state['values']['tags']) : array(); + $languages = isset($form_state['values']['languages']) ? array_filter($form_state['values']['languages']) : array(); + // Set a batch operation per entity:bundle. foreach (array_filter($form_state['values']['update']) as $option) { list($entity_type, $bundle) = explode(':', $option); - $batch['operations'][] = array('metatag_bulk_revert_batch_operation', array($entity_type, $bundle)); + $batch['operations'][] = array('metatag_bulk_revert_batch_operation', array($entity_type, $bundle, $tags, $languages)); } batch_set($batch); @@ -440,7 +477,7 @@ function metatag_bulk_revert_form_submit($form, &$form_state) { /** * Batch callback: delete custom metatags for selected bundles. */ -function metatag_bulk_revert_batch_operation($entity_type, $bundle, &$context) { +function metatag_bulk_revert_batch_operation($entity_type, $bundle, $tags, $languages, &$context) { if (!isset($context['sandbox']['current'])) { $context['sandbox']['count'] = 0; $context['sandbox']['current'] = 0; @@ -478,14 +515,53 @@ function metatag_bulk_revert_batch_operation($entity_type, $bundle, &$context) { foreach ($entity_ids as $entity_id) { $metatags = metatag_metatags_load($entity_type, $entity_id); if (!empty($metatags)) { - db_delete('metatag')->condition('entity_type', $entity_type) - ->condition('entity_id', $entity_id) - ->execute(); - metatag_metatags_cache_clear($entity_type, $entity_id); - $context['results'][] = t('Reverted metatags for @bundle with id @id.', array( - '@bundle' => $entity_type . ': ' . $bundle, - '@id' => $entity_id, - )); + $reset = FALSE; + if (empty($tags)) { + // All tags should be reset, so we just delete any records from the db. + $query = db_delete('metatag') + ->condition('entity_type', $entity_type) + ->condition('entity_id', $entity_id); + if (!empty($languages)) { + $query->condition('language', $languages, 'IN'); + } + $query->execute(); + metatag_metatags_cache_clear($entity_type, $entity_id); + $reset = TRUE; + } + else { + // Iterate over tags and unset those, that we want to reset. + $needs_reset = FALSE; + foreach ($metatags as $metatags_language => $metatags_tags) { + if (empty($languages) || in_array($metatags_language, $languages)) { + foreach ($metatags_tags as $metatags_tag => $metatags_value) { + if (in_array($metatags_tag, $tags)) { + unset($metatags[$metatags_language][$metatags_tag]); + $needs_reset = TRUE; + } + } + } + } + // Save modified metatags. + if ($needs_reset) { + // We don't have a revision id, so we'll get the active one. + // Unfortunately, the only way of getting the active revision ID is to + // first load the entity, and then extract the ID. This is a bit + // performance intensive, but it seems to be the only way of doing it. + $entities = entity_load($entity_type, array($entity_id)); + if (!empty($entities[$entity_id])) { + // We only care about the revision_id. + list(, $revision_id, ) = entity_extract_ids($entity_type, $entities[$entity_id]); + } + metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags, $bundle); + $reset = TRUE; + } + } + if ($reset) { + $context['results'][] = t('Reverted metatags for @bundle with id @id.', array( + '@bundle' => $entity_type . ': ' . $bundle, + '@id' => $entity_id, + )); + } } } diff --git a/www7/sites/all/modules/contrib/metatag/metatag.inc b/www7/sites/all/modules/contrib/metatag/metatag.inc index ab85a2de5..09bef4edc 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag.inc +++ b/www7/sites/all/modules/contrib/metatag/metatag.inc @@ -165,7 +165,10 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface { public function tidyValue($value) { // Check for Media strings from the WYSIWYG submodule. if (module_exists('media_wysiwyg') && strpos($value, '[[{') !== FALSE) { - $value = media_wysiwyg_filter($value); + // In https://www.drupal.org/node/2129273 media_wysiwyg_filter() was + // changed to require several additional arguments. + $langcode = language_default('language'); + $value = media_wysiwyg_filter($value, NULL, NULL, $langcode, NULL, NULL); } // Specifically replace encoded spaces, because some WYSIWYG editors are @@ -199,8 +202,9 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface { */ function convertUrlToAbsolute($url) { // Convert paths relative to the hostname, that start with a slash, to - // ones that are relative to the Drupal root path. - if (strpos($url, base_path()) === 0) { + // ones that are relative to the Drupal root path; ignore protocol-relative + // URLs. + if (strpos($url, base_path()) === 0 && strpos($url, '//') !== 0) { // Logic: // * Get the length of the base_path(), // * Get a portion of the image's path starting from the position equal diff --git a/www7/sites/all/modules/contrib/metatag/metatag.info b/www7/sites/all/modules/contrib/metatag/metatag.info index 8237f2d2d..fd43f5153 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag.info +++ b/www7/sites/all/modules/contrib/metatag/metatag.info @@ -16,69 +16,95 @@ dependencies[] = token configure = admin/config/search/metatags +; The main classes. files[] = metatag.inc + +; Defines the basic meta tags. files[] = metatag.migrate.inc + +; Search API integration. files[] = metatag.search_api.inc + ; Tests. files[] = tests/metatag.helper.test + ; Basic configuration handling. files[] = tests/metatag.unit.test + +; Basic tag testing. +files[] = tests/metatag.tags_helper.test +files[] = tests/metatag.tags.test + ; Core entities. files[] = tests/metatag.node.test files[] = tests/metatag.term.test files[] = tests/metatag.user.test + ; Handling of core's default meta tags. files[] = tests/metatag.core_tag_removal.test + +; The custom Bulk Revert functionality. +files[] = tests/metatag.bulk_revert.test + ; String handling. files[] = tests/metatag.string_handling.test files[] = tests/metatag.string_handling_with_i18n.test + +; XSS testing. +files[] = tests/metatag.xss.test + ; Images need specia attention. +test_dependencies[] = devel +test_dependencies[] = imagecache_token files[] = tests/metatag.image.test + ; Internationalization & translation. +test_dependencies[] = entity_translation +test_dependencies[] = i18n files[] = tests/metatag.locale.test +files[] = tests/metatag.node.with_i18n.test +files[] = tests/metatag.term.with_i18n.test files[] = tests/metatag.with_i18n_output.test files[] = tests/metatag.with_i18n_disabled.test files[] = tests/metatag.with_i18n_config.test -files[] = tests/metatag.with_i18n_node.test + +; Basic integration with Me. +test_dependencies[] = me +files[] = tests/metatag.with_me.test + ; Basic integration with Media. +test_dependencies[] = file_entity +test_dependencies[] = media files[] = tests/metatag.with_media.test + ; Basic integration with Panels. +test_dependencies[] = panels files[] = tests/metatag.with_panels.test + ; Basic integration with Profile2. +test_dependencies[] = profile2 files[] = tests/metatag.with_profile2.test + ; Basic integration with Search API. +test_dependencies[] = entity +test_dependencies[] = search_api files[] = tests/metatag.with_search_api.test -; Basic integration with Views. -files[] = tests/metatag.with_views.test -; This is required for testing image handling. -test_dependencies[] = devel -test_dependencies[] = imagecache_token - -; These are required for the internationalization & translation functionality. -test_dependencies[] = entity_translation -test_dependencies[] = i18n +; Integration with Workbench Moderation +test_dependencies[] = workbench_moderation +;files[] = tests/metatag.with_workbench_moderation,test -; These are required for the submodules. -test_dependencies[] = context -test_dependencies[] = panels +; Basic integration with Views. test_dependencies[] = views +files[] = tests/metatag.with_views.test -; These are required for the Media integration. -test_dependencies[] = file_entity -test_dependencies[] = media - -; These are required for the Search API integration. -test_dependencies[] = entity -test_dependencies[] = search_api - -; This is required for the Profile2-related tests. -test_dependencies[] = profile2 +; Other test dependencies. +test_dependencies[] = context -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag.install b/www7/sites/all/modules/contrib/metatag/metatag.install index c4fe9cf0d..2e1c46924 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag.install +++ b/www7/sites/all/modules/contrib/metatag/metatag.install @@ -78,10 +78,10 @@ function metatag_requirements($phase) { // Add a note if Page Title is also installed. if (module_exists('page_title')) { $requirements['metatag_page_title'] = array( - 'severity' => REQUIREMENT_INFO, + 'severity' => REQUIREMENT_WARNING, 'title' => 'Metatag', - 'value' => $t('Possible conflicts with Page Title module'), - 'description' => $t('The Metatag module is able to customize page titles so running the Page Title module simultaneously can lead to complications.'), + 'value' => $t('Page Title module should be removed'), + 'description' => $t('The Metatag module is able to customize page titles, so running the Page Title module simultaneously can lead to complications. Please follow the instructions to convert the Page Title settings and uninstall the module.', array('@page' => 'https://www.drupal.org/node/2774833')), ); } @@ -455,7 +455,7 @@ function metatag_enable() { } /** - * Replace one meta tag with another in the entity records. + * Replace one meta tag's with another in the entity records. * * @param array $sandbox * A Batch API sandbox, passed by reference. @@ -464,18 +464,18 @@ function metatag_enable() { * @param string $new_tag * The meta tag that replaces the old one. */ -function metatag_update_replace_meta_tag(&$sandbox, $old_tag, $new_tag) { +function metatag_update_replace_entity_tag(&$sandbox, $old_tag, $new_tag) { if (!isset($sandbox['progress'])) { // Count of all {metatag} records that contained an entry for the old meta // tag. $records_count = db_select('metatag', 'm') - ->condition('m.data', '%' . db_like('"" . $old_tag . ""') . '%', 'LIKE') + ->condition('m.data', '%' . db_like('"' . $old_tag . '"') . '%', 'LIKE') ->countQuery() ->execute() ->fetchField(); if (empty($records_count)) { - return t('No Metatag entity records needed to have the "' . $old_tag . '" meta tag renamed.'); + return t('No Metatag entity records needed to have the "@tag" meta tag renamed.', array('@tag' => $old_tag)); } $sandbox['max'] = $records_count; @@ -517,7 +517,84 @@ function metatag_update_replace_meta_tag(&$sandbox, $old_tag, $new_tag) { } else { $sandbox['#finished'] = 1; - return t('Converted the "' . $old_tag . '" meta tag for @count entity records to "' . $new_tag . '" meta tag.', array('@count' => $sandbox['progress'])); + return t('Converted the "@old_tag" meta tag for @count entity records to "@new_tag" meta tag.', array('@old_tag' => $old_tag, '@new_tag' => $new_tag, '@count' => $sandbox['progress'])); + } +} + +/** + * Replace one meta tag's value in the entity records. + * + * @param array $sandbox + * A Batch API sandbox, passed by reference. + * @param string $meta_tag + * The meta tag that needs its value replaced. + * @param string $old_value + * The meta tag value that is to be replaced. + * @param string $new_value + * The meta tag value that replaces the old one. + */ +function metatag_update_replace_entity_value(&$sandbox, $meta_tag, $old_value, $new_value) { + // The condition used for both queries. + $db_and = db_and(); + $db_and->condition('m.data', '%' . db_like('"' . $meta_tag . '"') . '%', 'LIKE'); + $db_and->condition('m.data', '%' . db_like('"' . $old_value . '"') . '%', 'LIKE'); + + if (!isset($sandbox['progress'])) { + // Count of all {metatag} records that contained an entry for the old meta + // tag value + $records_count = db_select('metatag', 'm') + ->condition($db_and) + ->countQuery() + ->execute() + ->fetchField(); + + if (empty($records_count)) { + return t('No Metatag entity records needed to have the "@tag" meta tag "@old_value" value replaced.', array('@tag' => $meta_tag, '@old_value' => $old_value)); + } + + $sandbox['max'] = $records_count; + $sandbox['progress'] = 0; + + // Keep track of the number of replaced values separately. + $sandbox['count'] = 0; + } + + // Count of rows that will be processed per iteration. + $limit = 100; + + // Fetches a part of records. + $records = db_select('metatag', 'm') + ->fields('m', array()) + ->condition($db_and) + ->range(0, $limit) + ->execute(); + + $count = 0; + $keys = array('entity_type', 'entity_id', 'revision_id', 'language'); + + // Loop over the values and correct them. + foreach ($records as $record) { + $record->data = unserialize($record->data); + + if (isset($record->data[$meta_tag])) { + $record->data[$meta_tag]['value'] = str_replace($old_value, $new_value, $record->data[$meta_tag]['value']); + drupal_write_record('metatag', $record, $keys); + + // Clear the cache for the entity this belongs to. + entity_get_controller($record->entity_type)->resetCache(array($record->entity_id)); + + $sandbox['count']++; + } + + $sandbox['progress']++; + } + + if (!empty($count)) { + $sandbox['#finished'] = min(0.99, $sandbox['progress'] / $sandbox['max']); + } + else { + $sandbox['#finished'] = 1; + return t('Replaced the value of @count entity records for the "@meta_tag" meta tag.', array('@meta_tag' => $meta_tag, '@count' => $sandbox['count'])); } } @@ -529,7 +606,7 @@ function metatag_update_replace_meta_tag(&$sandbox, $old_tag, $new_tag) { * @param string $new_tag * The meta tag that replaces the old one. */ -function metatag_update_replace_config($old_tag, $new_tag) { +function metatag_update_replace_config_tag($old_tag, $new_tag) { // Find all {metatag_config} records that contained an entry for the old meta // tag. $records = db_select('metatag_config', 'm') @@ -537,11 +614,11 @@ function metatag_update_replace_config($old_tag, $new_tag) { ->condition('m.config', '%' . db_like('"' . $old_tag . '"') . '%', 'LIKE') ->execute(); // This message will be returned if nothing needed to be updated. - $none_message = t('No Metatag configuration records needed to have the "og:video" meta tag fixed. That said, there may be other configurations elsewhere that do need updating.'); + $none_message = t('No Metatag configuration records needed to have the "@tag" meta tag fixed. That said, there may be other configurations elsewhere that do need updating.', array('@tag' => $old_tag)); // Loop over the values and correct them. if ($records->rowCount() == 0) { - drupal_set_message($none_message); + $message = $none_message; } else { $keys = array('cid'); @@ -552,18 +629,137 @@ function metatag_update_replace_config($old_tag, $new_tag) { $record->config = unserialize($record->config); if (isset($record->config[$old_tag])) { $record->config[$new_tag] = $record->config[$old_tag]; - unset($record->config['og:video']); + unset($record->config[$old_tag]); drupal_write_record('metatag_config', $record, $keys); $counter++; } } + if ($counter == 0) { + $message = $none_message; + } + else { + $message = t('Converted the "@old_tag" meta tag for @count configurations to the new "@new_tag" meta tag.', array('@old_tag' => $old_tag, '@new_tag' => $new_tag, '@count' => $counter)); + } + } + + // Clear all Metatag caches. + cache_clear_all('*', 'cache_metatag', TRUE); + drupal_static_reset('metatag_config_load_with_defaults'); + drupal_static_reset('metatag_entity_supports_metatags'); + drupal_static_reset('metatag_config_instance_info'); + drupal_static_reset('metatag_get_info'); + ctools_include('export'); + ctools_export_load_object_reset('metatag_config'); + + return $message; +} + +/** + * Replace one meta tag with another in the configs. + * + * @param string $meta_tag + * The meta tag that needs its value replaced. + * @param string $old_value + * The meta tag value that is to be replaced. + * @param string $new_value + * The meta tag value that replaces the old one. + */ +function metatag_update_replace_config_value($meta_tag, $old_value, $new_value) { + // Find all {metatag_config} records that contained an entry for the old meta + // tag. + $db_and = db_and(); + $db_and->condition('m.config', '%' . db_like('"' . $meta_tag . '"') . '%', 'LIKE'); + $db_and->condition('m.config', '%' . db_like('"' . $old_value . '"') . '%', 'LIKE'); + $records = db_select('metatag_config', 'm') + ->fields('m', array('cid', 'config')) + ->condition($db_and) + ->execute(); + // This message will be returned if nothing needed to be updated. + $none_message = t('No Metatag configuration records needed to have the "@tag" meta tag values updated. That said, there may be other configurations elsewhere that do need updating.', array('@tag' => $meta_tag)); + + // Loop over the values and correct them. + if ($records->rowCount() == 0) { + $message = $none_message; + } + else { + $keys = array('cid'); + + // Loop over the values and correct them. + $counter = 0; + foreach ($records as $record) { + $record->config = unserialize($record->config); + if (isset($record->config[$meta_tag])) { + $record->config[$meta_tag]['value'] = str_replace($old_value, $new_value, $record->config[$meta_tag]['value']); + drupal_write_record('metatag_config', $record, $keys); + $counter++; + } + } + if ($counter == 0) { + $message = $none_message; + } + else { + $message = t('Replaced the value of @count entity records for the "@meta_tag" meta tag.', array('@meta_tag' => $meta_tag, '@count' => $counter)); + } + } + + // Clear all Metatag caches. + cache_clear_all('*', 'cache_metatag', TRUE); + drupal_static_reset('metatag_config_load_with_defaults'); + drupal_static_reset('metatag_entity_supports_metatags'); + drupal_static_reset('metatag_config_instance_info'); + drupal_static_reset('metatag_get_info'); + ctools_include('export'); + ctools_export_load_object_reset('metatag_config'); + + return $message; +} + +/** + * Remove a specific meta tag from all configs. + * + * @param string $$tag_name + * The meta tag that is to be removed. + */ +function metatag_update_delete_config($tag_name) { + // Find all {metatag_config} records that contained an entry for the meta tag. + $records = db_select('metatag_config', 'm') + ->fields('m', array('cid', 'config')) + ->condition('m.config', '%' . db_like('"' . $tag_name . '"') . '%', 'LIKE') + ->execute(); + // This message will be returned if nothing needed to be updated. + $none_message = t('No Metatag configuration records needed to have the "@tag" meta tag removed.', array('@tag' => $tag_name)); + + // Loop over the values and correct them. + if ($records->rowCount() == 0) { + drupal_set_message($none_message); + } + else { + // Loop over the values and correct them. + $counter = 0; + foreach ($records as $record) { + $record->config = unserialize($record->config); + if (isset($record->config[$tag_name])) { + unset($record->config[$tag_name]); + drupal_write_record('metatag_config', $record, array('cid')); + $counter++; + } + } if ($counter == 0) { drupal_set_message($none_message); } else { - drupal_set_message(t('Converted the "' . $old_tag . '" meta tag for @count configurations to the new "' . $new_tag . '" meta tag.', array('@count' => $counter))); + drupal_set_message(t('Removed the "@tag" meta tag for @count configurations.', array('@tag' => $tag_name, '@count' => $counter))); } } + + // Clear all Metatag caches. + cache_clear_all('*', 'cache_metatag', TRUE); + drupal_static_reset('metatag_config_load_with_defaults'); + drupal_static_reset('metatag_entity_supports_metatags'); + drupal_static_reset('metatag_config_instance_info'); + drupal_static_reset('metatag_get_info'); + ctools_include('export'); + ctools_export_load_object_reset('metatag_config'); } /** @@ -1645,7 +1841,7 @@ function metatag_update_7025() { function metatag_update_7026(&$sandbox) { $old_tag = 'copyright'; $new_tag = 'rights'; - return metatag_update_replace_meta_tag($sandbox, $old_tag, $new_tag); + return metatag_update_replace_entity_tag($sandbox, $old_tag, $new_tag); } /** @@ -1688,7 +1884,7 @@ function metatag_update_7030() { function metatag_update_7031() { $old_tag = 'copyright'; $new_tag = 'rights'; - return metatag_update_replace_config($old_tag, $new_tag); + return metatag_update_replace_config_tag($old_tag, $new_tag); } /** @@ -2167,7 +2363,7 @@ function metatag_update_7107() { /** * Delete output translations if it's disabled. */ -function metatag_update_7108() { +function metatag_update_7108(&$sandbox) { if (!module_exists('locale') || !db_table_exists('locales_source')) { return t('No translations to fix as the locale system is not enabled.'); } @@ -2177,31 +2373,80 @@ function metatag_update_7108() { return t("Metatag: Not deleting output translations because that option is enabled."); } - $lids = db_select('locales_source', 'ls') - ->fields('ls', array('lid')) - ->condition('ls.textgroup', 'metatag') - ->condition('ls.context', 'output:%', 'LIKE') - ->execute() - ->fetchCol(); + $limit = 100; - if (!empty($lids)) { - // Delete records in the tables in reverse order, so that if the query fails - // and has to be reran it'll still find records. But it should be ok. - if (db_table_exists('i18n_string')) { - db_delete('i18n_string') - ->condition('lid', $lids) - ->execute(); + // When ran through Drush it's Ok to process a larger number of objects at a + // time. + if (drupal_is_cli()) { + $limit = 500; + } + + // Use the sandbox at your convenience to store the information needed to + // track progression between successive calls to the function. + if (!isset($sandbox['progress'])) { + // The count of records visited so far. + $sandbox['progress'] = 0; + + $sandbox['max'] = db_query("SELECT COUNT(lid) + FROM {locales_source} + WHERE textgroup = 'metatag' + AND context LIKE 'output:%'")->fetchField(); + + // If there's no data, don't bother with the extra work. + if (empty($sandbox['max'])) { + watchdog('metatag', 'Update 7108: No nodes need the translation entity string fixed.', array(), WATCHDOG_INFO); + if (drupal_is_cli()) { + drupal_set_message(t('Update 7108: No nodes need the translation entity string fixed.')); + } + return t('No nodes need the Metatag language values fixed.'); } - db_delete('locales_target') - ->condition('lid', $lids) - ->execute(); - db_delete('locales_source') - ->condition('lid', $lids) + + // A place to store messages during the run. + $sandbox['messages'] = array(); + + // An initial record of the number of records to be updated. + watchdog('metatag', 'Update 7108: !count records to update.', array('!count' => $sandbox['max']), WATCHDOG_INFO); + if (drupal_is_cli()) { + drupal_set_message(t('Update 7108: !count records to update.', array('!count' => $sandbox['max']))); + } + } + + // Get a batch of records that need to be fixed. + $records = db_query_range("SELECT lid + FROM {locales_source} + WHERE textgroup = 'metatag' + AND context LIKE 'output:%'", 0, $limit); + + $lids = $records->fetchCol(); + $count = count($lids); + // Delete records in the tables in reverse order, so that if the query fails + // and has to be reran it'll still find records. But it should be ok. + if (db_table_exists('i18n_string')) { + db_delete('i18n_string') + ->condition('lid', $lids, 'IN') ->execute(); - return t('Metatag: Removed @count output translation records that were not needed.', array('@count' => count($lids))); } - else { - return t('Metatag; No output translation records needed to be removed.'); + db_delete('locales_target') + ->condition('lid', $lids, 'IN') + ->execute(); + db_delete('locales_source') + ->condition('lid', $lids, 'IN') + ->execute(); + + $sandbox['progress'] = $sandbox['progress'] + $count; + + // Set the "finished" status, to tell batch engine whether this function + // needs to run again. If you set a float, this will indicate the progress of + // the batch so the progress bar will update. + $sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']); + + if ($sandbox['#finished']) { + // Clear all caches so the fixed data will be reloaded. + cache_clear_all('*', 'cache_metatag', TRUE); + + // hook_update_N() may optionally return a string which will be displayed + // to the user. + return t('Deleted output translation if disabled for @count items.', array('@count' => $sandbox['progress'])); } } @@ -2212,7 +2457,7 @@ function metatag_update_7109(&$sandbox) { module_load_include('install', 'metatag'); $old_tag = 'icon_any'; $new_tag = 'mask-icon'; - return metatag_update_replace_meta_tag($sandbox, $old_tag, $new_tag); + return metatag_update_replace_entity_tag($sandbox, $old_tag, $new_tag); } /** @@ -2222,5 +2467,22 @@ function metatag_update_7110() { module_load_include('install', 'metatag'); $old_tag = 'icon_any'; $new_tag = 'mask-icon'; - return metatag_update_replace_config($old_tag, $new_tag); + return metatag_update_replace_config_tag($old_tag, $new_tag); +} + +/** + * Remove the "metatag_ui" record from the {system} table. + */ +function metatag_update_7111() { + db_delete('system') + ->condition('name', 'metatag_ui') + ->execute(); +} + +/** + * The Publisher meta tag is now part of the Google Plus submodule. + */ +function metatag_update_7112() { + cache_clear_all('*', 'cache_metatag', TRUE); + drupal_set_message(t('The Publisher meta tag is now part of the Google Plus submodule.')); } diff --git a/www7/sites/all/modules/contrib/metatag/metatag.metatag.inc b/www7/sites/all/modules/contrib/metatag/metatag.metatag.inc index 924e697ad..bea0bf7cd 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag.metatag.inc +++ b/www7/sites/all/modules/contrib/metatag/metatag.metatag.inc @@ -326,28 +326,6 @@ function metatag_metatag_info() { ), ); - $info['tags']['publisher'] = array( - 'label' => t('Publisher URL'), - 'description' => '', - 'class' => 'DrupalLinkMetaTag', - 'group' => 'advanced', - 'weight' => ++$weight, - 'devel_generate' => array( - 'type' => 'url', - ), - ); - - $info['tags']['author'] = array( - 'label' => t('Author URL'), - 'description' => t("Used by some search engines to confirm authorship of the content on a page. Should be either the full URL for the author's Google+ profile page or a local page with information about the author."), - 'class' => 'DrupalLinkMetaTag', - 'group' => 'advanced', - 'weight' => ++$weight, - 'devel_generate' => array( - 'type' => 'url', - ), - ); - $info['tags']['original-source'] = array( 'label' => t('Original Source'), 'description' => '', @@ -384,7 +362,7 @@ function metatag_metatag_info() { $info['tags']['content-language'] = array( 'label' => t('Content language'), - 'description' => t("A deprecated meta tag for defining this page's two-letter language code(s)."), + 'description' => t("Used to define this page's language code. May be the two letter language code, e.g. \"de\" for German, or the two letter code with a dash and the two letter ISO country code, e.g. \"de-AT\" for German in Austria. Still used by Bing."), 'class' => 'DrupalTextMetaTag', 'group' => 'advanced', 'weight' => ++$weight, @@ -420,7 +398,7 @@ function metatag_metatag_info() { $info['tags']['icbm'] = array( 'label' => t('ICBM'), - 'description' => t('Geo-spatial information in "latitude, longitude" format, e.g. "50.167958, -97.133185"; see Wikipedia for details.'), + 'description' => t('Geo-spatial information in "latitude, longitude" format, e.g. "50.167958, -97.133185"; see Wikipedia for details.'), 'class' => 'DrupalTextMetaTag', 'group' => 'advanced', 'weight' => ++$weight, @@ -472,7 +450,7 @@ function metatag_metatag_info() { $info['tags']['expires'] = array( 'label' => t('Expires'), - 'description' => t("Control when the browser's internal cache of the current page should expire. The date must to be an RFC-1123-compliant date string that is represented in Greenwich Mean Time (GMT), e.g. '@date'. Set to '0' to stop the page being cached entirely.", array('@rfc' => 'http://www.csgnetwork.com/timerfc1123calc.html', '@date' => gmdate("D, d M Y H:i:s \G\M\T"))), + 'description' => t("Control when the browser's internal cache of the current page should expire. The date must to be an RFC-1123-compliant date string that is represented in Greenwich Mean Time (GMT), e.g. 'Thu, 01 Sep 2016 00:12:56 GMT'. Set to '0' to stop the page being cached entirely.", array('@rfc' => 'http://www.csgnetwork.com/timerfc1123calc.html')), 'class' => 'DrupalTextMetaTag', 'weight' => ++$weight, 'group' => 'advanced', diff --git a/www7/sites/all/modules/contrib/metatag/metatag.module b/www7/sites/all/modules/contrib/metatag/metatag.module index 3729d7543..8363fb40a 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag.module +++ b/www7/sites/all/modules/contrib/metatag/metatag.module @@ -1,4 +1,5 @@ &$config) { foreach ($config->config as $tag => &$value) { if (isset($value['value']) && is_string($value['value'])) { - $value['value'] = i18n_string_translate(array('metatag', 'metatag_config', $instance, $tag), $value['value'], $options); + $value['value'] = i18n_string_translate(array( + 'metatag', + 'metatag_config', + $instance, + $tag, + ), + $value['value'], + $options); } } } @@ -432,7 +440,7 @@ function metatag_config_cache_clear() { * @param mixed $revision_id * Optional revision ID to load instead of the entity ID. * - * @return + * @return array * An array of tag data keyed by language for the entity's current active * revision. */ @@ -445,7 +453,7 @@ function metatag_metatags_load($entity_type, $entity_id, $revision_id = NULL) { $entities = entity_load($entity_type, array($entity_id)); if (!empty($entities[$entity_id])) { // We only care about the revision_id. - list(, $revision_id, ) = entity_extract_ids($entity_type, $entities[$entity_id]); + list(, $revision_id,) = entity_extract_ids($entity_type, $entities[$entity_id]); } } @@ -470,10 +478,10 @@ function metatag_metatags_load($entity_type, $entity_id, $revision_id = NULL) { * The entity type to load. * @param array $entity_ids * The list of entity IDs. - * @param array $revision_id + * @param array $revision_ids * Optional revision ID to load instead of the entity ID. * - * @return + * @return array * An array of tag data, keyed by entity ID, revision ID and language. */ function metatag_metatags_load_multiple($entity_type, array $entity_ids, array $revision_ids = array()) { @@ -575,9 +583,12 @@ function metatag_metatags_load_multiple($entity_type, array $entity_ids, array $ * 'value' => "[node:field_thumbnail]", * ), * ), - * ); + * );. + * @param string|null $bundle + * The bundle of the entity that is being saved. Optional. */ -function metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags) { + +function metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags, $bundle = NULL) { // Check that $entity_id is numeric because of Entity API and string IDs. if (!is_numeric($entity_id)) { return; @@ -588,17 +599,17 @@ function metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags return; } - // Verify that the entity can be loaded. - $entity = entity_load($entity_type, array($entity_id)); - if (empty($entity)) { - return; + // Verify the entity bundle is supported, if not available just check the + // entity type. + if (!empty($bundle)) { + if (!metatag_entity_supports_metatags($entity_type, $bundle)) { + return; + } } - $entity = reset($entity); - list(, , $bundle) = entity_extract_ids($entity_type, $entity); - - // Don't do anything if the entity bundle is not supported. - if (!metatag_entity_supports_metatags($entity_type, $bundle)) { - return; + else { + if (!metatag_entity_supports_metatags($entity_type)) { + return; + } } // The revision_id must be a numeric value; some entities use NULL for the @@ -672,13 +683,13 @@ function metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags /** * Delete an entity's tags. * - * @param $entity_type - * The entity type - * @param $entity_id - * The entity's ID - * @param $revision_id + * @param string $entity_type + * The entity type. + * @param int $entity_id + * The entity's ID. + * @param int $revision_id * The entity's VID. - * @param $langcode + * @param string $langcode * The language ID of the entry to delete. If left blank, all language * entries for this entity will be deleted. */ @@ -699,11 +710,11 @@ function metatag_metatags_delete($entity_type, $entity_id, $revision_id = NULL, * The list of IDs. * @param array $revision_ids * An optional list of revision IDs; if omitted all revisions will be deleted. - * @param $langcode + * @param string $langcode * The language ID of the entities to delete. If left blank, all language * entries for the enities will be deleted. * - * @return boolean + * @return bool * If any problems were encountered will return FALSE, otherwise TRUE. */ function metatag_metatags_delete_multiple($entity_type, array $entity_ids, array $revision_ids = array(), $langcode = NULL) { @@ -829,7 +840,15 @@ function metatag_entity_load($entities, $entity_type) { } } catch (Exception $e) { - watchdog('metatag', 'Error loading meta tag data, do the database updates need to be run? The error occurred when loading record(s) %ids for the %type entity type. The error message was: %error', array('@update' => base_path() . 'update.php', '%ids' => implode(', ', array_keys($entities)), '%type' => $entity_type, '%error' => $e->getMessage()), WATCHDOG_WARNING); + watchdog('metatag', 'Error loading meta tag data, do the database updates need to be run? The error occurred when loading record(s) %ids for the %type entity type. The error message was: %error', + array( + '@update' => base_path() . 'update.php', + '%ids' => implode(', ', array_keys($entities)), + '%type' => $entity_type, + '%error' => $e->getMessage(), + ), + WATCHDOG_WARNING); + // Don't display the same message twice for Drush. if (drupal_is_cli()) { drupal_set_message(t('Run your updates, like drush updb.')); @@ -882,7 +901,7 @@ function metatag_entity_insert($entity, $entity_type) { return; } - metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags); + metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags, $bundle); } } @@ -943,7 +962,7 @@ function metatag_entity_update($entity, $entity_type) { } // Save the record. - metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags); + metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags, $bundle); } else { // Still ensure the meta tag output is cached. @@ -973,10 +992,8 @@ function metatag_field_attach_delete_revision($entity_type, $entity) { * * @param object $entity * The entity object to generate the metatags instance name for. - * * @param string $entity_type * The entity type of the entity. - * * @param string $bundle * The bundle of the entity. * @@ -1050,8 +1067,9 @@ function metatag_entity_view($entity, $entity_type, $view_mode, $langcode, $forc * TRUE if metatags can be loaded from and saved to the cache. FALSE if the * cache should be bypassed. * - * @return array + * @return mixed * A renderable array of metatags for the given entity. + * If this entity object isn't allowed meta tags, return FALSE (empty). */ function metatag_generate_entity_metatags($entity, $entity_type, $langcode = NULL, $view_mode = 'full', $cached = TRUE) { // Obtain some details of the entity that are needed elsewhere. @@ -1210,7 +1228,6 @@ function metatags_get_entity_metatags($entity_id, $entity_type, $langcode = NULL function metatag_metatags_view($instance, array $metatags = array(), array $options = array()) { $output = array(); - // Convert language codes to a language object. if (isset($options['language']) && is_string($options['language'])) { $languages = language_list(); @@ -1265,7 +1282,7 @@ function metatag_metatags_view($instance, array $metatags = array(), array $opti /** * Get the pager string for the current page. * - * return @string + * @return string * Returns a string based upon the 'metatag_pager_string' variable and the * current page number. */ @@ -1279,6 +1296,9 @@ function metatag_get_current_pager() { } } +/** + * Returns metatags values. + */ function metatag_metatags_values($instance, array $metatags = array(), array $options = array()) { $values = array(); @@ -1441,13 +1461,15 @@ function metatag_metatags_form(array &$form, $instance, array $metatags = array( $group = $info['groups'][$group_key] + array('form' => array(), 'description' => NULL); $form['metatags'][$langcode][$group_key] = $group['form'] + array( '#type' => 'fieldset', - '#title' => t($group['label']), - '#description' => !empty($group['description']) ? t($group['description']) : '', + '#title' => $group['label'], + '#description' => !empty($group['description']) ? $group['description'] : '', '#collapsible' => TRUE, '#collapsed' => TRUE, ); } - $form['metatags'][$langcode][$group_key][$metatag] = $metatag_form + array('#parents' => array('metatags', $langcode, $metatag)); + $form['metatags'][$langcode][$group_key][$metatag] = $metatag_form + array( + '#parents' => array('metatags', $langcode, $metatag), + ); // Hide the fieldset itself if there is not at least one of the meta tag // fields visible. @@ -1551,7 +1573,7 @@ function metatag_metatags_form_submit($form, &$form_state) { /** * Form API submission callback for Commerce product. * - * Unlike metatag_metatags_form_submit + * Unlike metatag_metatags_form_submit. * * @see metatag_metatags_save() */ @@ -1565,8 +1587,11 @@ function metatag_commerce_product_form_submit($form, &$form_state) { $entity_id = $product->product_id; $revision_id = $product->revision_id; + // Get the full entity details. + list(, , $bundle) = entity_extract_ids($entity_type, $product); + // Update the meta tags for this entity type. - metatag_metatags_save($entity_type, $entity_id, $revision_id, $form_state['values']['metatags']); + metatag_metatags_save($entity_type, $entity_id, $revision_id, $form_state['values']['metatags'], $bundle); } /** @@ -1597,7 +1622,7 @@ function metatag_field_extra_fields() { * enabled during installation. If an entity type is enabled it is assumed that * the entity bundles will also be enabled by default. * - * @see metatag_entity_type_is_suitable(). + * @see metatag_entity_type_is_suitable() */ function metatag_entity_supports_metatags($entity_type = NULL, $bundle = NULL) { $entity_types = &drupal_static(__FUNCTION__); @@ -1616,7 +1641,7 @@ function metatag_entity_supports_metatags($entity_type = NULL, $bundle = NULL) { // 'metatag_enable_{$entity_type}' the value FALSE, e.g.: // // // Disable metatags for file_entity. - // $conf['metatag_enable_file'] = FALSE; + // $conf['metatag_enable_file'] = FALSE;. // // @see Settings page. if (variable_get('metatag_enable_' . $entity_name, FALSE) == FALSE) { @@ -1638,7 +1663,7 @@ function metatag_entity_supports_metatags($entity_type = NULL, $bundle = NULL) { // 'metatag_enable_{$entity_type}__{$bundle}' the value FALSE, e.g.: // // // Disable metatags for carousel nodes. - // $conf['metatag_enable_node__carousel'] = FALSE; + // $conf['metatag_enable_node__carousel'] = FALSE;. // // @see Settings page. if (variable_get('metatag_enable_' . $entity_name . '__' . $bundle_name, TRUE) == FALSE) { @@ -1674,30 +1699,51 @@ function metatag_entity_supports_metatags($entity_type = NULL, $bundle = NULL) { } /** - * Enable support for a specific entity type. + * Enable support for a specific entity type if setting does not exist. * * @param string $entity_type + * The entity type. * @param string $bundle + * The bundle of the entity. + * @param bool $force_enable + * If TRUE, then the type is enabled regardless of any stored variables. + * + * @return bool + * TRUE if either the bundle or entity type was enabled by this function. */ -function metatag_entity_type_enable($entity_type, $bundle = NULL) { +function metatag_entity_type_enable($entity_type, $bundle = NULL, $force_enable = FALSE) { // The bundle was defined. + $bundle_set = FALSE; if (isset($bundle)) { - variable_set('metatag_enable_' . $entity_type . '__' . $bundle, TRUE); + $stored_bundle = variable_get('metatag_enable_' . $entity_type . '__' . $bundle, NULL); + if ($force_enable || !isset($stored_bundle)) { + variable_set('metatag_enable_' . $entity_type . '__' . $bundle, TRUE); + $bundle_set = TRUE; + } } // Always enable the entity type, because otherwise there's no point in // enabling the bundle. - variable_set('metatag_enable_' . $entity_type, TRUE); + $entity_type_set = FALSE; + $stored_entity_type = variable_get('metatag_enable_' . $entity_type, NULL); + if ($force_enable || !isset($stored_entity_type)) { + variable_set('metatag_enable_' . $entity_type, TRUE); + $entity_type_set = TRUE; + } // Clear the static cache so that the entity type / bundle will work. drupal_static_reset('metatag_entity_supports_metatags'); + + return $bundle_set || $entity_type_set; } /** * Disable support for a specific entity type. * * @param string $entity_type + * The entity type. * @param string $bundle + * The bundle of the entity. */ function metatag_entity_type_disable($entity_type, $bundle = NULL) { // The bundle was defined. @@ -1744,6 +1790,12 @@ function metatag_page_build(&$page) { return; } + // Special consideration for the Me module, which uses the "user/me" path and + // will cause problems. + if (arg(0) == 'user' && arg(1) == 'me' && function_exists('me_menu_alter')) { + return; + } + // The page region can be changed. $region = variable_get('metatag_page_region', 'content'); @@ -1810,14 +1862,14 @@ function metatag_page_build(&$page) { /** * Returns whether the current page is the page of the passed in entity. * - * @param $entity_type + * @param string $entity_type * The entity type; e.g. 'node' or 'user'. - * @param $entity + * @param object $entity * The entity object. * - * @return + * @return mixed * TRUE if the current page is the page of the specified entity, or FALSE - * otherwise. + * otherwise. If $entity_type == 'comment' return empty (FALSE). */ function _metatag_entity_is_page($entity_type, $entity) { // Exclude comment entities as this conflicts with comment_fragment.module. @@ -1929,8 +1981,7 @@ function metatag_field_attach_form($entity_type, $entity, &$form, &$form_state, $options['context'] = $entity_type; // @todo Remove metatag_form_alter() when https://www.drupal.org/node/1284642 is fixed in core. - //metatag_metatags_form($form, $instance, $metatags, $options); - + // metatag_metatags_form($form, $instance, $metatags, $options); $form['#metatags'] = array( 'instance' => $instance, 'metatags' => $metatags, @@ -1954,7 +2005,7 @@ function metatag_form_alter(&$form, $form_state, $form_id) { /** * Get the meta tag information array of a meta tag. * - * @param $metatag + * @param string $name * The meta tag name, e.g. description, for which the info shall be returned, * or NULL to return an array with info about all meta tags. */ @@ -1968,8 +2019,8 @@ function metatag_get_info($type = NULL, $name = NULL) { global $language; if (!isset($info)) { - // hook_metatag_info() includes translated strings, so each language is cached - // separately. + // hook_metatag_info() includes translated strings, so each language is + // cached separately. $cid = 'info:' . $language->language; if ($cache = metatag_cache_get($cid)) { @@ -2009,6 +2060,9 @@ function metatag_get_info($type = NULL, $name = NULL) { } } +/** + * Return instance of metatag. + */ function metatag_get_instance($metatag, array $data = array()) { $info = metatag_get_info('tags', $metatag); if (!empty($info['class']) && class_exists($info['class'])) { @@ -2020,16 +2074,16 @@ function metatag_get_instance($metatag, array $data = array()) { /** * Return the string value of a meta tag. * - * @param $metatag + * @param string $metatag * The meta tag string. - * @param $data + * @param array $data * The array of data for the meta tag class instance. - * @param $options + * @param array $options * An optional array of additional options to pass to the getValue() method * of the meta tag class instance. * - raw: A boolean if TRUE will not perform token replacement. * - * @return + * @return string * A string value. */ function metatag_get_value($metatag, array $data, array $options = array()) { @@ -2144,7 +2198,7 @@ function metatag_html_head_alter(&$elements) { 'canonical', 'shortlink', // Leave the shortcut icon, that's more of a theming thing. - // 'shortcut icon', + // 'shortcut icon',. ); foreach ($elements as $name => &$element) { // Ignore meta tags provided by Metatag. @@ -2166,11 +2220,17 @@ function metatag_html_head_alter(&$elements) { } } +/** + * Implements hook_get_form(). + */ function metatag_metatag_get_form($metatag, array $data = array(), array $options = array()) { $instance = metatag_get_instance($metatag, $data); return $instance->getForm($options); } +/** + * Returns Instance info if exists otherwise return FALSE. + */ function metatag_config_instance_info($instance = NULL) { global $language; @@ -2231,10 +2291,10 @@ function metatag_filter_values_from_defaults(array &$values, array $defaults = a /** * Return all the parents of a given configuration instance. * - * @param $instance + * @param string $instance * A meta tag configuration instance. * - * @return + * @return array * An array of instances starting with the $instance parameter, with the end * of the array being the global instance. */ @@ -2255,7 +2315,7 @@ function metatag_config_get_parent_instances($instance, $include_global = TRUE) /** * Get the proper label of a configuration instance. * - * @param $instance + * @param string $instance * A meta tag configuration instance. */ function metatag_config_instance_label($instance) { @@ -2344,19 +2404,19 @@ function metatag_config_is_enabled($instance, $include_defaults = FALSE, $includ } /** - * Wrapper around entity_language() to use LANGUAGE_NONE if the entity does not - * have a language assigned. + * Wrapper around entity_language(). * - * @param $entity_type + * @param mixed $entity_type * An entity type's machine name. - * @param $entity + * @param object $entity * The entity to review; will be typecast to an object if an array is passed. * - * @return - * A string indicating the language code to be used. + * @return string + * A string indicating the language code to be used; returns LANGUAGE_NONE if + * the entity does not have a language assigned. */ function metatag_entity_get_language($entity_type, $entity) { - // Determine the entity's language, af + // Determine the entity's language, af. $langcode = entity_language($entity_type, (object) $entity); // If no matching language was found, which will happen for e.g. terms and @@ -2534,7 +2594,6 @@ function _metatag_isdefaultrevision($entity) { // // Every moderation module saving a forward revision needs to return FALSE. // @todo: Refactor this workaround under D8. - // Support for Workbench Moderation v1 - if this is a node, check if the // content type supports moderation. if (function_exists('workbench_moderation_node_type_moderated') && workbench_moderation_node_type_moderated($entity->type) === TRUE) { @@ -2595,7 +2654,7 @@ function metatag_cache_default_cid_parts(array $cid_parts = array()) { /** * Wrapper for cache_set. * - * @see cache_set(). + * @see cache_set() */ function metatag_cache_set($cid, $data) { // Cache the data for later. @@ -2605,7 +2664,7 @@ function metatag_cache_set($cid, $data) { /** * Wrapper for cache_get. * - * @see cache_get(). + * @see cache_get() */ function metatag_cache_get($cid) { // Try to load the object. @@ -2616,6 +2675,7 @@ function metatag_cache_get($cid) { * Determines if we are in an error page and return the appropriate instance. * * @return string + * String of error. */ function metatag_is_error_page() { $known_errors = array( @@ -2651,9 +2711,12 @@ function metatag_admin_menu_cache_info() { * modes, must be fieldable, and may not be a configuration entity. * * @param string $entity_type + * The entity type. * @param array $entity_info + * Entity information. * * @return bool + * Return TRUE if suitable. */ function metatag_entity_type_is_suitable($entity_type, $entity_info = array()) { $suitable = TRUE; @@ -2719,8 +2782,9 @@ function metatag_entity_type_is_suitable($entity_type, $entity_info = array()) { */ function metatag_node_type_insert($info) { if (metatag_entity_supports_metatags('node')) { - metatag_entity_type_enable('node', $info->type); - drupal_set_message(t('Metatag support has been enabled for the @label content type.', array('@label' => $info->name))); + if (metatag_entity_type_enable('node', $info->type)) { + drupal_set_message(t('Metatag support has been enabled for the @label content type.', array('@label' => $info->name))); + } } } @@ -2740,8 +2804,9 @@ function metatag_node_type_delete($info) { */ function metatag_taxonomy_vocabulary_insert($vocabulary) { if (metatag_entity_supports_metatags('taxonomy_term')) { - metatag_entity_type_enable('taxonomy_term', $vocabulary->machine_name); - drupal_set_message(t('Metatag support has been enabled for the @label vocabulary.', array('@label' => $vocabulary->name))); + if (metatag_entity_type_enable('taxonomy_term', $vocabulary->machine_name)) { + drupal_set_message(t('Metatag support has been enabled for the @label vocabulary.', array('@label' => $vocabulary->name))); + } } } @@ -2764,7 +2829,7 @@ function metatag_workbench_moderation_transition($node, $previous_state, $new_st } /** - * sort callback for sorting by metatag instance string values. + * Sort callback for sorting by metatag instance string values. */ function _metatag_config_instance_sort($a, $b) { $a_contexts = explode(':', $a); @@ -3030,6 +3095,8 @@ function metatag_translations_delete($metatags, $context) { } /** + * Implements hook_config_insert(). + * * Implements hook_metatag_config_insert() on behalf of i18n_string. */ function i18n_string_metatag_config_insert($config) { @@ -3038,6 +3105,8 @@ function i18n_string_metatag_config_insert($config) { } /** + * Implements hook_config_update(). + * * Implements hook_metatag_config_update() on behalf of i18n_string. */ function i18n_string_metatag_config_update($config) { @@ -3046,6 +3115,8 @@ function i18n_string_metatag_config_update($config) { } /** + * Implements hook_config_delete(). + * * Implements hook_metatag_config_delete() on behalf of i18n_string. */ function i18n_string_metatag_config_delete($config) { diff --git a/www7/sites/all/modules/contrib/metatag/metatag.search_api.inc b/www7/sites/all/modules/contrib/metatag/metatag.search_api.inc index fce079254..84b3fae6f 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag.search_api.inc +++ b/www7/sites/all/modules/contrib/metatag/metatag.search_api.inc @@ -21,58 +21,60 @@ function metatag_search_api_alter_callback_info() { /** * Adds meta tag values to the indexed items. */ -class MetatagSearchAlterCallback extends SearchApiAbstractAlterCallback { +if (class_exists('SearchApiAbstractAlterCallback')) { + class MetatagSearchAlterCallback extends SearchApiAbstractAlterCallback { - /** - * {@inheritdoc} - */ - public function supportsIndex(SearchApiIndex $index) { - // Only works on entities. - return (bool) $index->getEntityType(); - } + /** + * {@inheritdoc} + */ + public function supportsIndex(SearchApiIndex $index) { + // Only works on entities. + return (bool) $index->getEntityType(); + } - /** - * {@inheritdoc} - */ - public function alterItems(array &$items) { - $entity_type = $this->index->getEntityType(); - $tags = metatag_get_info('tags'); - foreach ($items as $id => $item) { - foreach (array_keys($tags) as $tag) { - $items[$id]->{'metatag_' . $tag} = NULL; - if (isset($item->language) && isset($item->metatags[$item->language][$tag])) { - $instance = metatag_get_instance($tag, $item->metatags[$item->language][$tag]); - $items[$id]->{'metatag_' . $tag} = $instance->getValue(array('token data' => array($entity_type => $item))); + /** + * {@inheritdoc} + */ + public function alterItems(array &$items) { + $entity_type = $this->index->getEntityType(); + $tags = metatag_get_info('tags'); + foreach ($items as $id => $item) { + foreach (array_keys($tags) as $tag) { + $items[$id]->{'metatag_' . $tag} = NULL; + if (isset($item->language) && isset($item->metatags[$item->language][$tag])) { + $instance = metatag_get_instance($tag, $item->metatags[$item->language][$tag]); + $items[$id]->{'metatag_' . $tag} = $instance->getValue(array('token data' => array($entity_type => $item))); + } } } } - } - /** - * {@inheritdoc} - */ - public function propertyInfo() { - $properties = array(); + /** + * {@inheritdoc} + */ + public function propertyInfo() { + $properties = array(); - // Get available meta tags. - $tags = metatag_get_info('tags'); - foreach ($tags as $id => $tag) { - switch ($tag['class']) { - case 'DrupalLinkMetaTag': - $type = 'uri'; - break; - default: - $type = 'text'; - break; + // Get available meta tags. + $tags = metatag_get_info('tags'); + foreach ($tags as $id => $tag) { + switch ($tag['class']) { + case 'DrupalLinkMetaTag': + $type = 'uri'; + break; + default: + $type = 'text'; + break; + } + $properties['metatag_' . $id] = array( + 'label' => t('Meta tag: @label', array('@label' => $tag['label'])), + 'description' => t('@label meta tag attached to an item.', array('@label' => $tag['label'])), + 'type' => $type, + ); } - $properties['metatag_' . $id] = array( - 'label' => t('Meta tag: @label', array('@label' => $tag['label'])), - 'description' => t('@label meta tag attached to an item.', array('@label' => $tag['label'])), - 'type' => $type, - ); + + return $properties; } - return $properties; } - } diff --git a/www7/sites/all/modules/contrib/metatag/metatag.tokens.inc b/www7/sites/all/modules/contrib/metatag/metatag.tokens.inc index 576c93b9b..b4a053e70 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag.tokens.inc +++ b/www7/sites/all/modules/contrib/metatag/metatag.tokens.inc @@ -19,14 +19,14 @@ function metatag_token_info() { foreach ($metatag_info['tags'] as $value) { if (isset($value['group'], $metatag_info['groups'][$value['group']], $metatag_info['groups'][$value['group']]['label'])) { - $label = t($metatag_info['groups'][$value['group']]['label']) . ': ' . t($value['label']); + $label = $metatag_info['groups'][$value['group']]['label'] . ': ' . $value['label']; } else { - $label = t('Basic tags') . ': ' . t($value['label']); + $label = t('Basic tags') . ': ' . $value['label']; } $info['tokens']['metatag'][$value['name']] = array( 'name' => $label, - 'description' => t($value['description']), + 'description' => $value['description'], ); } @@ -77,7 +77,7 @@ function metatag_tokens($type, $tokens, array $data = array(), array $options = if ($type == 'metatag' && !empty($data['metatag'])) { $metatag = $data['metatag']; foreach ($tokens as $name => $original) { - if(isset($metatag[$name])){ + if (isset($metatag[$name])) { $replacements[$original] = $sanitize ? filter_xss($metatag[$name]) : $metatag[$name]; } } diff --git a/www7/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info b/www7/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info index 12a2f3f8c..8fbf5bc30 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info @@ -6,10 +6,11 @@ dependencies[] = metatag ; Tests. files[] = tests/metatag_app_links.test +files[] = tests/metatag_app_links.tags.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.tags.test new file mode 100644 index 000000000..87ab2e8bf --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.tags.test @@ -0,0 +1,58 @@ + 'Metatag tags: App Links', + 'description' => 'Test the App Links meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'al:android:app_name', + 'al:android:class', + 'al:android:package', + 'al:android:url', + 'al:ios:app_name', + 'al:ios:app_store_id', + 'al:ios:url', + 'al:ipad:app_name', + 'al:ipad:app_store_id', + 'al:ipad:url', + 'al:iphone:app_name', + 'al:iphone:app_store_id', + 'al:iphone:url', + 'al:web:should_fallback', + 'al:web:url', + 'al:windows:app_id', + 'al:windows:app_name', + 'al:windows:url', + 'al:windows_phone:app_id', + 'al:windows_phone:app_name', + 'al:windows_phone:url', + 'al:windows_universal:app_id', + 'al:windows_universal:app_name', + 'al:windows_universal:url', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_app_links'; + parent::setUp($modules); + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_context/metatag_context.info b/www7/sites/all/modules/contrib/metatag/metatag_context/metatag_context.info index f02e563c5..47563add7 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_context/metatag_context.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_context/metatag_context.info @@ -12,9 +12,9 @@ dependencies[] = context files[] = tests/metatag_context.test files[] = tests/metatag_context.i18n.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context.i18n.test b/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context.i18n.test index 9aa890e23..e909cc4b1 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context.i18n.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context.i18n.test @@ -13,6 +13,7 @@ class MetatagContextI18nTest extends MetatagTestHelper { 'name' => 'Metatag:Context tests, with i18n', 'description' => 'Test Metatag integration with the Context and i18n modules.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'context', 'i18n'), ); } @@ -34,6 +35,9 @@ class MetatagContextI18nTest extends MetatagTestHelper { // Enable all of the modules that are needed. parent::setUp($modules); + // Add more locales. + $this->setupLocales(); + // Set up the locales. $perms = array( 'translate admin strings', @@ -45,7 +49,9 @@ class MetatagContextI18nTest extends MetatagTestHelper { ); // This replaces the one from MetatagContextTest(). $this->adminUser = $this->createAdminUser($perms); - $this->setupLocales(); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); // Reload the translations. drupal_flush_all_caches(); diff --git a/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context.test b/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context.test index 1b2f3dd45..57751319d 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context.test @@ -16,6 +16,7 @@ class MetatagContextTest extends MetatagTestHelper { 'name' => 'Metatag:Context tests', 'description' => 'Test basic Metatag:Context functionality.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'context'), ); } @@ -36,6 +37,8 @@ class MetatagContextTest extends MetatagTestHelper { 'bypass node access', ); $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. $this->drupalLogin($this->adminUser); // Create a content type, with underscores. diff --git a/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.info b/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.info index 9e86f3f4a..ead362012 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.info @@ -9,9 +9,9 @@ dependencies[] = context dependencies[] = metatag dependencies[] = metatag_context -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.info b/www7/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.info index 0b0a97cc9..314f635c0 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.info @@ -6,10 +6,11 @@ dependencies[] = metatag ; Tests. files[] = tests/metatag_dc.test +files[] = tests/metatag_dc.tags.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_dc/tests/metatag_dc.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_dc/tests/metatag_dc.tags.test new file mode 100644 index 000000000..e585dd48e --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_dc/tests/metatag_dc.tags.test @@ -0,0 +1,70 @@ + 'Metatag tags: Dublin Core', + 'description' => 'Test the Dublin Core meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'dcterms.contributor', + 'dcterms.coverage', + 'dcterms.creator', + 'dcterms.date', + 'dcterms.description', + 'dcterms.format', + 'dcterms.identifier', + 'dcterms.language', + 'dcterms.publisher', + 'dcterms.relation', + 'dcterms.rights', + 'dcterms.source', + 'dcterms.subject', + 'dcterms.title', + 'dcterms.type', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_dc'; + parent::setUp($modules); + } + + /** + * Implements {meta_tag_name}_test_key() for 'dcterms.type'. + */ + public function dcterms_type_test_key() { + return 'metatags[und][dcterms.type][value]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'dcterms.type'. + */ + public function dcterms_type_test_value() { + return 'Text'; + } + + /** + * Implements {meta_tag_name}_test_xpath() for 'dcterms.type'. + */ + public function dcterms_type_test_xpath() { + return "//select[@name='metatags[und][dcterms.type][value]']"; + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.info b/www7/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.info index 9d3440939..de2a360b1 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.info @@ -7,10 +7,11 @@ dependencies[] = metatag_dc ; Tests. files[] = tests/metatag_dc_advanced.test +files[] = tests/metatag_dc_advanced.tags.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_dc_advanced/tests/metatag_dc_advanced.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_dc_advanced/tests/metatag_dc_advanced.tags.test new file mode 100644 index 000000000..7c4f12b37 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_dc_advanced/tests/metatag_dc_advanced.tags.test @@ -0,0 +1,74 @@ + 'Metatag tags: Dublin Core Advanced', + 'description' => 'Test the Advanced Dublin Core meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'dcterms.abstract', + 'dcterms.accessRights', + 'dcterms.accrualMethod', + 'dcterms.accrualPeriodicity', + 'dcterms.accrualPolicy', + 'dcterms.alternative', + 'dcterms.audience', + 'dcterms.available', + 'dcterms.bibliographicCitation', + 'dcterms.conformsTo', + 'dcterms.created', + 'dcterms.dateAccepted', + 'dcterms.dateCopyrighted', + 'dcterms.dateSubmitted', + 'dcterms.educationLevel', + 'dcterms.extent', + 'dcterms.hasFormat', + 'dcterms.hasPart', + 'dcterms.hasVersion', + 'dcterms.instructionalMethod', + 'dcterms.isFormatOf', + 'dcterms.isPartOf', + 'dcterms.isReferencedBy', + 'dcterms.isReplacedBy', + 'dcterms.isRequiredBy', + 'dcterms.isVersionOf', + 'dcterms.issued', + 'dcterms.license', + 'dcterms.mediator', + 'dcterms.medium', + 'dcterms.modified', + 'dcterms.provenance', + 'dcterms.references', + 'dcterms.replaces', + 'dcterms.requires', + 'dcterms.rightsHolder', + 'dcterms.spatial', + 'dcterms.tableOfContents', + 'dcterms.temporal', + 'dcterms.valid', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_dc_advanced'; + parent::setUp($modules); + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.info b/www7/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.info index c8bee4ef2..3f53acce9 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.info @@ -8,9 +8,9 @@ dependencies[] = metatag ; Tests. files[] = tests/metatag_devel.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.info b/www7/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.info index a0a9cb31a..6915c2b1f 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.info @@ -6,10 +6,11 @@ dependencies[] = metatag ; Tests. files[] = tests/metatag_facebook.test +files[] = tests/metatag_facebook.tags.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_facebook/tests/metatag_facebook.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_facebook/tests/metatag_facebook.tags.test new file mode 100644 index 000000000..91315f503 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_facebook/tests/metatag_facebook.tags.test @@ -0,0 +1,37 @@ + 'Metatag tags: Facebook', + 'description' => 'Test the Facebook meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'fb:admins', + 'fb:app_id', + 'fb:pages', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_facebook'; + parent::setUp($modules); + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.info b/www7/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.info index 406d386f9..f000dcd62 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.info @@ -9,10 +9,11 @@ files[] = metatag_favicons.mask-icon.class.inc ; Tests. files[] = tests/metatag_favicons.test +files[] = tests/metatag_favicons.tags.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.tags.test new file mode 100644 index 000000000..b56073f4f --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.tags.test @@ -0,0 +1,56 @@ + 'Metatag tags: Favicons', + 'description' => 'Test the Favicons meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'apple-touch-icon', + 'apple-touch-icon-precomposed', + 'apple-touch-icon-precomposed_114x114', + 'apple-touch-icon-precomposed_120x120', + 'apple-touch-icon-precomposed_144x144', + 'apple-touch-icon-precomposed_152x152', + 'apple-touch-icon-precomposed_180x180', + 'apple-touch-icon-precomposed_72x72', + 'apple-touch-icon-precomposed_76x76', + 'apple-touch-icon_114x114', + 'apple-touch-icon_120x120', + 'apple-touch-icon_144x144', + 'apple-touch-icon_152x152', + 'apple-touch-icon_180x180', + 'apple-touch-icon_72x72', + 'apple-touch-icon_76x76', + 'icon_16x16', + 'icon_192x192', + 'icon_32x32', + 'icon_96x96', + 'mask-icon', + 'shortcut icon', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_favicons'; + parent::setUp($modules); + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_cse/README.txt b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/README.txt new file mode 100644 index 000000000..4884d60fe --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/README.txt @@ -0,0 +1,22 @@ +Metatag: Google Custom Search Engine (CSE) +------------------------------------------ +This module adds certain meta tags that are primarily used by Google's Custom +Search Engine aka "CSE". + +The following meta tags are provided: +* thumbnail +* department +* audience +* doc_status +* rating + + +Credits +------------------------------------------------------------------------------ +The initial development was by Carlos E Basqueira [3]. + + +References +------------------------------------------------------------------------------ +1: http://www.dublincore.org/documents/dces/ +2: https://www.drupal.org/u/cebasqueira diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.info b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.info new file mode 100644 index 000000000..af53315b3 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.info @@ -0,0 +1,16 @@ +name = "Metatag: Google CSE - Custom Search Engine" +description = "Provides support for meta tags used for Google Custom Search Engine." +package = SEO +core = 7.x +dependencies[] = metatag + +; Tests. +files[] = tests/metatag_google_cse.test +files[] = tests/metatag_google_cse.tags.test + +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" +core = "7.x" +project = "metatag" +datestamp = "1480524802" + diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.install b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.install new file mode 100644 index 000000000..d30cebce7 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.install @@ -0,0 +1,5 @@ + t('Google Custom Search Engine (CSE)'), + 'description' => t("Meta tags used to control the mobile browser experience. Some of these meta tags have been replaced by newer mobile browsers. These meta tags usually only need to be set globally, rather than per-page."), + 'form' => array( + '#weight' => 80, + ), + ); + + $weight = 80; + + // Default values for each meta tag. + $tag_info_defaults = array( + 'class' => 'DrupalTextMetaTag', + 'group' => 'google_cse', + 'element' => array( + '#theme' => 'metatag_google_cse', + ), + ); + + $info['tags']['thumbnail'] = array( + 'label' => t('Thumbnail'), + 'description' => t('Use a url of a valid image.'), + 'weight' => ++$weight, + ) + $tag_info_defaults; + + $info['tags']['department'] = array( + 'label' => t('Department'), + 'description' => t('Department tag.'), + 'weight' => ++$weight, + ) + $tag_info_defaults; + + $info['tags']['audience'] = array( + 'label' => t('Content audience'), + 'description' => t('The conten audience, for example: all'), + 'weight' => ++$weight, + ) + $tag_info_defaults; + + $info['tags']['doc_status'] = array( + 'label' => t('Document status'), + 'description' => t('The Document status, for example: draft.'), + 'weight' => ++$weight, + ) + $tag_info_defaults; + + $info['tags']['google_rating'] = array( + 'label' => t('Results sorting'), + 'description' => t('Works only with numeric values'), + 'weight' => ++$weight, + ) + $tag_info_defaults; + + return $info; +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.module b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.module new file mode 100644 index 000000000..c68e936e8 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.module @@ -0,0 +1,47 @@ + 1); + } +} + +/** + * Implements hook_theme(). + */ +function metatag_google_cse_theme() { + $info['metatag_google_cse'] = array( + 'render element' => 'element', + ); + + return $info; +} + +/** + * Theme callback for a normal meta tag. + * + * The format is: + * + */ +function theme_metatag_google_cse($variables) { + $element = &$variables['element']; + + if ($element['#name'] === 'google_rating') { + $element['#name'] = 'rating'; + } + + $args = array( + '#name' => 'name', + '#value' => 'content', + ); + element_set_attributes($element, $args); + unset($element['#value']); + return theme('html_tag', $variables); +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.tags.test new file mode 100644 index 000000000..ed1883f52 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.tags.test @@ -0,0 +1,42 @@ + 'Metatag Google CSE tests', + 'description' => 'Test the Metatag:Google CSE module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'thumbnail', + 'department', + 'audience', + 'doc_status', + 'google_rating', + ); + + /** + * {@inheritdoc} + */ + public function setUp(array $modules = array()) { + $modules[] = 'metatag_google_cse'; + parent::setUp($modules); + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.test b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.test new file mode 100644 index 000000000..890d4ef67 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.test @@ -0,0 +1,47 @@ + 'Metatag Google CSE tests', + 'description' => 'Test the Metatag:Google CSE module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public function setUp(array $modules = array()) { + $modules[] = 'metatag_google_cse'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info index 0bdca073c..88e9e4145 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info @@ -9,10 +9,11 @@ files[] = metatag_google_plus.inc ; Tests. files[] = tests/metatag_google_plus.test +files[] = tests/metatag_google_plus.tags.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.metatag.inc b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.metatag.inc index be9183aca..6e46b2e1a 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.metatag.inc +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.metatag.inc @@ -120,7 +120,7 @@ function metatag_google_plus_metatag_info() { ) + $defaults; $info['tags']['itemprop:image'] = array( 'label' => t('Image URL'), - 'description' => t('The URL to a unique image representing the content of the page. Do not use a generic image such as your website logo, author photo, or other image that spans multiple pages. '), + 'description' => t('The URL to a unique image representing the content of the page. Do not use a generic image such as your website logo, author photo, or other image that spans multiple pages.'), 'weight' => ++$weight, 'image' => TRUE, 'devel_generate' => array( @@ -128,5 +128,25 @@ function metatag_google_plus_metatag_info() { ), ) + $defaults; + $info['tags']['author'] = array( + 'label' => t('Author URL'), + 'description' => t("Used by some search engines to confirm authorship of the content on a page. Should be either the full URL for the author's Google+ profile page or a local page with information about the author."), + 'class' => 'DrupalLinkMetaTag', + 'weight' => ++$weight, + 'devel_generate' => array( + 'type' => 'url', + ), + ) + $defaults; + $info['tags']['publisher'] = array( + 'label' => t('Publisher URL'), + 'description' => t("Used by some search engines to confirm publication of the content on a page. Should be the full URL for the publication's Google+ profile page."), + 'class' => 'DrupalLinkMetaTag', + 'weight' => ++$weight, + 'devel_generate' => array( + 'type' => 'url', + ), + ) + $defaults; + + return $info; } diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.tags.test new file mode 100644 index 000000000..43ff023c4 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.tags.test @@ -0,0 +1,61 @@ + 'Metatag tags: GooglePlus', + 'description' => 'Test the Google Plus meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'itemtype', + 'itemprop:name', + 'itemprop:description', + 'itemprop:image', + 'author', + 'publisher', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_google_plus'; + parent::setUp($modules); + } + + /** + * Implements {meta_tag_name}_test_key() for 'itemtype'. + */ + public function itemtype_test_key() { + return 'metatags[und][itemtype][value]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'itemtype'. + */ + public function itemtype_test_value() { + return 'Article'; + } + + /** + * Implements {meta_tag_name}_test_xpath() for 'itemtype'. + */ + public function itemtype_test_xpath() { + return "//select[@name='metatags[und][itemtype][value]']"; + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.info b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.info index a74e10b1f..f32cbb734 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.info @@ -10,11 +10,16 @@ dependencies[] = locale ; Tests. files[] = tests/metatag_hreflang.test -files[] = metatag_hreflang.with_entity_translation.test +files[] = tests/metatag_hreflang.tags.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Entity Translation integration. +test_dependencies[] = devel +test_dependencies[] = entity_translation +files[] = tests/metatag_hreflang.with_entity_translation.test + +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.install b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.install index 73629ffb9..0a25f3a72 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.install +++ b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.install @@ -34,3 +34,37 @@ function metatag_hreflang_uninstall() { // Delete any custom variables that are used. variable_del('metatag_hreflang_allow_dupe'); } + +/** + * Implementations of hook_update_N(). + */ + +/** + * Clear the Metatag cache so the updated hreflang default is caught. + */ +function metatag_hreflang_update_7101() { + cache_clear_all('*', 'cache_metatag', TRUE); + return t('All Metatag caches cleared.'); +} + +/** + * Fix hreflang=xdefault for config definitions. + */ +function metatag_hreflang_update_7102() { + module_load_include('install', 'metatag'); + $meta_tag = 'hreflang_xdefault'; + $old_value = '[node:source:url]'; + $new_value = '[node:url-original]'; + return metatag_update_replace_config_value($meta_tag, $old_value, $new_value); +} + +/** + * Fix hreflang=xdefault for all entities. + */ +function metatag_hreflang_update_7103() { + module_load_include('install', 'metatag'); + $meta_tag = 'hreflang_xdefault'; + $old_value = '[node:source:url]'; + $new_value = '[node:url-original]'; + return metatag_update_replace_entity_value($sandbox, $meta_tag, $old_value, $new_value); +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.metatag.inc b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.metatag.inc index 47f6c786d..7def3be86 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.metatag.inc +++ b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.metatag.inc @@ -21,7 +21,7 @@ function metatag_hreflang_metatag_bundled_config_alter(array &$configs) { case 'node': // The x-default should default to the source language. $config->config += array( - 'hreflang_xdefault' => array('value' => '[node:source:url]'), + 'hreflang_xdefault' => array('value' => '[node:url-original]'), ); // Add all of the other hreflang values. diff --git a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.module b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.module index b550e3ff2..6465c4357 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.module +++ b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.module @@ -4,6 +4,9 @@ * Primary hook implementations for Metatag:hreflang. */ +// @todo Clear caches for all versions of an entity when a translation is edited +// so that the hreflang meta tags update appropriately. + /** * Implements hook_ctools_plugin_api(). */ @@ -34,8 +37,8 @@ function theme_metatag_link_hreflang($variables) { $element['#name'] = 'alternate'; $args = array( '#name' => 'rel', - '#value' => 'href', '#hreflang' => 'hreflang', + '#value' => 'href', ); element_set_attributes($element, $args); unset($element['#value']); @@ -55,25 +58,26 @@ function metatag_hreflang_form_metatag_admin_settings_form_alter(&$form, &$form_ } /** - * Implements hook_html_head_alter(). + * Implements hook_metatag_metatags_view_alter(). * - * Remove any hreflang="LANGCODE" values that match hreflang="x-default". + * Remove any hreflang="LANGCODE" values that match hreflang="x-default". Using + * this hook instead of hook_html_head_alter() as it gets closer to Metatag's + * data structures, and the results are cached so this won't be executed on + * every page request. */ -function metatag_hreflang_html_head_alter(&$elements) { +function metatag_hreflang_metatag_metatags_view_alter(&$output, $instance, $options) { // This behaviour may be disabled from the Metatag settings page. if (!variable_get('metatag_hreflang_allow_dupe', FALSE)) { - if (!empty($elements['metatag_hreflang_xdefault']['#value'])) { - $default = $elements['metatag_hreflang_xdefault']['#value']; - - // Look for other hreflang meta tags. - foreach ($elements as $tag_name => &$element) { + if (!empty($output['hreflang_xdefault'])) { + $default = $output['hreflang_xdefault']['#attached']['drupal_add_html_head'][0][0]['#value']; + foreach ($output as $tag_name => &$tag) { // Skip the x-default tag. - if ($tag_name == 'metatag_hreflang_xdefault') { + if ($tag_name == 'hreflang_xdefault') { continue; } - if (strpos($tag_name, 'metatag_hreflang_') === 0) { - if ($element['#value'] == $default) { - $element['#access'] = FALSE; + if (strpos($tag_name, 'hreflang_') === 0) { + if ($tag['#attached']['drupal_add_html_head'][0][0]['#value'] == $default) { + $tag['#attached']['drupal_add_html_head'][0][0]['#access'] = FALSE; } } } diff --git a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.tokens.inc b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.tokens.inc index c57ee9923..a7a84e605 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.tokens.inc +++ b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.tokens.inc @@ -14,6 +14,13 @@ function metatag_hreflang_token_info() { return; } + // Don't do anything if the patch was applied to Entity Translation to add + // these. + // @see https://www.drupal.org/node/2603056 + if (module_load_include('tokens.inc', 'entity_translation')) { + return; + } + $info = array(); $languages = language_list('enabled'); @@ -30,6 +37,11 @@ function metatag_hreflang_token_info() { } } + $info['tokens']['node']['url-original'] = array( + 'name' => t('URL (original language)'), + 'description' => t("The URL for the node that is the original source for the current node's translation."), + ); + return $info; } @@ -51,6 +63,17 @@ function metatag_hreflang_tokens($type, $tokens, array $data = array(), array $o $languages = language_list('enabled'); if (!empty($languages[1]) && is_array($languages[1]) && count($languages[1]) > 1) { foreach ($tokens as $name => $original) { + // The original entity's URL. + if ($name == 'url-original') { + if (isset($node->translations->original, $languages[1][$node->translations->original])) { + $url_options = $options; + $url_options['language'] = $languages[1][$node->translations->original]; + $url_options['absolute'] = TRUE; + $replacements[$original] = url('node/' . $node->nid, $url_options); + } + } + + // Separate URLs for each translation. foreach ($node->translations->data as $langcode => $translation) { if ($name == 'url-' . $langcode) { $url_options = $options; diff --git a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.tags.test new file mode 100644 index 000000000..7c9e3ca87 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.tags.test @@ -0,0 +1,79 @@ + 'Metatag tags: Hreflang', + 'description' => 'Test the Hreflang meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'hreflang_xdefault', + // Additional meta tags added at the end of setUp(). + // @see setUp() + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_hreflang'; + parent::setUp($modules); + + // Create an admin user that can also manage locales. + $perms = array( + // For Locale, so languages can be added. + 'administer languages', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Add some new languages. + foreach ($this->supportedLocales() as $langcode) { + if ($langcode != 'en') { + $this->addSiteLanguage($langcode); + } + } + + // Clear all the caches so that all of the various hooks are activated and + // the appropriate tokens, fields, meta tags, etc are available. + drupal_flush_all_caches(); + + // Additional meta tags that will be available. + foreach ($this->supportedLocales() as $langcode) { + $this->tags[] = 'hreflang_' . $langcode; + } + } + + /** + * The list of locales that are being tested. + * + * @return array + * A simple list of language codes. + */ + private function supportedLocales() { + return array( + 'de', + 'fr', + 'es', + // English is automatic, so remember to not try enabling it. + 'en', + ); + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.with_entity_translation.test b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.with_entity_translation.test index 9615bd8ae..c0532fc23 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.with_entity_translation.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.with_entity_translation.test @@ -14,6 +14,7 @@ class MetatagHreflangWithEntityTranslationTest extends MetatagTestHelper { 'name' => 'Metatag tests for hreflang with Entity Translation', 'description' => 'Test Metatag:hreflang with the Entity Translation module.', 'group' => 'Metatag', + 'dependencies' => array('devel', 'entity_translation'), ); } @@ -21,13 +22,258 @@ class MetatagHreflangWithEntityTranslationTest extends MetatagTestHelper { * {@inheritdoc} */ function setUp(array $modules = array()) { + // Used for debugging some token values. + $modules[] = 'devel'; + // Need Locale for the multiple languages. $modules[] = 'locale'; + // Need Entity Translation for the tokens to work. + $modules[] = 'entity_translation'; + + // This module. $modules[] = 'metatag_hreflang'; + // Enable all of the modules & install the site. parent::setUp($modules); + + // Add some new languages. + $this->setupLocales($this->supportedLocales()); + + // The content that will be used. + $content_type = 'page'; + + // Create an admin user that can also manage locales. + $perms = array( + // For Locale, so languages can be added. + 'administer languages', + + // For Entity Translation, so content can be translated. + 'translate any entity', + + // For Devel, for access to the node's "devel" tab. + 'access devel information', + + // For Field UI, so field settings can be changed. + 'administer fields', + + // For Node, so content type settings can be changed. + 'administer content types', + + // For Node, so content can be created and edited. + 'create ' . $content_type . ' content', + 'edit any ' . $content_type . ' content', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Enable translation support for the content type. + variable_set('language_content_type_' . $content_type, ENTITY_TRANSLATION_ENABLED); + + // Allow the body field to be translated. + $this->drupalGet('admin/structure/types/manage/' . $content_type . '/fields/body'); + $this->assertResponse(200); + $this->assertFieldByName('field[translatable]'); + $edit = array( + 'field[translatable]' => TRUE, + ); + $this->drupalPost(NULL, $edit, t('Save settings')); + + // Clear all the caches so that all of the various hooks are activated and + // the appropriate tokens, fields, meta tags, etc are available. + drupal_flush_all_caches(); + } + + /** + * The list of locales that are being tested. + * + * @return array + * A simple list of language codes. + */ + private function supportedLocales() { + return array( + 'de', + 'fr', + 'es', + 'en', + ); + } + + /** + * Assert that the appropriate hreflang meta tag fields are present. + * + * @param string $form_langcode + * The langcode of the current form. Defaults to LANGUAGE_NONE, which is + * what is used on an empty node/add form. + */ + private function assertHreflangFields($form_langcode = LANGUAGE_NONE) { + // The x-default field has a specific default. + $this->assertFieldByName("metatags[{$form_langcode}][hreflang_xdefault][value]", "[node:url-original]", 'Found the hreflang=x-default meta tag and it has the correct default value.'); + + // Confirm each of the support locales has its own field and the appropriate + // default value. + foreach ($this->supportedLocales() as $langcode) { + $this->assertFieldByName("metatags[{$form_langcode}][hreflang_{$langcode}][value]", "[node:url-{$langcode}]", format_string('Found the hreflang field for the "%lang" locale and it has the correct default value.', array('%lang' => $langcode))); + } + } + + /** + * Confirm that each locale has a field added and shows the appropriate + * default value. + */ + function testFormFields() { + $this->drupalGet('node/add/page'); + $this->assertResponse(200); + + // Confirm the fields exist. + $this->assertHreflangFields(); + } + + /** + * Confirm that the meta tags output are correct. + */ + function testOutput() { + // All of the locales we're supporting in these tests. The languages have + // been enabled already, so this gets a list of language objects. + $languages = language_list('enabled'); + $locales = $languages[1]; + + // Identify the site's default language. + $default_language = language_default('language'); + + // Create an English node so it can be translated. + $args = array( + 'language' => $default_language, + ); + $node = $this->drupalCreateNode($args); + $this->verbose($node); + + // Load the translation page. + $this->drupalGet('node/' . $node->nid . '/translate'); + $this->assertResponse(200); + $this->assertText(t('Not translated')); + + // Confirm that there are links to translate the node. + $urls = array(); + foreach ($locales as $langcode => $locale) { + // There won't be a link to translate to English, that's the default + // language for thos node. + if ($langcode == $default_language) { + continue; + } + + // Confirm that a link to translate the node into each locale exists. + $url = 'node/' . $node->nid . '/edit/add/' . $node->language . '/' . $langcode; + $urls[$langcode] = $url; + // @todo This fails in testbot. + // $this->assertLinkbyHref(url($url)); + } + + // Check each of the 'translate' pages loads properly. + foreach ($urls as $langcode => $url) { + // Confirm the 'translate' page loads. + $this->drupalGet($url); + $this->assertResponse(200); + + // Confirm all of the hreflang fields exist. + $this->assertHreflangFields($langcode); + + // Save the translation. + $edit = array( + // Add a custom title. + "metatags[{$langcode}][title][value]" => "Tranlation for {$langcode}", + ); + $this->drupalPost(NULL, $edit, t('Save')); + } + + // Load the translation page again to confirm everything was translated. + $this->drupalGet('node/' . $node->nid . '/translate'); + $this->assertResponse(200); + $this->assertNoText(t('Not translated')); + + // Load the node's devel page to see the translations data. + $this->drupalGet('node/' . $node->nid . '/devel'); + $this->assertResponse(200); + + // Load the node's devel page and confirm each of the tokens is available. + $this->drupalGet('node/' . $node->nid . '/devel/token'); + $this->assertResponse(200); + foreach ($locales as $langcode => $locale) { + $this->assertText("[node:url-{$langcode}]"); + } + + // Load the node page again, confirm each hreflang meta tag. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200); + $xpath = $this->xpath("//link[@rel='alternate']"); + $this->verbose($xpath); + $this->assertEqual(count($xpath), count($locales), 'The correct number of hreflang meta tags was found'); + + // Try to find the position of the xdefault value in the $xpath structure. + $xdefault_pos = NULL; + // This is slightly messy logic as the sort order of $locales may be + // different to the meta tags. + foreach ($locales as $langcode => $locale) { + $found = FALSE; + foreach ($xpath as $ctr => $item) { + if ($item['hreflang'] == 'x-default') { + $xdefault_pos = $ctr; + } + elseif ($item['hreflang'] == $langcode) { + $found = TRUE; + $this->assertEqual($xpath[$ctr]['hreflang'], $langcode); + // @todo Fix this. Not sure why, but the url() call returns the URL + // without the language prefix. + // $url_options = array( + // 'language' => $locale, + // 'absolute' => TRUE, + // ); + // $this->assertEqual($xpath[$ctr]['href'], url('node/' . $node->nid, $url_options)); + } + } + + // The node's default language should not have been found, it should have + // been turned into an xdefault. + if ($langcode == $node->language) { + $this->assertFalse((bool)$found, format_string("A regular hreflang meta tag for the node's default language (%lang) was not found.", array('%lang' => $langcode))); + } + + // Translations should have been found. + else { + $this->assertTrue((bool)$found, format_string('The hreflang meta tag for %lang was found.', array('%lang' => $langcode))); + } + } + + // Confirm the hreflang=xdefault meta tag was found. + $this->assertNotNull($xdefault_pos, 'The hreflang=xdefault meta tag was found.'); + if (!is_null($xdefault_pos)) { + $this->assertEqual($xpath[$xdefault_pos]['href'], url('node/' . $node->nid, array('absolute' => TRUE)), 'Found the x-default value.'); + } + + // Enable the xdefault-dupe option. + variable_set('metatag_hreflang_allow_dupe', TRUE); + metatag_config_cache_clear(); + + // Load the node page again. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200); + + // Confirm there are now more meta tags. + $xpath = $this->xpath("//link[@rel='alternate']"); + $this->verbose($xpath); + $this->assertEqual(count($xpath), count($locales) + 1, 'The correct number of hreflang meta tags was found.'); + $found = FALSE; + foreach ($xpath as $ctr => $item) { + if ($item['hreflang'] == $node->language) { + $found = $ctr; + } + } + $this->assertTrue((bool)$found, "Found an hreflang meta tag for the node's default locale."); + if ($found) { + $this->assertEqual($xpath[$found]['hreflang'], $node->language); + } } - // @todo Make sure the hreflang meta tag is added for each enabled language. } diff --git a/www7/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.info b/www7/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.info index 73111b25c..5f4daf40d 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.info @@ -9,9 +9,9 @@ dependencies[] = metatag ; Tests. files[] = tests/metatag_importer.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.page_title.inc b/www7/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.page_title.inc index 79c2b59c1..5bc28425c 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.page_title.inc +++ b/www7/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.page_title.inc @@ -2,7 +2,7 @@ /** * @file * Functionality for migrating data from the Page Title module. - */ + */ /** * FormAPI callback for the Page Title importer. @@ -70,7 +70,7 @@ function metatag_importer_for_page_title() { if (!empty($metatag_config_node_type) && isset($metatag_config_node_type->config['title'])) { $title_setting = $metatag_config_node_type->config['title']['value']; } - else if (isset($metatag_config_node->config['title'])) { + elseif (isset($metatag_config_node->config['title'])) { $title_setting = $metatag_config_node->config['title']['value']; } else { diff --git a/www7/sites/all/modules/contrib/metatag/metatag_mobile/README.txt b/www7/sites/all/modules/contrib/metatag/metatag_mobile/README.txt index 742706a0f..1735a66d8 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_mobile/README.txt +++ b/www7/sites/all/modules/contrib/metatag/metatag_mobile/README.txt @@ -9,6 +9,7 @@ Mobile: + iOS: diff --git a/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info b/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info index 6ca2f896d..d4d9c7dfe 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info @@ -6,10 +6,11 @@ dependencies[] = metatag ; Tests. files[] = tests/metatag_mobile.test +files[] = tests/metatag_mobile.tags.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.metatag.inc b/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.metatag.inc index 9df7b9b8f..5eed54996 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.metatag.inc +++ b/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.metatag.inc @@ -40,7 +40,7 @@ function metatag_mobile_metatag_info() { $weight = 80; // Default values for each meta tag. - $tag_info_defaults = array( + $defaults = array( 'description' => '', 'class' => 'DrupalTextMetaTag', 'group' => 'mobile', @@ -50,27 +50,27 @@ function metatag_mobile_metatag_info() { 'label' => t('Theme Color'), 'description' => t('A color in hexidecimal format, e.g. "#0000ff" for blue; must include the "#" symbol. Used by some browsers to control the background color of the toolbar, the color used with an icon, etc.'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['MobileOptimized'] = array( 'label' => t('Mobile Optimized'), 'description' => t('Using the value "width" tells certain mobile Internet Explorer browsers to display as-is, without being resized. Alternatively a numerical width may be used to indicate the desired page width the page should be rendered in: "240" is the suggested default, "176" for older browsers or "480" for newer devices with high DPI screens.'), 'weight' => ++$weight, 'multiple' => TRUE, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['HandheldFriendly'] = array( 'label' => t('Handheld-Friendly'), 'description' => t('Some older mobile browsers will expect this meta tag to be set to "true" to indicate that the site has been designed with mobile browsers in mind.'), 'weight' => ++$weight, 'multiple' => TRUE, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['viewport'] = array( 'label' => t('Viewport'), 'description' => t('Used by most contemporary browsers to control the display for mobile browsers. Please read a guide on responsive web design for details of what values to use.'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['cleartype'] = array( 'label' => t('Cleartype'), @@ -79,10 +79,29 @@ function metatag_mobile_metatag_info() { 'element' => array( '#theme' => 'metatag_http_equiv', ), - ) + $tag_info_defaults; + ) + $defaults; + + $info['tags']['amphtml'] = array( + 'label' => t('AMP URL'), + 'description' => t('Provides an absolute URL to an AMP-formatted version of the current page. See the official AMP specifications for details on how the page should be formatted.', array('@url' => 'https://www.ampproject.org/')), + 'class' => 'DrupalLinkMetaTag', + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['alternate_handheld'] = array( + 'label' => t('Handheld URL'), + 'description' => t('Provides an absolute URL to a specially formatted version of the current page designed for "feature phones", mobile phones that do not support modern browser standards. See the official Google Mobile SEO Guide for details on how the page should be formatted.', array('@url' => 'https://developers.google.com/webmasters/mobile-sites/mobile-seo/other-devices?hl=en#feature_phones')), + 'class' => 'DrupalLinkMetaTag', + 'weight' => ++$weight, + 'element' => array( + '#theme' => 'metatag_mobile_alt_handheld', + '#name' => 'alternate', + '#media' => 'handheld', + ), + ) + $defaults; // Default values for each meta tag. - $tag_info_defaults = array( + $defaults = array( 'description' => '', 'class' => 'DrupalTextMetaTag', 'group' => 'apple_mobile', @@ -92,31 +111,31 @@ function metatag_mobile_metatag_info() { 'label' => t('iTunes App details'), 'description' => t('This informs iOS devices to display a banner to a specific app. If used, it must provide the "app-id" value, the "affiliate-data" and "app-argument" values are optional.'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['apple-mobile-web-app-capable'] = array( 'label' => t('Web app capable?'), 'description' => t('If set to "yes", the application will run in full-screen mode; the default behavior is to use Safari to display web content.'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['apple-mobile-web-app-status-bar-style'] = array( 'label' => t('Status bar color'), 'description' => t('Requires the "Web app capable" meta tag to be set to "yes". May be set to "default", "black", or "black-translucent".'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['apple-mobile-web-app-title'] = array( 'label' => t('Apple Mobile Web App Title'), 'description' => t('Overrides the long site title when using the Apple Add to Home Screen.'), 'weight' => ++$weight - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['format-detection'] = array( 'label' => t('Format detection'), 'description' => t('If set to "telephone=no" the page will not be checked for phone numbers, which would be presented.'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['ios-app-link-alternative'] = array( 'label' => t('iOS app link alternative'), @@ -127,10 +146,10 @@ function metatag_mobile_metatag_info() { '#theme' => 'metatag_mobile_ios_app', ), 'header' => FALSE, - ) + $tag_info_defaults; + ) + $defaults; // Default values for each meta tag. - $tag_info_defaults = array( + $defaults = array( 'description' => '', 'class' => 'DrupalTextMetaTag', 'group' => 'android_mobile', @@ -145,7 +164,7 @@ function metatag_mobile_metatag_info() { '#theme' => 'metatag_mobile_android_app', ), 'header' => FALSE, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['android-manifest'] = array( 'label' => t('Manifest'), @@ -155,10 +174,10 @@ function metatag_mobile_metatag_info() { 'element' => array( '#name' => 'manifest', ), - ) + $tag_info_defaults; + ) + $defaults; // Default values for each meta tag. - $tag_info_defaults = array( + $defaults = array( 'description' => '', 'class' => 'DrupalTextMetaTag', 'group' => 'windows_mobile', @@ -171,120 +190,120 @@ function metatag_mobile_metatag_info() { 'element' => array( '#theme' => 'metatag_http_equiv', ), - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['application-name'] = array( 'label' => t('Application name'), 'description' => t('The default name displayed with the pinned sites tile (or icon). Set the content attribute to the desired name.'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-allowDomainApiCalls'] = array( 'label' => t('MSApplication - Allow domain API calls'), 'description' => t('Allows tasks to be defined on child domains of the fully qualified domain name associated with the pinned site. Should be either "true" or "false".'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-allowDomainMetaTags'] = array( 'label' => t('MSApplication - Allow domain meta tags'), 'description' => t('Allows tasks to be defined on child domains of the fully qualified domain name associated with the pinned site. Should be either "true" or "false".'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-badge'] = array( 'label' => t('MSApplication - Badge'), 'description' => t('A semi-colon -separated string that must contain the "polling-uri=" value with the full URL to a Badge Schema XML file. May also contain "frequency=" value set to either 30, 60, 360, 720 or 1440 (default) which specifies (in minutes) how often the URL should be polled.'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-config'] = array( 'label' => t('MSApplication - Config'), 'description' => t('Should contain the full URL to a Browser configuration schema file that further controls tile customizations.'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-navbutton-color'] = array( 'label' => t('MSApplication - Nav button color'), 'description' => t('Controls the color of the Back and Forward buttons in the pinned site browser window.'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-notification'] = array( 'label' => t('MSApplication - Notification'), 'description' => t('A semi-colon -separated string containing "polling-uri=" (required), "polling-uri2=", "polling-uri3=", "polling-uri4=" and "polling-uri5=" to indicate the URLs for notifications. May also contain a "frequency=" value to specify how often (in minutes) the URLs will be polled; limited to 30, 60, 360, 720 or 1440 (default). May also contain the value "cycle=" to control the notifications cycle.'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-square150x150logo'] = array( 'label' => t('MSApplication - Square logo, 150px x 150px'), 'description' => t('The URL to a logo file that is 150px by 150px.'), 'image' => TRUE, 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-square310x310logo'] = array( 'label' => t('MSApplication - Square logo, 310px x 310px'), 'description' => t('The URL to a logo file that is 310px by 310px.'), 'image' => TRUE, 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-square70x70logo'] = array( 'label' => t('MSApplication - Square logo, 70px x 70px'), 'description' => t('The URL to a logo file that is 70px by 70px.'), 'image' => TRUE, 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-wide310x150logo'] = array( 'label' => t('MSApplication - Wide logo, 310px x 150px'), 'description' => t('The URL to a logo file that is 310px by 150px.'), 'image' => TRUE, 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-starturl'] = array( 'label' => t('MSApplication - Start URL'), 'description' => t('The URL to the root page of the site.'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-task'] = array( 'label' => t('MSApplication - Task'), 'description' => t('A semi-colon -separated string defining the "jump" list task. Should contain the "name=" value to specify the task\'s name, the "action-uri=" value to set the URL to load when the jump list is clicked, the "icon-uri=" value to set the URL to an icon file to be displayed, and "window-type=" set to either "tab" (default), "self" or "window" to control how the link opens in the browser.'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-task-separator'] = array( 'label' => t('MSApplication - Task separator'), 'description' => t(''), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-tilecolor'] = array( 'label' => t('MSApplication - Tile color'), 'description' => t('The HTML color to use as the background color for the live tile.'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-tileimage'] = array( 'label' => t('MSApplication - Tile image'), 'description' => t('The URL to an image to use as the background for the live tile.'), 'image' => TRUE, 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-tooltip'] = array( 'label' => t('MSApplication - Tooltip'), 'description' => t('Controls the text shown in the tooltip for the pinned site\'s shortcut.'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; $info['tags']['msapplication-window'] = array( 'label' => t('MSApplication - Window'), 'description' => t('A semi-colon -separated value that controls the dimensions of the initial window. Should contain the values "width=" and "height=" to control the width and height respectively.'), 'weight' => ++$weight, - ) + $tag_info_defaults; + ) + $defaults; return $info; } diff --git a/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.module b/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.module index 53a122aae..4d7f3d6e9 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.module +++ b/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.module @@ -23,6 +23,9 @@ function metatag_mobile_theme() { $info['metatag_mobile_ios_app'] = array( 'render element' => 'element', ); + $info['metatag_mobile_alt_handheld'] = array( + 'render element' => 'element', + ); return $info; } @@ -55,6 +58,25 @@ function theme_metatag_mobile_ios_app($variables) { return theme('metatag_link_rel', $variables); } + +/** + * Theme callback for a handheld-formatted alternative URL. + * + * The format is: + * + */ +function theme_metatag_mobile_alt_handheld($variables) { + $element = &$variables['element']; + $args = array( + '#name' => 'rel', + '#media' => 'media', + '#value' => 'href', + ); + element_set_attributes($element, $args); + unset($element['#value']); + return theme('html_tag', $variables); +} + /* * theme-color * MobileOptimized diff --git a/www7/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.tags.test new file mode 100644 index 000000000..f8a3c4425 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.tags.test @@ -0,0 +1,68 @@ + 'Metatag tags: Mobile', + 'description' => 'Test the mobile meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'alternate_handheld', + 'amphtml', + 'android-app-link-alternative', + 'android-manifest', + 'apple-itunes-app', + 'apple-mobile-web-app-capable', + 'apple-mobile-web-app-status-bar-style', + 'apple-mobile-web-app-title', + 'application-name', + 'cleartype', + 'format-detection', + 'HandheldFriendly', + 'ios-app-link-alternative', + 'MobileOptimized', + 'msapplication-allowDomainApiCalls', + 'msapplication-allowDomainMetaTags', + 'msapplication-badge', + 'msapplication-config', + 'msapplication-navbutton-color', + 'msapplication-notification', + 'msapplication-square150x150logo', + 'msapplication-square310x310logo', + 'msapplication-square70x70logo', + 'msapplication-starturl', + 'msapplication-task', + 'msapplication-task-separator', + 'msapplication-tilecolor', + 'msapplication-tileimage', + 'msapplication-tooltip', + 'msapplication-wide310x150logo', + 'msapplication-window', + 'theme-color', + 'viewport', + 'x-ua-compatible', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_mobile'; + parent::setUp($modules); + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.info b/www7/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.info index b2837e2f2..0a3a373d4 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.info @@ -6,10 +6,11 @@ dependencies[] = metatag ; Tests. files[] = tests/metatag_opengraph.test +files[] = tests/metatag_opengraph.tags.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.install b/www7/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.install index 89c30f96a..abe78df0b 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.install +++ b/www7/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.install @@ -80,7 +80,7 @@ function metatag_opengraph_update_7103(&$sandbox) { module_load_include('install', 'metatag'); $old_tag = 'og:video'; $new_tag = 'og:video:url'; - return metatag_update_replace_meta_tag($sandbox, $old_tag, $new_tag); + return metatag_update_replace_entity_tag($sandbox, $old_tag, $new_tag); } /** @@ -90,7 +90,7 @@ function metatag_opengraph_update_7104() { module_load_include('install', 'metatag'); $old_tag = 'og:video'; $new_tag = 'og:video:url'; - return metatag_update_replace_config($old_tag, $new_tag); + return metatag_update_replace_config_tag($old_tag, $new_tag); } /** diff --git a/www7/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.tags.test new file mode 100644 index 000000000..d6e28244d --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.tags.test @@ -0,0 +1,133 @@ + 'Metatag tags: OpenGraph', + 'description' => 'Test the OpenGraph meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'article:author', + 'article:expiration_time', + 'article:modified_time', + 'article:published_time', + 'article:publisher', + 'article:section', + 'article:tag', + 'book:author', + 'book:isbn', + 'book:release_date', + 'book:tag', + 'og:audio', + 'og:audio:secure_url', + 'og:audio:type', + 'og:country_name', + 'og:description', + 'og:determiner', + 'og:email', + 'og:fax_number', + 'og:image', + 'og:image:height', + 'og:image:secure_url', + 'og:image:type', + 'og:image:url', + 'og:image:width', + 'og:latitude', + 'og:locale', + 'og:locale:alternate', + 'og:locality', + 'og:longitude', + 'og:phone_number', + 'og:postal_code', + 'og:region', + 'og:see_also', + 'og:site_name', + 'og:street_address', + 'og:title', + 'og:type', + 'og:updated_time', + 'og:url', + 'og:video:height', + 'og:video:secure_url', + 'og:video:type', + 'og:video:url', + 'og:video:width', + 'profile:first_name', + 'profile:gender', + 'profile:last_name', + 'profile:username', + 'video:actor', + 'video:actor:role', + 'video:director', + 'video:duration', + 'video:release_date', + 'video:series', + 'video:tag', + 'video:writer', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_opengraph'; + parent::setUp($modules); + } + + /** + * Implements {meta_tag_name}_test_key() for 'og:type'. + */ + public function og_type_test_key() { + return 'metatags[und][og:type][value]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'og:type'. + */ + public function og_type_test_value() { + return 'article'; + } + + /** + * Implements {meta_tag_name}_test_xpath() for 'og:type'. + */ + public function og_type_test_xpath() { + return "//select[@name='metatags[und][og:type][value]']"; + } + + /** + * Implements {meta_tag_name}_test_key() for 'og:determiner'. + */ + public function og_determiner_test_key() { + return 'metatags[und][og:determiner][value]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'og:determiner'. + */ + public function og_determiner_test_value() { + return 'a'; + } + + /** + * Implements {meta_tag_name}_test_xpath() for 'og:determiner'. + */ + public function og_determiner_test_xpath() { + return "//select[@name='metatags[und][og:determiner][value]']"; + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.info b/www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.info index 3f26e1148..fcab07c69 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.info @@ -7,10 +7,11 @@ dependencies[] = metatag_opengraph ; Tests. files[] = tests/metatag_opengraph_products.test +files[] = tests/metatag_opengraph_products.tags.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.tags.test new file mode 100644 index 000000000..067d72db6 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.tags.test @@ -0,0 +1,60 @@ + 'Metatag tags: OpenGraph Products', + 'description' => 'Test the OpenGraph Products meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'product:availability', + 'product:brand', + 'product:category', + 'product:color', + 'product:condition', + 'product:ean', + 'product:expiration_time', + 'product:isbn', + 'product:material', + 'product:mfr_part_no', + 'product:pattern', + 'product:plural_title', + 'product:price:amount', + 'product:price:currency', + 'product:product_link', + 'product:retailer', + 'product:retailer_part_no', + 'product:retailer_title', + 'product:shipping_cost:amount', + 'product:shipping_cost:currency', + 'product:shipping_weight:units', + 'product:shipping_weight:value', + 'product:size', + 'product:upc', + 'product:weight:units', + 'product:weight:value', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_opengraph_products'; + parent::setUp($modules); + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.info b/www7/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.info index bcdf6d80c..a17a14929 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.info @@ -10,9 +10,9 @@ dependencies[] = panels files[] = tests/metatag_panels.test files[] = tests/metatag_panels.i18n.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.i18n.test b/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.i18n.test index 96891a866..3748e3bc4 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.i18n.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.i18n.test @@ -13,6 +13,7 @@ class MetatagPanelsI18nTest extends MetatagTestHelper { 'name' => 'Metatag:Panels i18n tests', 'description' => 'Test Metatag integration via the Metatag:Panels module.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'panels', 'page_manager', 'i18n'), ); } @@ -36,6 +37,9 @@ class MetatagPanelsI18nTest extends MetatagTestHelper { parent::setUp($modules); + // Add more locales. + $this->setupLocales(); + // Set up the locales. $perms = array( 'administer languages', @@ -45,7 +49,9 @@ class MetatagPanelsI18nTest extends MetatagTestHelper { 'translate user-defined strings', ); $this->adminUser = $this->createAdminUser($perms); - $this->setupLocales(); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); // Reload the translations. drupal_flush_all_caches(); diff --git a/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.test b/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.test index 4266cfea2..dfd7d0093 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.test @@ -13,6 +13,7 @@ class MetatagPanelsTest extends MetatagTestHelper { 'name' => 'Metatag:Panels tests', 'description' => 'Test Metatag integration via the Metatag:Panels module.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'panels', 'page_manager'), ); } diff --git a/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.info b/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.info index d7eca7892..98172a9d7 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.info @@ -10,9 +10,9 @@ dependencies[] = page_manager dependencies[] = metatag dependencies[] = metatag_panels -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.info b/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.info index c28c08d23..111022820 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.info @@ -6,10 +6,11 @@ dependencies[] = metatag ; Tests. files[] = tests/metatag_twitter_cards.test +files[] = tests/metatag_twitter_cards.tags.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.install b/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.install index 95c9b1f94..d2ae3774c 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.install +++ b/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.install @@ -27,7 +27,7 @@ function metatag_twitter_cards_update_7100(&$sandbox) { module_load_include('install', 'metatag'); $old_tag = 'twitter:image:src'; $new_tag = 'twitter:image'; - return metatag_update_replace_meta_tag($sandbox, $old_tag, $new_tag); + return metatag_update_replace_entity_tag($sandbox, $old_tag, $new_tag); } /** @@ -37,7 +37,7 @@ function metatag_twitter_cards_update_7101() { module_load_include('install', 'metatag'); $old_tag = 'twitter:image:src'; $new_tag = 'twitter:image'; - return metatag_update_replace_config($old_tag, $new_tag); + return metatag_update_replace_config_tag($old_tag, $new_tag); } /** diff --git a/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.metatag.inc b/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.metatag.inc index 71b96b098..10f962ea3 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.metatag.inc +++ b/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.metatag.inc @@ -367,7 +367,7 @@ function metatag_twitter_cards_metatag_info() { ) + $defaults; $info['tags']['twitter:app:id:googleplay'] = array( 'label' => t('Google Play app ID'), - 'description' => t("String value, and should be the domain hierarchy representation of your app's ID in Google Play."), + 'description' => t("Your app ID in the Google Play Store (i.e. \"com.android.app\")."), 'weight' => ++$weight, 'element' => array( '#theme' => 'metatag_twitter_cards' diff --git a/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.tags.test new file mode 100644 index 000000000..cbd134c77 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.tags.test @@ -0,0 +1,90 @@ + 'Metatag tags: Twitter Cards', + 'description' => 'Test the Twitter Cards meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'twitter:app:country', + 'twitter:app:id:googleplay', + 'twitter:app:id:ipad', + 'twitter:app:id:iphone', + 'twitter:app:name:googleplay', + 'twitter:app:name:ipad', + 'twitter:app:name:iphone', + 'twitter:app:url:googleplay', + 'twitter:app:url:ipad', + 'twitter:app:url:iphone', + 'twitter:card', + 'twitter:creator', + 'twitter:creator:id', + 'twitter:data1', + 'twitter:data2', + 'twitter:description', + 'twitter:image', + 'twitter:image0', + 'twitter:image1', + 'twitter:image2', + 'twitter:image3', + 'twitter:image:alt', + 'twitter:image:height', + 'twitter:image:width', + 'twitter:label1', + 'twitter:label2', + 'twitter:player', + 'twitter:player:height', + 'twitter:player:stream', + 'twitter:player:stream:content_type', + 'twitter:player:width', + 'twitter:site', + 'twitter:site:id', + 'twitter:title', + 'twitter:url', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_twitter_cards'; + parent::setUp($modules); + } + + /** + * Implements {meta_tag_name}_test_key() for 'twitter:card'. + */ + public function twitter_card_test_key() { + return 'metatags[und][twitter:card][value]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'twitter:card'. + */ + public function twitter_card_test_value() { + return 'summary'; + } + + /** + * Implements {meta_tag_name}_test_xpath() for 'twitter:card'. + */ + public function twitter_card_test_xpath() { + return "//select[@name='metatags[und][twitter:card][value]']"; + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.info b/www7/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.info index b23dd1932..9bf253ccb 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.info @@ -6,10 +6,11 @@ dependencies[] = metatag ; Tests. files[] = tests/metatag_verification.test +files[] = tests/metatag_verification.tags.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.install b/www7/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.install new file mode 100644 index 000000000..0a87ec19e --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.install @@ -0,0 +1,25 @@ + 'verification', ); - $info['tags']['alexaVerifyID'] = array( - 'label' => t('Alexa'), - 'description' => t('A string provided by Alexa, which can be obtained from the Alexa "Claim Your Site" page.', array('@alexa' => 'http://www.alexa.com/', '@verify_url' => 'http://www.alexa.com/siteowners/claim')), - 'weight' => ++$weight, - ) + $defaults; - $info['tags']['msvalidate.01'] = array( 'label' => t('Bing'), 'description' => t('A string provided by Bing, full details are available from the Bing online help.', array('@bing' => 'http://www.bing.com/', '@verify_url' => 'http://www.bing.com/webmaster/help/how-to-verify-ownership-of-your-site-afcfefc6')), @@ -62,12 +56,6 @@ function metatag_verification_metatag_info() { 'weight' => ++$weight, ) + $defaults; - $info['tags']['y_key'] = array( - 'label' => t('Yahoo'), - 'description' => t('A string provided by Yahoo.', array('@yahoo' => 'http://www.yahoo.com/')), - 'weight' => ++$weight, - ) + $defaults; - $info['tags']['yandex-verification'] = array( 'label' => t('Yandex'), 'description' => t('A string provided by Yandex, full details are available from the Yandex online help.', array('@yandex' => 'http://www.yandex.com/', '@verify_url' => 'http://api.yandex.com/webmaster/doc/dg/reference/hosts-type.xml')), diff --git a/www7/sites/all/modules/contrib/metatag/metatag_verification/tests/metatag_verification.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_verification/tests/metatag_verification.tags.test new file mode 100644 index 000000000..3e344ccf1 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/metatag_verification/tests/metatag_verification.tags.test @@ -0,0 +1,40 @@ + 'Metatag tags: Verification', + 'description' => 'Test the Verification meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'baidu-site-verification', + 'google-site-verification', + 'msvalidate.01', + 'norton-safeweb-site-verification', + 'p:domain_verify', + 'yandex-verification', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_verification'; + parent::setUp($modules); + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag_views/metatag_views.info b/www7/sites/all/modules/contrib/metatag/metatag_views/metatag_views.info index 8a3065f3d..dc05d87df 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_views/metatag_views.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_views/metatag_views.info @@ -13,9 +13,9 @@ files[] = metatag_views_plugin_display_extender_metatags.inc files[] = tests/metatag_views.test files[] = tests/metatag_views.i18n.test -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views.i18n.test b/www7/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views.i18n.test index c6d560cc5..7d7c03902 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views.i18n.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views.i18n.test @@ -33,6 +33,9 @@ class MetatagViewsI18nTest extends MetatagTestHelper { parent::setUp($modules); + // Add more locales. + $this->setupLocales(); + // Set up the locales. $perms = array( 'administer languages', @@ -42,7 +45,9 @@ class MetatagViewsI18nTest extends MetatagTestHelper { 'translate user-defined strings', ); $this->adminUser = $this->createAdminUser($perms); - $this->setupLocales(); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); // Reload the translations. drupal_flush_all_caches(); diff --git a/www7/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.info b/www7/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.info index dcfc08635..8d7c0ccb7 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.info @@ -9,9 +9,9 @@ dependencies[] = metatag dependencies[] = metatag_views dependencies[] = views -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.bulk_revert.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.bulk_revert.test new file mode 100644 index 000000000..b28bdc890 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.bulk_revert.test @@ -0,0 +1,51 @@ + 'Metatag bulk revert', + 'description' => 'Test the Metatag bulk revert functionality.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), + ); + } + + /** + * Test the Bulk Revert functionality works. + */ + function testBulkRevertPageLoads() { + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + + $this->drupalGet('admin/config/search/metatags/bulk-revert'); + $this->assertResponse(200); + + // Confirm each of the entity checkboxes is present. + foreach (entity_get_info() as $entity_type => $entity_info) { + foreach (array_keys($entity_info['bundles']) as $bundle) { + if (metatag_entity_supports_metatags($entity_type, $bundle)) { + $this->assertFieldByName("update[{$entity_type}:{$bundle}]"); + } + } + } + + // Confirm each of the meta tags is available as a checkbox. + foreach (metatag_get_info('tags') as $tag_name => $tag) { + $this->assertFieldByName("tags[{$tag_name}]"); + } + + // Confirm each of the languages has a checkbox. + $this->assertFieldByName("languages[" . LANGUAGE_NONE . "]"); + foreach (language_list() as $language) { + $this->assertFieldByName("languages[{$language->language}]"); + } + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.core_tag_removal.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.core_tag_removal.test index 1efabf326..bc4ae329b 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.core_tag_removal.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.core_tag_removal.test @@ -13,6 +13,7 @@ class MetatagCoreTagRemovalTest extends MetatagTestHelper { 'name' => 'Metatag core tag handling', 'description' => 'Test Metatag integration with the locale module.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), ); } @@ -37,7 +38,7 @@ class MetatagCoreTagRemovalTest extends MetatagTestHelper { unset($config->config['generator']); metatag_config_save($config); // Dump out the current config, to aid with debugging. - $this->verbose('
    ' . print_r($config, TRUE) . '
    '); + $this->verbose($config); // Load the front page. $this->drupalGet(''); diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.helper.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.helper.test index fa6f09f51..6854b097b 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.helper.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.helper.test @@ -4,7 +4,7 @@ * A base class for the Metatag tests, provides shared methods. */ -class MetatagTestHelper extends DrupalWebTestCase { +abstract class MetatagTestHelper extends DrupalWebTestCase { /** * Admin user. * @@ -25,13 +25,9 @@ class MetatagTestHelper extends DrupalWebTestCase { $modules[] = 'ctools'; $modules[] = 'token'; - // Metatag modules. + // Metatag modules. Only enable the main module, submodules will be tested + // separately. $modules[] = 'metatag'; - $modules[] = 'metatag_dc'; - $modules[] = 'metatag_facebook'; - $modules[] = 'metatag_google_plus'; - $modules[] = 'metatag_opengraph'; - $modules[] = 'metatag_twitter_cards'; // Adds some functionality for testing the entity handling. $modules[] = 'metatag_test'; @@ -39,6 +35,23 @@ class MetatagTestHelper extends DrupalWebTestCase { parent::setUp($modules); } + /** + * {@inheritdoc} + */ + protected function verbose($message, $title = NULL) { + // Handle arrays, objects, etc. + if (!is_string($message)) { + $message = "
    \n" . print_r($message, TRUE) . "\n
    \n"; + } + + // Optional title to go before the output. + if (!empty($title)) { + $title = '

    ' . check_plain($title) . "

    \n"; + } + + parent::verbose($title . $message); + } + /** * Load the Performance admin page and clear all caches. */ @@ -63,7 +76,7 @@ class MetatagTestHelper extends DrupalWebTestCase { )); // Enable meta tags for this new content type. - metatag_entity_type_enable('node', $machine_name); + metatag_entity_type_enable('node', $machine_name, TRUE); return $content_type; } @@ -82,6 +95,7 @@ class MetatagTestHelper extends DrupalWebTestCase { // Basic permissions for the module. 'administer meta tags', 'edit meta tags', + // General admin access. 'access administration pages', ); @@ -147,7 +161,7 @@ class MetatagTestHelper extends DrupalWebTestCase { taxonomy_vocabulary_save($vocabulary); // Enable meta tags for this new vocabulary. - metatag_entity_type_enable('taxonomy_term', $vocab_name); + metatag_entity_type_enable('taxonomy_term', $vocab_name, TRUE); return $vocabulary; } @@ -217,26 +231,6 @@ class MetatagTestHelper extends DrupalWebTestCase { // 'original-source' => array('value' => ''), // 'revisit-after' => array('value' => ''), // 'content-language' => array('value' => ''),' - - // Dublin Core meta tags. - 'dcterms.format' => array('value' => 'text/html'), - 'dcterms.identifier' => array('value' => '[current-page:url:absolute]'), - 'dcterms.title' => array('value' => '[current-page:title]'), - 'dcterms.type' => array('value' => 'Text'), - - // Google+ meta tags. - 'itemprop:name' => array('value' => '[current-page:title]'), - - // Open Graph meta tags. - 'og:site_name' => array('value' => '[site:name]'), - 'og:title' => array('value' => '[current-page:title]'), - 'og:type' => array('value' => 'article'), - 'og:url' => array('value' => '[current-page:url:absolute]'), - - // Twitter Cards meta tags. - 'twitter:card' => array('value' => 'summary'), - 'twitter:title' => array('value' => '[current-page:title]'), - 'twitter:url' => array('value' => '[current-page:url:absolute]'), ); } @@ -272,36 +266,58 @@ class MetatagTestHelper extends DrupalWebTestCase { /** * Set up a basic starting point for the locales. * - * This assumes the Locale module is enabled. + * This assumes the Locale module is enabled. This also must be done before + * other user accounts are logged in. + * + * @param array $locales + * A list of locales to be enabled, in langcode format. */ - public function setupLocales() { - // If there isn't an admin user already, create one. - if (empty($this->adminUser)) { - $perms = array( - 'administer languages', - 'translate interface', - 'access administration pages', - ); - $this->adminUser = $this->createAdminUser($perms); + public function setupLocales(array $locales = array()) { + // If no locales were requested, add Spanish and French. + if (empty($locales)) { + $locales[] = 'es'; + $locales[] = 'fr'; } - // Log in as the admin user. - $this->drupalLogin($this->adminUser); + // Log in as an admin user with privs to just set up the locales. + $perms = array( + 'administer languages', + 'translate interface', + 'access administration pages', + ); + $admin_user = $this->drupalCreateUser($perms); + $this->drupalLogin($admin_user); // Load the admin page, just to have a point of reference. $this->drupalGet('admin'); $this->assertResponse(200, 'Loaded the main admin page.'); - // Add French. - $this->addSiteLanguage('fr'); + // Identify the site's default language. + $default_language = language_default('language'); - // Add Spanish. - $this->addSiteLanguage('es'); + // Add the locales. + foreach ($locales as $langcode) { + // Don't create the default language, it's already present. + if ($langcode != $default_language) { + $this->addSiteLanguage($langcode); + } + } // Enable URL language detection and selection. - $edit = array('language[enabled][locale-url]' => '1'); - $this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings')); + $this->drupalGet('admin/config/regional/language/configure'); $this->assertResponse(200); + $edit = array( + 'language[enabled][locale-url]' => TRUE, + ); + // Also enable path handling for Entity Translation if it is installed. + if (module_exists('entity_translation')) { + $edit['language_content[enabled][locale-url]'] = TRUE; + } + $this->drupalPost(NULL, $edit, t('Save settings')); + $this->assertResponse(200); + + // Once all the setup is done, log out the user. + $this->drupalLogout(); } /** @@ -714,4 +730,21 @@ class MetatagTestHelper extends DrupalWebTestCase { return $saved_file; } + /** + * Verify a user entity's meta tags load correctly. + * + * @param object $user + * A user object that is to be tested. + */ + function assertUserEntityTags($user) { + // Load the user's profile page. + $this->drupalGet('user/' . $user->uid); + $this->assertResponse(200); + + // Verify the title is using the custom default for this vocabulary. + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertEqual($xpath[0]['content'], $user->name . " ponies"); + } + } diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.image.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.image.test index f58df4a65..547a98198 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.image.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.image.test @@ -13,6 +13,7 @@ class MetatagCoreImageTest extends MetatagTestHelper { 'name' => 'Metatag core tests for images', 'description' => 'Test Metatag integration with image files.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'devel_generate'), ); } @@ -20,8 +21,12 @@ class MetatagCoreImageTest extends MetatagTestHelper { * {@inheritdoc} */ function setUp(array $modules = array()) { + // Needs the OpenGraph submodule because of testNodeFieldValueMultiple(). + $modules[] = 'metatag_opengraph'; + // Need image handling. $modules[] = 'image'; + // Need the Devel Generate image generator. $modules[] = 'devel_generate'; @@ -46,7 +51,7 @@ class MetatagCoreImageTest extends MetatagTestHelper { metatag_config_save($config); // Dump out the current config, to aid with debugging. - $this->verbose('
    ' . print_r($config, TRUE) . '
    '); + $this->verbose($config); // Load the front page. $this->drupalGet(''); @@ -87,7 +92,7 @@ class MetatagCoreImageTest extends MetatagTestHelper { metatag_config_save($config); // Dump out the current config, to aid with debugging. - $this->verbose('
    ' . print_r($config, TRUE) . '
    '); + $this->verbose($config); // Load the front page. $this->drupalGet(''); @@ -128,7 +133,7 @@ class MetatagCoreImageTest extends MetatagTestHelper { metatag_config_save($config); // Dump out the current config, to aid with debugging. - $this->verbose('
    ' . print_r($config, TRUE) . '
    '); + $this->verbose($config); // Load the front page. $this->drupalGet(''); @@ -144,6 +149,40 @@ class MetatagCoreImageTest extends MetatagTestHelper { $this->assertResponse(200, "The image_src meta tag's value could be loaded."); } + /** + * Confirm that an image can be added to a global configuration using the + * image's protocol-relative URL. + */ + function testConfigProtocolRelativeURL() { + // Generate a test image. + $image_uri = $this->generateImage(); + $this->verbose($image_uri); + + // Work out the web-accessible URL for this image. + $image_url = file_create_url($image_uri); + + // Make the URL protocol-relative. + $relative_url = str_replace('http://', '//', $image_url); + + // Update the global config to add an image meta tag. + $config = metatag_config_load('global'); + $config->config['image_src']['value'] = $relative_url; + metatag_config_save($config); + + // Dump out the current config, to aid with debugging. + $this->verbose($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm that the image_src meta tag has the expected values. + $xpath = $this->xpath("//link[@rel='image_src']"); + $this->assertEqual(count($xpath), 1, 'One image_src meta tag found.'); + $this->assertEqual($xpath[0]['href'], $relative_url, 'The image_src meta tag with a protocol-relative URL is being output correctly.'); + $this->assertNotEqual($xpath[0]['href'], $image_url, 'The image_src meta tag does not contain the absolute URL.'); + } + /** * Confirm that an image can be added to a global configuration using the * image's internal URI. @@ -166,7 +205,7 @@ class MetatagCoreImageTest extends MetatagTestHelper { metatag_config_save($config); // Dump out the current config, to aid with debugging. - $this->verbose('
    ' . print_r($config, TRUE) . '
    '); + $this->verbose($config); // Load the front page. $this->drupalGet(''); @@ -217,7 +256,7 @@ class MetatagCoreImageTest extends MetatagTestHelper { metatag_config_save($config); // Dump out the current config, to aid with debugging. - $this->verbose('
    ' . print_r($config, TRUE) . '
    '); + $this->verbose($config); // Load the front page. $this->drupalGet(''); @@ -245,7 +284,7 @@ class MetatagCoreImageTest extends MetatagTestHelper { $image_url = file_create_url($image->uri); // Dump out the file object, to aid with debugging. - $this->verbose('
    ' . print_r($image, TRUE) . '
    '); + $this->verbose($image); // Update the article-image default settings to use the new image field. $entity_type = 'node'; @@ -295,7 +334,7 @@ class MetatagCoreImageTest extends MetatagTestHelper { $image_url = file_create_url($image->uri); // Dump out the file object, to aid with debugging. - $this->verbose('
    ' . print_r($image, TRUE) . '
    '); + $this->verbose($image); // Create an example node. $args = array( @@ -310,7 +349,7 @@ class MetatagCoreImageTest extends MetatagTestHelper { // Forcibly reload the node, to avoid working with a cached version. $node = node_load($node->nid, NULL, TRUE); - $this->verbose('

    Node:

    ' . print_r($node, TRUE) . '
    '); + $this->verbose($node, 'Node'); // Load the node page. $this->drupalGet('node/' . $node->nid); @@ -350,8 +389,8 @@ class MetatagCoreImageTest extends MetatagTestHelper { $image2_url = file_create_url($image2->uri); // Dump out the file objects, to aid with debugging. - $this->verbose('

    Image #1

    ' . print_r($image1, TRUE) . '
    '); - $this->verbose('

    Image #2

    ' . print_r($image2, TRUE) . '
    '); + $this->verbose($image1, 'Image #1'); + $this->verbose($image2, 'Image #2'); // Create an example node. $args = array( @@ -367,7 +406,7 @@ class MetatagCoreImageTest extends MetatagTestHelper { // Forcibly reload the node, to avoid working with a cached version. $node = node_load($node->nid, NULL, TRUE); - $this->verbose('

    Node:

    ' . print_r($node, TRUE) . '
    '); + $this->verbose($node, 'Node'); // Load the node page. $this->drupalGet('node/' . $node->nid); @@ -409,8 +448,8 @@ class MetatagCoreImageTest extends MetatagTestHelper { $image2_url = file_create_url($image2->uri); // Dump out the file objects, to aid with debugging. - $this->verbose('

    Image #1

    ' . print_r($image1, TRUE) . '
    '); - $this->verbose('

    Image #2

    ' . print_r($image2, TRUE) . '
    '); + $this->verbose($image1, 'Image #1'); + $this->verbose($image2, 'Image #2'); // Create an example node. $args = array( @@ -426,7 +465,7 @@ class MetatagCoreImageTest extends MetatagTestHelper { // Forcibly reload the node, to avoid working with a cached version. $node = node_load($node->nid, NULL, TRUE); - $this->verbose('

    Node:

    ' . print_r($node, TRUE) . '
    '); + $this->verbose($node, 'Node'); // Load the node page. $this->drupalGet('node/' . $node->nid); diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.locale.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.locale.test index 37c2abe57..c4f73eb1c 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.locale.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.locale.test @@ -5,6 +5,7 @@ */ class MetatagCoreLocaleTest extends MetatagTestHelper { + /** * {@inheritdoc} */ @@ -13,6 +14,7 @@ class MetatagCoreLocaleTest extends MetatagTestHelper { 'name' => 'Metatag core tests for Locale', 'description' => 'Test Metatag integration with the locale module.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), ); } @@ -37,6 +39,9 @@ class MetatagCoreLocaleTest extends MetatagTestHelper { // Create a content type. $this->createContentType($content_type, $label); + // Add more locales. + $this->setupLocales(); + // Create an admin user and log them in. $perms = array( // Needed for the content type. @@ -49,10 +54,9 @@ class MetatagCoreLocaleTest extends MetatagTestHelper { 'translate interface', ); $this->adminUser = $this->createAdminUser($perms); - $this->drupalLogin($this->adminUser); - // Prep the locales. - $this->setupLocales(); + // Log in the admin user. + $this->drupalLogin($this->adminUser); // Load the node form in each locale, confirm it has the fields. This also // preloads the field labels into the locale system. diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.node.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.node.test index f256fc7ca..1478a6b0e 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.node.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.node.test @@ -5,6 +5,7 @@ */ class MetatagCoreNodeTest extends MetatagTestHelper { + /** * {@inheritdoc} */ @@ -13,6 +14,7 @@ class MetatagCoreNodeTest extends MetatagTestHelper { 'name' => 'Metatag core tests for nodes', 'description' => 'Test Metatag edit functionality for nodes.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), ); } @@ -43,6 +45,8 @@ class MetatagCoreNodeTest extends MetatagTestHelper { 'administer nodes', ); $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. $this->drupalLogin($this->adminUser); // Assign default values for the new content type. @@ -65,12 +69,7 @@ class MetatagCoreNodeTest extends MetatagTestHelper { // Submit the form with some values. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[node:title]', - 'metatags[und][dcterms.creator][value]' => '[node:author]', - 'metatags[und][dcterms.date][value]' => '[node:created:custom:Y-m-d\TH:iP]', - 'metatags[und][dcterms.format][value]' => 'text/html', - 'metatags[und][dcterms.identifier][value]' => '[current-page:url:absolute]', - 'metatags[und][dcterms.language][value]' => '[node:language]', + 'metatags[und][abstract][value]' => '[node:title]', ), t('Save')); $this->assertResponse(200); @@ -92,7 +91,7 @@ class MetatagCoreNodeTest extends MetatagTestHelper { // Verify that it's possible to submit values to the form. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[node:title] ponies', + 'metatags[und][abstract][value]' => '[node:title] ponies', 'title' => 'Who likes magic', ), t('Save')); $this->assertResponse(200); @@ -100,7 +99,7 @@ class MetatagCoreNodeTest extends MetatagTestHelper { // The meta tags that will be checked for. $expected = array( 'und' => array( - 'dcterms.subject' => array( + 'abstract' => array( 'value' => '[node:title] ponies', ), ), @@ -121,25 +120,25 @@ class MetatagCoreNodeTest extends MetatagTestHelper { if (preg_match('@node/(\d+)$@', $this->getUrl(), $matches)) { $nid = end($matches); $node = node_load($nid); - $this->verbose('

    node_load(' . $nid . ')

    ' . print_r($node, TRUE) . '
    '); + $this->verbose($node, 'node_load(' . $nid . ')'); // Only the non-default values are stored. $this->assertEqual($expected, $node->metatags); // Confirm the APIs can load the data for this node. $metatags = metatag_metatags_load('node', $node->nid); - $this->verbose('

    metatag_metatags_load("node", ' . $node->nid . ')

    ' . print_r($metatags, TRUE) . '
    '); + $this->verbose($metatags, 'metatag_metatags_load("node", ' . $node->nid . ')'); $this->assertEqual($expected, $metatags); $metatags = metatag_metatags_load_multiple('node', array($node->nid)); - $this->verbose('

    metatag_metatags_load_multiple("node", array(' . $node->nid . '))

    ' . print_r($metatags, TRUE) . '
    '); + $this->verbose($metatags, 'metatag_metatags_load_multiple("node", array(' . $node->nid . '))'); $this->assertEqual(array($node->nid => array($node->vid => $expected)), $metatags); // Confirm the APIs can load the data for this node revision. $metatags = metatag_metatags_load('node', $node->nid, $node->vid); - $this->verbose('

    metatag_metatags_load("node", ' . $node->nid . ', ' . $node->vid . ')

    ' . print_r($metatags, TRUE) . '
    '); + $this->verbose($metatags, 'metatag_metatags_load("node", ' . $node->nid . ', ' . $node->vid . ')'); $this->assertEqual($expected, $metatags); $metatags = metatag_metatags_load_multiple('node', array($node->nid), array($node->vid)); - $this->verbose('

    metatag_metatags_load_multiple("node", array(' . $node->nid . '), array(' . $node->vid . '))

    ' . print_r($metatags, TRUE) . '
    '); + $this->verbose($metatags, 'metatag_metatags_load_multiple("node", array(' . $node->nid . '), array(' . $node->vid . '))'); $this->assertEqual(array($node->nid => array($node->vid => $expected)), $metatags); } @@ -149,8 +148,8 @@ class MetatagCoreNodeTest extends MetatagTestHelper { } // Verify the title is using the custom default for this content type. - $xpath = $this->xpath("//meta[@name='dcterms.subject']"); - $this->assertEqual(count($xpath), 1, 'Exactly one dcterms.subject meta tag found.'); + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); $this->assertEqual($xpath[0]['content'], 'Who likes magic ponies'); // Core's canonical tag is a relative URL, whereas Metatag outputs an @@ -180,7 +179,7 @@ class MetatagCoreNodeTest extends MetatagTestHelper { $this->assertResponse(200); // Try submitting text to the page. $args = array( - 'metatags[und][dcterms.subject][value]' => '[node:title] kittens', + 'metatags[und][abstract][value]' => '[node:title] kittens', 'title' => $new_title, 'revision' => 1, 'log' => 'Creating a new revision', @@ -192,7 +191,7 @@ class MetatagCoreNodeTest extends MetatagTestHelper { // A new version of the expected results $expected_updated = array( 'und' => array( - 'dcterms.subject' => array( + 'abstract' => array( 'value' => '[node:title] kittens', ), ), @@ -208,10 +207,10 @@ class MetatagCoreNodeTest extends MetatagTestHelper { $this->assertText(strip_tags(t('@type %title has been updated.', $t_args))); // Verify the title is still using the custom default for this content type. - $xpath = $this->xpath("//meta[@name='dcterms.subject']"); - $this->assertEqual(count($xpath), 1, 'Exactly one dcterms.subject meta tag found.'); - $this->assertNotEqual($xpath[0]['content'], $old_title . ' ponies', 'Did not find the new dcterms.subject meta tag.'); - $this->assertEqual($xpath[0]['content'], $new_title . ' kittens', 'Found the old dcterms.subject meta tag.'); + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertNotEqual($xpath[0]['content'], $old_title . ' ponies', 'Did not find the new abstract meta tag.'); + $this->assertEqual($xpath[0]['content'], $new_title . ' kittens', 'Found the old abstract meta tag.'); // Load the node revisions page. $this->drupalGet('node/' . $node->nid . '/revisions'); @@ -226,43 +225,43 @@ class MetatagCoreNodeTest extends MetatagTestHelper { $this->drupalGet('node/' . $node->nid . '/revisions/' . $old_vid . '/view'); // Verify the page loaded correctly. $this->assertResponse(200, 'Loaded the original revision of this node.'); - $xpath = $this->xpath("//meta[@name='dcterms.subject']"); - $this->assertEqual(count($xpath), 1, 'Exactly one dcterms.subject meta tag found.'); - $this->assertNotEqual($xpath[0]['content'], $new_title . ' kittens', 'Did not find the new dcterms.subject meta tag.'); - $this->assertEqual($xpath[0]['content'], $old_title . ' ponies', 'Found the old dcterms.subject meta tag.'); + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertNotEqual($xpath[0]['content'], $new_title . ' kittens', 'Did not find the new abstract meta tag.'); + $this->assertEqual($xpath[0]['content'], $old_title . ' ponies', 'Found the old abstract meta tag.'); // Load the updated node; force-load it to make sure it's loaded properly. $updated_node = node_load($node->nid, NULL, TRUE); $updated_vid = $updated_node->vid; - $this->verbose('

    node_load(' . $node->nid . ', NULL, TRUE)

    ' . print_r($updated_node, TRUE) . '
    '); + $this->verbose($updated_node, 'node_load(' . $node->nid . ', NULL, TRUE)'); // Confirm the APIs can load the data for this node. $metatags = metatag_metatags_load('node', $updated_node->nid); - $this->verbose('

    metatag_metatags_load("node", ' . $updated_node->nid . ')

    ' . print_r($metatags, TRUE) . '
    '); + $this->verbose($metatags, 'metatag_metatags_load("node", ' . $updated_node->nid . ')'); $this->assertEqual($expected_updated, $metatags); $this->assertNotEqual($expected, $metatags); // This one is complicated. If only the entity id is passed in it will load // the {metatag} records for *all* of the entity's revisions. $metatags = metatag_metatags_load_multiple('node', array($updated_node->nid)); - $this->verbose('

    metatag_metatags_load_multiple("node", array(' . $updated_node->nid . '))

    ' . print_r($metatags, TRUE) . '
    '); + $this->verbose($metatags, 'metatag_metatags_load_multiple("node", array(' . $updated_node->nid . '))'); $this->assertEqual(array($updated_node->nid => array($node->vid => $expected, $updated_node->vid => $expected_updated)), $metatags); // Confirm the APIs can load the data for this node revision. $metatags = metatag_metatags_load('node', $updated_node->nid, $updated_vid); - $this->verbose('

    metatag_metatags_load("node", ' . $updated_node->nid . ', ' . $updated_node->vid . ')

    ' . print_r($metatags, TRUE) . '
    '); + $this->verbose($metatags, 'metatag_metatags_load("node", ' . $updated_node->nid . ', ' . $updated_node->vid . ')'); $this->assertEqual($expected_updated, $metatags); $this->assertNotEqual($expected, $metatags); $metatags = metatag_metatags_load_multiple('node', array($updated_node->nid), array($updated_node->vid)); - $this->verbose('

    metatag_metatags_load_multiple("node", array(' . $updated_node->nid . '), array(' . $updated_node->vid . '))

    ' . print_r($metatags, TRUE) . '
    '); + $this->verbose($metatags, 'metatag_metatags_load_multiple("node", array(' . $updated_node->nid . '), array(' . $updated_node->vid . '))'); $this->assertEqual(array($updated_node->nid => array($updated_node->vid => $expected_updated)), $metatags); // Load the current revision again. $this->drupalGet('node/' . $node->nid); $this->assertResponse(200, 'Loaded the current revision of this node.'); - $xpath = $this->xpath("//meta[@name='dcterms.subject']"); - $this->assertEqual(count($xpath), 1, 'Exactly one dcterms.subject meta tag found.'); - $this->assertNotEqual($xpath[0]['content'], $old_title . ' ponies', 'Did not find the old dcterms.subject meta tag.'); - $this->assertEqual($xpath[0]['content'], $new_title . ' kittens', 'Found the new dcterms.subject meta tag.'); + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertNotEqual($xpath[0]['content'], $old_title . ' ponies', 'Did not find the old abstract meta tag.'); + $this->assertEqual($xpath[0]['content'], $new_title . ' kittens', 'Found the new abstract meta tag.'); // Revert to the original revision. $this->drupalGet('node/' . $node->nid . '/revisions/' . $old_vid . '/revert'); @@ -279,10 +278,10 @@ class MetatagCoreNodeTest extends MetatagTestHelper { // Load the current revision, which will now have the old meta tags. $this->drupalGet('node/' . $node->nid); $this->assertResponse(200, 'Loaded the current revision of this node.'); - $xpath = $this->xpath("//meta[@name='dcterms.subject']"); - $this->assertEqual(count($xpath), 1, 'Exactly one dcterms.subject meta tag found.'); - $this->assertNotEqual($xpath[0]['content'], $new_title . ' kittens', 'Did not find the new dcterms.subject meta tag.'); - $this->assertEqual($xpath[0]['content'], $old_title . ' ponies', 'Found the old dcterms.subject meta tag again.'); + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertNotEqual($xpath[0]['content'], $new_title . ' kittens', 'Did not find the new abstract meta tag.'); + $this->assertEqual($xpath[0]['content'], $old_title . ' ponies', 'Found the old abstract meta tag again.'); // Delete the original revision. $this->drupalGet('node/' . $node->nid . '/revisions/' . $old_vid . '/delete'); @@ -301,10 +300,10 @@ class MetatagCoreNodeTest extends MetatagTestHelper { metatag_config_cache_clear(); $this->drupalGet('node/' . $node->nid); $this->assertResponse(200, 'Loaded the current revision of this node again.'); - $xpath = $this->xpath("//meta[@name='dcterms.subject']"); - $this->assertEqual(count($xpath), 1, 'Exactly one dcterms.subject meta tag found.'); - $this->assertNotEqual($xpath[0]['content'], $new_title . ' kittens', 'Did not find the new dcterms.subject meta tag.'); - $this->assertEqual($xpath[0]['content'], $old_title . ' ponies', 'Found the old dcterms.subject meta tag again.'); + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertNotEqual($xpath[0]['content'], $new_title . ' kittens', 'Did not find the new abstract meta tag.'); + $this->assertEqual($xpath[0]['content'], $old_title . ' ponies', 'Found the old abstract meta tag again.'); // Delete the second revision. $this->drupalGet('node/' . $node->nid . '/revisions/' . $updated_vid . '/delete'); @@ -323,9 +322,107 @@ class MetatagCoreNodeTest extends MetatagTestHelper { metatag_config_cache_clear(); $this->drupalGet('node/' . $node->nid); $this->assertResponse(200, 'Loaded the current revision of this node again.'); - $xpath = $this->xpath("//meta[@name='dcterms.subject']"); - $this->assertEqual(count($xpath), 1, 'Exactly one dcterms.subject meta tag found.'); - $this->assertNotEqual($xpath[0]['content'], $new_title . ' kittens', 'Did not find the new dcterms.subject meta tag.'); - $this->assertEqual($xpath[0]['content'], $old_title . ' ponies', 'Found the old dcterms.subject meta tag again.'); + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertNotEqual($xpath[0]['content'], $new_title . ' kittens', 'Did not find the new abstract meta tag.'); + $this->assertEqual($xpath[0]['content'], $old_title . ' ponies', 'Found the old abstract meta tag again.'); + } + + /** + * Tests different 'preview' options. #1: Disabled. + */ + public function testNodePreviewOption0() { + $this->checkNodePreviewOption(0); + } + + /** + * Tests different 'preview' options. #2: Optional, without preview. + */ + public function testNodePreviewOption1NoPreview() { + $this->checkNodePreviewOption(1, FALSE); + } + + /** + * Tests different 'preview' options. #2: Optional, with preview. + */ + public function testNodePreviewOption1Preview() { + $this->checkNodePreviewOption(1, TRUE); + } + + /** + * Tests different 'preview' options. #3: Preview required. + */ + public function testNodePreviewOption2() { + $this->checkNodePreviewOption(2); + } + + /** + * Change the node preview option at the content type level, confirm meta tags + * still save correctly. + * + * @param int $option + * A suitable value for the 'node_preview' option for a content type, must + * be either 0, 1 or 2. + * @param bool $preview + * Whether to perform a preview. Has the following implications: + * - if $option === 0, $preview is ignored, no preview is performed. + * - if $option === 1, $preview is considered, a preview may be performed. + * - if $option === 2, $preview is ignored, a preview is performed. + */ + function checkNodePreviewOption($option, $preview = FALSE) { + $content_type = 'article'; + $label = 'Test'; + + // Create an admin user and log them in. + $perms = array( + // Needed for the content type. + 'create ' . $content_type . ' content', + 'edit any ' . $content_type . ' content', + + // Required for customizing the node preview option. + 'administer content types', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Set the node preview mode. + $this->drupalGet('admin/structure/types/manage/' . $content_type); + $this->assertResponse(200); + $edit = array( + 'node_preview' => $option, + ); + $this->drupalPost(NULL, $edit, t('Save content type')); + $this->assertText(strip_tags(t('The content type %name has been updated.', array('%name' => t('Article'))))); + + // Create a test node. + $this->drupalGet('node/add/' . $content_type); + $this->assertResponse(200); + + // Save a custom meta tag. + $edit = array( + 'metatags[und][abstract][value]' => '[node:title] ponies', + 'title' => 'Who likes magic', + ); + + // A preview may be optionally performed. Core allows three combinations: + // * 0 = Disallowed. + // * 1 = Optional. + // * 2 = Required. + if (($option === 1 && $preview) || $option === 2) { + $this->drupalPost(NULL, $edit, t('Preview')); + $this->drupalPost(NULL, array(), t('Save')); + } + else { + $this->drupalPost(NULL, $edit, t('Save')); + } + $this->assertResponse(200); + + // Verify the title is using the custom default for this content type. + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'Who likes magic ponies'); } + } diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_node.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.node.with_i18n.test similarity index 92% rename from www7/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_node.test rename to www7/sites/all/modules/contrib/metatag/tests/metatag.node.with_i18n.test index 351ed8f50..526974e36 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_node.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.node.with_i18n.test @@ -4,15 +4,16 @@ * Tests for the Metatag module to ensure i18n integration doesn't break. */ -class MetatagCoreWithI18nNodeTest extends MetatagTestHelper { +class MetatagCoreNodeWithI18nTest extends MetatagTestHelper { /** * {@inheritdoc} */ public static function getInfo() { return array( - 'name' => 'Metatag core tests with i18n: node', + 'name' => 'Metatag core node tests with i18n', 'description' => 'Test Metatag node config integration with the i18n module.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'i18n'), ); } @@ -27,6 +28,9 @@ class MetatagCoreWithI18nNodeTest extends MetatagTestHelper { // Enable all of the modules that are needed. parent::setUp($modules); + // Add more locales. + $this->setupLocales(); + // Set up the locales. $perms = array( 'administer languages', @@ -36,7 +40,9 @@ class MetatagCoreWithI18nNodeTest extends MetatagTestHelper { 'translate user-defined strings', ); $this->adminUser = $this->createAdminUser($perms); - $this->setupLocales(); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); // Reload the translations. drupal_flush_all_caches(); diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.string_handling.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.string_handling.test index 6dd04b10c..93af1a810 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.string_handling.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.string_handling.test @@ -23,6 +23,7 @@ class MetatagCoreStringHandlingTest extends MetatagTestHelper { 'name' => 'Metatag core tests for string handling', 'description' => "Tests Metatag's string handling.", 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), ); } @@ -45,6 +46,8 @@ class MetatagCoreStringHandlingTest extends MetatagTestHelper { 'administer nodes', ); $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. $this->drupalLogin($this->adminUser); } @@ -176,6 +179,11 @@ class MetatagCoreStringHandlingTest extends MetatagTestHelper { ), ), ), + 'metatags' => array( + LANGUAGE_NONE => array( + 'abstract' => array('value' => '[node:title]'), + ), + ), )); // Page titles have a suffix added automatically. @@ -198,15 +206,7 @@ class MetatagCoreStringHandlingTest extends MetatagTestHelper { // Test a few other versions of the title, to ensure it isn't broken // on another tag. - $xpath = $this->xpath("//meta[@name='dcterms.title']"); - $this->assertEqual($xpath[0]['content'], $title_original); - $this->assertNotEqual($xpath[0]['content'], $title_encoded); - $this->assertNotEqual($xpath[0]['content'], $title_encodeded); - $xpath = $this->xpath("//meta[@property='og:title']"); - $this->assertEqual($xpath[0]['content'], $title_original); - $this->assertNotEqual($xpath[0]['content'], $title_encoded); - $this->assertNotEqual($xpath[0]['content'], $title_encodeded); - $xpath = $this->xpath("//meta[@name='twitter:title']"); + $xpath = $this->xpath("//meta[@name='abstract']"); $this->assertEqual($xpath[0]['content'], $title_original); $this->assertNotEqual($xpath[0]['content'], $title_encoded); $this->assertNotEqual($xpath[0]['content'], $title_encodeded); diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.string_handling_with_i18n.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.string_handling_with_i18n.test index 0d2b84475..f4c449c15 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.string_handling_with_i18n.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.string_handling_with_i18n.test @@ -17,6 +17,7 @@ class MetatagCoreStringHandlingWithI18nTest extends MetatagCoreStringHandlingTes 'name' => 'Metatag core tests for string handling w i18n', 'description' => "Tests Metatag's string handling when i18n is enabled.", 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'i18n'), ); } diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.tags.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.tags.test new file mode 100644 index 000000000..6802967c3 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.tags.test @@ -0,0 +1,138 @@ + 'Metatag tags: Basic', + 'description' => 'Test the basic meta tags.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'abstract', + 'cache-control', + 'canonical', + 'content-language', + 'description', + 'expires', + 'generator', + 'geo.placename', + 'geo.position', + 'geo.region', + 'icbm', + 'image_src', + 'keywords', + 'news_keywords', + 'next', + 'original-source', + 'pragma', + 'prev', + 'rating', + 'referrer', + 'refresh', + 'revisit-after', + 'rights', + 'robots', + 'shortlink', + 'standout', + 'title', + ); + + /** + * Implements {meta_tag_name}_test_xpath() for 'abstract'. + */ + public function abstract_test_xpath() { + return "//textarea[@name='metatags[und][abstract][value]']"; + } + + /** + * Implements {meta_tag_name}_test_xpath() for 'description'. + */ + public function description_test_xpath() { + return "//textarea[@name='metatags[und][description][value]']"; + } + + /** + * Implements {meta_tag_name}_test_key() for 'rating'. + */ + public function rating_test_key() { + return 'metatags[und][rating][value]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'general'. + */ + public function rating_test_value() { + return 'general'; + } + + /** + * Implements {meta_tag_name}_test_xpath() for 'rating'. + */ + public function rating_test_xpath() { + return "//select[@name='metatags[und][rating][value]']"; + } + + /** + * Implements {meta_tag_name}_test_key() for 'referrer'. + */ + public function referrer_test_key() { + return 'metatags[und][referrer][value]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'referrer'. + */ + public function referrer_test_value() { + return 'origin'; + } + + /** + * Implements {meta_tag_name}_test_xpath() for 'referrer'. + */ + public function referrer_test_xpath() { + return "//select[@name='metatags[und][referrer][value]']"; + } + + /** + * Implements {meta_tag_name}_test_value() for 'robots'. + */ + public function robots_test_key() { + return 'metatags[und][robots][value][index]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'robots'. + */ + public function robots_test_value() { + return TRUE; + } + + /** + * Implements {meta_tag_name}_test_xpath() for 'robots'. + */ + public function robots_test_xpath() { + return "//input[@name='metatags[und][robots][value][index]' and @type='checkbox']"; + } + + /** + * Implements {meta_tag_name}_test_value() for 'revisit-after'. + */ + public function revisit_after_test_value() { + return 2; + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.tags_helper.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.tags_helper.test new file mode 100644 index 000000000..35ac1c558 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.tags_helper.test @@ -0,0 +1,94 @@ +createAdminUser(); + $this->drupalLogin($account); + } + + /** + * Tests that this module's tags are available. + */ + function testTagsArePresent() { + // Load the global config. + $this->drupalGet('admin/config/search/metatags/config/global'); + $this->assertResponse(200); + + // Confirm the various meta tags are available. + foreach ($this->tags as $tag) { + // Convert tag names to something more suitable for a function name. + $tagname = str_replace(array('.', '-', ':'), '_', $tag); + + // Look for a custom method named "{$tagname}_test_xpath", if found use + // that method to get the xpath definition for this meta tag, otherwise it + // defaults to just looking for a text input field. + $method = "{$tagname}_test_xpath"; + if (method_exists($this, $method)) { + $xpath = $this->$method(); + } + else { + $xpath = "//input[@name='metatags[und][{$tag}][value]' and @type='text']"; + } + $this->assertFieldByXPath($xpath, NULL, format_string('The "%tag" tag field was found.', array('%tag' => $tag))); + } + } + + /** + * Confirm that the meta tags can be saved. + */ + function testTagsAreSaveable() { + // Load the global config. + $this->drupalGet('admin/config/search/metatags/config/global'); + $this->assertResponse(200); + + // Update the Global defaults and test them. + $values = array(); + foreach ($this->tags as $tag) { + // Convert tag names to something more suitable for a function name. + $tagname = str_replace(array('.', '-', ':', ' '), '_', $tag); + + // Look for a custom method named "{$tagname}_test_key", if found use + // that method to get the test string for this meta tag, otherwise it + // defaults to the meta tag's name. + $method = "{$tagname}_test_key"; + if (method_exists($this, $method)) { + $test_key = $this->$method(); + } + else { + $test_key = "metatags[und][{$tag}][value]"; + } + + // Look for a custom method named "{$tagname}_test_value", if found use + // that method to get the test string for this meta tag, otherwise it + // defaults to just generating a random string. + $method = "{$tagname}_test_value"; + if (method_exists($this, $method)) { + $test_value = $this->$method(); + } + else { + $test_value = $this->randomString(); + } + + $values[$test_key] = $test_value; + } + $this->drupalPost(NULL, $values, 'Save'); + $this->assertText(strip_tags(t('The meta tag defaults for @label have been saved.', array('@label' => 'Global')))); + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.term.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.term.test index 5361c0bc8..e235d9912 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.term.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.term.test @@ -13,6 +13,7 @@ class MetatagCoreTermTest extends MetatagTestHelper { 'name' => 'Metatag core tests for terms', 'description' => 'Test Metatag edit functionality for terms.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), ); } @@ -58,6 +59,8 @@ class MetatagCoreTermTest extends MetatagTestHelper { 'create url aliases', ); $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. $this->drupalLogin($this->adminUser); // Assign default values for the new vocabulary. @@ -80,9 +83,7 @@ class MetatagCoreTermTest extends MetatagTestHelper { // Submit the form with some values. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[term:name]', - 'metatags[und][dcterms.format][value]' => 'text/html', - 'metatags[und][dcterms.identifier][value]' => '[current-page:url:absolute]', + 'metatags[und][abstract][value]' => '[term:name]', ), t('Save')); $this->assertResponse(200); @@ -104,7 +105,7 @@ class MetatagCoreTermTest extends MetatagTestHelper { // Verify that it's possible to submit values to the form. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[term:name] ponies', + 'metatags[und][abstract][value]' => '[term:name] ponies', 'name' => $term_name, 'path[alias]' => $term_path, ), t('Save')); @@ -144,7 +145,7 @@ class MetatagCoreTermTest extends MetatagTestHelper { // Only the non-default values are stored. $expected = array( 'und' => array( - 'dcterms.subject' => array( + 'abstract' => array( 'value' => '[term:name] ponies', ), ), @@ -158,8 +159,8 @@ class MetatagCoreTermTest extends MetatagTestHelper { } // Verify the title is using the custom default for this vocabulary. - $xpath = $this->xpath("//meta[@name='dcterms.subject']"); - $this->assertEqual(count($xpath), 1, 'Exactly one dcterms.subject meta tag found.'); + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); $this->assertEqual($xpath[0]['content'], "Who likes magic ponies"); } } diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.term.with_i18n.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.term.with_i18n.test new file mode 100644 index 000000000..126147981 --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.term.with_i18n.test @@ -0,0 +1,113 @@ + 'Metatag core term tests with i18n', + 'description' => 'Test Metatag taxonomy config integration with the i18n module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'i18n'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + // Need the i18n and i18n_strings modules. + $modules[] = 'i18n'; + $modules[] = 'i18n_string'; + + // Enable all of the modules that are needed. + parent::setUp($modules); + + // Add more locales. + $this->setupLocales(); + + // Set up the locales. + $perms = array( + 'administer languages', + 'translate interface', + // From i18n. + 'translate admin strings', + 'translate user-defined strings', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Reload the translations. + drupal_flush_all_caches(); + module_load_include('admin.inc', 'i18n_string'); + i18n_string_refresh_group('metatag'); + } + + /** + * Test translations of the main taxonomy term configuration. + */ + public function testI18nTermConfig() { + // Plan out the different translation string tests. + $string_en = 'It is a term page!'; + $config_name = 'metatag_config:taxonomy_term:title'; + + // Confirm the translation page exists and has some Metatag strings. + $this->searchTranslationPage('', $config_name); + + // Confirm the string is not present yet. + $this->searchTranslationPage($string_en, $config_name, FALSE); + + // Load the meta tags. + $instance = 'taxonomy_term'; + $config = metatag_config_load($instance); + + // Set something specific as the homepage. + $config->config['title']['value'] = $string_en; + metatag_config_save($config); + + // Confirm the string is present now. + $this->searchTranslationPage($string_en, $config_name); + + // Get the translation string lid for the term's title. + $lid = $this->getTranslationLidByContext($config_name); + $this->assertNotEqual($lid, 0, 'Found the locales_source string for the taxonomy term title tag.'); + } + + /** + * Test translations of the 'tags' vocabulary configuration. + */ + public function testI18nTermTagsConfig() { + // Plan out the different translation string tests. + $string_en = 'It is a taxonomy term Tags page!'; + $config_name = 'metatag_config:taxonomy_term:tags:title'; + + // Confirm the translation page exists and has some Metatag strings. + $this->searchTranslationPage('', $config_name); + + // Confirm the string is not present yet. + $this->searchTranslationPage($string_en, $config_name, FALSE); + + // Create a new config object for the taxonomy_term:tags structure. + $config = new StdClass(); + $config->instance = 'taxonomy_term:tags'; + + // Set an example tag. + $config->config['title']['value'] = $string_en; + metatag_config_save($config); + + // Confirm the string is present now. + $this->searchTranslationPage($string_en, $config_name); + + // Get the translation string lid for the term's title. + $lid = $this->getTranslationLidByContext($config_name); + $this->assertNotEqual($lid, 0, 'Found the locales_source string for the taxonomy term title tag.'); + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.unit.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.unit.test index 3049e69a2..48a16885b 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.unit.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.unit.test @@ -13,6 +13,7 @@ class MetatagCoreUnitTest extends MetatagTestHelper { 'name' => 'Metatag unit tests', 'description' => 'Test basic meta tag functionality for entities.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), ); } diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.user.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.user.test index 3f42c80a3..21e7b370e 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.user.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.user.test @@ -13,6 +13,7 @@ class MetatagCoreUserTest extends MetatagTestHelper { 'name' => 'Metatag core tests for users', 'description' => 'Test Metatag edit functionality for users.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), ); } @@ -38,7 +39,7 @@ class MetatagCoreUserTest extends MetatagTestHelper { // Submit the form with some values. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[user:name]', + 'metatags[und][abstract][value]' => '[user:name]', ), t('Save')); $this->assertResponse(200); @@ -58,7 +59,7 @@ class MetatagCoreUserTest extends MetatagTestHelper { // Verify that it's possible to submit values to the form. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[user:name] ponies', + 'metatags[und][abstract][value]' => '[user:name] ponies', ), t('Save')); $this->assertResponse(200); @@ -76,7 +77,7 @@ class MetatagCoreUserTest extends MetatagTestHelper { // Only the non-default values are stored. $expected = array( 'und' => array( - 'dcterms.subject' => array( + 'abstract' => array( 'value' => '[user:name] ponies', ), ), @@ -87,21 +88,4 @@ class MetatagCoreUserTest extends MetatagTestHelper { $this->assertUserEntityTags($this->adminUser); } - /** - * Verify a user entity's meta tags load correctly. - * - * @param object $user - * A user object that is to be tested. - */ - function assertUserEntityTags($user) { - // Load the user's profile page. - $this->drupalGet('user/' . $user->uid); - $this->assertResponse(200); - - // Verify the title is using the custom default for this vocabulary. - $xpath = $this->xpath("//meta[@name='dcterms.subject']"); - $this->assertEqual(count($xpath), 1, 'Exactly one dcterms.subject meta tag found.'); - $this->assertEqual($xpath[0]['content'], $user->name . " ponies"); - } - } diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_config.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_config.test index 95d0d17d2..1215fc1c1 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_config.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_config.test @@ -13,6 +13,7 @@ class MetatagCoreWithI18nConfigTest extends MetatagTestHelper { 'name' => 'Metatag core tests with i18n: configs', 'description' => 'Test Metatag configuration integration with the i18n module.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'i18n'), ); } @@ -27,6 +28,9 @@ class MetatagCoreWithI18nConfigTest extends MetatagTestHelper { // Enable all of the modules that are needed. parent::setUp($modules); + // Add more locales. + $this->setupLocales(); + // Set up the locales. $perms = array( 'administer languages', @@ -40,7 +44,9 @@ class MetatagCoreWithI18nConfigTest extends MetatagTestHelper { 'administer nodes', ); $this->adminUser = $this->createAdminUser($perms); - $this->setupLocales(); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); // Reload the translations. drupal_flush_all_caches(); diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_disabled.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_disabled.test index 82da280a6..9cfe348a3 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_disabled.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_disabled.test @@ -13,6 +13,7 @@ class MetatagCoreWithI18nDisabledTest extends MetatagTestHelper { 'name' => 'Metatag core tests with i18n disabled', 'description' => 'Test Metatag integration with the i18n module enabled but the integration disabled.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'i18n'), ); } @@ -27,6 +28,9 @@ class MetatagCoreWithI18nDisabledTest extends MetatagTestHelper { // Enable all of the modules that are needed. parent::setUp($modules); + // Add more locales. + $this->setupLocales(); + // Set up the locales. $perms = array( 'administer languages', @@ -36,7 +40,9 @@ class MetatagCoreWithI18nDisabledTest extends MetatagTestHelper { 'translate user-defined strings', ); $this->adminUser = $this->createAdminUser($perms); - $this->setupLocales(); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); // Turn off i18n integration. variable_set('metatag_i18n_disabled', TRUE); diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_output.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_output.test index e5a227d41..23d5bbd76 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_output.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_output.test @@ -13,6 +13,7 @@ class MetatagCoreWithI18nOutputTest extends MetatagTestHelper { 'name' => 'Metatag core tests with i18n: output', 'description' => 'Test Metatag integration with the i18n module.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'i18n'), ); } @@ -27,6 +28,9 @@ class MetatagCoreWithI18nOutputTest extends MetatagTestHelper { // Enable all of the modules that are needed. parent::setUp($modules); + // Add more locales. + $this->setupLocales(); + // Set up the locales. $perms = array( 'administer languages', @@ -36,7 +40,9 @@ class MetatagCoreWithI18nOutputTest extends MetatagTestHelper { 'translate user-defined strings', ); $this->adminUser = $this->createAdminUser($perms); - $this->setupLocales(); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); } /** diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_me.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_me.test new file mode 100644 index 000000000..93c1a8e3e --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_me.test @@ -0,0 +1,69 @@ + 'Metatag core tests with Me', + 'description' => 'Test Metatag integration with the Me module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'me'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'me'; + + parent::setUp($modules); + } + + /** + * Make sure the /user/me path doesn't load any meta tags. + */ + public function testMePath() { + // Create an admin user and log them in. + if (!isset($this->adminUser)) { + $this->adminUser = $this->createAdminUser(); + } + $this->drupalLogin($this->adminUser); + + // Load the user's profile page. + // Load the 'me' page. + $this->drupalGet('user/' . $this->adminUser->uid); + $this->assertResponse(200); + + // Look for some meta tags that should exist. + $xpath = $this->xpath("//meta[@name='generator']"); + $this->assertEqual(count($xpath), 1, 'Exactly one generator meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'Drupal 7 (http://drupal.org)'); + $xpath = $this->xpath("//link[@rel='canonical']"); + $this->assertEqual(count($xpath), 1, 'Exactly one canonical meta tag found.'); + $this->assertEqual($xpath[0]['href'], url('user/' . $this->adminUser->uid, array('absolute' => TRUE))); + $xpath = $this->xpath("//link[@rel='shortlink']"); + $this->assertEqual(count($xpath), 1, 'Exactly one shortlink meta tag found.'); + $this->assertEqual($xpath[0]['href'], url('user/' . $this->adminUser->uid, array('absolute' => TRUE))); + + // Load the 'me' page. + $this->drupalGet('user/me'); + $this->assertResponse(200); + + // Confirm the meta tags defined above don't exist. + $xpath = $this->xpath("//meta[@name='generator']"); + $this->assertEqual(count($xpath), 0, 'Did not find the generator meta tag.'); + $xpath = $this->xpath("//link[@rel='canonical']"); + $this->assertEqual(count($xpath), 0, 'Did not find the canonical meta tag.'); + $xpath = $this->xpath("//link[@rel='shortlink']"); + $this->assertEqual(count($xpath), 0, 'Did not find the shortlink meta tag.'); + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_media.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_media.test index 9356eb37b..46ee287f8 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_media.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_media.test @@ -14,6 +14,7 @@ class MetatagCoreWithMediaTest extends MetatagTestHelper { 'name' => 'Metatag core tests with Media', 'description' => 'Test Metatag integration with the Media module.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'file_entity', 'media'), ); } diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_panels.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_panels.test index 8fa5fbcb0..edd87fffa 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_panels.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_panels.test @@ -14,6 +14,7 @@ class MetatagCoreWithPanelsTest extends MetatagTestHelper { 'name' => 'Metatag core tests with Panels', 'description' => 'Test Metatag integration with the Panels module.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'panels', 'page_manager'), ); } @@ -51,6 +52,8 @@ class MetatagCoreWithPanelsTest extends MetatagTestHelper { 'administer page manager', ); $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. $this->drupalLogin($this->adminUser); // Create a test node. @@ -65,7 +68,7 @@ class MetatagCoreWithPanelsTest extends MetatagTestHelper { // Verify that it's possible to submit values to the form. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[node:title] ponies', + 'metatags[und][abstract][value]' => '[node:title] ponies', 'title' => 'Who likes magic', ), t('Save')); $this->assertResponse(200); @@ -148,8 +151,8 @@ class MetatagCoreWithPanelsTest extends MetatagTestHelper { } // Verify the title is using the custom default for this content type. - $xpath = $this->xpath("//meta[@name='dcterms.subject']"); - $this->assertEqual(count($xpath), 1, 'Exactly one dcterms.subject meta tag found.'); + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); $this->assertEqual($xpath[0]['content'], 'Who likes magic ponies'); } diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_profile2.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_profile2.test index b3077e126..b1479c193 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_profile2.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_profile2.test @@ -16,6 +16,7 @@ class MetatagCoreWithProfile2Test extends MetatagCoreUserTest { 'name' => 'Metatag core tests with Profile2', 'description' => 'Test Metatag integration with the Profile2 module.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'profile2'), ); } @@ -56,7 +57,7 @@ class MetatagCoreWithProfile2Test extends MetatagCoreUserTest { // Verify that it's possible to submit values to the form. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[user:name] ponies', + 'metatags[und][abstract][value]' => '[user:name] ponies', ), t('Save')); $this->assertResponse(200); @@ -109,7 +110,7 @@ class MetatagCoreWithProfile2Test extends MetatagCoreUserTest { // Verify that it's possible to submit values to the form. $edit = array( - 'metatags[und][dcterms.subject][value]' => '[user:name] ponies', + 'metatags[und][abstract][value]' => '[user:name] ponies', ); $this->drupalPost(NULL, $edit, t('Save')); $this->assertResponse(200); diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_search_api.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_search_api.test index d8ec01e6c..452625d32 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_search_api.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_search_api.test @@ -38,6 +38,7 @@ class MetatagCoreWithSearchAPITest extends MetatagTestHelper { 'name' => 'Metatag Search API tests', 'description' => 'Tests the Metatag Search API integration.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'entity', 'search_api'), ); } @@ -63,6 +64,8 @@ class MetatagCoreWithSearchAPITest extends MetatagTestHelper { 'administer search_api', ); $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. $this->drupalLogin($this->adminUser); // Create an index. diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_views.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_views.test index 00d5c3c94..fb84ed876 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_views.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_views.test @@ -14,6 +14,7 @@ class MetatagCoreWithViewsTest extends MetatagTestHelper { 'name' => 'Metatag core tests with Views', 'description' => 'Test Metatag integration with the Views module.', 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'views'), ); } @@ -58,6 +59,8 @@ class MetatagCoreWithViewsTest extends MetatagTestHelper { 'administer views', ); $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. $this->drupalLogin($this->adminUser); // Load the "add default configuration" page. @@ -78,9 +81,7 @@ class MetatagCoreWithViewsTest extends MetatagTestHelper { // Submit the form with some values. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[term:name]', - 'metatags[und][dcterms.format][value]' => 'text/html', - 'metatags[und][dcterms.identifier][value]' => '[current-page:url:absolute]', + 'metatags[und][abstract][value]' => '[term:name]', ), t('Save')); $this->assertResponse(200); @@ -102,7 +103,7 @@ class MetatagCoreWithViewsTest extends MetatagTestHelper { // Verify that it's possible to submit values to the form. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[term:name] ponies', + 'metatags[und][abstract][value]' => '[term:name] ponies', 'name' => $term_name, 'path[alias]' => $term_path, ), t('Save')); @@ -133,7 +134,7 @@ class MetatagCoreWithViewsTest extends MetatagTestHelper { $this->assertResponse(200); $vars = variable_get('views_defaults'); - $this->verbose(print_r($vars, TRUE)); + $this->verbose($vars); $this->assertFalse($vars['taxonomy_term'], 'Taxonomy term page is enabled.'); // Load the page again. @@ -166,7 +167,7 @@ class MetatagCoreWithViewsTest extends MetatagTestHelper { // Only the non-default values are stored. $expected = array( 'und' => array( - 'dcterms.subject' => array( + 'abstract' => array( 'value' => '[term:name] ponies', ), ), @@ -180,8 +181,8 @@ class MetatagCoreWithViewsTest extends MetatagTestHelper { } // Verify the title is using the custom default for this vocabulary. - $xpath = $this->xpath("//meta[@name='dcterms.subject']"); - $this->assertEqual(count($xpath), 1, 'Exactly one dcterms.subject meta tag found.'); + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); $this->assertEqual($xpath[0]['content'], "Who likes magic ponies"); } diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.xss.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.xss.test new file mode 100644 index 000000000..595812e9c --- /dev/null +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.xss.test @@ -0,0 +1,195 @@ +alert("xss");'; + + /** + * String that causes an alert when metatags aren't filtered for xss. + * + * @var string + */ + private $xssString = '"> 'Metatag core tests for XSS.', + 'description' => 'Test Metatag for XSS vulnerabilities.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + parent::setUp($modules); + + $content_type = 'page'; + + // Create an admin user and log them in. + $perms = array( + // Needed for the content type. + 'create ' . $content_type . ' content', + 'delete any ' . $content_type . ' content', + 'edit any ' . $content_type . ' content', + + // This permission is required in order to create new revisions. + 'administer nodes', + ); + $this->adminUser = $this->createAdminUser($perms); + $this->drupalLogin($this->adminUser); + } + + /** + * Verify XSS injected in global Node config is not rendered. + */ + function testXssMetatagConfig() { + // Submit the form with some example XSS values. + $this->drupalGet('admin/config/search/metatags/config/global'); + $this->assertResponse(200); + $edit = array( + 'metatags[und][title][value]' => $this->xssTitleString, + 'metatags[und][abstract][value]' => $this->xssString, + 'metatags[und][image_src][value]' => $this->xssImageString, + ); + $this->drupalPost(NULL, $edit, t('Save')); + $this->assertResponse(200); + + // Use front page to test. + $this->drupalGet(''); + + // Verify title is clean. + $this->assertNoTitle($this->xssTitleString); + $this->assertNoRaw($this->xssTitleString); + + // Verify the abstract is clean. + $this->assertRaw($this->escapedXssTag); + $this->assertNoRaw($this->xssString); + + // Verify the image_src is clean. + $this->assertRaw($this->escapedXssImageTag); + $this->assertNoRaw($this->xssImageString); + } + + /** + * Verify XSS injected in the entity metatag override field is not rendered. + */ + public function testXssEntityOverride() { + $title = 'Test Page'; + + // Load a page node. + $this->drupalGet('node/add/page'); + $this->assertResponse(200); + + // Submit the node with some example XSS values. + $edit = array( + 'title' => $title, + 'metatags[und][title][value]' => $this->xssTitleString, + 'metatags[und][description][value]' => $this->xssString, + 'metatags[und][abstract][value]' => $this->xssString, + ); + $this->drupalPost(NULL, $edit, t('Save')); + + // Verify the page saved. + $this->assertResponse(200); + $this->assertText(t('Basic page @title has been created.', array('@title' => $title))); + + // Verify title is not the injected string and thus cleaned. + $this->assertNoTitle($this->xssTitleString); + $this->assertNoRaw($this->xssTitleString); + + // Verify the description and abstract are clean. + $this->assertRaw($this->escapedXssTag); + $this->assertNoRaw($this->xssString); + } + + /** + * Verify XSS injected in the entity titles are not rendered. + */ + public function testXssEntityTitle() { + // Load a page node. + $this->drupalGet('node/add/page'); + $this->assertResponse(200); + + // Submit the node with some example XSS values. + $edit = array( + 'title' => $this->xssTitleString, + 'body[und][0][value]' => 'hello world', + ); + $this->drupalPost(NULL, $edit, t('Save')); + + // Verify the page saved. + $this->assertResponse(200); + $this->assertText(t('has been created.')); + + // Verify title is not the injected string and thus cleaned. + $this->assertNoRaw($this->xssTitleString); + } + + /** + * Verify XSS injected in the body field is not rendered. + */ + public function testXssEntityBody() { + $title = 'Hello World'; + + // Load a page node. + $this->drupalGet('node/add/page'); + $this->assertResponse(200); + + // Submit the node with a test body value. + $edit = array( + 'title' => $title, + 'body[und][0][value]' => $this->xssString, + ); + $this->drupalPost(NULL, $edit, t('Save')); + + // Verify the page saved. + $this->assertResponse(200); + $this->assertText(t('Basic page @title has been created.', array('@title' => $title))); + + // Verify body field is clean. + $this->assertNoRaw($this->xssString); + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag_search_test.info b/www7/sites/all/modules/contrib/metatag/tests/metatag_search_test.info index b3161cc83..d8ed4a31c 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag_search_test.info +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag_search_test.info @@ -8,9 +8,9 @@ dependencies[] = search_api hidden = TRUE -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag_test.info b/www7/sites/all/modules/contrib/metatag/tests/metatag_test.info index 279c1ceaf..664065ecc 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag_test.info +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag_test.info @@ -7,9 +7,9 @@ hidden = TRUE dependencies[] = metatag -; Information added by Drupal.org packaging script on 2016-06-30 -version = "7.x-1.17" +; Information added by Drupal.org packaging script on 2016-11-30 +version = "7.x-1.18" core = "7.x" project = "metatag" -datestamp = "1467306248" +datestamp = "1480524802" From 08f1ac2d18326654819d6a42daf8eda9d456a738 Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Sat, 10 Dec 2016 11:46:07 +0100 Subject: [PATCH 07/16] Update ctools to 7.x-1.12 --- .../ctools/bulk_export/bulk_export.info | 6 +- .../all/modules/contrib/ctools/css/button.css | 1 + .../all/modules/contrib/ctools/ctools.api.php | 5 +- .../all/modules/contrib/ctools/ctools.info | 14 ++- .../ctools_access_ruleset.info | 6 +- .../ctools_ajax_sample.info | 6 +- .../ctools_custom_content.info | 6 +- .../ctools_plugin_example.info | 6 +- .../contrib/ctools/drush/ctools.drush.inc | 2 +- .../contrib/ctools/includes/content.inc | 10 +- .../ctools/includes/context-access-admin.inc | 1 - .../contrib/ctools/includes/context.inc | 17 +-- .../contrib/ctools/includes/plugins.inc | 38 ++++--- .../modules/contrib/ctools/includes/uuid.inc | 4 +- .../page_manager/help/getting-started.html | 2 +- .../page_manager/page_manager.admin.inc | 6 ++ .../ctools/page_manager/page_manager.info | 6 +- .../page_manager/plugins/tasks/page.admin.inc | 9 ++ .../ctools/plugins/arguments/terms.inc | 1 + .../plugins/content_types/block/block.inc | 6 +- .../node_context/node_book_menu.inc | 101 ++++++++++++++++++ .../node_context/node_book_nav.inc | 12 +-- .../contrib/ctools/stylizer/stylizer.info | 6 +- .../contrib/ctools/term_depth/term_depth.info | 6 +- .../modules/contrib/ctools/tests/context.test | 26 ++++- .../all/modules/contrib/ctools/tests/css.test | 2 +- .../contrib/ctools/tests/css_cache.test | 2 +- .../contrib/ctools/tests/ctools.plugins.test | 2 +- .../ctools_export_test/ctools_export.test | 2 +- .../ctools_export_test.info | 6 +- .../ctools/tests/ctools_plugin_test.info | 6 +- .../contrib/ctools/tests/math_expression.test | 2 +- .../ctools/tests/math_expression_stack.test | 2 +- .../contrib/ctools/tests/object_cache.test | 2 +- .../ctools/views_content/views_content.info | 6 +- 35 files changed, 252 insertions(+), 83 deletions(-) create mode 100644 www7/sites/all/modules/contrib/ctools/plugins/content_types/node_context/node_book_menu.inc diff --git a/www7/sites/all/modules/contrib/ctools/bulk_export/bulk_export.info b/www7/sites/all/modules/contrib/ctools/bulk_export/bulk_export.info index d9e4dfc8a..22dc566ad 100644 --- a/www7/sites/all/modules/contrib/ctools/bulk_export/bulk_export.info +++ b/www7/sites/all/modules/contrib/ctools/bulk_export/bulk_export.info @@ -6,9 +6,9 @@ package = Chaos tool suite version = CTOOLS_MODULE_VERSION -; Information added by Drupal.org packaging script on 2016-10-16 -version = "7.x-1.11" +; Information added by Drupal.org packaging script on 2016-11-22 +version = "7.x-1.12" core = "7.x" project = "ctools" -datestamp = "1476581654" +datestamp = "1479787162" diff --git a/www7/sites/all/modules/contrib/ctools/css/button.css b/www7/sites/all/modules/contrib/ctools/css/button.css index 15e484be3..ead8f8ef8 100644 --- a/www7/sites/all/modules/contrib/ctools/css/button.css +++ b/www7/sites/all/modules/contrib/ctools/css/button.css @@ -19,6 +19,7 @@ .ctools-button-processed .ctools-content ul { list-style-image: none; list-style-type: none; + margin-left: 0; } .ctools-button-processed li { diff --git a/www7/sites/all/modules/contrib/ctools/ctools.api.php b/www7/sites/all/modules/contrib/ctools/ctools.api.php index a7ab78395..f328a7ca7 100644 --- a/www7/sites/all/modules/contrib/ctools/ctools.api.php +++ b/www7/sites/all/modules/contrib/ctools/ctools.api.php @@ -199,7 +199,10 @@ function hook_ctools_render_alter(&$info, &$page, &$context) { * or categories or to rename content on specific sites. */ function hook_ctools_content_subtype_alter($subtype, $plugin) { - $subtype['render last'] = TRUE; + // Force a particular subtype of a particular plugin to render last. + if ($plugin['module'] == 'some_plugin_module' && $plugin['name'] == 'some_plugin_name' && $subtype['subtype_id'] == 'my_subtype_id') { + $subtype['render last'] = TRUE; + } } /** diff --git a/www7/sites/all/modules/contrib/ctools/ctools.info b/www7/sites/all/modules/contrib/ctools/ctools.info index bdd3794ca..3a2d031ec 100644 --- a/www7/sites/all/modules/contrib/ctools/ctools.info +++ b/www7/sites/all/modules/contrib/ctools/ctools.info @@ -6,11 +6,19 @@ files[] = includes/context.inc files[] = includes/css-cache.inc files[] = includes/math-expr.inc files[] = includes/stylizer.inc + +; Tests. +files[] = tests/context.test +files[] = tests/css.test files[] = tests/css_cache.test +files[] = tests/ctools.plugins.test +files[] = tests/math_expression.test +files[] = tests/math_expression_stack.test +files[] = tests/object_cache.test -; Information added by Drupal.org packaging script on 2016-10-16 -version = "7.x-1.11" +; Information added by Drupal.org packaging script on 2016-11-22 +version = "7.x-1.12" core = "7.x" project = "ctools" -datestamp = "1476581654" +datestamp = "1479787162" diff --git a/www7/sites/all/modules/contrib/ctools/ctools_access_ruleset/ctools_access_ruleset.info b/www7/sites/all/modules/contrib/ctools/ctools_access_ruleset/ctools_access_ruleset.info index 8d5a77c4f..bfa178341 100644 --- a/www7/sites/all/modules/contrib/ctools/ctools_access_ruleset/ctools_access_ruleset.info +++ b/www7/sites/all/modules/contrib/ctools/ctools_access_ruleset/ctools_access_ruleset.info @@ -5,9 +5,9 @@ package = Chaos tool suite version = CTOOLS_MODULE_VERSION dependencies[] = ctools -; Information added by Drupal.org packaging script on 2016-10-16 -version = "7.x-1.11" +; Information added by Drupal.org packaging script on 2016-11-22 +version = "7.x-1.12" core = "7.x" project = "ctools" -datestamp = "1476581654" +datestamp = "1479787162" diff --git a/www7/sites/all/modules/contrib/ctools/ctools_ajax_sample/ctools_ajax_sample.info b/www7/sites/all/modules/contrib/ctools/ctools_ajax_sample/ctools_ajax_sample.info index dcb634d71..52126d517 100644 --- a/www7/sites/all/modules/contrib/ctools/ctools_ajax_sample/ctools_ajax_sample.info +++ b/www7/sites/all/modules/contrib/ctools/ctools_ajax_sample/ctools_ajax_sample.info @@ -5,9 +5,9 @@ version = CTOOLS_MODULE_VERSION dependencies[] = ctools core = 7.x -; Information added by Drupal.org packaging script on 2016-10-16 -version = "7.x-1.11" +; Information added by Drupal.org packaging script on 2016-11-22 +version = "7.x-1.12" core = "7.x" project = "ctools" -datestamp = "1476581654" +datestamp = "1479787162" diff --git a/www7/sites/all/modules/contrib/ctools/ctools_custom_content/ctools_custom_content.info b/www7/sites/all/modules/contrib/ctools/ctools_custom_content/ctools_custom_content.info index 715e4539f..ee2d2d1e8 100644 --- a/www7/sites/all/modules/contrib/ctools/ctools_custom_content/ctools_custom_content.info +++ b/www7/sites/all/modules/contrib/ctools/ctools_custom_content/ctools_custom_content.info @@ -5,9 +5,9 @@ package = Chaos tool suite version = CTOOLS_MODULE_VERSION dependencies[] = ctools -; Information added by Drupal.org packaging script on 2016-10-16 -version = "7.x-1.11" +; Information added by Drupal.org packaging script on 2016-11-22 +version = "7.x-1.12" core = "7.x" project = "ctools" -datestamp = "1476581654" +datestamp = "1479787162" diff --git a/www7/sites/all/modules/contrib/ctools/ctools_plugin_example/ctools_plugin_example.info b/www7/sites/all/modules/contrib/ctools/ctools_plugin_example/ctools_plugin_example.info index 97b3ebfe6..337e699d2 100644 --- a/www7/sites/all/modules/contrib/ctools/ctools_plugin_example/ctools_plugin_example.info +++ b/www7/sites/all/modules/contrib/ctools/ctools_plugin_example/ctools_plugin_example.info @@ -8,9 +8,9 @@ dependencies[] = page_manager dependencies[] = advanced_help core = 7.x -; Information added by Drupal.org packaging script on 2016-10-16 -version = "7.x-1.11" +; Information added by Drupal.org packaging script on 2016-11-22 +version = "7.x-1.12" core = "7.x" project = "ctools" -datestamp = "1476581654" +datestamp = "1479787162" diff --git a/www7/sites/all/modules/contrib/ctools/drush/ctools.drush.inc b/www7/sites/all/modules/contrib/ctools/drush/ctools.drush.inc index 1862dbe94..0342c7347 100644 --- a/www7/sites/all/modules/contrib/ctools/drush/ctools.drush.inc +++ b/www7/sites/all/modules/contrib/ctools/drush/ctools.drush.inc @@ -64,7 +64,7 @@ function ctools_drush_command() { 'machine names' => 'Space separated list of exportables you want to view.', ), 'options' => array( - 'indent' => 'The string to use for indentation when dispalying the exportable export code. Defaults to \'\'.', + 'indent' => 'The string to use for indentation when displaying the exportable export code. Defaults to \'\'.', 'no-colour' => 'Remove any colour formatting from export string output. Ideal if you are sending the output of this command to a file.', 'module' => $module_text, 'all' => $all_text, diff --git a/www7/sites/all/modules/contrib/ctools/includes/content.inc b/www7/sites/all/modules/contrib/ctools/includes/content.inc index ae1c6073d..6490d8d57 100644 --- a/www7/sites/all/modules/contrib/ctools/includes/content.inc +++ b/www7/sites/all/modules/contrib/ctools/includes/content.inc @@ -155,6 +155,11 @@ function ctools_content_get_subtypes($type) { // Walk through the subtypes and ensure minimal settings are // retained. foreach ($subtypes as $id => $subtype) { + // Ensure that the 'subtype_id' value exists. + if (!isset($subtype['subtype_id'])) { + $subtype['subtype_id'] = $id; + } + // Use exact name since this is a modify by reference. ctools_content_prepare_subtype($subtypes[$id], $plugin); } @@ -217,6 +222,7 @@ function ctools_content_prepare_subtype(&$subtype, $plugin) { } } + // Trigger hook_ctools_content_subtype_alter(). drupal_alter('ctools_content_subtype', $subtype, $plugin); } @@ -241,8 +247,8 @@ function ctools_content_prepare_subtype(&$subtype, $plugin) { * Any incoming content, if this display is a wrapper. * * @return - * The content as rendered by the plugin. This content should be an array - * with the following possible keys: + * The content as rendered by the plugin, or NULL. + * This content should be an object with the following possible properties: * - title: The safe to render title of the content. * - title_heading: The title heading. * - content: The safe to render HTML content. diff --git a/www7/sites/all/modules/contrib/ctools/includes/context-access-admin.inc b/www7/sites/all/modules/contrib/ctools/includes/context-access-admin.inc index 76643cf62..ea2a7c816 100644 --- a/www7/sites/all/modules/contrib/ctools/includes/context-access-admin.inc +++ b/www7/sites/all/modules/contrib/ctools/includes/context-access-admin.inc @@ -367,7 +367,6 @@ function ctools_access_ajax_edit($fragment = NULL, $id = NULL) { 'contexts' => $contexts, 'title' => t('Edit criteria'), 'ajax' => TRUE, - 'ajax' => TRUE, 'modal' => TRUE, 'modal return' => TRUE, ); diff --git a/www7/sites/all/modules/contrib/ctools/includes/context.inc b/www7/sites/all/modules/contrib/ctools/includes/context.inc index 8b6d6032f..a532f6575 100644 --- a/www7/sites/all/modules/contrib/ctools/includes/context.inc +++ b/www7/sites/all/modules/contrib/ctools/includes/context.inc @@ -676,14 +676,19 @@ function ctools_context_keyword_substitute($string, $keywords, $contexts, $conve } } - if (empty($context_keywords[$context]) || !empty($context_keywords[$context]->empty)) { - $keywords['%' . $keyword] = ''; - } - else if (!empty($converter)) { - $keywords['%' . $keyword] = ctools_context_convert_context($context_keywords[$context], $converter, $converter_options); + if (!isset($context_keywords[$context])) { + $keywords['%' . $keyword] = '%' . $keyword; } else { - $keywords['%' . $keyword] = $context_keywords[$keyword]->title; + if (empty($context_keywords[$context]) || !empty($context_keywords[$context]->empty)) { + $keywords['%' . $keyword] = ''; + } + else if (!empty($converter)) { + $keywords['%' . $keyword] = ctools_context_convert_context($context_keywords[$context], $converter, $converter_options); + } + else { + $keywords['%' . $keyword] = $context_keywords[$keyword]->title; + } } } } diff --git a/www7/sites/all/modules/contrib/ctools/includes/plugins.inc b/www7/sites/all/modules/contrib/ctools/includes/plugins.inc index 65f366290..d524f7465 100644 --- a/www7/sites/all/modules/contrib/ctools/includes/plugins.inc +++ b/www7/sites/all/modules/contrib/ctools/includes/plugins.inc @@ -200,18 +200,18 @@ function ctools_plugin_api_get_hook($owner, $api) { /** * Fetch a group of plugins by name. * - * @param $module - * The name of the module that utilizes this plugin system. It will be - * used to call hook_ctools_plugin_$plugin() to get more data about the plugin. - * @param $type + * @param string $module + * The name of the module that utilizes this plugin system. It will be used to + * get more data about the plugin as defined on hook_ctools_plugin_type(). + * @param string $type * The type identifier of the plugin. - * @param $id + * @param string $id * If specified, return only information about plugin with this identifier. * The system will do its utmost to load only plugins with this id. * - * @return - * An array of information arrays about the plugins received. The contents - * of the array are specific to the plugin. + * @return array + * An array of information arrays about the plugins received. The contents of + * the array are specific to the plugin. */ function ctools_get_plugins($module, $type, $id = NULL) { // Store local caches of plugins and plugin info so we don't have to do full @@ -224,10 +224,14 @@ function ctools_get_plugins($module, $type, $id = NULL) { $info = ctools_plugin_get_plugin_type_info(); - // Bail out noisily if an invalid module/type combination is requested. if (!isset($info[$module][$type])) { - watchdog('ctools', 'Invalid plugin module/type combination requested: module @module and type @type', array('@module' => $module, '@type' => $type), WATCHDOG_ERROR); - return array(); + // If we don't find the plugin we attempt a cache rebuild before bailing out + $info = ctools_plugin_get_plugin_type_info(TRUE); + // Bail out noisily if an invalid module/type combination is requested. + if (!isset($info[$module][$type])) { + watchdog('ctools', 'Invalid plugin module/type combination requested: module @module and type @type', array('@module' => $module, '@type' => $type), WATCHDOG_ERROR); + return array(); + } } // Make sure our plugins array is populated. @@ -235,8 +239,8 @@ function ctools_get_plugins($module, $type, $id = NULL) { $plugins[$module][$type] = array(); } - // Attempt to shortcut this whole piece of code if we already have - // the requested plugin: + // Attempt to shortcut this whole piece of code if we already have the + // requested plugin: if ($id && array_key_exists($id, $plugins[$module][$type])) { return $plugins[$module][$type][$id]; } @@ -271,8 +275,8 @@ function ctools_get_plugins($module, $type, $id = NULL) { $plugins[$module][$type] = ctools_plugin_load_hooks($info[$module][$type]); } - // Then see if we should load all files. We only do this if we - // want a list of all plugins or there was a cache miss. + // Then see if we should load all files. We only do this if we want a list of + // all plugins or there was a cache miss. if (empty($setup[$module][$type]) && ($build_cache || !$id)) { $setup[$module][$type] = TRUE; $plugins[$module][$type] = array_merge($plugins[$module][$type], ctools_plugin_load_includes($info[$module][$type])); @@ -296,8 +300,8 @@ function ctools_get_plugins($module, $type, $id = NULL) { } - // If we were told earlier that this is cacheable and the cache was - // empty, give something back. + // If we were told earlier that this is cacheable and the cache was empty, + // give something back. if ($build_cache) { cache_set("plugins:$module:$type", $plugins[$module][$type], $info[$module][$type]['cache table']); } diff --git a/www7/sites/all/modules/contrib/ctools/includes/uuid.inc b/www7/sites/all/modules/contrib/ctools/includes/uuid.inc index 6e4c42c32..13897f1fd 100644 --- a/www7/sites/all/modules/contrib/ctools/includes/uuid.inc +++ b/www7/sites/all/modules/contrib/ctools/includes/uuid.inc @@ -9,7 +9,9 @@ /** * Pattern for detecting a valid UUID. */ -define('UUID_PATTERN', '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}'); +if (!defined('UUID_PATTERN')) { + define('UUID_PATTERN', '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}'); +} /** * Generates a UUID using the Windows internal GUID generator. diff --git a/www7/sites/all/modules/contrib/ctools/page_manager/help/getting-started.html b/www7/sites/all/modules/contrib/ctools/page_manager/help/getting-started.html index 4e4f24ae8..6a75a3706 100644 --- a/www7/sites/all/modules/contrib/ctools/page_manager/help/getting-started.html +++ b/www7/sites/all/modules/contrib/ctools/page_manager/help/getting-started.html @@ -4,7 +4,7 @@ This is a quick summary:
      -
    • Visit administer >> site building >> pages to get to the primary page manager interface.
    • +
    • Visit administer >> structure >> pages to get to the primary page manager interface.
    • You can add custom pages for your basic landing pages, front pages, whatever you like for normal content display.
    • You can use the system pages to create finer control of how taxonomy vocabularies, nodes and user profiles are displayed.
    • When you add your first custom page, do not bother with the optional features. You will not need these until you get to more advanced tasks.
    • diff --git a/www7/sites/all/modules/contrib/ctools/page_manager/page_manager.admin.inc b/www7/sites/all/modules/contrib/ctools/page_manager/page_manager.admin.inc index 2a78fd9fb..95d12255b 100644 --- a/www7/sites/all/modules/contrib/ctools/page_manager/page_manager.admin.inc +++ b/www7/sites/all/modules/contrib/ctools/page_manager/page_manager.admin.inc @@ -1688,6 +1688,12 @@ function page_manager_handler_clone_submit(&$form, &$form_state) { page_manager_handler_add_to_page($form_state['page'], $handler, $form_state['values']['title']); + // Variant is cloned and added to the Page. Ensure the uuids are re-generated. + panels_panel_context_get_display($handler); + if (isset($handler->conf['display']) && method_exists($handler->conf['display'], 'clone_display')) { + $handler->conf['display'] = $handler->conf['display']->clone_display(); + } + $plugin = page_manager_get_task_handler($handler->handler); // It has no forms at all. Add the variant and go to its first operation. $keys = array_keys($plugin['operations']); diff --git a/www7/sites/all/modules/contrib/ctools/page_manager/page_manager.info b/www7/sites/all/modules/contrib/ctools/page_manager/page_manager.info index 944c7976a..9fe2b2f41 100644 --- a/www7/sites/all/modules/contrib/ctools/page_manager/page_manager.info +++ b/www7/sites/all/modules/contrib/ctools/page_manager/page_manager.info @@ -5,9 +5,9 @@ dependencies[] = ctools package = Chaos tool suite version = CTOOLS_MODULE_VERSION -; Information added by Drupal.org packaging script on 2016-10-16 -version = "7.x-1.11" +; Information added by Drupal.org packaging script on 2016-11-22 +version = "7.x-1.12" core = "7.x" project = "ctools" -datestamp = "1476581654" +datestamp = "1479787162" diff --git a/www7/sites/all/modules/contrib/ctools/page_manager/plugins/tasks/page.admin.inc b/www7/sites/all/modules/contrib/ctools/page_manager/plugins/tasks/page.admin.inc index 5cc128341..b2ae8cbe2 100644 --- a/www7/sites/all/modules/contrib/ctools/page_manager/plugins/tasks/page.admin.inc +++ b/www7/sites/all/modules/contrib/ctools/page_manager/plugins/tasks/page.admin.inc @@ -1462,6 +1462,15 @@ function page_manager_page_form_clone_submit(&$form, &$form_state) { $original->path = $form_state['values']['path']; $handlers = !empty($form_state['values']['handlers']) ? $form_state['page']->handlers : FALSE; + // Ensure the handler uuids are re-generated. + if ($handlers) { + foreach ($handlers as &$handler) { + if (isset($handler->conf['display']) && method_exists($handler->conf['display'], 'clone_display')) { + $handler->conf['display'] = $handler->conf['display']->clone_display(); + } + } + } + // Export the handler, which is a fantastic way to clean database IDs out of it. $export = page_manager_page_export($original, $handlers); ob_start(); diff --git a/www7/sites/all/modules/contrib/ctools/plugins/arguments/terms.inc b/www7/sites/all/modules/contrib/ctools/plugins/arguments/terms.inc index 4298ea91d..d31f28de3 100644 --- a/www7/sites/all/modules/contrib/ctools/plugins/arguments/terms.inc +++ b/www7/sites/all/modules/contrib/ctools/plugins/arguments/terms.inc @@ -65,6 +65,7 @@ function ctools_terms_breadcrumb($conf, $context) { return; } + $current = new stdClass(); $current->tid = $context->tids[0]; $breadcrumb = array(); while ($parents = taxonomy_get_parents($current->tid)) { diff --git a/www7/sites/all/modules/contrib/ctools/plugins/content_types/block/block.inc b/www7/sites/all/modules/contrib/ctools/plugins/content_types/block/block.inc index 4d4c31c31..46b02e9e8 100644 --- a/www7/sites/all/modules/contrib/ctools/plugins/content_types/block/block.inc +++ b/www7/sites/all/modules/contrib/ctools/plugins/content_types/block/block.inc @@ -372,9 +372,9 @@ function profile_ctools_block_info($module, $delta, &$info) { } function book_ctools_block_info($module, $delta, &$info) { - // Hide the book navigation block which isn't as rich as what we can - // do with context. - $info = NULL; + $info['title'] = t('Book navigation menu'); + $info['icon'] = 'icon_core_block_menu.png'; + $info['category'] = t('Node'); } function blog_ctools_block_info($module, $delta, &$info) { diff --git a/www7/sites/all/modules/contrib/ctools/plugins/content_types/node_context/node_book_menu.inc b/www7/sites/all/modules/contrib/ctools/plugins/content_types/node_context/node_book_menu.inc new file mode 100644 index 000000000..84497c858 --- /dev/null +++ b/www7/sites/all/modules/contrib/ctools/plugins/content_types/node_context/node_book_menu.inc @@ -0,0 +1,101 @@ + TRUE, + 'title' => t('Book navigation menu'), + 'icon' => '../block/icon_core_block_menu.png', + 'description' => t('The book menu belonging to the current book node.'), + 'required context' => new ctools_context_required(t('Node'), 'node'), + 'category' => t('Node'), + ); +} + +function ctools_node_book_menu_content_type_render($subtype, $conf, $panel_args, $context) { + $node = isset($context->data) ? clone($context->data) : NULL; + $block = new stdClass(); + $block->module = 'book_menu'; + + if ($conf['override_title']) { + $block->title = t($conf['override_title_text']); + } + else { + $block->title = t('Book navigation menu'); + } + if ($node) { + $block->delta = $node->nid; + // TODO: the value is not available somehow?!? + $book_block_mode = isset($conf['book_block_mode']) ? $conf['book_block_mode'] : 'book pages'; + + // Code below is taken from function book_block_view(). + $current_bid = empty($node->book['bid']) ? 0 : $node->book['bid']; + + if ($book_block_mode === 'all pages') { + $block->subject = t('Book navigation'); + $book_menus = array(); + $pseudo_tree = array(0 => array('below' => FALSE)); + foreach (book_get_books() as $book_id => $book) { + if ($book['bid'] === $current_bid) { + // If the current page is a node associated with a book, the menu + // needs to be retrieved. + $book_menus[$book_id] = menu_tree_output(menu_tree_all_data($node->book['menu_name'], $node->book)); + } + else { + // Since we know we will only display a link to the top node, there + // is no reason to run an additional menu tree query for each book. + $book['in_active_trail'] = FALSE; + // Check whether user can access the book link. + $book_node = node_load($book['nid']); + $book['access'] = node_access('view', $book_node); + $pseudo_tree[0]['link'] = $book; + $book_menus[$book_id] = menu_tree_output($pseudo_tree); + } + } + $book_menus['#theme'] = 'book_all_books_block'; + $block->content = $book_menus; + } + elseif ($current_bid) { + // Only display this block when the user is browsing a book. + $select = db_select('node', 'n') + ->fields('n', array('title')) + ->condition('n.nid', $node->book['bid']) + ->addTag('node_access'); + $title = $select->execute()->fetchField(); + // Only show the block if the user has view access for the top-level node. + if ($title) { + $tree = menu_tree_all_data($node->book['menu_name'], $node->book); + // There should only be one element at the top level. + $data = array_shift($tree); + // TODO: subject is not rendered + $block->subject = theme('book_title_link', array('link' => $data['link'])); + $block->content = ($data['below']) ? menu_tree_output($data['below']) : ''; + } + } + } + else { + $block->content = t('Book navigation pager goes here.'); + $block->delta = 'unknown'; + } + + return $block; +} + +function ctools_node_book_menu_content_type_admin_title($subtype, $conf, $context) { + return t('"@s" book navigation pager', array('@s' => $context->identifier)); +} + +function ctools_node_book_menu_content_type_edit_form($form, &$form_state) { + // Grab block form from the book module. + $block_form = book_block_configure($delta = ''); + // TODO: this does not work yet. + // See TODO in: ctools_node_book_menu_content_type_render + if (isset($form_state['input']['book_block_mode'])) { + $block_form['book_block_mode']['#default_value'] = $form_state['input']['book_block_mode']; + } + $form += $block_form; + return $form; +} diff --git a/www7/sites/all/modules/contrib/ctools/plugins/content_types/node_context/node_book_nav.inc b/www7/sites/all/modules/contrib/ctools/plugins/content_types/node_context/node_book_nav.inc index 403db8d11..f0529b431 100644 --- a/www7/sites/all/modules/contrib/ctools/plugins/content_types/node_context/node_book_nav.inc +++ b/www7/sites/all/modules/contrib/ctools/plugins/content_types/node_context/node_book_nav.inc @@ -7,9 +7,9 @@ if (module_exists('book')) { */ $plugin = array( 'single' => TRUE, - 'title' => t('Book navigation'), - 'icon' => 'icon_node.png', - 'description' => t('The navigation menu the book the node belongs to.'), + 'title' => t('Book navigation pager'), + 'icon' => '../block/icon_core_booknavigation.png', + 'description' => t('The navigational pager and sub pages of the current book node.'), 'required context' => new ctools_context_required(t('Node'), 'node'), 'category' => t('Node'), ); @@ -20,13 +20,13 @@ function ctools_node_book_nav_content_type_render($subtype, $conf, $panel_args, $block = new stdClass(); $block->module = 'book_nav'; - $block->title = t('Book navigation'); + $block->title = t('Book navigation pager'); if ($node) { $block->content = isset($node->book) ? theme('book_navigation', array('book_link' => $node->book)) : ''; $block->delta = $node->nid; } else { - $block->content = t('Book navigation goes here.'); + $block->content = t('Book navigation pager goes here.'); $block->delta = 'unknown'; } @@ -34,7 +34,7 @@ function ctools_node_book_nav_content_type_render($subtype, $conf, $panel_args, } function ctools_node_book_nav_content_type_admin_title($subtype, $conf, $context) { - return t('"@s" book navigation', array('@s' => $context->identifier)); + return t('"@s" book navigation pager', array('@s' => $context->identifier)); } function ctools_node_book_nav_content_type_edit_form($form, &$form_state) { diff --git a/www7/sites/all/modules/contrib/ctools/stylizer/stylizer.info b/www7/sites/all/modules/contrib/ctools/stylizer/stylizer.info index 66957648a..79dc89295 100644 --- a/www7/sites/all/modules/contrib/ctools/stylizer/stylizer.info +++ b/www7/sites/all/modules/contrib/ctools/stylizer/stylizer.info @@ -6,9 +6,9 @@ version = CTOOLS_MODULE_VERSION dependencies[] = ctools dependencies[] = color -; Information added by Drupal.org packaging script on 2016-10-16 -version = "7.x-1.11" +; Information added by Drupal.org packaging script on 2016-11-22 +version = "7.x-1.12" core = "7.x" project = "ctools" -datestamp = "1476581654" +datestamp = "1479787162" diff --git a/www7/sites/all/modules/contrib/ctools/term_depth/term_depth.info b/www7/sites/all/modules/contrib/ctools/term_depth/term_depth.info index 91701667f..885a5d0dc 100644 --- a/www7/sites/all/modules/contrib/ctools/term_depth/term_depth.info +++ b/www7/sites/all/modules/contrib/ctools/term_depth/term_depth.info @@ -5,9 +5,9 @@ dependencies[] = ctools package = Chaos tool suite version = CTOOLS_MODULE_VERSION -; Information added by Drupal.org packaging script on 2016-10-16 -version = "7.x-1.11" +; Information added by Drupal.org packaging script on 2016-11-22 +version = "7.x-1.12" core = "7.x" project = "ctools" -datestamp = "1476581654" +datestamp = "1479787162" diff --git a/www7/sites/all/modules/contrib/ctools/tests/context.test b/www7/sites/all/modules/contrib/ctools/tests/context.test index bdf14e3f4..2dd4f4d4f 100644 --- a/www7/sites/all/modules/contrib/ctools/tests/context.test +++ b/www7/sites/all/modules/contrib/ctools/tests/context.test @@ -5,7 +5,7 @@ class CtoolsContextKeywordsSubstitutionTestCase extends DrupalWebTestCase { return array( 'name' => 'Keywords substitution', 'description' => 'Verify that keywords are properly replaced with data.', - 'group' => 'Chaos Tools Suite', + 'group' => 'ctools', ); } @@ -51,6 +51,30 @@ class CtoolsContextKeywordsSubstitutionTestCase extends DrupalWebTestCase { "%{$node->title}", t('Keyword after escaped and unescaped percent sign has been replaced.'), ), + '%%foo:bar' => array( + "%foo:bar", + t('Non-existant context ignored.'), + ), + 'There was about 20%-30% difference in price.' => array( + 'There was about 20%-30% difference in price.', + t('Non-keyword percent sign left untouched.'), + ), + 'href="my%20file%2dname.pdf"' => array( + 'href="my%20file%2dname.pdf"', + t('HTTP URL escape left untouched.'), + ), + 'href="my%a0file%fdname.pdf"' => array( + 'href="my%a0file%fdname.pdf"', + t('HTTP URL escape (high-chars) left untouched.'), + ), + 'Click here!' => array( + 'Click here!', + t('HTTP URL escape percent sign left untouched in HTML.'), + ), + 'SELECT * FROM {table} WHERE field = "%s"' => array( + 'SELECT * FROM {table} WHERE field = "%s"', + t('SQL percent sign left untouched.'), + ), ); foreach ($checks as $string => $expectations) { list($expected_result, $message) = $expectations; diff --git a/www7/sites/all/modules/contrib/ctools/tests/css.test b/www7/sites/all/modules/contrib/ctools/tests/css.test index 4a5200caa..3ffd42a57 100644 --- a/www7/sites/all/modules/contrib/ctools/tests/css.test +++ b/www7/sites/all/modules/contrib/ctools/tests/css.test @@ -12,7 +12,7 @@ class CtoolsCssTestCase extends DrupalWebTestCase { return array( 'name' => 'CSS Tools tests', 'description' => '...', - 'group' => 'Chaos Tools Suite', + 'group' => 'ctools', ); } diff --git a/www7/sites/all/modules/contrib/ctools/tests/css_cache.test b/www7/sites/all/modules/contrib/ctools/tests/css_cache.test index e289b42c9..0b3528daa 100644 --- a/www7/sites/all/modules/contrib/ctools/tests/css_cache.test +++ b/www7/sites/all/modules/contrib/ctools/tests/css_cache.test @@ -16,7 +16,7 @@ class CtoolsObjectCache extends DrupalWebTestCase { return array( 'name' => 'Ctools CSS cache', 'description' => 'Tests the custom CSS cache handler.', - 'group' => 'Chaos Tools Suite', + 'group' => 'ctools', ); } diff --git a/www7/sites/all/modules/contrib/ctools/tests/ctools.plugins.test b/www7/sites/all/modules/contrib/ctools/tests/ctools.plugins.test index fe1829cfb..7e866b162 100644 --- a/www7/sites/all/modules/contrib/ctools/tests/ctools.plugins.test +++ b/www7/sites/all/modules/contrib/ctools/tests/ctools.plugins.test @@ -12,7 +12,7 @@ class CtoolsPluginsGetInfoTestCase extends DrupalWebTestCase { return array( 'name' => 'Get plugin info', 'description' => 'Verify that plugin type definitions can properly set and overide values.', - 'group' => 'Chaos Tools Suite', + 'group' => 'ctools', ); } diff --git a/www7/sites/all/modules/contrib/ctools/tests/ctools_export_test/ctools_export.test b/www7/sites/all/modules/contrib/ctools/tests/ctools_export_test/ctools_export.test index 1accfd740..6a062de78 100644 --- a/www7/sites/all/modules/contrib/ctools/tests/ctools_export_test/ctools_export.test +++ b/www7/sites/all/modules/contrib/ctools/tests/ctools_export_test/ctools_export.test @@ -14,7 +14,7 @@ class CtoolsExportCrudTestCase extends DrupalWebTestCase { return array( 'name' => 'CTools export CRUD tests', 'description' => 'Test the CRUD functionality for the ctools export system.', - 'group' => 'Chaos Tools Suite', + 'group' => 'ctools', ); } diff --git a/www7/sites/all/modules/contrib/ctools/tests/ctools_export_test/ctools_export_test.info b/www7/sites/all/modules/contrib/ctools/tests/ctools_export_test/ctools_export_test.info index f2d96edce..1f2612ee5 100644 --- a/www7/sites/all/modules/contrib/ctools/tests/ctools_export_test/ctools_export_test.info +++ b/www7/sites/all/modules/contrib/ctools/tests/ctools_export_test/ctools_export_test.info @@ -8,9 +8,9 @@ hidden = TRUE files[] = ctools_export.test -; Information added by Drupal.org packaging script on 2016-10-16 -version = "7.x-1.11" +; Information added by Drupal.org packaging script on 2016-11-22 +version = "7.x-1.12" core = "7.x" project = "ctools" -datestamp = "1476581654" +datestamp = "1479787162" diff --git a/www7/sites/all/modules/contrib/ctools/tests/ctools_plugin_test.info b/www7/sites/all/modules/contrib/ctools/tests/ctools_plugin_test.info index bd9061221..4a6d27669 100644 --- a/www7/sites/all/modules/contrib/ctools/tests/ctools_plugin_test.info +++ b/www7/sites/all/modules/contrib/ctools/tests/ctools_plugin_test.info @@ -12,9 +12,9 @@ files[] = math_expression.test files[] = math_expression_stack.test hidden = TRUE -; Information added by Drupal.org packaging script on 2016-10-16 -version = "7.x-1.11" +; Information added by Drupal.org packaging script on 2016-11-22 +version = "7.x-1.12" core = "7.x" project = "ctools" -datestamp = "1476581654" +datestamp = "1479787162" diff --git a/www7/sites/all/modules/contrib/ctools/tests/math_expression.test b/www7/sites/all/modules/contrib/ctools/tests/math_expression.test index 730e079a5..8810e8c48 100644 --- a/www7/sites/all/modules/contrib/ctools/tests/math_expression.test +++ b/www7/sites/all/modules/contrib/ctools/tests/math_expression.test @@ -13,7 +13,7 @@ class CtoolsMathExpressionTestCase extends DrupalWebTestCase { return array( 'name' => 'CTools math expression tests', 'description' => 'Test the math expression library of ctools.', - 'group' => 'Chaos Tools Suite', + 'group' => 'ctools', ); } diff --git a/www7/sites/all/modules/contrib/ctools/tests/math_expression_stack.test b/www7/sites/all/modules/contrib/ctools/tests/math_expression_stack.test index 8143a55b8..bdd469592 100644 --- a/www7/sites/all/modules/contrib/ctools/tests/math_expression_stack.test +++ b/www7/sites/all/modules/contrib/ctools/tests/math_expression_stack.test @@ -13,7 +13,7 @@ class CtoolsMathExpressionStackTestCase extends DrupalWebTestCase { return array( 'name' => 'CTools math expression stack tests', 'description' => 'Test the stack class of the math expression library.', - 'group' => 'Chaos Tools Suite', + 'group' => 'ctools', ); } diff --git a/www7/sites/all/modules/contrib/ctools/tests/object_cache.test b/www7/sites/all/modules/contrib/ctools/tests/object_cache.test index 8791d7e70..2e714d6be 100644 --- a/www7/sites/all/modules/contrib/ctools/tests/object_cache.test +++ b/www7/sites/all/modules/contrib/ctools/tests/object_cache.test @@ -12,7 +12,7 @@ class CtoolsObjectCache extends DrupalWebTestCase { return array( 'name' => 'Ctools object cache storage', 'description' => 'Verify that objects are written, readable and lockable.', - 'group' => 'Chaos Tools Suite', + 'group' => 'ctools', ); } diff --git a/www7/sites/all/modules/contrib/ctools/views_content/views_content.info b/www7/sites/all/modules/contrib/ctools/views_content/views_content.info index 84e2ae55f..4f78dbddb 100644 --- a/www7/sites/all/modules/contrib/ctools/views_content/views_content.info +++ b/www7/sites/all/modules/contrib/ctools/views_content/views_content.info @@ -10,9 +10,9 @@ files[] = plugins/views/views_content_plugin_display_ctools_context.inc files[] = plugins/views/views_content_plugin_display_panel_pane.inc files[] = plugins/views/views_content_plugin_style_ctools_context.inc -; Information added by Drupal.org packaging script on 2016-10-16 -version = "7.x-1.11" +; Information added by Drupal.org packaging script on 2016-11-22 +version = "7.x-1.12" core = "7.x" project = "ctools" -datestamp = "1476581654" +datestamp = "1479787162" From 6942730debb4bf04abc6027ba12b7c0e3bf67691 Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Sat, 10 Dec 2016 11:46:30 +0100 Subject: [PATCH 08/16] Update feeds to 7.x-2.0-beta3 --- .../all/modules/contrib/feeds/CHANGELOG.txt | 84 +- .../all/modules/contrib/feeds/README.txt | 31 +- .../all/modules/contrib/feeds/feeds.drush.inc | 850 +++++++++++++++++ .../all/modules/contrib/feeds/feeds.info | 13 +- .../all/modules/contrib/feeds/feeds.module | 93 +- .../all/modules/contrib/feeds/feeds.rules.inc | 5 +- .../modules/contrib/feeds/feeds.tokens.inc | 17 +- .../feeds/feeds_import/feeds_import.info | 6 +- .../contrib/feeds/feeds_news/feeds_news.info | 6 +- .../contrib/feeds/feeds_ui/feeds_ui.admin.inc | 9 +- .../contrib/feeds/feeds_ui/feeds_ui.css | 8 + .../contrib/feeds/feeds_ui/feeds_ui.info | 6 +- .../contrib/feeds/includes/FeedsImporter.inc | 2 +- .../contrib/feeds/includes/FeedsSource.inc | 7 + .../contrib/feeds/libraries/ParserCSV.inc | 9 +- .../libraries/common_syndication_parser.inc | 162 +++- .../contrib/feeds/libraries/opml_parser.inc | 3 +- .../modules/contrib/feeds/mappers/date.inc | 178 +++- .../modules/contrib/feeds/mappers/file.inc | 151 ++- .../contrib/feeds/plugins/FeedsCSVParser.inc | 30 +- .../contrib/feeds/plugins/FeedsFetcher.inc | 8 + .../feeds/plugins/FeedsFileFetcher.inc | 28 + .../contrib/feeds/plugins/FeedsOPMLParser.inc | 9 + .../contrib/feeds/plugins/FeedsParser.inc | 120 ++- .../contrib/feeds/plugins/FeedsProcessor.inc | 21 +- .../feeds/plugins/FeedsSimplePieParser.inc | 9 + .../feeds/plugins/FeedsSyndicationParser.inc | 17 + .../feeds/plugins/FeedsUserProcessor.inc | 437 ++++++++- .../tests/common_syndication_parser.test | 27 + .../modules/contrib/feeds/tests/feeds.test | 25 +- .../feeds/tests/feeds/content_date.csv | 6 +- .../feeds/tests/feeds/developmentseed.rss2 | 1 + .../tests/feeds/entries-without-base-url.atom | 45 + .../contrib/feeds/tests/feeds/users.csv | 12 +- .../contrib/feeds/tests/feeds/users_roles.csv | 5 + .../feeds/tests/feeds_content_type.test | 110 +++ .../feeds/tests/feeds_fetcher_file.test | 133 ++- .../feeds/tests/feeds_mapper_date.test | 166 +++- .../feeds/tests/feeds_mapper_file.test | 560 ++++++++++- .../contrib/feeds/tests/feeds_parser_csv.test | 195 ++++ .../feeds/tests/feeds_parser_syndication.test | 66 +- .../feeds/tests/feeds_processor_user.test | 889 +++++++++++++++++- .../contrib/feeds/tests/feeds_rules.test | 185 ++++ .../contrib/feeds/tests/feeds_tests.info | 6 +- .../contrib/feeds/tests/feeds_tests.module | 69 +- .../contrib/feeds/tests/feeds_tests.rules.inc | 30 + .../contrib/feeds/tests/feeds_tokens.test | 94 ++ 47 files changed, 4664 insertions(+), 279 deletions(-) create mode 100644 www7/sites/all/modules/contrib/feeds/feeds.drush.inc create mode 100644 www7/sites/all/modules/contrib/feeds/tests/feeds/entries-without-base-url.atom create mode 100644 www7/sites/all/modules/contrib/feeds/tests/feeds/users_roles.csv create mode 100644 www7/sites/all/modules/contrib/feeds/tests/feeds_content_type.test create mode 100644 www7/sites/all/modules/contrib/feeds/tests/feeds_rules.test create mode 100644 www7/sites/all/modules/contrib/feeds/tests/feeds_tests.rules.inc create mode 100644 www7/sites/all/modules/contrib/feeds/tests/feeds_tokens.test diff --git a/www7/sites/all/modules/contrib/feeds/CHANGELOG.txt b/www7/sites/all/modules/contrib/feeds/CHANGELOG.txt index 7ced0112c..cd99211af 100644 --- a/www7/sites/all/modules/contrib/feeds/CHANGELOG.txt +++ b/www7/sites/all/modules/contrib/feeds/CHANGELOG.txt @@ -1,4 +1,84 @@ -Feeds 7.x 2.0 Beta 2, 2016-02-17 +Feeds 7.x 2.0 Beta 3, 2016-11-24 +-------------------------------- + +- Issue #1870528 by MegaChriz: Added tests for rules event + feeds_import_IMPORTER_ID and the rules action feeds_skip_item. Also specified + bundle for all feeds_import_IMPORTER_ID events (previously this attribute was + only declared for the node processor). +- Issue #1886230 by MegaChriz, generalredneck: fixed invoking rules events + "feeds_before_import" and "feeds_after_import". +- By MegaChriz: add rules as a test dependency for issue #1886230. +- Issue #2822831 by MegaChriz: Fixed only delete non-existent when the option is + explicitly set to FEEDS_DELETE_NON_EXISTENT. +- Issue #1171114 by drclaw, MegaChriz, twistor, impara, cgmonroe, Anas_maw, + azinck, justanothermark, vinmassaro, rhouse, lwalley, patrik.hultgren, + kenpeter, ufku, mahmost: Allow user to choose the method of file handling. +- Issue #1281496 by twistor, MegaChriz, natew: fixed prepend base url for + relative links in entries in atom feeds. +- By MegaChriz: listed variable module as test dependency as somehow the testbot + didn't checkout this module anymore. The variable module is a dependency of + the i18n module. +- Issue #2822679 by MegaChriz: Improved documentation for options --file, --url + and --stdin for the Drush command 'feeds-import'. +- Issue #2790741 by MegaChriz: added timezone option for date:end. +- Issue #2537926 by maximpodorov, MegaChriz, das-peter: Enhance tokens + performance. +- Issue #2778655 by joelpittet: Renamed $form_status in feeds_ui_overview_form() + to $form_state. +- Issue #2485059 by MegaChriz: Added delete protection for user id 1. +- Issue #2490782 by MegaChriz, heykarthikwithu: fixed a few comment docblocks. +- Issue #2771803 by MegaChriz: Added some tests for the CSV template. +- Issue #1570544 by MegaChriz, gaurav.goyal, AndrewsizZ, hpbruna, arrrgh, + vcrkid, firfin: Add UID target to user processor. +- Issue #2655470 by alan-ps, Louis Delacretaz: Added a timezone target to the + user processor. +- Issue #1143280 by David_Rothstein, MegaChriz, dshields, Matt V., marktheshark: + Provide an option to delete the uploaded file after import is done. +- Issue #2719151 by MegaChriz: Fixed don't retrieve title from feed if feed node + does not use the node title field. +- Issue #608408 by MegaChriz, andypost, queenvictoria, pcambra, twistor, + ivanbueno, mparker17, kenorb, agnese.stelce, alan-ps, clemens.tolboom, TommyK, + JurriaanRoelofs, ericduran, ShaunDychko, sir_squall, alex_b, markabur, Kasper + Souren, eiriksm: Added drush integration for Feeds. +- Issue #2225019 by twistor: Make FeedsDateTime stringable. +- Issue #722740 by twistor, mglaman, relaxnow, dooug, willieseabrook, + David_Rothstein, jeffschuler, lapek, Matthew Davidson: Feeds Date mapper + converts imported dates to GMT unless in UNIX timestamp format. +- Issue #2730207 by MegaChriz, twistor: Correction for the fix to log items that + are not UTF-8-encoded. +- Issue #2730207 by MegaChriz: Fixed logging failed items that are not + UTF-8-encoded. +- Issue #2735981 by MegaChriz: Fixed failing branch tests due to new "administer + fields" permission (see also change record #2483307). +- Issue #1611554 by MegaChriz, hanoii, webservant316, PascalAnimateur, + eugene.ilyin: Added support for importing encrypted passwords. +- Issue #1894542 by mikran, MegaChriz: Fixed replace roles with + "Additional roles" when replacing existing users. +- By MegaChriz: corrected a few indentations in plugins/FeedsUserProcessor.inc. +- Issue #1376774 by MegaChriz, PascalAnimateur, dooug, grndlvl, yannickoo, + daveparrish, joelpittet, maxplus, twistor: Added mapping target for user + roles. +- Issue #1804674 by Pancho, travismccauley, MegaChriz: Fixed broken link in + missing feeds plugin message when the feeds_ui module is disabled. +- Issue #2704171 by MegaChriz: Fixed parse RSS feeds that contain additional + whitespace. +- Issue #2704825 by alan-ps, MegaChriz: Fixed import Feeds importer overwrote + importer existing in code without "Replace existing" option set. +- Issue #2648304 by MegaChriz, OWast: RSS 2.0: add support for item->source + element. +- Issue #2645074 by MegaChriz, MiroslavBanov: Could not retrieve title from feed + - support Title module. +- Issue #1621602 by MegaChriz, twistor: Fixed 'Could not retrieve title from + feed' error message for parsers that cannot provide a title from the source. +- Issue #1810442 by David_Rothstein, MegaChriz: Corrected wording on importer + page when there are no unique fields and when using the CSV parser. +- Issue #2382245 by MegaChriz, twistor: Added import links to the admin menu. +- Issue #2690169 by tterranigma, MegaChriz: updated README.txt: documented + feeds_library_dir variable and removed no longer relevant parts. +- Issue #2367829 by MegaChriz, diamondsea: Added descriptions for options for + "Update existing" setting. + +Feeds 7.x 2.0 Beta 2, 2016-02-21 -------------------------------- - By MegaChriz: test dependencies should be specified in the main module.info @@ -257,7 +337,7 @@ Feeds 7.x 2.0 Beta 1, 2015-07-02 to importing importers. - Fix validation for importing importers. -Feeds 7.x 2.0 Alpha 8, 2012-04-22 +Feeds 7.x 2.0 Alpha 8, 2013-04-22 --------------------------------- - Issue #1555974 by twistor | andyg5000: Fixed Save button should also add field diff --git a/www7/sites/all/modules/contrib/feeds/README.txt b/www7/sites/all/modules/contrib/feeds/README.txt index dd112ea4e..3948da2f5 100644 --- a/www7/sites/all/modules/contrib/feeds/README.txt +++ b/www7/sites/all/modules/contrib/feeds/README.txt @@ -32,7 +32,7 @@ Features Requirements ============ -- CTools 1.x +- CTools 7.x-1.x http://drupal.org/project/ctools - Job Scheduler http://drupal.org/project/job_scheduler @@ -92,14 +92,6 @@ What's neat about Feeds News is that it comes with a configured View that shows a list of news items with every feed on the feed node's "View items" tab. It also comes with an OPML importer filter that can be accessed under /import. -- Feeds Fast News - - -This feature is very similar to Feeds News. The big difference is that instead -of aggregating a node for every item on a feed, it creates a database record -in a single table, thus significantly improving performance. This approach -especially starts to save resources when many items are being aggregated and -expired (= deleted) on a site. - - Feeds Import - This feature is an example illustrating Feeds' import capabilities. It contains @@ -111,7 +103,7 @@ PubSubHubbub support Feeds supports the PubSubHubbub publish/subscribe protocol. Follow these steps to set it up for your site. -http://code.google.com/p/pubsubhubbub/ +https://github.com/pubsubhubbub/ - Go to admin/build/feeds and edit (override) the importer configuration you would like to use for PubSubHubbub. @@ -146,12 +138,6 @@ API Overview See "The developer's guide to Feeds": http://drupal.org/node/622700 -Testing -======= - -See "The developer's guide to Feeds": -http://drupal.org/node/622700 - Debugging ========= @@ -178,6 +164,12 @@ Default: FALSE Description: Set to TRUE for enabling debug output to /DRUPALTMPDIR/feeds_[sitename].log +Name: feeds_library_dir +Default: FALSE +Description: The location where Feeds should look for libraries that it uses. + You can use this variable to override the libraries that are in + the Feeds libraries folder, for example "http_request.inc". + Name: feeds_importer_class Default: 'FeedsImporter' Description: The class to use for importing feeds. @@ -186,13 +178,6 @@ Name: feeds_source_class Default: 'FeedsSource' Description: The class to use for handling feed sources. -Name: feeds_data_$importer_id -Default: feeds_data_$importer_id -Description: The table used by FeedsDataProcessor to store feed items. Usually a - FeedsDataProcessor builds a table name from a prefix (feeds_data_) - and the importer's id ($importer_id). This default table name can - be overridden by defining a variable with the same name. - Name: feeds_process_limit Default: 50 The number of nodes feed node processor creates or deletes in one diff --git a/www7/sites/all/modules/contrib/feeds/feeds.drush.inc b/www7/sites/all/modules/contrib/feeds/feeds.drush.inc new file mode 100644 index 000000000..52f85e7f2 --- /dev/null +++ b/www7/sites/all/modules/contrib/feeds/feeds.drush.inc @@ -0,0 +1,850 @@ + 'Get a list of all Feeds importers in the system.', + 'aliases' => array('feeds'), + ); + + $items['feeds-list-feeds'] = array( + 'description' => 'List all feed sources.', + 'arguments' => array( + 'importer' => 'The name of the Feeds importer whose instances will be listed. Optional.', + ), + 'examples' => array( + 'drush feeds-list-feeds' => 'List all instances of all feeds.', + 'drush feeds-list-feeds rss_feed' => 'List all feed sources of the rss_feed importer.', + 'drush feeds-list-feeds --limit=3' => 'Only list the first three feed sources.', + ), + 'options' => array( + 'limit' => 'Limit the number of feeds to show in the list. Optional.', + ), + 'aliases' => array('feeds-lf'), + ); + + $items['feeds-import'] = array( + 'description' => 'Imports a feed.', + 'arguments' => array( + 'importer' => 'The name of the Feeds importer that will be refreshed. Mandatory.', + ), + 'options' => array( + 'nid' => '(optional) The nid of the Feeds importer that will be imported.', + 'file' => '(optional) The file to import. Bypasses the configured fetcher and does *not* update the source configuration.', + 'url' => '(optional) The URL to import. Bypasses the configured fetcher and does *not* update the source configuration.', + 'stdin' => '(optional) Read the file to import from stdin. Bypasses the configured fetcher and does *not* update the source configuration.', + ), + 'examples' => array( + 'drush feeds-import my_importer' => "Import items with the importer 'my_importer'.", + 'drush feeds-import my_importer --nid=2' => "Import items with the importer 'my_importer' for feed node 2.", + ), + 'aliases' => array('feeds-im'), + ); + + $items['feeds-import-all'] = array( + 'description' => 'Import all instances of feeds of the given type.', + 'arguments' => array( + 'importer' => 'The name of the Feeds importer that will be refreshed. Omitting the importer will cause all instances of all feeds to be imported.', + ), + 'examples' => array( + 'drush feeds-import-all' => 'Import all instances of all feeds.', + 'drush feeds-import-all my_importer' => "Import all instances of the importer 'my_importer'.", + 'drush feeds-import-all my_importer --limit=10' => "Import 10 instances of the feed 'my_importer'.", + ), + 'options' => array( + 'limit' => 'Limit the number of feeds to import. Optional.', + ), + 'aliases' => array('feeds-ia', 'feeds-im-all'), + ); + + $items['feeds-clear'] = array( + 'description' => 'Delete all items from a feed.', + 'arguments' => array( + 'importer' => 'The name of the Feeds importer that will be cleared. Mandatory.', + ), + 'options' => array( + 'nid' => 'The ID of the Feed node that will be cleared. Required if the importer is attached to a content type.', + ), + 'examples' => array( + 'drush feeds-clear my_importer' => "Deletes all items imported with the importer 'my_importer'. The importer must use the standalone import form.", + 'drush feeds-clear my_importer --nid=2' => "Deletes all items imported with the importer 'my_importer' for the feed node with ID 2. The importer must be attached to a content type.", + ), + ); + + $items['feeds-enable'] = array( + 'description' => 'Enables one or more Feeds importers.', + 'arguments' => array( + 'importers' => 'A space delimited list of Feeds importers. Mandatory.', + ), + 'examples' => array( + 'drush feeds-enable importer_1 importer_2' => "Enable Feeds importers 'importer_1' and 'importer_2'.", + ), + 'aliases' => array('feeds-en'), + ); + + $items['feeds-disable'] = array( + 'description' => 'Disable one or more Feeds importers.', + 'arguments' => array( + 'importers' => 'A space delimited list of Feeds importers. Mandatory.', + ), + 'examples' => array( + 'drush feeds-disable importer_1 importer_2' => "Disable Feeds importers 'importer_1' and 'importer_2'.", + ), + 'aliases' => array('feeds-dis'), + ); + + $items['feeds-delete'] = array( + 'description' => 'Deletes one or more Feeds importers.', + 'arguments' => array( + 'importers' => 'A space delimited list of Feeds importers. Mandatory.', + ), + 'examples' => array( + 'drush feeds-delete importer_1 importer_2' => "Delete Feeds importers 'importer_1' and 'importer_2'.", + ), + ); + + $items['feeds-revert'] = array( + 'description' => 'Reverts one or more Feeds importers.', + 'arguments' => array( + 'importers' => 'A space delimited list of Feeds importers. Mandatory.', + ), + 'examples' => array( + 'drush feeds-revert importer_1 importer_2' => "Revert Feeds importers 'importer_1' and 'importer_2'.", + ), + ); + + return $items; +} + +/** + * Implements hook_drush_help(). + */ +function feeds_drush_help($section) { + switch ($section) { + case 'drush:feeds-list-importers': + return dt('Show a list of available Feeds importers with information about them.'); + case 'drush:feeds-list-feeds': + return dt("List all feed sources. You can limit the number of feed sources to display by setting the option '--limit'."); + case 'drush:feeds-import': + $help = dt("Import items from a feed. Follow the command with the importer name to import items with. If the importer is attached to a content type, specify also the feed node with the option '--nid'."); + $help .= "\n" . dt("Note that the options '--file', '--stdin' and '--url' temporary bypass the configured fetcher and do *not* update the source configuration. For example, if a file was uploaded for the feed source, that file will remain there even when you specify a different file using the '--file' option. Same story applies for when importing from a url. If you omit these options, the last stored source will be used."); + return $help; + case 'drush:feeds-import-all': + return dt('Import items from all feeds. Optionally specify the importer name to import all feeds for.'); + case 'drush:feeds-clear': + return dt("Delete all items from a feed. Follow the command with the importer name to delete items from. If the importer is attached to a content type, specify also the feed node with the option '--nid'."); + case 'drush:feeds-enable': + return dt('Enable the specified Feeds importers. Follow the command with a space delimited list of importer names.'); + case 'drush:feeds-disable': + return dt('Disable the specified Feeds importers. Follow the command with a space delimited list of importer names.'); + case 'drush:feeds-delete': + return dt('Delete the specified Feeds importers. Follow the command with a space delimited list of importer names.'); + case 'drush:feeds-revert': + return dt('Revert the specified Feeds importers. Follow the command with a space delimited list of importer names.'); + } +} + +/** + * Prints a list of all Feeds importers. + */ +function drush_feeds_list_importers() { + if (!$importers = feeds_importer_load_all(TRUE)) { + drush_print(dt('No importers available.')); + return; + } + + $rows = array(); + + $rows[] = array( + dt('Name'), + dt('Description'), + dt('Attached to'), + dt('Status'), + dt('State'), + ); + + foreach ($importers as $importer) { + if ($importer->export_type == EXPORT_IN_CODE) { + $state = dt('Default'); + } + elseif ($importer->export_type == EXPORT_IN_DATABASE) { + $state = dt('Normal'); + } + elseif ($importer->export_type == (EXPORT_IN_CODE | EXPORT_IN_DATABASE)) { + $state = dt('Overridden'); + } + + $rows[] = array( + $importer->config['name'] . ' (' . $importer->id . ')', + $importer->config['description'], + $importer->config['content_type'] ? dt(node_type_get_name($importer->config['content_type'])) : dt('none'), + $importer->disabled ? dt('Disabled') : dt('Enabled'), + $state, + ); + } + + drush_print_table($rows, TRUE); +} + +/** + * Lists all feeds. + * + * @param string $importer_id + * (optional) The importer id. + */ +function drush_feeds_list_feeds($importer_id = NULL) { + if (!$limit = drush_get_option('limit')) { + $limit = DRUSH_FEEDS_DEFAULT_LIMIT; + } + + $header = array( + 'importer_id' => dt('Importer ID'), + 'feed_nid' => dt('Feed NID'), + 'feed_title' => dt('Feed title'), + 'imported' => dt('Last imported'), + 'source' => dt('Feed source'), + 'process_in_background' => dt('Process in background'), + ); + + $rows = array(); + $nids = array(); + + foreach (_drush_feeds_get_all($importer_id, $limit) as $feed) { + $feed_config = feeds_source($feed->id, $feed->feed_nid)->importer->getConfig(); + + $rows[] = array( + 'importer_id' => $feed->id, + 'feed_nid' => $feed->feed_nid, + 'feed_title' => '', + 'imported' => $feed->imported ? date('Y-m-d H:i:s', $feed->imported) : dt('Never'), + 'source' => is_scalar($feed->source) ? $feed->source : gettype($feed->source), + 'process_in_background' => !empty($feed_config['process_in_background']) ? dt('Yes') : dt('No'), + ); + + // Collect node ID's to find titles for. + if ($feed->feed_nid) { + $nids[] = $feed->feed_nid; + } + } + + // Find titles for feed nodes. + if (count($nids)) { + $nodes = db_select('node') + ->fields('node', array('nid', 'title')) + ->condition('nid', $nids) + ->execute() + ->fetchAllKeyed(); + + foreach ($rows as &$row) { + $nid = $row['feed_nid']; + if ($nid && isset($nodes[$nid])) { + $row['feed_title'] = $nodes[$nid]; + } + } + } + + // Check if there were any results. + if (count($rows) == 0) { + if (empty($importer_id)) { + drush_print(dt('There are no feed sources.')); + } + else { + drush_print(dt("No feed sources exists for importer '@importer_id'.", array( + '@importer_id' => $importer_id, + ))); + } + return FALSE; + } + + // Create table. + $table = array_merge(array($header), $rows); + + drush_print_table($table, TRUE); +} + +/** + * Imports a given importer/source. + * + * @param string $importer_id + * (optional) The importer id to filter on. + */ +function drush_feeds_import($importer_id = NULL) { + if (!strlen($importer_id)) { + drush_set_error(dt("Please specify the importer to import items with. If the importer is attached to a content type, specify also the feed node with the option '--nid'.")); + return FALSE; + } + + if (!$feed_nid = drush_get_option('nid')) { + $feed_nid = 0; + } + + try { + $source = feeds_source($importer_id, $feed_nid)->existing(); + } + catch (FeedsNotExistingException $e) { + $importer = feeds_importer_load($importer_id); + if (!$importer) { + drush_set_error(dt("The importer '@importer' does not exist or is not enabled.", array( + '@importer' => $importer_id, + ))); + return FALSE; + } + + if ($feed_nid == 0) { + // Check if the importer is a standalone importer. + if ($importer->config['content_type']) { + drush_set_error(dt("The importer '@importer' is attached to a content type. Please specify the feed node to import items for with the option '--nid'. To show a list of available feed nodes for this importer, use 'drush feeds-list-feeds @importer'.", array( + '@importer' => $importer_id, + ))); + return FALSE; + } + elseif (drush_get_option('file') || drush_get_option('url') || drush_get_option('stdin')) { + // Create a new source. + $source = feeds_source($importer_id); + $source->save(); + } + } + elseif (!$importer->config['content_type']) { + $message = dt("The importer '@importer' is not attached to a content type. Do you want to import items for this importer?", array( + '@importer' => $importer_id, + )); + + if (!drush_confirm($message)) { + return drush_log(dt('Aborting.'), 'ok'); + } + else { + drush_set_option('nid', 0); + // Avoid asking for confirmation twice. + drush_set_option('feeds_import_skip_confirm', 1); + return drush_feeds_import($importer_id); + } + } + + if (empty($source)) { + // Only abort at this point when no source object exists. It can exist + // when the importer is not attached to a content type and a file, url or + // stdin is supplied. + if ($feed_nid == 0) { + drush_set_error(dt("No source exists yet for the importer '@importer'. There is nothing to import. You can import from a file or url using the options '--file' or '--url' or go to /import/@importer to configure the source to import. See 'drush help feeds-import' for more information.", array( + '@importer' => $importer_id, + ))); + return FALSE; + } + else { + drush_set_error(dt("There is no feed node with ID @nid for importer '@importer'. To show a list of available feed nodes for this importer, use 'drush feeds-list-feeds @importer'.", array( + '@importer' => $importer_id, + '@nid' => $feed_nid, + ))); + return FALSE; + } + } + } + + // Propose confirmation message. + $messages = array(); + $vars = array( + '@importer' => $importer_id, + '@feed_nid' => $feed_nid, + ); + if ($feed_nid) { + $messages[] = dt("Items will be imported with the importer '@importer' for the feed node @feed_nid.", $vars); + } + else { + $messages[] = dt("Items will be imported with the importer '@importer'.", $vars); + } + + $result = NULL; + if ($filename = drush_get_option('file')) { + $filepath = _drush_feeds_find_file($filename); + if (!is_file($filepath)) { + drush_set_error(dt("The file '@file' does not exist.", array('@file' => $filename))); + return FALSE; + } + else { + $filepath = realpath($filepath); + } + $result = new FeedsFileFetcherResult($filepath); + + $messages[] = dt("The items will be imported from the file '@file'.", array( + '@file' => $filepath, + )); + } + elseif ($url = drush_get_option('url')) { + $result = new FeedsHTTPFetcherResult($url); + + $messages[] = dt("The items will be imported from the url '@url'.", array( + '@url' => $url, + )); + } + elseif (drush_get_option('stdin')) { + $result = new FeedsFetcherResult(file_get_contents('php://stdin')); + + $messages[] = dt('The items will be imported from stdin.'); + } + + // Only ask for confirmation if it wasn't already asked before. See above. + if (!drush_get_option('feeds_import_skip_confirm')) { + $messages[] = dt('Do you really want to continue?'); + $message = implode(' ', $messages); + if (!drush_confirm($message)) { + return drush_log(dt('Aborting.'), 'ok'); + } + } + + // Start the import! + if ($result) { + try { + $source->pushImport($result); + } + catch (Exception $e) { + drush_set_error($e->getMessage()); + return FALSE; + } + } + else { + _drush_feeds_create_import_batch($importer_id, $feed_nid); + drush_backend_batch_process(); + return; + } +} + +/** + * Imports all feeds. + * + * @param string $importer_id + * (optional) The importer id to filter on. + */ +function drush_feeds_import_all($importer_id = NULL) { + if (!$limit = drush_get_option('limit')) { + $limit = DRUSH_FEEDS_DEFAULT_LIMIT; + } + + // Set flag for whether or not executing the batch. When all importers are not + // not confirmed there are no batches set and in that case there are no + // batches to process. + $execute_batch = FALSE; + + foreach (_drush_feeds_get_all($importer_id, $limit) as $feed) { + if (!isset($feed->source) || !strlen($feed->source)) { + continue; + } + + try { + $source = feeds_source($feed->id, $feed->feed_nid)->existing(); + } + catch (FeedsNotExistingException $e) { + continue; + } + + // Compose messages. + $vars = array( + '@importer_id' => $source->id, + '@feed_nid' => $source->feed_nid, + ); + if ($source->feed_nid) { + $feed_node = node_load($source->feed_nid); + if ($feed_node) { + $vars['@title'] = $feed_node->title; + } + else { + drush_set_error(dt('The feed node @feed_nid (@importer_id) does not exist.', $vars)); + continue; + } + $confirm_message = dt("Do you want to import items with the importer '@importer_id' for the feed '@title'?", $vars); + $skip_message = dt("Skipping importer '@importer_id' for feed '@title'.", $vars); + } + else { + $confirm_message = dt("Do you want to import items with the importer '@importer_id'?", $vars); + $skip_message = dt("Skipping importer '@importer_id'.", $vars); + } + + if (drush_confirm($confirm_message)) { + _drush_feeds_create_import_batch($feed->id, $feed->feed_nid); + $execute_batch = TRUE; + } + else { + drush_log($skip_message, 'ok'); + } + } + + if ($execute_batch) { + drush_backend_batch_process(); + } +} + +/** + * Creates a batch job for an import. + * + * @param string $importer_id + * The importer id. + * @param int $feed_nid + * The feed node id. + */ +function _drush_feeds_create_import_batch($importer_id, $feed_nid) { + $feed_node = FALSE; + if ($feed_nid) { + if (!$feed_node = node_load($feed_nid)) { + drush_set_error(dt('The feed node @feed_nid (@importer_id) does not exist.', array('@importer_id' => $importer_id, '@feed_nid' => $feed_nid))); + return FALSE; + } + } + + $title = $feed_node ? $feed_node->title . ' (' . $importer_id . ')' : $importer_id; + + drush_log(dt('Importing: @title', array('@title' => $title)), 'ok'); + + $batch = array( + 'title' => '', + 'operations' => array( + array('feeds_batch', array('import', $importer_id, $feed_nid)), + ), + 'progress_message' => '', + ); + + batch_set($batch); +} + +/** + * Clears a Feeds importer. + * + * @param string $importer_id + * The importer id to clean. + */ +function drush_feeds_clear($importer_id = NULL) { + if (!strlen($importer_id)) { + drush_set_error(dt("Please specify the importer to delete all imported items from. If the importer is attached to a content type, specify also the feed node with the option '--nid'.")); + return FALSE; + } + + if (!$feed_nid = drush_get_option('nid')) { + $feed_nid = 0; + } + + try { + feeds_source($importer_id, $feed_nid)->existing(); + } + catch (FeedsNotExistingException $e) { + $importer = feeds_importer_load($importer_id); + if (!$importer) { + drush_set_error(dt("The importer '@importer' does not exist or is not enabled.", array( + '@importer' => $importer_id, + ))); + return FALSE; + } + + if ($feed_nid == 0) { + // Check if the importer is a standalone importer. + if ($importer->config['content_type']) { + drush_set_error(dt("The importer '@importer' is attached to a content type. Please specify the feed node to delete items from with the option '--nid'. To show a list of available feed nodes for this importer, use 'drush feeds-list-feeds @importer'.", array( + '@importer' => $importer_id, + ))); + return FALSE; + } + } + elseif (!$importer->config['content_type']) { + $message = dt("The importer '@importer' is not attached to a content type. Do you want to clear all items for this importer?", array( + '@importer' => $importer_id, + )); + + if (!drush_confirm($message)) { + return drush_log(dt('Aborting.'), 'ok'); + } + else { + drush_set_option('nid', 0); + // Avoid asking for confirmation twice. + drush_set_option('feeds_clear_skip_confirm', 1); + return drush_feeds_clear($importer_id); + } + } + + drush_set_error(dt("There is no feed node with ID @nid for importer '@importer'. To show a list of available feed nodes for this importer, use 'drush feeds-list-feeds @importer'.", array( + '@importer' => $importer_id, + '@nid' => $feed_nid, + ))); + return FALSE; + } + + // Only ask for confirmation if it wasn't already asked before. See above. + if (!drush_get_option('feeds_clear_skip_confirm')) { + if ($feed_nid) { + $message = dt("All items imported with the importer '@importer' for the feed node @feed_nid will be deleted. Do you really want to continue?", array( + '@importer' => $importer_id, + '@feed_nid' => $feed_nid, + )); + } + else { + $message = dt("All items imported with the importer '@importer' will be deleted. Do you really want to continue?", array( + '@importer' => $importer_id, + )); + } + if (!drush_confirm($message)) { + return drush_log(dt('Aborting.'), 'ok'); + } + } + + $batch = array( + 'title' => dt('Clearing !importer', array('!importer' => $importer_id)), + 'operations' => array( + array('feeds_batch', array('clear', $importer_id, $feed_nid)), + ), + ); + + batch_set($batch); + drush_backend_batch_process(); +} + +/** + * Enables a set of Feeds importers. + */ +function drush_feeds_enable() { + $all = array_keys(feeds_importer_load_all(TRUE)); + $enabled = array_keys(feeds_importer_load_all()); + $missing = array_diff(func_get_args(), $all); + $to_enable = array_diff(func_get_args(), $enabled, $missing); + $already_enabled = array_intersect(func_get_args(), $enabled); + + if ($missing) { + drush_print(dt('The following importers are missing: !importers', array('!importers' => implode(', ', $missing)))); + } + + if ($already_enabled) { + drush_print(dt('The following importers are already enabled: !importers', array('!importers' => implode(', ', $already_enabled)))); + } + + if ($to_enable) { + drush_print(dt('The following importers will be enabled: !importers', array('!importers' => implode(', ', $to_enable)))); + } + elseif (count(func_get_args()) == 0) { + return drush_set_error(dt('Please specify a space delimited list of importers to enable.')); + } + else { + return drush_print(dt('There are no importers to enable.')); + } + + if (!drush_confirm(dt('Do you really want to continue?'))) { + return drush_log(dt('Aborting.'), 'ok'); + } + + $disabled = variable_get('default_feeds_importer', array()); + + foreach ($to_enable as $importer_id) { + unset($disabled[$importer_id]); + drush_log(dt("The importer '!importer' has been enabled.", array('!importer' => $importer_id)), 'ok'); + } + + variable_set('default_feeds_importer', $disabled); + feeds_cache_clear(); +} + +/** + * Disables a set of Feeds importers. + */ +function drush_feeds_disable() { + $all = array_keys(feeds_importer_load_all(TRUE)); + $enabled = array_keys(feeds_importer_load_all()); + $to_disable = array_intersect(func_get_args(), $enabled); + $missing = array_diff(func_get_args(), $all); + $already_disabled = array_diff(func_get_args(), $enabled, $missing); + + if ($missing) { + drush_print(dt('The following importers are missing: !importers', array('!importers' => implode(', ', $missing)))); + } + + if ($already_disabled) { + drush_print(dt('The following importers are already disabled: !importers', array('!importers' => implode(', ', $already_disabled)))); + } + + if ($to_disable) { + drush_print(dt('The following importers will be disabled: !importers', array('!importers' => implode(', ', $to_disable)))); + } + elseif (count(func_get_args()) == 0) { + return drush_set_error(dt('Please specify a space delimited list of importers to disable.')); + } + else { + return drush_print(dt('There are no importers to disable.')); + } + + if (!drush_confirm(dt('Do you really want to continue?'))) { + return drush_log(dt('Aborting.'), 'ok'); + } + + $disabled = variable_get('default_feeds_importer', array()); + foreach ($to_disable as $importer_id) { + $disabled[$importer_id] = TRUE; + drush_log(dt("The importer '!importer' has been disabled.", array('!importer' => $importer_id)), 'ok'); + } + + variable_set('default_feeds_importer', $disabled); + feeds_cache_clear(); +} + +/** + * Deletes a set of Feeds importers. + */ +function drush_feeds_delete() { + $all = feeds_importer_load_all(TRUE); + $to_delete = array_intersect_key($all, array_flip(func_get_args())); + $missing = array_diff(func_get_args(), array_keys($all)); + $cant_delete = array(); + + // Filter out default importers that are not overridden. + foreach ($to_delete as $delta => $importer) { + if ($importer->export_type === EXPORT_IN_CODE) { + unset($to_delete[$delta]); + $cant_delete[$importer->id] = $importer->id; + } + } + + if ($missing) { + drush_print(dt('The following importers are missing: !importers', array('!importers' => implode(', ', $missing)))); + } + + if ($cant_delete) { + drush_print(dt('The following importers cannot be deleted because they only exist in code: !importers', array('!importers' => implode(', ', array_keys($cant_delete))))); + } + + if ($to_delete) { + drush_print(dt('The following importers will be deleted: !importers', array('!importers' => implode(', ', array_keys($to_delete))))); + } + elseif (count(func_get_args()) == 0) { + return drush_set_error(dt('Please specify a space delimited list of importers to delete.')); + } + else { + return drush_print(dt('There are no importers to delete.')); + } + + if (!drush_confirm(dt('Do you really want to continue?'))) { + return drush_log(dt('Aborting.'), 'ok'); + } + + foreach ($to_delete as $importer) { + $importer->delete(); + drush_log(dt("The importer '!importer' was deleted successfully.", array('!importer' => $importer->id)), 'ok'); + } + + feeds_cache_clear(); +} + +/** + * Reverts a set of feeds. + */ +function drush_feeds_revert() { + $all = feeds_importer_load_all(TRUE); + $missing = array_diff(func_get_args(), array_keys($all)); + $to_revert = array_intersect_key($all, array_flip(func_get_args())); + $cant_revert = array(); + $cant_revert_db = array(); + + // Filter out non-overridden importers. + foreach ($to_revert as $delta => $importer) { + if ($importer->export_type !== (EXPORT_IN_CODE | EXPORT_IN_DATABASE)) { + unset($to_revert[$delta]); + if ($importer->export_type == EXPORT_IN_DATABASE) { + $cant_revert_db[$importer->id] = $importer->id; + } + else { + $cant_revert[$importer->id] = $importer->id; + } + } + } + + if ($missing) { + drush_print(dt('The following importers are missing: !importers', array('!importers' => implode(', ', $missing)))); + } + + if ($cant_revert) { + drush_print(dt('The following importers cannot be reverted because they are not overridden: !importers', array('!importers' => implode(', ', array_keys($cant_revert))))); + } + if ($cant_revert_db) { + drush_print(dt('The following importers cannot be reverted because they only exist in the database: !importers', array('!importers' => implode(', ', array_keys($cant_revert_db))))); + } + + if ($to_revert) { + drush_print(dt('The following importers will be reverted: !importers', array('!importers' => implode(', ', array_keys($to_revert))))); + } + elseif (count(func_get_args()) == 0) { + return drush_set_error(dt('Please specify a space delimited list of importers to revert.')); + } + else { + return drush_print(dt('There are no importers to revert.')); + } + + if (!drush_confirm(dt('Do you really want to continue?'))) { + return drush_log(dt('Aborting.'), 'ok'); + } + + foreach ($to_revert as $importer) { + $importer->delete(); + drush_log(dt("The importer '!importer' was reverted successfully.", array('!importer' => $importer->id)), 'ok'); + } + + feeds_cache_clear(); +} + +/** + * Returns all feed instances filtered by an optional importer. + * + * @param string $importer_id + * (optional) The importer id. + * @param int $limit + * (optional) The number of feeds to return. + * + * @return DatabaseStatementInterface + * A list of feeds objects. + */ +function _drush_feeds_get_all($importer_id = NULL, $limit = DRUSH_FEEDS_DEFAULT_LIMIT) { + if (isset($importer_id)) { + return db_query_range("SELECT * FROM {feeds_source} WHERE id = :importer ORDER BY imported ASC", 0, $limit, array(':importer' => $importer_id)); + } + + return db_query_range("SELECT * FROM {feeds_source} ORDER BY imported ASC", 0, $limit); +} + +/** + * Tries to find the specified file at several locations. + * + * @param string $filename + * The file to look for. + * + * @return string + * If found, the file that was found. + * NULL otherwise. + */ +function _drush_feeds_find_file($filename) { + // If the full path to the file is specified, the file will be found right away. + if (is_file($filename)) { + // Found! + return $filename; + } + + // Look for the file within the current active directory. + $search = drush_cwd() . '/' . $filename; + if (is_file($search)) { + // Found! + return $search; + } + + // Look for the file within the directory Drupal is installed in. + // bootstrap_drupal_root() sets the active directory to the Drupal root. + $search = getcwd() . '/' . $filename; + if (is_file($search)) { + // Found! + return $search; + } +} diff --git a/www7/sites/all/modules/contrib/feeds/feeds.info b/www7/sites/all/modules/contrib/feeds/feeds.info index 24b6a6820..cf072d829 100644 --- a/www7/sites/all/modules/contrib/feeds/feeds.info +++ b/www7/sites/all/modules/contrib/feeds/feeds.info @@ -8,8 +8,10 @@ dependencies[] = job_scheduler test_dependencies[] = date:date test_dependencies[] = entity_translation:entity_translation test_dependencies[] = feeds_xpathparser:feeds_xpathparser -test_dependencies[] = link:link test_dependencies[] = i18n:i18n_taxonomy +test_dependencies[] = link:link +test_dependencies[] = rules:rules +test_dependencies[] = variable:variable files[] = includes/FeedsConfigurable.inc files[] = includes/FeedsImporter.inc @@ -37,6 +39,7 @@ files[] = plugins/FeedsUserProcessor.inc ; Tests files[] = tests/feeds.test files[] = tests/common_syndication_parser.test +files[] = tests/feeds_content_type.test files[] = tests/feeds_date_time.test files[] = tests/feeds_mapper_date.test files[] = tests/feeds_mapper_date_multiple.test @@ -64,10 +67,12 @@ files[] = tests/feeds_processor_node.test files[] = tests/feeds_processor_term.test files[] = tests/feeds_processor_user.test files[] = tests/feeds_push.test +files[] = tests/feeds_rules.test files[] = tests/feeds_scheduler.test files[] = tests/feeds_mapper_link.test files[] = tests/feeds_mapper_summary.test files[] = tests/feeds_mapper_taxonomy.test +files[] = tests/feeds_tokens.test files[] = tests/http_request.test files[] = tests/parser_csv.test @@ -80,9 +85,9 @@ files[] = views/feeds_views_handler_field_source.inc files[] = views/feeds_views_handler_filter_severity.inc files[] = views/feeds_views_plugin_argument_validate_feed_nid.inc -; Information added by Drupal.org packaging script on 2016-02-21 -version = "7.x-2.0-beta2" +; Information added by Drupal.org packaging script on 2016-11-24 +version = "7.x-2.0-beta3" core = "7.x" project = "feeds" -datestamp = "1456055647" +datestamp = "1479993785" diff --git a/www7/sites/all/modules/contrib/feeds/feeds.module b/www7/sites/all/modules/contrib/feeds/feeds.module index 41122b4f2..7cded509c 100644 --- a/www7/sites/all/modules/contrib/feeds/feeds.module +++ b/www7/sites/all/modules/contrib/feeds/feeds.module @@ -604,8 +604,12 @@ function feeds_node_validate($node, $form, &$form_state) { $last_feeds = $node->feeds; $source->configFormValidate($last_feeds); - // If node title is empty, try to retrieve title from feed. - if (trim($node->title) == '') { + // Check if title form element is hidden. + $title_hidden = (isset($form['title']['#access']) && !$form['title']['#access']); + + // If the node title is empty and the title form element wasn't hidden, try to + // retrieve the title from the feed. + if (isset($node->title) && trim($node->title) == '' && !$title_hidden) { try { $source->addConfig($last_feeds); if (!$last_title = $source->preview()->title) { @@ -688,11 +692,6 @@ function feeds_node_delete($node) { */ function feeds_form_node_form_alter(&$form, $form_state) { if ($importer_id = feeds_get_importer_id($form['#node']->type)) { - // Set title to not required, try to retrieve it from feed. - if (isset($form['title'])) { - $form['title']['#required'] = FALSE; - } - // Enable uploads. $form['#attributes']['enctype'] = 'multipart/form-data'; @@ -706,6 +705,14 @@ function feeds_form_node_form_alter(&$form, $form_state) { ); $form['feeds'] += $source->configForm($form_state); $form['#feed_id'] = $importer_id; + + // If the parser has support for delivering a source title, set node title + // to not required and try to retrieve it from the source if the node title + // is left empty by the user. + // @see feeds_node_validate() + if (isset($form['title']) && $source->importer()->parser->providesSourceTitle()) { + $form['title']['#required'] = FALSE; + } } } @@ -845,6 +852,69 @@ function feeds_flush_caches() { return array(); } +/** + * Implements hook_admin_menu_output_build(). + * + * Shows available importers in the "Content" section of the admin menu. + * Requires the "admin_menu" module to be enabled. + */ +function feeds_admin_menu_output_build(array &$content) { + // Add new top-level item to the menu. + if (!isset($content['menu'])) { + return; + } + $access = FALSE; + foreach (feeds_enabled_importers() as $importer_id) { + if (user_access('administer feeds') || user_access("import $importer_id feeds")) { + $access = TRUE; + break; + } + } + + if (!$access) { + return; + } + + $content['menu']['admin/content']['admin/content/feeds_import'] = array( + '#title' => t('Import'), + '#href' => 'import', + ); + + foreach (feeds_importer_load_all() as $importer) { + $content['menu']['admin/content']['admin/content/feeds_import'][$importer->id] = array( + '#title' => t($importer->config['name']), + '#href' => !empty($importer->config['content_type']) ? 'node/add/' . $importer->config['content_type'] : 'import/' . check_plain($importer->id), + '#access' => user_access('administer feeds') || user_access("import $importer->id feeds"), + ); + } +} + +/** + * Implements hook_menu_local_tasks_alter(). + * + * Adds "Import" link as local action on content overview page. + */ +function feeds_menu_local_tasks_alter(&$data, $router_item, $root_path) { + if ($root_path == 'admin/content') { + $data['actions']['output'][] = array( + '#theme' => 'menu_local_task', + '#link' => array( + 'title' => t('Import'), + 'href' => 'import', + 'localized_options' => array( + 'attributes' => array( + 'title' => t('Import'), + ), + ), + ), + '#access' => feeds_page_access(), + // Add weight so it appears after the local action "Add content". + '#weight' => 1, + ); + } +} + + /** * @} */ @@ -1107,8 +1177,13 @@ function feeds_plugin($plugin, $id) { $args = array('%plugin' => $plugin, '@id' => $id); if (user_access('administer feeds')) { - $args['@link'] = url('admin/structure/feeds/' . $id); - drupal_set_message(t('Missing Feeds plugin %plugin. See @id. Check whether all required libraries and modules are installed properly.', $args), 'warning', FALSE); + if (module_exists('feeds_ui')) { + $args['@link'] = url('admin/structure/feeds/' . $id); + drupal_set_message(t('Missing Feeds plugin %plugin. See @id. Check whether all required libraries and modules are installed properly.', $args), 'warning', FALSE); + } + else { + drupal_set_message(t('Missing Feeds plugin %plugin used by the importer "@id". Check whether all required libraries and modules are installed properly. Enable the Feeds Admin UI module to check the importer\'s settings.', $args), 'warning', FALSE); + } } else { drupal_set_message(t('Missing Feeds plugin %plugin. Please contact your site administrator.', $args), 'warning', FALSE); diff --git a/www7/sites/all/modules/contrib/feeds/feeds.rules.inc b/www7/sites/all/modules/contrib/feeds/feeds.rules.inc index dce753a40..c104d163f 100644 --- a/www7/sites/all/modules/contrib/feeds/feeds.rules.inc +++ b/www7/sites/all/modules/contrib/feeds/feeds.rules.inc @@ -44,16 +44,13 @@ function feeds_rules_event_info() { $entity_type => array( 'label' => t('Imported @label', array('@label' => $label)), 'type' => $entity_type, + 'bundle' => $processor->bundle(), // Saving is handled by feeds anyway (unless the skip action is used). 'skip save' => TRUE, ), ), 'access callback' => 'feeds_rules_access_callback', ); - // Add bundle information if the node processor is used. - if ($processor instanceof FeedsNodeProcessor) { - $info['feeds_import_'. $importer->id]['variables'][$entity_type]['bundle'] = $processor->bundle(); - } } return $info; } diff --git a/www7/sites/all/modules/contrib/feeds/feeds.tokens.inc b/www7/sites/all/modules/contrib/feeds/feeds.tokens.inc index a5145b666..84b72c262 100644 --- a/www7/sites/all/modules/contrib/feeds/feeds.tokens.inc +++ b/www7/sites/all/modules/contrib/feeds/feeds.tokens.inc @@ -29,19 +29,22 @@ function feeds_tokens($type, $tokens, array $data, array $options) { $sanitize = !empty($options['sanitize']); + $feed_source_tokens = token_find_with_prefix($tokens, 'feed-source'); + $feed_source_token_exists = array_key_exists('feed-source', $tokens); + + if (empty($feed_source_tokens) && !$feed_source_token_exists) { + return $replacements; + } + $feed_nid = feeds_get_feed_nid($data['node']->nid, 'node'); if ($feed_nid && $feed_source = node_load($feed_nid)) { - foreach ($tokens as $name => $original) { - switch ($name) { - case 'feed-source': - $replacements[$original] = $sanitize ? check_plain($feed_source->title) : $feed_source->title; - break; - } + if (isset($tokens['feed-source'])) { + $replacements[$tokens['feed-source']] = $sanitize ? check_plain($feed_source->title) : $feed_source->title; } // Chained node token relationships. - if ($feed_source_tokens = token_find_with_prefix($tokens, 'feed-source')) { + if (!empty($feed_source_tokens)) { $replacements += token_generate('node', $feed_source_tokens, array('node' => $feed_source), $options); } } diff --git a/www7/sites/all/modules/contrib/feeds/feeds_import/feeds_import.info b/www7/sites/all/modules/contrib/feeds/feeds_import/feeds_import.info index 189ca0920..9793db5e5 100644 --- a/www7/sites/all/modules/contrib/feeds/feeds_import/feeds_import.info +++ b/www7/sites/all/modules/contrib/feeds/feeds_import/feeds_import.info @@ -10,9 +10,9 @@ features[feeds_importer][] = node features[feeds_importer][] = user files[] = feeds_import.test -; Information added by Drupal.org packaging script on 2016-02-21 -version = "7.x-2.0-beta2" +; Information added by Drupal.org packaging script on 2016-11-24 +version = "7.x-2.0-beta3" core = "7.x" project = "feeds" -datestamp = "1456055647" +datestamp = "1479993785" diff --git a/www7/sites/all/modules/contrib/feeds/feeds_news/feeds_news.info b/www7/sites/all/modules/contrib/feeds/feeds_news/feeds_news.info index 34eca86d4..331cae321 100644 --- a/www7/sites/all/modules/contrib/feeds/feeds_news/feeds_news.info +++ b/www7/sites/all/modules/contrib/feeds/feeds_news/feeds_news.info @@ -19,9 +19,9 @@ features[views_view][] = feeds_defaults_feed_items files[] = feeds_news.module files[] = feeds_news.test -; Information added by Drupal.org packaging script on 2016-02-21 -version = "7.x-2.0-beta2" +; Information added by Drupal.org packaging script on 2016-11-24 +version = "7.x-2.0-beta3" core = "7.x" project = "feeds" -datestamp = "1456055647" +datestamp = "1479993785" diff --git a/www7/sites/all/modules/contrib/feeds/feeds_ui/feeds_ui.admin.inc b/www7/sites/all/modules/contrib/feeds/feeds_ui/feeds_ui.admin.inc index cdfb43c17..a757dc805 100644 --- a/www7/sites/all/modules/contrib/feeds/feeds_ui/feeds_ui.admin.inc +++ b/www7/sites/all/modules/contrib/feeds/feeds_ui/feeds_ui.admin.inc @@ -48,7 +48,7 @@ function feeds_ui_mapping_help() { /** * Build overview of available configurations. */ -function feeds_ui_overview_form($form, &$form_status) { +function feeds_ui_overview_form($form, array &$form_state) { $form = $form['enabled'] = $form['disabled'] = array(); $form['#header'] = array( @@ -651,6 +651,9 @@ function feeds_ui_mapping_settings_form($form, $form_state, $i, $mapping, $targe return array( '#type' => 'container', + '#attributes' => array( + 'class' => array('feeds-target-config'), + ), 'settings' => $settings_form, 'save_settings' => $base_button + array( '#type' => 'submit', @@ -1198,9 +1201,7 @@ function feeds_ui_importer_import_validate($form, &$form_state) { $exists = feeds_ui_importer_machine_name_exists($feeds_importer->id); if ($exists && !$form_state['values']['id_override']) { - if (feeds_importer($feeds_importer->id)->export_type != EXPORT_IN_CODE) { - return form_error($form['id'], t('Feeds importer already exists with that id.')); - } + return form_error($form['id'], t('Feeds importer already exists with that id.')); } if (!$form_state['values']['bypass_validation']) { diff --git a/www7/sites/all/modules/contrib/feeds/feeds_ui/feeds_ui.css b/www7/sites/all/modules/contrib/feeds/feeds_ui/feeds_ui.css index d089e4106..6679d018c 100644 --- a/www7/sites/all/modules/contrib/feeds/feeds_ui/feeds_ui.css +++ b/www7/sites/all/modules/contrib/feeds/feeds_ui/feeds_ui.css @@ -104,3 +104,11 @@ ul.container-actions li form input { #center table form { margin: 0; } + +div.feeds-container-body .feeds-target-config div.item-list ul li { + list-style: outside none disc; + margin: 0 0 0.25em 1.5em; +} +.feeds-target-config .description { + white-space: normal; +} diff --git a/www7/sites/all/modules/contrib/feeds/feeds_ui/feeds_ui.info b/www7/sites/all/modules/contrib/feeds/feeds_ui/feeds_ui.info index cf3bc30b2..5230cdde2 100644 --- a/www7/sites/all/modules/contrib/feeds/feeds_ui/feeds_ui.info +++ b/www7/sites/all/modules/contrib/feeds/feeds_ui/feeds_ui.info @@ -7,9 +7,9 @@ configure = admin/structure/feeds files[] = feeds_ui.test -; Information added by Drupal.org packaging script on 2016-02-21 -version = "7.x-2.0-beta2" +; Information added by Drupal.org packaging script on 2016-11-24 +version = "7.x-2.0-beta3" core = "7.x" project = "feeds" -datestamp = "1456055647" +datestamp = "1479993785" diff --git a/www7/sites/all/modules/contrib/feeds/includes/FeedsImporter.inc b/www7/sites/all/modules/contrib/feeds/includes/FeedsImporter.inc index 5286b1d0a..cad769596 100644 --- a/www7/sites/all/modules/contrib/feeds/includes/FeedsImporter.inc +++ b/www7/sites/all/modules/contrib/feeds/includes/FeedsImporter.inc @@ -150,7 +150,7 @@ class FeedsImporter extends FeedsConfigurable { /** * Copy a FeedsImporter configuration into this importer. * - * @param FeedsImporter $importer + * @param FeedsConfigurable $configurable * The feeds importer object to copy from. */ public function copy(FeedsConfigurable $configurable) { diff --git a/www7/sites/all/modules/contrib/feeds/includes/FeedsSource.inc b/www7/sites/all/modules/contrib/feeds/includes/FeedsSource.inc index 8349b3127..b5577a15e 100644 --- a/www7/sites/all/modules/contrib/feeds/includes/FeedsSource.inc +++ b/www7/sites/all/modules/contrib/feeds/includes/FeedsSource.inc @@ -381,6 +381,9 @@ class FeedsSource extends FeedsConfigurable { // If fetcher result is empty, we are starting a new import, log. if (empty($this->fetcher_result)) { module_invoke_all('feeds_before_import', $this); + if (module_exists('rules')) { + rules_invoke_event('feeds_before_import', $this); + } $this->state[FEEDS_START] = time(); } @@ -414,7 +417,11 @@ class FeedsSource extends FeedsConfigurable { if ($result == FEEDS_BATCH_COMPLETE || isset($e)) { $this->imported = time(); $this->log('import', 'Imported in @s seconds.', array('@s' => $this->imported - $this->state[FEEDS_START]), WATCHDOG_INFO); + $this->importer->fetcher->afterImport($this); module_invoke_all('feeds_after_import', $this); + if (module_exists('rules')) { + rules_invoke_event('feeds_after_import', $this); + } unset($this->fetcher_result, $this->state); } $this->save(); diff --git a/www7/sites/all/modules/contrib/feeds/libraries/ParserCSV.inc b/www7/sites/all/modules/contrib/feeds/libraries/ParserCSV.inc index 6e3307146..5b218bb94 100644 --- a/www7/sites/all/modules/contrib/feeds/libraries/ParserCSV.inc +++ b/www7/sites/all/modules/contrib/feeds/libraries/ParserCSV.inc @@ -171,7 +171,7 @@ class ParserCSV { /** * Get the byte number where the parser left off after last parse() call. * - * @return + * @return int * 0 if all lines or no line has been parsed, the byte position of where a * timeout or the line limit has been reached otherwise. This position can be * used to set the start byte for the next iteration after parse() has @@ -198,11 +198,8 @@ class ParserCSV { * * @param Iterator $lineIterator * An Iterator object that yields line strings, e.g. ParserCSVIterator. - * @param $start - * The byte number from where to start parsing the file. - * @param $lines - * The number of lines to parse, 0 for all lines. - * @return + * + * @return array * Two dimensional array that contains the data in the CSV file. */ public function parse(Iterator $lineIterator) { diff --git a/www7/sites/all/modules/contrib/feeds/libraries/common_syndication_parser.inc b/www7/sites/all/modules/contrib/feeds/libraries/common_syndication_parser.inc index 2fa1bbd18..d2296eb34 100644 --- a/www7/sites/all/modules/contrib/feeds/libraries/common_syndication_parser.inc +++ b/www7/sites/all/modules/contrib/feeds/libraries/common_syndication_parser.inc @@ -13,12 +13,17 @@ /** * Parse the feed into a data structure. * - * @param $feed - * The feed object (contains the URL or the parsed XML structure. - * @return - * stdClass The structured datas extracted from the feed. + * @param string $string + * The feed object (contains the URL or the parsed XML structure). + * + * @return array|false + * The structured datas extracted from the feed or FALSE in case of failures. */ function common_syndication_parser_parse($string) { + // SimpleXML can only deal with XML declaration at the start of the document, + // so remove any surrounding whitespace. + $string = trim($string); + @ $xml = simplexml_load_string($string, NULL, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NOCDATA); // Got a malformed XML. @@ -41,10 +46,11 @@ function common_syndication_parser_parse($string) { /** * Determine the feed format of a SimpleXML parsed object structure. * - * @param $xml - * SimpleXML-preprocessed feed. - * @return - * The feed format short description or FALSE if not compatible. + * @param SimpleXMLElement $xml + * SimpleXML-preprocessed feed. + * + * @return string|false + * The feed format short description or FALSE if not compatible. */ function _parser_common_syndication_feed_format_detect($xml) { if (!is_object($xml)) { @@ -80,11 +86,7 @@ function _parser_common_syndication_atom10_parse($feed_XML) { "georss" => "http://www.georss.org/georss", ); - $base = $feed_XML->xpath("@base"); - $base = (string) array_shift($base); - if (!valid_url($base, TRUE)) { - $base = FALSE; - } + $base = _parser_common_syndication_atom10_parse_base_url($feed_XML); // Detect the title $parsed_source['title'] = isset($feed_XML->title) ? _parser_common_syndication_title("{$feed_XML->title}") : ""; @@ -92,20 +94,13 @@ function _parser_common_syndication_atom10_parse($feed_XML) { $parsed_source['description'] = isset($feed_XML->subtitle) ? "{$feed_XML->subtitle}" : ""; $parsed_source['link'] = _parser_common_syndication_link($feed_XML->link); - if (valid_url($parsed_source['link']) && !valid_url($parsed_source['link'], TRUE) && !empty($base)) { + if ($base && !valid_url($parsed_source['link'], TRUE) && valid_url($parsed_source['link'])) { $parsed_source['link'] = $base . $parsed_source['link']; } $parsed_source['items'] = array(); foreach ($feed_XML->entry as $news) { - - $original_url = NULL; - $guid = !empty($news->id) ? "{$news->id}" : NULL; - if (valid_url($guid, TRUE)) { - $original_url = $guid; - } - $georss = (array)$news->children($ns["georss"]); $geoname = ''; if (isset($georss['featureName'])) { @@ -158,13 +153,6 @@ function _parser_common_syndication_atom10_parse($feed_XML) { $body .= "{$news->summary}"; } - if (!empty($news->content['src'])) { - // some src elements in some valid atom feeds contained no urls at all - if (valid_url("{$news->content['src']}", TRUE)) { - $original_url = "{$news->content['src']}"; - } - } - $original_author = ''; if (!empty($news->source->author->name)) { $original_author = "{$news->source->author->name}"; @@ -176,8 +164,6 @@ function _parser_common_syndication_atom10_parse($feed_XML) { $original_author = "{$feed_XML->author->name}"; } - $original_url = _parser_common_syndication_link($news->link); - $item = array(); $item['title'] = _parser_common_syndication_title($title, $body); $item['description'] = $body; @@ -195,17 +181,32 @@ function _parser_common_syndication_atom10_parse($feed_XML) { $item['timestamp'] = _parser_common_syndication_parse_date("{$news->updated}"); } - $item['url'] = trim($original_url); - if (valid_url($item['url']) && !valid_url($item['url'], TRUE) && !empty($base)) { - $item['url'] = $base . $item['url']; + $item['guid'] = (string) $news->id; + + $item['url'] = _parser_common_syndication_link($news->link); + + if (!$item['url'] && !empty($news->content['src']) && valid_url($news->content['src'], TRUE)) { + $item['url'] = (string) $news->content['src']; } - // Fall back on URL if GUID is empty. - if (!empty($guid)) { - $item['guid'] = $guid; + + if (!strlen($item['url']) && $item['guid'] && valid_url($item['guid'], TRUE)) { + $item['url'] = $item['guid']; } - else { + + if (!valid_url($item['url'], TRUE) && valid_url($item['url'])) { + if ($item_base = _parser_common_syndication_atom10_parse_base_url($news)) { + $item['url'] = $item_base . $item['url']; + } + elseif ($base) { + $item['url'] = $base . $item['url']; + } + } + + // Fall back on URL if GUID is empty. + if (!strlen($item['guid'])) { $item['guid'] = $item['url']; } + $item['geolocations'] = array(); if ($lat && $lon) { $item['geolocations'] = array( @@ -220,9 +221,61 @@ function _parser_common_syndication_atom10_parse($feed_XML) { $item['domains'] = isset($additional_taxonomies['ATOM Domains']) ? $additional_taxonomies['ATOM Domains'] : array(); $parsed_source['items'][] = $item; } + return $parsed_source; } +/** + * Finds the base URL of an Atom document. + * + * @param SimpleXMLElement $xml + * The XML document. + * + * @return string|false + * Returns the base URL or false on failure. + */ +function _parser_common_syndication_atom10_parse_base_url(SimpleXMLElement $xml) { + $base = $xml->attributes('xml', TRUE)->base; + if (!$base) { + $base = $xml['base']; + } + + if ($base && valid_url($base, TRUE)) { + return rtrim($base, '/') . '/'; + } + + // Try to build a base from the self link. + foreach ($xml->xpath('*[local-name() = "link" and @rel="self" and @href]') as $self) { + if (valid_url($self['href'], TRUE)) { + return _parser_common_syndication_string_url_path((string) $self['href']); + } + } + + // Try to build a base from the alternate link. + foreach ($xml->xpath('*[local-name() = "link" and @rel="alternate" and @href]') as $alternate) { + if (valid_url($alternate['href'], TRUE)) { + return _parser_common_syndication_string_url_path((string) $alternate['href']); + } + } + + return FALSE; +} + +/** + * Removes the path parts of an absolute URL. + * + * @param string $url + * The absolute URL. + * + * @return string + * The absolute URL with the path stripped. + */ +function _parser_common_syndication_string_url_path($url) { + $pos = strpos($url, '/', strpos($url, '//') + 2); + + return $pos ? substr($url, 0, $pos + 1) : $url . '/'; +} + /** * Parse RDF Site Summary (RSS) 1.0 feeds in RDF/XML format. * @@ -357,6 +410,9 @@ function _parser_common_syndication_RSS20_parse($feed_XML) { foreach ($feed_XML->xpath('//item') as $news) { $title = $body = $original_author = $original_url = $guid = ''; + // Get optional source url. + $source_url = (string) $news->source['url']; + $category = $news->xpath('category'); // Get children for current namespace. $content = (array)$news->children($ns["content"]); @@ -454,6 +510,13 @@ function _parser_common_syndication_RSS20_parse($feed_XML) { } $item['url'] = trim($original_url); $item['guid'] = $guid; + if (!empty($news['source'])) { + $item['source:title'] = $news['source']; + } + else { + $item['source:title'] = NULL; + } + $item['source:url'] = trim($source_url); $item['geolocations'] = array(); if (isset($geoname, $lat, $lon)) { @@ -476,10 +539,11 @@ function _parser_common_syndication_RSS20_parse($feed_XML) { /** * Parse a date comes from a feed. * - * @param $date_string - * The date string in various formats. - * @return - * The timestamp of the string or the current time if can't be parsed + * @param string $date_str + * The date string in various formats. + * + * @return int + * The timestamp of the string or the current time if can't be parsed. */ function _parser_common_syndication_parse_date($date_str) { // PHP < 5.3 doesn't like the GMT- notation for parsing timezones. @@ -512,9 +576,10 @@ function _parser_common_syndication_parse_date($date_str) { * See http://www.w3.org/TR/NOTE-datetime for more information. * Originally from MagpieRSS (http://magpierss.sourceforge.net/). * - * @param $date_str - * A string with a potentially W3C DTF date. - * @return + * @param string $date_str + * A potentially W3C DTF date. + * + * @return int|false * A timestamp if parsed successfully or FALSE if not. */ function _parser_common_syndication_parse_w3cdtf($date_str) { @@ -549,8 +614,11 @@ function _parser_common_syndication_parse_w3cdtf($date_str) { * Extract the link that points to the original content (back to site or * original article) * - * @param $links - * Array of SimpleXML objects + * @param array $links + * Array of SimpleXML objects + * + * @return string + * An URL if found. An empty string otherwise. */ function _parser_common_syndication_link($links) { $to_link = ''; @@ -565,7 +633,7 @@ function _parser_common_syndication_link($links) { } } } - return $to_link; + return trim($to_link); } /** diff --git a/www7/sites/all/modules/contrib/feeds/libraries/opml_parser.inc b/www7/sites/all/modules/contrib/feeds/libraries/opml_parser.inc index d1faefcc1..c5b7cb3c8 100644 --- a/www7/sites/all/modules/contrib/feeds/libraries/opml_parser.inc +++ b/www7/sites/all/modules/contrib/feeds/libraries/opml_parser.inc @@ -10,7 +10,8 @@ * * @param $raw * File contents. - * @return + * + * @return array * An array of the parsed OPML file. */ function opml_parser_parse($raw) { diff --git a/www7/sites/all/modules/contrib/feeds/mappers/date.inc b/www7/sites/all/modules/contrib/feeds/mappers/date.inc index c75f125f0..82a95f68b 100644 --- a/www7/sites/all/modules/contrib/feeds/mappers/date.inc +++ b/www7/sites/all/modules/contrib/feeds/mappers/date.inc @@ -2,31 +2,48 @@ /** * @file - * On behalf implementation of Feeds mapping API for date + * On behalf implementation of Feeds mapping API for date.module. */ /** * Implements hook_feeds_processor_targets(). - * - * @todo Only provides "end date" target if field allows it. */ function date_feeds_processor_targets($entity_type, $bundle_name) { $targets = array(); + $field_types = array( + 'date' => TRUE, + 'datestamp' => TRUE, + 'datetime' => TRUE, + ); + foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) { $info = field_info_field($name); - if (in_array($info['type'], array('date', 'datestamp', 'datetime'))) { - $targets[$name . ':start'] = array( - 'name' => t('@name: Start', array('@name' => $instance['label'])), - 'callback' => 'date_feeds_set_target', - 'description' => t('The start date for the @name field. Also use if mapping both start and end.', array('@name' => $instance['label'])), - 'real_target' => $name, - ); + + if (!isset($field_types[$info['type']])) { + continue; + } + + $targets[$name . ':start'] = array( + 'name' => check_plain($instance['label']), + 'callback' => 'date_feeds_set_target', + 'description' => t('The start date for the @name field. Also use if mapping both start and end.', array('@name' => $instance['label'])), + 'real_target' => $name, + 'summary_callbacks' => array('date_feeds_summary_callback'), + 'form_callbacks' => array('date_feeds_form_callback'), + ); + + if (!empty($info['settings']['todate'])) { + // Change the label for the start date. + $targets[$name . ':start']['name'] = t('@name: Start', array('@name' => $instance['label'])); + $targets[$name . ':end'] = array( 'name' => t('@name: End', array('@name' => $instance['label'])), 'callback' => 'date_feeds_set_target', 'description' => t('The end date for the @name field.', array('@name' => $instance['label'])), 'real_target' => $name, + 'summary_callbacks' => array('date_feeds_summary_callback'), + 'form_callbacks' => array('date_feeds_form_callback'), ); } } @@ -38,25 +55,142 @@ function date_feeds_processor_targets($entity_type, $bundle_name) { * Callback for setting date values. */ function date_feeds_set_target(FeedsSource $source, $entity, $target, array $values, array $mapping) { - list($field_name, $sub_field) = explode(':', $target, 2); + $language = $mapping['language']; + list($target, $sub_field) = explode(':', $target, 2); + + $value_key = $sub_field === 'start' ? 'value' : 'value2'; + $offset_key = $sub_field === 'start' ? 'offset' : 'offset2'; + + $field = isset($entity->$target) ? $entity->$target : array($language => array()); + + $info = field_info_field($target); + $format = date_type_format($info['type']); + + $db_tz = new DateTimeZone(date_get_timezone_db($info['settings']['tz_handling'])); + $default_tz = new DateTimeZone(_date_feeds_get_default_timezone($mapping)); $delta = 0; foreach ($values as $value) { + $value = _date_feeds_get_date_object($value, $default_tz); - if (!($value instanceof FeedsDateTimeElement)) { - - if (empty($value) || !is_numeric($value) && is_string($value) && !date_create($value)) { - $value = new FeedsDateTimeElement(NULL, NULL); - } - elseif ($sub_field == 'end') { - $value = new FeedsDateTimeElement(NULL, $value); - } - else { - $value = new FeedsDateTimeElement($value, NULL); + if (!$value || !empty($value->errors)) { + $field[$language][$delta][$value_key] = ''; + } + else { + if (!isset($field[$language][$delta]['timezone'])) { + $field[$language][$delta]['timezone'] = $value->getTimezone()->getName(); } + + $value->setTimezone($db_tz); + + $field[$language][$delta][$value_key] = $value->format($format, TRUE); + $field[$language][$delta][$offset_key] = $value->getOffset(); } - $value->buildDateField($entity, $field_name, $delta, $mapping['language']); $delta++; } + + $entity->$target = $field; +} + +/** + * Summary callback for date field targets. + */ +function date_feeds_summary_callback(array $mapping, $target, array $form, array $form_state) { + $mapping += array('timezone' => 'UTC'); + + $options = _date_feeds_timezone_options(); + + return t('Default timezone: %zone', array('%zone' => $options[$mapping['timezone']])); +} + +/** + * Form callback for date field targets. + */ +function date_feeds_form_callback(array $mapping, $target, array $form, array $form_state) { + $mapping += array('timezone' => 'UTC'); + + return array( + 'timezone' => array( + '#type' => 'select', + '#title' => t('Timezone handling'), + '#options' => _date_feeds_timezone_options(), + '#default_value' => $mapping['timezone'], + '#description' => t('This value will only be used if the timezone is mising.'), + ), + ); +} + +/** + * Returns the timezone options. + * + * @return array + * A map of timezone options. + */ +function _date_feeds_timezone_options() { + return array( + '__SITE__' => t('Site default'), + ) + system_time_zones(); +} + +/** + * Returns the timezone to be used as the default. + * + * @param array $mapping + * The mapping array. + * + * @return string + * The timezone to use as the default. + */ +function _date_feeds_get_default_timezone(array $mapping) { + $mapping += array('timezone' => 'UTC'); + + if ($mapping['timezone'] === '__SITE__') { + return variable_get('date_default_timezone', 'UTC'); + } + + return $mapping['timezone']; +} + +/** + * Converts a date string or object into a DateObject. + * + * @param DateTime|string|int $value + * The date value or object. + * @param DateTimeZone $default_tz + * The default timezone. + * + * @return DateObject + * The converted DateObject. + */ +function _date_feeds_get_date_object($value, DateTimeZone $default_tz) { + if ($value instanceof DateObject) { + return $value; + } + + // Convert DateTime and FeedsDateTime. + if ($value instanceof DateTime) { + if (!$value->getTimezone() || !preg_match('/[a-zA-Z]/', $value->getTimezone()->getName())) { + $value->setTimezone($default_tz); + } + return new DateObject($value->format(DATE_FORMAT_ISO), $value->getTimezone()); + } + + if (is_string($value) || is_object($value) && method_exists($value, '__toString')) { + $value = trim($value); + } + + // Filter out meaningless values. + if (empty($value) || !is_string($value) && !is_int($value)) { + return FALSE; + } + + // Support year values. + if ((string) $value === (string) (int) $value) { + if ($value >= variable_get('date_min_year', 100) && $value <= variable_get('date_max_year', 4000)) { + return new DateObject('January ' . $value, $default_tz); + } + } + + return new DateObject($value, $default_tz); } diff --git a/www7/sites/all/modules/contrib/feeds/mappers/file.inc b/www7/sites/all/modules/contrib/feeds/mappers/file.inc index 644cbb2b8..a6c6c8337 100644 --- a/www7/sites/all/modules/contrib/feeds/mappers/file.inc +++ b/www7/sites/all/modules/contrib/feeds/mappers/file.inc @@ -6,6 +6,26 @@ * image.module. */ +/** + * Flag for dealing with existing files: Replace the existing file if it is + * different. Do nothing if the new file is exactly the same as the existing + * file. + */ +define('FEEDS_FILE_EXISTS_REPLACE_DIFFERENT', 3); + +/** + * Flag for dealing with existing files: If the new file is different, rename + * it by appending a number until the name is unique. Do nothing if the new file + * is exactly the same as the existing file. + */ +define('FEEDS_FILE_EXISTS_RENAME_DIFFERENT', 4); + +/** + * Flag for dealing with existing files: Do nothing if a file with the same name + * already exists. + */ +define('FEEDS_FILE_EXISTS_SKIP', 5); + /** * Implements hook_feeds_processor_targets(). */ @@ -21,6 +41,8 @@ function file_feeds_processor_targets($entity_type, $bundle_name) { 'callback' => 'file_feeds_set_target', 'description' => t('The URI of the @label field.', array('@label' => $instance['label'])), 'real_target' => $name, + 'summary_callbacks' => array('file_feeds_summary_callback'), + 'form_callbacks' => array('file_feeds_form_callback'), ); // Keep the old target name for backwards compatibility, but hide it from @@ -61,6 +83,7 @@ function file_feeds_processor_targets($entity_type, $bundle_name) { */ function file_feeds_set_target(FeedsSource $source, $entity, $target, array $values, array $mapping) { $language = $mapping['language']; + $mapping += array('file_exists' => FILE_EXISTS_RENAME); // Add default of uri for backwards compatibility. list($field_name, $sub_field) = explode(':', $target . ':uri'); @@ -70,7 +93,7 @@ function file_feeds_set_target(FeedsSource $source, $entity, $target, array $val foreach ($values as $k => $v) { if (!($v instanceof FeedsEnclosure)) { - if (is_string($v)) { + if (!empty($v) && is_string($v)) { $values[$k] = new FeedsEnclosure($v, file_get_mimetype($v)); } else { @@ -121,15 +144,53 @@ function file_feeds_set_target(FeedsSource $source, $entity, $target, array $val break; case 'uri': + $skip = FALSE; if ($v) { + if ($mapping['file_exists'] == FEEDS_FILE_EXISTS_SKIP) { + if (file_exists($destination . '/' . basename($v->getValue()))) { + $skip = TRUE; + } + else { + // We already know the file doesn't exist so we don't have to + // worry about anything being renamed, but we do need a valid + // replace value for file_save(). + $mapping['file_exists'] = FILE_EXISTS_RENAME; + } + } + if ($mapping['file_exists'] == FEEDS_FILE_EXISTS_REPLACE_DIFFERENT) { + if (file_exists($destination . '/' . basename($v->getValue())) && file_feeds_file_compare($v->getValue(), $destination . '/' . basename($v->getValue()))) { + $skip = TRUE; + } + else { + // Either the file doesn't exist or it does and it's different. + $mapping['file_exists'] = FILE_EXISTS_REPLACE; + } + } + if ($mapping['file_exists'] == FEEDS_FILE_EXISTS_RENAME_DIFFERENT) { + if (file_exists($destination . '/' . basename($v->getValue())) && file_feeds_file_compare($v->getValue(), $destination . '/' . basename($v->getValue()))) { + $skip = TRUE; + } + else { + // Either the file doesn't exist or it does and it's different. + $mapping['file_exists'] = FILE_EXISTS_RENAME; + } + } + if ($skip) { + // Create a new dummy feeds enclosure where the value is the file + // already in the file system (it will be skipped by getFile()). + $mapping['file_exists'] = FEEDS_FILE_EXISTS_SKIP; + $existing_path = $destination . '/' . basename($v->getValue()); + $v = new FeedsEnclosure($existing_path, file_get_mimetype($existing_path)); + } try { $v->setAllowedExtensions($instance_info['settings']['file_extensions']); - $field[$language][$delta] += (array) $v->getFile($destination); + $field[$language][$delta] += (array) $v->getFile($destination, $mapping['file_exists']); // @todo: Figure out how to properly populate this field. $field[$language][$delta]['display'] = 1; } catch (Exception $e) { watchdog('feeds', check_plain($e->getMessage())); + continue; } } break; @@ -140,3 +201,89 @@ function file_feeds_set_target(FeedsSource $source, $entity, $target, array $val $entity->$field_name = $field; } + +/** + * Mapping configuration summary callback for file targets. + */ +function file_feeds_summary_callback($mapping, $target, $form, $form_state) { + $mapping += array('file_exists' => FILE_EXISTS_RENAME); + switch ($mapping['file_exists']) { + case FILE_EXISTS_REPLACE: + return t('Replace existing files'); + + case FILE_EXISTS_RENAME: + return t('Rename if file exists'); + + case FEEDS_FILE_EXISTS_REPLACE_DIFFERENT: + return t('Replace only if file exists, but is different'); + + case FEEDS_FILE_EXISTS_RENAME_DIFFERENT: + return t('Rename only if file exists, but is different'); + + case FEEDS_FILE_EXISTS_SKIP: + return t('Skip if file exists'); + } +} + +/** + * Mapping configuration form callback for file targets. + */ +function file_feeds_form_callback($mapping, $target, $form, $form_state) { + $description = array( + '#theme' => 'item_list', + '#items' => array( + t('Rename: files whose name is already in use are renamed.'), + t('Replace: files on the site with the same name are replaced.'), + t('Replace only if different: files on the site with the same name are replaced only if the file to import is different, in other cases the file will not be imported. Works only if the file to import is locally accessible.'), + t('Rename only if different: files on the site with the same name are renamed only if the file to import is different, in other cases the file will not be imported. Works only if the file to import is locally accessible.'), + t('Skip existing: files whose name is already in use are not imported.'), + ), + ); + + return array( + 'file_exists' => array( + '#type' => 'select', + '#title' => t('Replacement method'), + '#default_value' => !empty($mapping['file_exists']) ? $mapping['file_exists'] : FILE_EXISTS_RENAME, + '#options' => array( + FILE_EXISTS_RENAME => t('Rename'), + FILE_EXISTS_REPLACE => t('Replace'), + FEEDS_FILE_EXISTS_REPLACE_DIFFERENT => t('Replace only if different'), + FEEDS_FILE_EXISTS_RENAME_DIFFERENT => t('Rename only if different'), + FEEDS_FILE_EXISTS_SKIP => t('Skip existing'), + ), + '#description' => t('New files are always copied. Files that have a name that is already in use on the site are handled based on this setting.') . drupal_render($description) . t('Note that this setting has no effect when using the File (Field) Paths module.'), + ), + ); +} + +/** + * Compares two files to determine if they are the same. + * + * @param string $file1 + * The path to the first file to compare. + * + * @param string $file2 + * The path to the second file to compare. + * + * @return bool + * TRUE if the files are the same. + * FALSE otherwise. + */ +function file_feeds_file_compare($file1, $file2) { + // If the file size is different then assume they are different files. + // However, remote files may return FALSE from filesize() so only compare + // file sizes if both values are not empty. + $filesize1 = filesize($file1); + $filesize2 = filesize($file2); + if ($filesize1 !== FALSE && $filesize2 !== FALSE && $filesize1 !== $filesize2) { + return FALSE; + } + + // File sizes are the same so check md5 hash of files. + if (md5_file($file1) != md5_file($file2)) { + return FALSE; + } + + return TRUE; +} diff --git a/www7/sites/all/modules/contrib/feeds/plugins/FeedsCSVParser.inc b/www7/sites/all/modules/contrib/feeds/plugins/FeedsCSVParser.inc index f9caeaf84..073a56d03 100644 --- a/www7/sites/all/modules/contrib/feeds/plugins/FeedsCSVParser.inc +++ b/www7/sites/all/modules/contrib/feeds/plugins/FeedsCSVParser.inc @@ -56,12 +56,14 @@ class FeedsCSVParser extends FeedsParser { /** * Get first line and use it for column names, convert them to lower case. * Be aware that the $parser and iterator objects can be modified in this - * function since they are passed in by reference + * function since they are passed in by reference. * * @param ParserCSV $parser * @param ParserCSVIterator $iterator - * @return - * An array of lower-cased column names to use as keys for the parsed items. + * + * @return array|false + * An array of lower-cased column names to use as keys for the parsed items + * or FALSE if the document was empty. */ protected function parseHeader(ParserCSV $parser, ParserCSVIterator $iterator) { $parser->setLineLimit(1); @@ -81,8 +83,13 @@ class FeedsCSVParser extends FeedsParser { * * @param ParserCSV $parser * @param ParserCSVIterator $iterator - * @return - * An array of rows of the CSV keyed by the column names previously set + * @param int $start + * The byte number from where to start parsing the file. + * @param int $limit + * The number of lines to parse, 0 for all lines. + * + * @return array + * An array of rows of the CSV keyed by the column names previously set. */ protected function parseItems(ParserCSV $parser, ParserCSVIterator $iterator, $start = 0, $limit = 0) { $parser->setLineLimit($limit); @@ -149,7 +156,18 @@ class FeedsCSVParser extends FeedsParser { $output = t('Import !csv_files with one or more of these columns: @columns.', array('!csv_files' => l(t('CSV files'), 'http://en.wikipedia.org/wiki/Comma-separated_values'), '@columns' => implode(', ', $sources))); $items = array(); - $items[] = format_plural(count($uniques), 'Column @columns is mandatory and considered unique: only one item per @columns value will be created.', 'Columns @columns are mandatory and values in these columns are considered unique: only one entry per value in one of these column will be created.', array('@columns' => implode(', ', $uniques))); + if ($uniques) { + $items[] = format_plural(count($uniques), + 'Column @columns is mandatory and considered unique: only one item per @columns value will be created.', + 'Columns @columns are mandatory and values in these columns are considered unique: only one entry per value in one of these column will be created.', + array( + '@columns' => implode(', ', $uniques), + ) + ); + } + else { + $items[] = t('No columns are unique. The import will only create new items, no items will be updated.'); + } $items[] = l(t('Download a template'), 'import/' . $this->id . '/template'); $form['help'] = array( '#prefix' => '
      ', diff --git a/www7/sites/all/modules/contrib/feeds/plugins/FeedsFetcher.inc b/www7/sites/all/modules/contrib/feeds/plugins/FeedsFetcher.inc index 33457de66..9a7e8da56 100644 --- a/www7/sites/all/modules/contrib/feeds/plugins/FeedsFetcher.inc +++ b/www7/sites/all/modules/contrib/feeds/plugins/FeedsFetcher.inc @@ -222,4 +222,12 @@ abstract class FeedsFetcher extends FeedsPlugin { * $source, NULL otherwise. */ public function importPeriod(FeedsSource $source) {} + + /** + * Invoked after an import is finished. + * + * @param $source + * A FeedsSource object. + */ + public function afterImport(FeedsSource $source) {} } diff --git a/www7/sites/all/modules/contrib/feeds/plugins/FeedsFileFetcher.inc b/www7/sites/all/modules/contrib/feeds/plugins/FeedsFileFetcher.inc index a3b415c90..88292aec9 100644 --- a/www7/sites/all/modules/contrib/feeds/plugins/FeedsFileFetcher.inc +++ b/www7/sites/all/modules/contrib/feeds/plugins/FeedsFileFetcher.inc @@ -213,6 +213,7 @@ class FeedsFileFetcher extends FeedsFetcher { return array( 'allowed_extensions' => 'txt csv tsv xml opml', + 'delete_uploaded_file' => FALSE, 'direct' => FALSE, 'directory' => $scheme . '://feeds', 'allowed_schemes' => $schemes, @@ -230,6 +231,19 @@ class FeedsFileFetcher extends FeedsFetcher { '#description' => t('Allowed file extensions for upload.'), '#default_value' => $this->config['allowed_extensions'], ); + $form['delete_uploaded_file'] = array( + '#type' => 'checkbox', + '#title' => t('Immediately delete uploaded file after import'), + '#description' => t('Useful if the file contains private information. If not selected, the file will remain on the server, allowing the import to be re-run without having to upload it again. This setting has no effect when the option "@direct" is enabled.', array( + '@direct' => t('Supply path to file or directory directly'), + )), + '#default_value' => $this->config['delete_uploaded_file'], + '#states' => array( + 'disabled' => array( + ':input[name="direct"]' => array('checked' => TRUE), + ), + ), + ); $form['direct'] = array( '#type' => 'checkbox', '#title' => t('Supply path to file or directory directly'), @@ -300,6 +314,20 @@ class FeedsFileFetcher extends FeedsFetcher { } } + /** + * Overrides FeedsFetcher::afterImport(). + */ + public function afterImport(FeedsSource $source) { + // Immediately delete the file after import, if requested. + if (!empty($this->config['delete_uploaded_file'])) { + $source_config = $source->getConfigFor($this); + if (!empty($source_config['fid'])) { + $this->deleteFile($source_config['fid'], $source->feed_nid); + $source->setConfigFor($this, $this->sourceDefaults()); + } + } + } + /** * Deletes a file. * diff --git a/www7/sites/all/modules/contrib/feeds/plugins/FeedsOPMLParser.inc b/www7/sites/all/modules/contrib/feeds/plugins/FeedsOPMLParser.inc index 53aeee137..f8e2a4866 100644 --- a/www7/sites/all/modules/contrib/feeds/plugins/FeedsOPMLParser.inc +++ b/www7/sites/all/modules/contrib/feeds/plugins/FeedsOPMLParser.inc @@ -36,4 +36,13 @@ class FeedsOPMLParser extends FeedsParser { ), ) + parent::getMappingSources(); } + + /** + * Overrides FeedsParser::providesSourceTitle(). + * + * This parser supports retrieving a title from the source. + */ + public function providesSourceTitle() { + return TRUE; + } } diff --git a/www7/sites/all/modules/contrib/feeds/plugins/FeedsParser.inc b/www7/sites/all/modules/contrib/feeds/plugins/FeedsParser.inc index 412888e74..e4fb66ca5 100644 --- a/www7/sites/all/modules/contrib/feeds/plugins/FeedsParser.inc +++ b/www7/sites/all/modules/contrib/feeds/plugins/FeedsParser.inc @@ -171,6 +171,20 @@ abstract class FeedsParser extends FeedsPlugin { $item = $result->currentItem(); return isset($item[$element_key]) ? $item[$element_key] : ''; } + + /** + * Returns if the parsed result can have a title. + * + * Parser classes should override this method in case they support a source + * title. + * + * @return bool + * TRUE if the parsed result can have a title. + * FALSE otherwise. + */ + public function providesSourceTitle() { + return FALSE; + } } /** @@ -285,9 +299,9 @@ class FeedsEnclosure extends FeedsElement { * * @param string */ - protected $mime_type; + protected $mime_type; - /** + /** * The default list of allowed extensions. * * @param string @@ -429,31 +443,35 @@ class FeedsEnclosure extends FeedsElement { /** * Get a Drupal file object of the enclosed resource, download if necessary. * - * @param $destination + * @param string $destination * The path or uri specifying the target directory in which the file is * expected. Don't use trailing slashes unless it's a streamwrapper scheme. + * @param int $replace + * Replace behavior when the destination file already exists. + * @see file_save_data() * - * @return - * A Drupal temporary file object of the enclosed resource. + * @return stdClass|FALSE + * A Drupal temporary file object of the enclosed resource or FALSE if the + * value is empty. * * @throws Exception * If file object could not be created. */ - public function getFile($destination) { - $file = NULL; + public function getFile($destination, $replace = FILE_EXISTS_RENAME) { + $file = FALSE; if ($this->getValue()) { // Prepare destination directory. file_prepare_directory($destination, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY); // Copy or save file depending on whether it is remote or local. if (drupal_realpath($this->getSanitizedUri())) { - $file = new stdClass(); - $file->uid = 0; - $file->uri = $this->getSanitizedUri(); + $file = new stdClass(); + $file->uid = 0; + $file->uri = $this->getSanitizedUri(); $file->filemime = $this->getMIMEType(); $file->filename = $this->getSafeFilename(); if (drupal_dirname($file->uri) !== $destination) { - $file = file_copy($file, $destination); + $file = file_copy($file, $destination, $replace); } else { // If file is not to be copied, check whether file already exists, @@ -462,6 +480,9 @@ class FeedsEnclosure extends FeedsElement { $existing_files = file_load_multiple(array(), array('uri' => $file->uri)); if (count($existing_files)) { $existing = reset($existing_files); + if ($replace == FEEDS_FILE_EXISTS_SKIP) { + return $existing; + } $file->fid = $existing->fid; $file->filename = $existing->filename; } @@ -480,7 +501,7 @@ class FeedsEnclosure extends FeedsElement { $filename = transliteration_clean_filename($filename); } - $file = file_save_data($this->getContent(), $destination . $filename); + $file = file_save_data($this->getContent(), $destination . $filename, $replace); } catch (Exception $e) { watchdog_exception('Feeds', $e, nl2br(check_plain($e))); @@ -499,6 +520,8 @@ class FeedsEnclosure extends FeedsElement { /** * Defines a date element of a parsed result (including ranges, repeat). + * + * @deprecated This is no longer in use and will not be maintained. */ class FeedsDateTimeElement extends FeedsElement { @@ -659,6 +682,8 @@ class FeedsDateTimeElement extends FeedsElement { * class. * * @see FeedsDateTimeElement + * + * @deprecated Use DateObject instead. */ class FeedsDateTime extends DateTime { public $granularity = array(); @@ -667,24 +692,11 @@ class FeedsDateTime extends DateTime { private $_serialized_timezone; /** - * Helper function to prepare the object during serialization. - * - * We are extending a core class and core classes cannot be serialized. + * The original time value passed into the constructor. * - * Ref: http://bugs.php.net/41334, http://bugs.php.net/39821 - */ - public function __sleep() { - $this->_serialized_time = $this->format('c'); - $this->_serialized_timezone = $this->getTimezone()->getName(); - return array('_serialized_time', '_serialized_timezone'); - } - - /** - * Upon unserializing, we must re-build ourselves using local variables. + * @var mixed */ - public function __wakeup() { - $this->__construct($this->_serialized_time, new DateTimeZone($this->_serialized_timezone)); - } + protected $originalValue; /** * Overridden constructor. @@ -696,6 +708,8 @@ class FeedsDateTime extends DateTime { * PHP DateTimeZone object, NULL allowed */ public function __construct($time = '', $tz = NULL) { + $this->originalValue = $time; + if (is_numeric($time)) { // Assume UNIX timestamp if it doesn't look like a simple year. if (strlen($time) > 4) { @@ -733,6 +747,43 @@ class FeedsDateTime extends DateTime { $this->setGranularityFromTime($time, $tz); } + /** + * Helper function to prepare the object during serialization. + * + * We are extending a core class and core classes cannot be serialized. + * + * Ref: http://bugs.php.net/41334, http://bugs.php.net/39821 + */ + public function __sleep() { + $this->_serialized_time = $this->format('c'); + $this->_serialized_timezone = $this->getTimezone()->getName(); + return array('_serialized_time', '_serialized_timezone'); + } + + /** + * Upon unserializing, we must re-build ourselves using local variables. + */ + public function __wakeup() { + $this->__construct($this->_serialized_time, new DateTimeZone($this->_serialized_timezone)); + } + + /** + * Returns the string representation. + * + * Will try to use the literal input, if that is a string. Fallsback to + * ISO-8601. + * + * @return string + * The string version of this DateTime object. + */ + public function __toString() { + if (is_scalar($this->originalValue)) { + return (string) $this->originalValue; + } + + return $this->format('Y-m-d\TH:i:sO'); + } + /** * This function will keep this object's values by default. */ @@ -847,6 +898,7 @@ class FeedsDateTime extends DateTime { protected function toArray() { return array('year' => $this->format('Y'), 'month' => $this->format('m'), 'day' => $this->format('d'), 'hour' => $this->format('H'), 'minute' => $this->format('i'), 'second' => $this->format('s'), 'zone' => $this->format('e')); } + } /** @@ -864,12 +916,16 @@ function feeds_to_unixtime($date, $default_value) { if (is_numeric($date)) { return $date; } - elseif (is_string($date) && !empty($date)) { - $date = new FeedsDateTimeElement($date); + + if ($date instanceof FeedsDateTimeElement) { return $date->getValue(); } - elseif ($date instanceof FeedsDateTimeElement) { - return $date->getValue(); + + if (is_string($date) || is_object($date) && method_exists($date, '__toString')) { + if ($date_object = date_create(trim($date))) { + return $date_object->format('U'); + } } + return $default_value; } diff --git a/www7/sites/all/modules/contrib/feeds/plugins/FeedsProcessor.inc b/www7/sites/all/modules/contrib/feeds/plugins/FeedsProcessor.inc index a77a284e0..ead72acb3 100644 --- a/www7/sites/all/modules/contrib/feeds/plugins/FeedsProcessor.inc +++ b/www7/sites/all/modules/contrib/feeds/plugins/FeedsProcessor.inc @@ -465,7 +465,7 @@ abstract class FeedsProcessor extends FeedsPlugin { */ protected function clean(FeedsState $state) { // We clean only if needed. - if ($this->config['update_non_existent'] == FEEDS_SKIP_NON_EXISTENT) { + if ($this->config['update_non_existent'] != FEEDS_DELETE_NON_EXISTENT) { return; } @@ -883,14 +883,15 @@ abstract class FeedsProcessor extends FeedsPlugin { $form['update_existing'] = array( '#type' => 'radios', '#title' => t('Update existing @entities', $tokens), - '#description' => - t('Existing @entities will be determined using mappings that are a "unique target".', $tokens), + '#description' => t('Existing @entities will be determined using mappings that are a "unique target".', $tokens), '#options' => array( FEEDS_SKIP_EXISTING => t('Do not update existing @entities', $tokens), FEEDS_REPLACE_EXISTING => t('Replace existing @entities', $tokens), FEEDS_UPDATE_EXISTING => t('Update existing @entities', $tokens), ), '#default_value' => $this->config['update_existing'], + '#after_build' => array('feeds_processor_config_form_update_existing_after_build'), + '#tokens' => $tokens, ); global $user; $formats = filter_formats($user); @@ -1263,6 +1264,9 @@ abstract class FeedsProcessor extends FeedsPlugin { foreach ($out as $key => $value) { if (is_string($value)) { + if (function_exists('mb_check_encoding') && !mb_check_encoding($value, 'UTF-8')) { + $value = utf8_encode($value); + } $out[$key] = truncate_utf8($value, 100, FALSE, TRUE); } } @@ -1292,3 +1296,14 @@ abstract class FeedsProcessor extends FeedsPlugin { } class FeedsProcessorBundleNotDefined extends Exception {} + +/** + * Form after build callback for the field "update_existing". + * + * Adds descriptions to options of this field. + */ +function feeds_processor_config_form_update_existing_after_build($field) { + $field[FEEDS_REPLACE_EXISTING]['#description'] = t('Loads records directly from the database, bypassing the Entity API. Faster, but use with caution.'); + $field[FEEDS_UPDATE_EXISTING]['#description'] = t('Loads complete @entities using the Entity API for full integration with other modules. Slower, but most reliable.', $field['#tokens']); + return $field; +} diff --git a/www7/sites/all/modules/contrib/feeds/plugins/FeedsSimplePieParser.inc b/www7/sites/all/modules/contrib/feeds/plugins/FeedsSimplePieParser.inc index 018d98ad5..dd17b6b77 100644 --- a/www7/sites/all/modules/contrib/feeds/plugins/FeedsSimplePieParser.inc +++ b/www7/sites/all/modules/contrib/feeds/plugins/FeedsSimplePieParser.inc @@ -215,6 +215,15 @@ class FeedsSimplePieParser extends FeedsParser { ) + parent::getMappingSources(); } + /** + * Overrides FeedsParser::providesSourceTitle(). + * + * This parser supports retrieving a title from the source. + */ + public function providesSourceTitle() { + return TRUE; + } + /** * Returns cache directory. Creates it if it doesn't exist. */ diff --git a/www7/sites/all/modules/contrib/feeds/plugins/FeedsSyndicationParser.inc b/www7/sites/all/modules/contrib/feeds/plugins/FeedsSyndicationParser.inc index 09b0cb327..3da4af9a4 100644 --- a/www7/sites/all/modules/contrib/feeds/plugins/FeedsSyndicationParser.inc +++ b/www7/sites/all/modules/contrib/feeds/plugins/FeedsSyndicationParser.inc @@ -76,6 +76,23 @@ class FeedsSyndicationParser extends FeedsParser { 'name' => t('Geo Locations'), 'description' => t('An array of geographic locations with a name and a position.'), ), + 'source:url' => array( + 'name' => t('Source: URL'), + 'description' => t('The URL of the RSS channel that the item came from.'), + ), + 'source:title' => array( + 'name' => t('Source: Title'), + 'description' => t('The title of the RSS channel that the item came from.'), + ), ) + parent::getMappingSources(); } + + /** + * Overrides FeedsParser::providesSourceTitle(). + * + * This parser supports retrieving a title from the source. + */ + public function providesSourceTitle() { + return TRUE; + } } diff --git a/www7/sites/all/modules/contrib/feeds/plugins/FeedsUserProcessor.inc b/www7/sites/all/modules/contrib/feeds/plugins/FeedsUserProcessor.inc index 47d26e5cd..d9d62c0cd 100644 --- a/www7/sites/all/modules/contrib/feeds/plugins/FeedsUserProcessor.inc +++ b/www7/sites/all/modules/contrib/feeds/plugins/FeedsUserProcessor.inc @@ -16,6 +16,30 @@ define('FEEDS_BLOCK_NON_EXISTENT', 'block'); * Feeds processor plugin. Create users from feed items. */ class FeedsUserProcessor extends FeedsProcessor { + /** + * Search by role name. + */ + const ROLE_SEARCH_NAME = 'name'; + + /** + * Search by role id. + */ + const ROLE_SEARCH_RID = 'rid'; + + /** + * Unencrypted password. + */ + const PASS_UNENCRYPTED = 'none'; + + /** + * MD5 encrypted password. + */ + const PASS_MD5 = 'md5'; + + /** + * SHA512 encrypted password. + */ + const PASS_SHA512 = 'sha512'; /** * Define entity type. @@ -41,6 +65,7 @@ class FeedsUserProcessor extends FeedsProcessor { $account->uid = 0; $account->roles = array_filter($this->config['roles']); $account->status = $this->config['status']; + $account->is_new = TRUE; return $account; } @@ -53,6 +78,21 @@ class FeedsUserProcessor extends FeedsProcessor { // Copy the password so that we can compare it again at save. $user->feeds_original_pass = $user->pass; + + // Reset roles and status when an user is replaced. + if ($this->config['update_existing'] == FEEDS_REPLACE_EXISTING) { + $user->roles = array_filter($this->config['roles']); + $user->status = $this->config['status']; + + // Unserialize user data if it is still serialized. + if (!empty($user->data) && @unserialize($user->data)) { + $user->data = unserialize($user->data); + } + else { + $user->data = array(); + } + } + return $user; } @@ -65,6 +105,26 @@ class FeedsUserProcessor extends FeedsProcessor { if (empty($account->name) || empty($account->mail) || !valid_email_address($account->mail)) { throw new FeedsValidationException(t('User name missing or email not valid.')); } + + // Check when an user ID gets set or changed during processing if that user + // ID is not already in use. + if (!empty($account->uid)) { + $is_new = !empty($account->feeds_item->is_new); + $different = !empty($account->feeds_item->entity_id) && $account->feeds_item->entity_id != $account->uid; + if ($is_new || $different) { + $exists = entity_load_unchanged('user', $account->uid); + if ($exists) { + throw new FeedsValidationException(t('Could not update user ID to @uid since that ID is already in use.', array( + '@uid' => $account->uid, + ))); + } + } + } + + // Timezone validation. + if (!empty($account->timezone) && !array_key_exists($account->timezone, system_time_zones())) { + throw new FeedsValidationException(t("Failed importing '@name'. User's timezone is not valid.", array('@name' => $account->name))); + } } /** @@ -82,7 +142,27 @@ class FeedsUserProcessor extends FeedsProcessor { unset($edit['pass']); } + // Check if the user ID changed when updating users. + if (!empty($account->feeds_item->entity_id) && $account->feeds_item->entity_id != $account->uid) { + // The user ID of the existing user is different. Try to update the user ID. + db_update('users') + ->fields(array( + 'uid' => $account->uid, + )) + ->condition('uid', $account->feeds_item->entity_id) + ->execute(); + } + user_save($account, $edit); + + // If an encrypted password was given, directly set this in the database. + if ($account->uid && !empty($account->pass_crypted)) { + db_update('users') + ->fields(array('pass' => $account->pass_crypted)) + ->condition('uid', $account->uid) + ->execute(); + } + if ($account->uid && !empty($account->openid)) { $authmap = array( 'uid' => $account->uid, @@ -99,6 +179,16 @@ class FeedsUserProcessor extends FeedsProcessor { * Delete multiple user accounts. */ protected function entityDeleteMultiple($uids) { + // Prevent user 1 from being deleted. + if (in_array(1, $uids)) { + $uids = array_diff($uids, array(1)); + + // But do delete the associated feeds item. + db_delete('feeds_item') + ->condition('entity_type', $this->entityType()) + ->condition('entity_id', 1) + ->execute(); + } user_delete_multiple($uids); } @@ -148,16 +238,51 @@ class FeedsUserProcessor extends FeedsProcessor { } /** - * Override setTargetElement to operate on a target item that is a node. + * Overrides FeedsProcessor::map(). + * + * Ensures that the user is assigned additional roles that are configured on + * the settings. The roles could have been revoked when there was mapped to + * the "roles_list" target. */ - public function setTargetElement(FeedsSource $source, $target_user, $target_element, $value) { + protected function map(FeedsSource $source, FeedsParserResult $result, $target_item = NULL) { + $target_item = parent::map($source, $result, $target_item); + + // Assign additional roles as configured. + $roles = array_filter($this->config['roles']); + foreach ($roles as $rid) { + $target_item->roles[$rid] = $rid; + } + + return $target_item; + } + + /** + * Overrides setTargetElement() to operate on a target item that is an user. + */ + public function setTargetElement(FeedsSource $source, $target_user, $target_element, $value, array $mapping = array()) { switch ($target_element) { + case 'pass': + $this->setPassTarget($source, $target_user, $target_element, $value, $mapping); + break; + case 'created': $target_user->created = feeds_to_unixtime($value, REQUEST_TIME); break; + case 'language': $target_user->language = strtolower($value); break; + + case 'roles_list': + // Ensure that the role list is an array. + $value = (array) $value; + $this->rolesListSetTarget($source, $target_user, $target_element, $value, $mapping); + break; + + case 'timezone': + $target_user->timezone = $value; + break; + default: parent::setTargetElement($source, $target_user, $target_element, $value); break; @@ -170,23 +295,30 @@ class FeedsUserProcessor extends FeedsProcessor { public function getMappingTargets() { $targets = parent::getMappingTargets(); $targets += array( + 'uid' => array( + 'name' => t('User ID'), + 'description' => t('The uid of the user. NOTE: use this feature with care, user ids are usually assigned by Drupal.'), + 'optional_unique' => TRUE, + ), 'name' => array( 'name' => t('User name'), 'description' => t('Name of the user.'), 'optional_unique' => TRUE, - ), + ), 'mail' => array( 'name' => t('Email address'), 'description' => t('Email address of the user.'), 'optional_unique' => TRUE, - ), + ), 'created' => array( 'name' => t('Created date'), 'description' => t('The created (e. g. joined) data of the user.'), - ), + ), 'pass' => array( - 'name' => t('Unencrypted Password'), - 'description' => t('The unencrypted user password.'), + 'name' => t('Password'), + 'description' => t('The user password.'), + 'summary_callbacks' => array(array($this, 'passSummaryCallback')), + 'form_callbacks' => array(array($this, 'passFormCallback')), ), 'status' => array( 'name' => t('Account status'), @@ -196,13 +328,23 @@ class FeedsUserProcessor extends FeedsProcessor { 'name' => t('User language'), 'description' => t('Default language for the user.'), ), + 'timezone' => array( + 'name' => t('Timezone'), + 'description' => t('The timezone identifier, like UTC or Europe/Lisbon.'), + ), + 'roles_list' => array( + 'name' => t('User roles'), + 'description' => t('User roles provided as role names in comma separated list.'), + 'summary_callbacks' => array(array($this, 'rolesListSummaryCallback')), + 'form_callbacks' => array(array($this, 'rolesListFormCallback')), + ), ); if (module_exists('openid')) { $targets['openid'] = array( 'name' => t('OpenID identifier'), 'description' => t('The OpenID identifier of the user. CAUTION: Use only for migration purposes, misconfiguration of the OpenID identifier can lead to severe security breaches like users gaining access to accounts other than their own.'), 'optional_unique' => TRUE, - ); + ); } $this->getHookTargets($targets); @@ -222,12 +364,18 @@ class FeedsUserProcessor extends FeedsProcessor { // target's value. foreach ($this->uniqueTargets($source, $result) as $target => $value) { switch ($target) { + case 'uid': + $uid = db_query("SELECT uid FROM {users} WHERE uid = :uid", array(':uid' => $value))->fetchField(); + break; + case 'name': $uid = db_query("SELECT uid FROM {users} WHERE name = :name", array(':name' => $value))->fetchField(); break; + case 'mail': $uid = db_query("SELECT uid FROM {users} WHERE mail = :mail", array(':mail' => $value))->fetchField(); break; + case 'openid': $uid = db_query("SELECT uid FROM {authmap} WHERE authname = :authname AND module = 'openid'", array(':authname' => $value))->fetchField(); break; @@ -240,6 +388,18 @@ class FeedsUserProcessor extends FeedsProcessor { return 0; } + /** + * Overrides FeedsProcessor::initEntitiesToBeRemoved(). + * + * Removes user 1 from the list of entities to be removed. + */ + protected function initEntitiesToBeRemoved(FeedsSource $source, FeedsState $state) { + parent::initEntitiesToBeRemoved($source, $state); + + // Prevent user 1 from being deleted. + unset($state->removeList[1]); + } + /** * Overrides FeedsProcessor::clean(). * @@ -270,4 +430,265 @@ class FeedsUserProcessor extends FeedsProcessor { } } + /** + * Returns default values for mapper "roles_list". + */ + public function rolesListDefaults() { + $roles = user_roles(TRUE); + unset($roles[DRUPAL_AUTHENTICATED_RID]); + $rids = array_keys($roles); + $rids = array_combine($rids, $rids); + return array( + 'role_search' => self::ROLE_SEARCH_NAME, + 'allowed_roles' => $rids, + 'autocreate' => 0, + 'revoke_roles' => 1, + ); + } + + /** + * Mapping configuration summary callback for target "roles_list". + */ + public function rolesListSummaryCallback(array $mapping, $target, array $form, array $form_state) { + $options = array(); + + // Add in defaults. + $defaults = $this->rolesListDefaults(); + $mapping += $defaults; + $mapping['allowed_roles'] += $defaults['allowed_roles']; + + // Role search. + $role_search_options = $this->rolesListRoleSearchOptions(); + $options[] = t('Search roles by: @search', array('@search' => $role_search_options[$mapping['role_search']])); + + // Allowed roles. + $role_names = array(); + $roles = user_roles(TRUE); + foreach (array_filter($mapping['allowed_roles']) as $rid => $enabled) { + $role_names[] = $roles[$rid]; + } + + if (empty($role_names)) { + $role_names = array('<' . t('none') . '>'); + } + $options[] = t('Allowed roles: %roles', array('%roles' => implode(', ', $role_names))); + + // Autocreate. + if ($mapping['autocreate']) { + $options[] = t('Automatically create roles'); + } + else { + $options[] = t('Only assign existing roles'); + } + + // Revoke roles. + if ($mapping['revoke_roles']) { + $options[] = t('Revoke roles: yes'); + } + else { + $options[] = t('Revoke roles: no'); + } + + return implode('
      ', $options); + } + + /** + * Mapping configuration form callback for target "roles_list". + */ + public function rolesListFormCallback(array $mapping, $target, array $form, array $form_state) { + // Add in defaults. + $defaults = $this->rolesListDefaults(); + $mapping += $defaults; + $mapping['allowed_roles'] += $defaults['allowed_roles']; + + $allowed_roles_options = user_roles(TRUE); + unset($allowed_roles_options[DRUPAL_AUTHENTICATED_RID]); + + return array( + 'role_search' => array( + '#type' => 'select', + '#title' => t('Search roles by'), + '#options' => $this->rolesListRoleSearchOptions(), + '#default_value' => $mapping['role_search'], + ), + 'allowed_roles' => array( + '#type' => 'checkboxes', + '#title' => t('Allowed roles'), + '#options' => $allowed_roles_options, + '#default_value' => $mapping['allowed_roles'], + '#description' => t('Select the roles to accept from the feed.
      Any other roles will be ignored.') + ), + 'autocreate' => array( + '#type' => 'checkbox', + '#title' => t('Auto create'), + '#description' => t("Create the role if it doesn't exist."), + '#default_value' => $mapping['autocreate'], + ), + 'revoke_roles' => array( + '#type' => 'checkbox', + '#title' => t('Revoke roles'), + '#description' => t('If enabled, roles that are not provided by the feed will be revoked for the user. This affects only the "Allowed roles" as configured above.'), + '#default_value' => $mapping['revoke_roles'], + ), + ); + } + + /** + * Returns role list options. + */ + public function rolesListRoleSearchOptions() { + return array( + self::ROLE_SEARCH_NAME => t('Role name'), + self::ROLE_SEARCH_RID => t('Role ID'), + ); + } + + /** + * Sets role target on the user entity. + */ + public function rolesListSetTarget(FeedsSource $source, $entity, $target, array $values, array $mapping) { + // Add in defaults. + $defaults = $this->rolesListDefaults(); + $mapping += $defaults; + $mapping['allowed_roles'] += $defaults['allowed_roles']; + + // Eventually revoke roles. Do not touch roles that are not allowed to set + // by the source. + if ($mapping['revoke_roles']) { + foreach ($mapping['allowed_roles'] as $rid) { + unset($entity->roles[$rid]); + } + } + + foreach ($values as $value) { + $role = NULL; + + $value = trim($value); + if (strlen($value) < 1) { + // No role provided. Continue to the next role. + continue; + } + + switch ($mapping['role_search']) { + case self::ROLE_SEARCH_NAME: + $role = user_role_load_by_name($value); + if (!$role && !empty($mapping['autocreate'])) { + // Create new role if role doesn't exist. + $role = new stdClass(); + $role->name = $value; + user_role_save($role); + $role = user_role_load_by_name($role->name); + } + break; + + case self::ROLE_SEARCH_RID: + $role = user_role_load($value); + break; + } + + if ($role) { + // Check if the role may be assigned. + if (isset($mapping['allowed_roles'][$role->rid]) && !$mapping['allowed_roles'][$role->rid]) { + // This role may *not* be assiged. + continue; + } + $entity->roles[$role->rid] = $role->name; + } + } + } + + /** + * Mapping configuration summary callback for target "pass". + */ + public function passSummaryCallback($mapping, $target, $form, $form_state) { + $options = $this->passSummaryCallbackOptions(); + if (!isset($mapping['pass_encryption'])) { + $mapping['pass_encryption'] = self::PASS_UNENCRYPTED; + } + return t('Password encryption: @encryption', array('@encryption' => $options[$mapping['pass_encryption']])); + } + + /** + * Returns the list of available password encryption methods. + * + * Used by ::passSummaryCallback(). + * + * @return array + * An array of password encryption option titles. + * + * @see passSummaryCallback() + */ + protected function passSummaryCallbackOptions() { + return array( + self::PASS_UNENCRYPTED => t('None'), + self::PASS_MD5 => t('MD5'), + self::PASS_SHA512 => t('SHA512'), + ); + } + + /** + * Mapping configuration form callback for target "pass". + */ + public function passFormCallback($mapping, $target, $form, $form_state) { + return array( + 'pass_encryption' => array( + '#type' => 'select', + '#title' => t('Password encryption'), + '#options' => $this->passFormCallbackOptions(), + '#default_value' => !empty($mapping['pass_encryption']) ? $mapping['pass_encryption'] : self::PASS_UNENCRYPTED, + ), + ); + } + + /** + * Returns the list of available password encryption methods. + * + * Used by ::passFormCallback(). + * + * @return array + * An array of password encryption option titles. + * + * @see passFormCallback() + */ + protected function passFormCallbackOptions() { + return array( + self::PASS_UNENCRYPTED => t('Unencrypted'), + self::PASS_MD5 => t('MD5 (used in older versions of Drupal)'), + self::PASS_SHA512 => t('SHA512 (default in Drupal 7)'), + ); + } + + /** + * Sets the password on the user target. + * + * @see setTargetElement() + */ + protected function setPassTarget($source, $target_user, $target_element, $value, $mapping) { + if (empty($value)) { + return; + } + if (!isset($mapping['pass_encryption'])) { + $mapping['pass_encryption'] = self::PASS_UNENCRYPTED; + } + + switch ($mapping['pass_encryption']) { + case self::PASS_MD5: + require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc'); + $new_hash = user_hash_password($value); + if ($new_hash) { + // Indicate an updated password. + $new_hash = 'U' . $new_hash; + $target_user->pass = $target_user->pass_crypted = $new_hash; + } + break; + + case self::PASS_SHA512: + $target_user->pass = $target_user->pass_crypted = $value; + break; + + default: + $target_user->pass = $value; + break; + } + } } diff --git a/www7/sites/all/modules/contrib/feeds/tests/common_syndication_parser.test b/www7/sites/all/modules/contrib/feeds/tests/common_syndication_parser.test index d8eabb4ca..d68ca4b52 100644 --- a/www7/sites/all/modules/contrib/feeds/tests/common_syndication_parser.test +++ b/www7/sites/all/modules/contrib/feeds/tests/common_syndication_parser.test @@ -33,6 +33,7 @@ class CommonSyndicationParserTestCase extends DrupalWebTestCase { $this->_testRSS2(); $this->_testAtomGeoRSS(); $this->_testAtomGeoRSSWithoutAuthor(); + $this->_testAtomEntriesWithoutBaseUrl(); } /** @@ -91,6 +92,32 @@ class CommonSyndicationParserTestCase extends DrupalWebTestCase { $feed = common_syndication_parser_parse($string); } + /** + * Tests if the base url is prepended for entries without base url. + * + * For example, the url in the following entry should be parsed as + * 'http://www.example.com/node/123' and not as 'node/123'. + * @code + * + * + * + * @endcode + */ + protected function _testAtomEntriesWithoutBaseUrl() { + $string = $this->readFeed('entries-without-base-url.atom'); + $feed = common_syndication_parser_parse($string); + + // Assert that all items got the base url assigned. + $expected = array( + 'http://www.example.com/node/1281496#comment-11669575', + 'http://www.example.com/node/1281496#comment-10080648', + 'http://www.example.com/node/1281496#comment-10062564', + ); + foreach ($feed['items'] as $key => $item) { + $this->assertEqual($expected[$key], $item['url']); + } + } + /** * Helper to read a feed. */ diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds.test b/www7/sites/all/modules/contrib/feeds/tests/feeds.test index b3ce145ce..c486773d8 100644 --- a/www7/sites/all/modules/contrib/feeds/tests/feeds.test +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds.test @@ -90,6 +90,7 @@ class FeedsWebTestCase extends DrupalWebTestCase { $permissions[] = 'administer users'; $permissions[] = 'administer feeds'; $permissions[] = 'administer filters'; + $permissions[] = 'administer fields'; // Create an admin user and log in. $this->admin_user = $this->drupalCreateUser($permissions); @@ -468,7 +469,14 @@ class FeedsWebTestCase extends DrupalWebTestCase { // Set some settings. $edit = array(); foreach ($config as $key => $value) { - $edit["config[$i][settings][$key]"] = $value; + if (is_array($value)) { + foreach ($value as $subkey => $subvalue) { + $edit["config[$i][settings][$key][$subkey]"] = $subvalue; + } + } + else { + $edit["config[$i][settings][$key]"] = $value; + } } $this->drupalPostAJAX(NULL, $edit, 'mapping_settings_update_' . $i); $this->drupalPost(NULL, array(), t('Save')); @@ -583,12 +591,23 @@ class FeedsWebTestCase extends DrupalWebTestCase { /** * Copies a directory. + * + * @param string $source + * The path of the source directory, from which files should be copied. + * @param string $dest + * The path of the destination directory, where files should be copied to. + * @param array $mapping + * (optional) The files to rename in the process. + * To skip files from being copied, map filename to FALSE. */ - public function copyDir($source, $dest) { + public function copyDir($source, $dest, array $mapping = array()) { $result = file_prepare_directory($dest, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); foreach (@scandir($source) as $file) { if (is_file("$source/$file")) { - $file = file_unmanaged_copy("$source/$file", "$dest/$file"); + $new_name = isset($mapping[$file]) ? $mapping[$file] : $file; + if ($new_name !== FALSE) { + $file = file_unmanaged_copy("$source/$file", "$dest/$new_name"); + } } } } diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds/content_date.csv b/www7/sites/all/modules/contrib/feeds/tests/feeds/content_date.csv index 68a59cff9..c2262e28e 100644 --- a/www7/sites/all/modules/contrib/feeds/tests/feeds/content_date.csv +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds/content_date.csv @@ -1,3 +1,3 @@ -"guid","title","created","end" -1,"Lorem ipsum",1251936720,1351936720 -2,"Ut wisi enim ad minim veniam",1251932360,1351932360 +"guid","title","created","end","datetime_start","datetime_end" +1,"Lorem ipsum",1251936720,1351936720,"1955-11-05 12:00","1955-11-05 15:00" +2,"Ut wisi enim ad minim veniam",1251932360,1351932360,"21-10-2015 23:29","22-10-2015 2:29" diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds/developmentseed.rss2 b/www7/sites/all/modules/contrib/feeds/tests/feeds/developmentseed.rss2 index 90f5deafa..54106859a 100644 --- a/www7/sites/all/modules/contrib/feeds/tests/feeds/developmentseed.rss2 +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds/developmentseed.rss2 @@ -42,6 +42,7 @@ Tue, 06 Oct 2009 15:21:48 +0000 Development Seed 974 at http://developmentseed.org + Technological Solutions for Progressive Organizations Week in DC Tech: October 5th Edition diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds/entries-without-base-url.atom b/www7/sites/all/modules/contrib/feeds/tests/feeds/entries-without-base-url.atom new file mode 100644 index 000000000..043c78b6a --- /dev/null +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds/entries-without-base-url.atom @@ -0,0 +1,45 @@ + + + Feeds issue #1281496 + + + 2016-10-29T20:35:56Z + + dcotruta + + http://www.example.com/node/1281496 + + + Re-spin the patch + + comment-11669575 + 2016-09-28T17:08:00Z + Re-spin the patch for feeds 7.x-2.0-beta2. + + natew + + + + + Thanks twistor, I just tried the latest patch + + comment-10080648 + 2015-07-02T19:33:00Z + Thanks twistor, I just tried the latest patch and this works for me. The feed items get imported and the proper url is set. + + natew + + + + + Probably missed a string cast somewhere. + + comment-10062564 + 2015-06-26T19:52:00Z + Probably missed a string cast somewhere. + + twistor + + + + diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds/users.csv b/www7/sites/all/modules/contrib/feeds/tests/feeds/users.csv index aede81cab..27f24035a 100644 --- a/www7/sites/all/modules/contrib/feeds/tests/feeds/users.csv +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds/users.csv @@ -1,6 +1,6 @@ -name,mail,since,password -Morticia,morticia@example.com,1244347500,mort -Fester,fester@example.com,1241865600,fest -Gomez,gomez@example.com,1228572000,gome -Wednesday,wednesdayexample.com,1228347137,wedn -Pugsley,pugsley@example,1228260225,pugs +uid,name,mail,since,password,password_md5,password_sha512,timezone +201,Morticia,morticia@example.com,1244347500,mort,e0108a7eb91670308fff8179a4785453,$S$DfuNE4ur7Jq8xVoJURGm8oMIYunKd366KQUE6akc3EXW/ym9ghpq,UTC +202,Fester,fester@example.com,1241865600,fest,c8cce3815094f01f0ab774fd4f7a77d4,$S$DjJPqmjlWTIen0nQrG3a.vA71Vc0DqCpKuB.g9zmBMnGzIV6JxqH, +203,Gomez,gomez@example.com,1228572000,gome,8a5346b9a510f1f698ab0062b71201ac,$S$Dv.EtHlTfnrxuWGLbe3cf31mD9MF6.4u2Z46M2o2dMGgQGzi7m/5,utc +204,Wednesday,wednesdayexample.com,1228347137,wedn,fefb673afaf531dbd78771976a150dc8,$S$DdPzksGh/c8UukipWagAhTzaqUp/eNHVPiC.x6URBQyA503Z41PI,America/New_York +205,Pugsley,pugsley@example,1228260225,pugs,09189568a8ee4d0addf53d2f6e4847cd,$S$D1oUihjrYXr.4iesN8Sfw1rVRLdo188v0NRGgcNR/V09oIyYPYmZ,Europe/Lisbon diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds/users_roles.csv b/www7/sites/all/modules/contrib/feeds/tests/feeds/users_roles.csv new file mode 100644 index 000000000..414cfef42 --- /dev/null +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds/users_roles.csv @@ -0,0 +1,5 @@ +name,mail,since,password,roles,rids +Morticia,morticia@example.com,1244347500,mort,editor,6 +Fester,fester@example.com,1241865600,fest,manager,4 +Gomez,gomez@example.com,1228572000,gome,tester| |manager,5| |4 +Pugsley,pugsley@example.com,1228260225,pugs,, \ No newline at end of file diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds_content_type.test b/www7/sites/all/modules/contrib/feeds/tests/feeds_content_type.test new file mode 100644 index 000000000..4ee2b2aa6 --- /dev/null +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds_content_type.test @@ -0,0 +1,110 @@ + 'Feed content type', + 'description' => 'Tests behavior for when an importer is attached to a content type.', + 'group' => 'Feeds', + ); + } + + public function setUp() { + parent::setUp(); + + // Create an importer configuration. + $this->createImporterConfiguration('Syndication', 'syndication'); + $this->addMappings('syndication', + array( + 0 => array( + 'source' => 'title', + 'target' => 'title', + 'unique' => FALSE, + ), + 1 => array( + 'source' => 'description', + 'target' => 'body', + ), + 2 => array( + 'source' => 'timestamp', + 'target' => 'created', + ), + 3 => array( + 'source' => 'url', + 'target' => 'url', + 'unique' => TRUE, + ), + 4 => array( + 'source' => 'guid', + 'target' => 'guid', + 'unique' => TRUE, + ), + ) + ); + } + + /** + * Tests if titles can be retrieved from a feed. + */ + public function testRetrieveTitleFromFeed() { + // The Common syndication parser supports retrieving title from feed. + $edit = array( + 'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/developmentseed.rss2', + ); + $this->drupalPost('node/add/page', $edit, 'Save'); + + $node = node_load(1); + $this->assertEqual('Development Seed - Technological Solutions for Progressive Organizations', $node->title, 'The title was retrieved from the feed.'); + } + + /** + * Tests if the node title is required when the CSV parser is used. + */ + public function testRequiredNodeTitleWithCSVParser() { + // Set parser to CSV. + $this->setPlugin('syndication', 'FeedsCSVParser'); + + $edit = array( + 'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/content.csv', + ); + $this->drupalPost('node/add/page', $edit, 'Save'); + + $this->assertText('Title field is required.'); + } + + /** + * Tests that the feed node gets no title if the content type does not use the + * node title field. + */ + public function testWithContentTypeWithoutTitle() { + // Set that the content type 'page' has no title. + db_update('node_type') + ->fields(array( + 'has_title' => 0, + )) + ->condition('type', 'page') + ->execute(); + + // Flush caches so this change is picked up. + drupal_flush_all_caches(); + + // And import a RSS feed with a title. + $edit = array( + 'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/developmentseed.rss2', + ); + $this->drupalPost('node/add/page', $edit, 'Save'); + + // Assert that the feed node didn't got a title from the source. + $node = node_load(1); + $this->assertEqual('', $node->title, 'The feed node has no title.'); + } + +} diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds_fetcher_file.test b/www7/sites/all/modules/contrib/feeds/tests/feeds_fetcher_file.test index 65736031d..089c7c02f 100644 --- a/www7/sites/all/modules/contrib/feeds/tests/feeds_fetcher_file.test +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds_fetcher_file.test @@ -18,24 +18,31 @@ class FeedsFileFetcherTestCase extends FeedsWebTestCase { } /** - * Test scheduling on cron. + * {@inheritdoc} */ - public function testPublicFiles() { + public function setUp() { + parent::setUp(); + // Set up an importer. $this->createImporterConfiguration('Node import', 'node'); // Set and configure plugins and mappings. $this->setSettings('node', NULL, array('content_type' => '')); $this->setPlugin('node', 'FeedsFileFetcher'); $this->setPlugin('node', 'FeedsCSVParser'); - $mappings = array( + $this->addMappings('node', array( '0' => array( 'source' => 'title', 'target' => 'title', ), - ); - $this->addMappings('node', $mappings); - // Straight up upload is covered in other tests, focus on direct mode - // and file batching here. + )); + } + + /** + * Test scheduling on cron. + */ + public function testPublicFiles() { + // Straight up upload is covered in other tests, focus on direct mode and + // file batching here. $settings = array( 'direct' => TRUE, 'directory' => 'public://feeds', @@ -72,24 +79,8 @@ class FeedsFileFetcherTestCase extends FeedsWebTestCase { * Test uploading private files. */ public function testPrivateFiles() { - // Set up an importer. - $this->createImporterConfiguration('Node import', 'node'); - // Set and configure plugins and mappings. - $edit = array( - 'content_type' => '', - ); - $this->drupalPost('admin/structure/feeds/node/settings', $edit, 'Save'); - $this->setPlugin('node', 'FeedsFileFetcher'); - $this->setPlugin('node', 'FeedsCSVParser'); - $mappings = array( - '0' => array( - 'source' => 'title', - 'target' => 'title', - ), - ); - $this->addMappings('node', $mappings); - // Straight up upload is covered in other tests, focus on direct mode - // and file batching here. + // Straight up upload is covered in other tests, focus on direct mode and + // file batching here. $settings = array( 'direct' => TRUE, 'directory' => 'private://feeds', @@ -111,4 +102,96 @@ class FeedsFileFetcherTestCase extends FeedsWebTestCase { $this->assertText('Created 18 nodes'); } + /** + * Tests if files can be removed after the import has finished. + */ + public function testRemoveFileAfterImport() { + $this->setSettings('node', 'FeedsFileFetcher', array( + 'delete_uploaded_file' => TRUE, + 'directory' => 'private://feeds', + )); + + // Import the file. + $this->importFile('node', $this->absolutePath() . '/tests/feeds/content.csv'); + $this->assertText('Created 2 nodes'); + + // Assert that the file no longer exists. + $this->assertFalse(file_exists('private://feeds/content.csv'), 'The imported file no longer exists.'); + + // Assert that the file is no longer shown on the import form. + $this->drupalGet('import/node'); + $this->assertNoText('nodes.csv'); + } + + /** + * Tests if files can be removed after import when running the import in + * background. + */ + public function testRemoveFileAfterImportInBackground() { + // Configure to import in background and import as often as possible. + $this->setSettings('node', NULL, array( + 'import_period' => 0, + 'import_on_create' => FALSE, + 'process_in_background' => TRUE, + )); + $this->setSettings('node', 'FeedsFileFetcher', array( + 'delete_uploaded_file' => TRUE, + 'directory' => 'private://feeds', + )); + + // Make sure that the import cannot be completed in one run. + variable_set('feeds_process_limit', 5); + + // Set variable to enforce that only five items get imported per cron run. + // @see feeds_tests_cron_queue_alter() + // @see feeds_tests_feeds_after_save() + variable_set('feeds_tests_feeds_source_import_queue_time', 5); + variable_set('feeds_tests_feeds_after_save_sleep', 1); + + // Import a file with 9 nodes. + $this->importFile('node', $this->absolutePath() . '/tests/feeds/nodes.csv'); + + // Assert that the file has been created. + $this->assertTrue(file_exists('private://feeds/nodes.csv'), 'The imported file is created.'); + + // Run cron and assert that five nodes have been created. + $this->cronRun(); + $node_count = db_select('node') + ->fields('node', array()) + ->countQuery() + ->execute() + ->fetchField(); + $this->assertEqual(5, $node_count, format_string('Five nodes have been created (actual: @count).', array( + '@count' => $node_count, + ))); + + // Assert that the file to import still exists as the import hasn't finished + // yet. + drupal_flush_all_caches(); + $this->assertTrue(file_exists('private://feeds/nodes.csv'), 'The imported file still exists.'); + + // Run cron again to import the remaining 4 nodes and assert that 9 nodes + // exist in total. + $this->cronRun(); + $node_count = db_select('node') + ->fields('node', array()) + ->countQuery() + ->execute() + ->fetchField(); + $this->assertEqual(9, $node_count, format_string('Nine nodes have been created (actual: @count).', array( + '@count' => $node_count, + ))); + + // Assert that the file to import finally has been removed now. + drupal_flush_all_caches(); + $this->assertFalse(file_exists('private://feeds/nodes.csv'), 'The imported file no longer exists.'); + + // Assert that running a second import does not result into errors. + $this->cronRun(); + + // Assert that the file is no longer shown on the import form. + $this->drupalGet('import/node'); + $this->assertNoText('nodes.csv'); + } + } diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds_mapper_date.test b/www7/sites/all/modules/contrib/feeds/tests/feeds_mapper_date.test index 7dd8cfac5..e76f3471e 100644 --- a/www7/sites/all/modules/contrib/feeds/tests/feeds_mapper_date.test +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds_mapper_date.test @@ -37,11 +37,11 @@ class FeedsMapperDateTestCase extends FeedsMapperTestCase { $typename = $this->createContentType(array(), array( 'date' => 'date', 'datestamp' => 'datestamp', - //'datetime' => 'datetime', // REMOVED because the field is broken ATM. + 'datetime' => 'datetime', )); // Hack to get date fields to not round to every 15 minutes. - foreach (array('date', 'datestamp') as $field) { + foreach (array('date', 'datestamp', 'datetime') as $field) { $field = 'field_' . $field; $edit = array( 'widget_type' => 'date_select', @@ -84,6 +84,10 @@ class FeedsMapperDateTestCase extends FeedsMapperTestCase { 'source' => 'timestamp', 'target' => 'field_datestamp:start', ), + 4 => array( + 'source' => 'timestamp', + 'target' => 'field_datetime:start', + ), )); $edit = array( @@ -108,6 +112,7 @@ class FeedsMapperDateTestCase extends FeedsMapperTestCase { $this->drupalGet("node/$i/edit"); $this->assertNodeFieldValue('date', $values[$i-1]); $this->assertNodeFieldValue('datestamp', $values[$i-1]); + $this->assertNodeFieldValue('datetime', $values[$i-1]); } } @@ -120,6 +125,126 @@ class FeedsMapperDateTestCase extends FeedsMapperTestCase { } } + /** + * Tests importing dates using the timezone mapping option. + */ + public function testTimezoneMappingOption() { + // Create content type. + $typename = $this->createContentType(array(), array( + 'date' => 'date', + 'datestamp' => 'datestamp', + 'datetime' => 'datetime', + )); + + // Hack to get date fields to not round to every 15 minutes. + foreach (array('date', 'datestamp', 'datetime') as $field) { + $field = 'field_' . $field; + $edit = array( + 'widget_type' => 'date_select', + ); + $this->drupalPost('admin/structure/types/manage/' . $typename . '/fields/' . $field . '/widget-type', $edit, 'Continue'); + $edit = array( + 'instance[widget][settings][increment]' => 1, + 'field[settings][enddate_get]' => 1, + 'instance[settings][default_value]' => 'blank', + ); + $this->drupalPost('admin/structure/types/manage/' . $typename . '/fields/' . $field, $edit, 'Save settings'); + $edit = array( + 'widget_type' => 'date_text', + ); + $this->drupalPost('admin/structure/types/manage/' . $typename . '/fields/' . $field . '/widget-type', $edit, 'Continue'); + } + + // Create and configure importer. + $this->createImporterConfiguration('Content CSV', 'csv'); + $this->setSettings('csv', NULL, array( + 'content_type' => '', + 'import_period' => FEEDS_SCHEDULE_NEVER, + )); + $this->setPlugin('csv', 'FeedsFileFetcher'); + $this->setPlugin('csv', 'FeedsCSVParser'); + $this->setSettings('csv', 'FeedsNodeProcessor', array( + 'bundle' => $typename, + )); + $this->addMappings('csv', array( + 0 => array( + 'source' => 'title', + 'target' => 'title', + 'unique' => TRUE, + ), + // Los Angeles == UTC-08:00. + 1 => array( + 'source' => 'datetime_start', + 'target' => 'field_date:start', + 'timezone' => 'America/Los_Angeles', + ), + 2 => array( + 'source' => 'datetime_end', + 'target' => 'field_date:end', + 'timezone' => 'America/Los_Angeles', + ), + // Amsterdam == UTC+01:00. + 3 => array( + 'source' => 'datetime_start', + 'target' => 'field_datestamp:start', + 'timezone' => 'Europe/Amsterdam', + ), + 4 => array( + 'source' => 'datetime_end', + 'target' => 'field_datestamp:end', + 'timezone' => 'Europe/Amsterdam', + ), + // Sydney == UTC+10:00. + 5 => array( + 'source' => 'datetime_start', + 'target' => 'field_datetime:start', + 'timezone' => 'Australia/Sydney', + ), + 6 => array( + 'source' => 'datetime_end', + 'target' => 'field_datetime:end', + 'timezone' => 'Australia/Sydney', + ), + )); + + // Import CSV file. + $this->importFile('csv', $this->absolutePath() . '/tests/feeds/content_date.csv'); + $this->assertText('Created 2 nodes'); + + // Check the imported nodes. + $date_values = array( + // Wintertime. + // (Hear me calling) + 1 => array( + 'field_date_start' => '11/05/1955 - 20:00', + 'field_date_end' => '11/05/1955 - 23:00', + 'field_datestamp_start' => '11/05/1955 - 11:00', + 'field_datestamp_end' => '11/05/1955 - 14:00', + 'field_datetime_start' => '11/05/1955 - 02:00', + 'field_datetime_end' => '11/05/1955 - 05:00', + ), + // Summertime =+0100. + // (Dee dee dee) + 2 => array( + 'field_date_start' => '10/22/2015 - 06:29', + 'field_date_end' => '10/22/2015 - 09:29', + 'field_datestamp_start' => '10/21/2015 - 21:29', + 'field_datestamp_end' => '10/22/2015 - 00:29', + 'field_datetime_start' => '10/21/2015 - 12:29', + 'field_datetime_end' => '10/21/2015 - 15:29', + ), + ); + for ($i = 1; $i <= 2; $i++) { + $this->drupalGet("node/$i/edit"); + $this->assertFieldByName('field_date[und][0][value][date]', $date_values[$i]['field_date_start']); + $this->assertFieldByName('field_date[und][0][value2][date]', $date_values[$i]['field_date_end']); + $this->assertFieldByName('field_datestamp[und][0][value][date]', $date_values[$i]['field_datestamp_start']); + $this->assertFieldByName('field_datestamp[und][0][value2][date]', $date_values[$i]['field_datestamp_end']); + $this->assertFieldByName('field_datetime[und][0][value][date]', $date_values[$i]['field_datetime_start']); + $this->assertFieldByName('field_datetime[und][0][value2][date]', $date_values[$i]['field_datetime_end']); + } + } + /** * Tests if values are cleared out when an empty value is provided. */ @@ -141,6 +266,7 @@ class FeedsMapperDateTestCase extends FeedsMapperTestCase { $edit = array( 'instance[widget][settings][increment]' => 1, 'field[settings][enddate_get]' => 1, + 'instance[settings][default_value]' => 'blank', ); $this->drupalPost('admin/structure/types/manage/' . $typename . '/fields/' . $field, $edit, 'Save settings'); $edit = array( @@ -210,11 +336,11 @@ class FeedsMapperDateTestCase extends FeedsMapperTestCase { ); for ($i = 1; $i <= 2; $i++) { $this->drupalGet("node/$i/edit"); - $this->assertNodeFieldValue('date', $date_values[$i]['created']); + $this->assertFieldByName('field_date[und][0][value][date]', $date_values[$i]['created']); $this->assertFieldByName('field_date[und][0][value2][date]', $date_values[$i]['end']); - $this->assertNodeFieldValue('datestamp', $date_values[$i]['created']); + $this->assertFieldByName('field_datestamp[und][0][value][date]', $date_values[$i]['created']); $this->assertFieldByName('field_datestamp[und][0][value2][date]', $date_values[$i]['end']); - $this->assertNodeFieldValue('datetime', $date_values[$i]['created']); + $this->assertFieldByName('field_datetime[und][0][value][date]', $date_values[$i]['created']); $this->assertFieldByName('field_datetime[und][0][value2][date]', $date_values[$i]['end']); } @@ -225,12 +351,12 @@ class FeedsMapperDateTestCase extends FeedsMapperTestCase { // Check if all values were cleared out for both nodes. for ($i = 1; $i <= 2; $i++) { $this->drupalGet("node/$i/edit"); - $this->assertNoNodeFieldValue('date', $date_values[$i]['created']); - $this->assertNoFieldByName('field_date[und][0][value2][date]', $date_values[$i]['end']); - $this->assertNoNodeFieldValue('datestamp', $date_values[$i]['created']); - $this->assertNoFieldByName('field_datestamp[und][0][value2][date]', $date_values[$i]['end']); - $this->assertNoNodeFieldValue('datetime', $date_values[$i]['created']); - $this->assertNoFieldByName('field_datetime[und][0][value2][date]', $date_values[$i]['end']); + $this->assertFieldByName('field_date[und][0][value][date]', ''); + $this->assertFieldByName('field_date[und][0][value2][date]', ''); + $this->assertFieldByName('field_datestamp[und][0][value][date]', ''); + $this->assertFieldByName('field_datestamp[und][0][value2][date]', ''); + $this->assertFieldByName('field_datetime[und][0][value][date]', ''); + $this->assertFieldByName('field_datetime[und][0][value2][date]', ''); $this->drupalGet("node/$i"); $this->assertNoText('date_label'); $this->assertNoText('datestamp_label'); @@ -242,11 +368,11 @@ class FeedsMapperDateTestCase extends FeedsMapperTestCase { $this->assertText('Updated 2 nodes'); for ($i = 1; $i <= 2; $i++) { $this->drupalGet("node/$i/edit"); - $this->assertNodeFieldValue('date', $date_values[$i]['created']); + $this->assertFieldByName('field_date[und][0][value][date]', $date_values[$i]['created']); $this->assertFieldByName('field_date[und][0][value2][date]', $date_values[$i]['end']); - $this->assertNodeFieldValue('datestamp', $date_values[$i]['created']); + $this->assertFieldByName('field_datestamp[und][0][value][date]', $date_values[$i]['created']); $this->assertFieldByName('field_datestamp[und][0][value2][date]', $date_values[$i]['end']); - $this->assertNodeFieldValue('datetime', $date_values[$i]['created']); + $this->assertFieldByName('field_datetime[und][0][value][date]', $date_values[$i]['created']); $this->assertFieldByName('field_datetime[und][0][value2][date]', $date_values[$i]['end']); } @@ -256,12 +382,12 @@ class FeedsMapperDateTestCase extends FeedsMapperTestCase { // Check if all values were cleared out for node 1. $this->drupalGet('node/1/edit'); - $this->assertNoNodeFieldValue('date', $date_values[1]['created']); - $this->assertNoFieldByName('field_date[und][0][value2][date]', $date_values[1]['end']); - $this->assertNoNodeFieldValue('datestamp', $date_values[1]['created']); - $this->assertNoFieldByName('field_datestamp[und][0][value2][date]', $date_values[1]['end']); - $this->assertNoNodeFieldValue('datetime', $date_values[1]['created']); - $this->assertNoFieldByName('field_datetime[und][0][value2][date]', $date_values[1]['end']); + $this->assertFieldByName('field_date[und][0][value2][date]', ''); + $this->assertFieldByName('field_date[und][0][value2][date]', ''); + $this->assertFieldByName('field_datestamp[und][0][value2][date]', ''); + $this->assertFieldByName('field_datestamp[und][0][value2][date]', ''); + $this->assertFieldByName('field_datetime[und][0][value2][date]', ''); + $this->assertFieldByName('field_datetime[und][0][value2][date]', ''); // Check if labels for fields that should be cleared out are not shown. $this->drupalGet('node/1'); $this->assertNoText('date_label'); diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds_mapper_file.test b/www7/sites/all/modules/contrib/feeds/tests/feeds_mapper_file.test index 6138be0e5..9451e451a 100644 --- a/www7/sites/all/modules/contrib/feeds/tests/feeds_mapper_file.test +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds_mapper_file.test @@ -20,27 +20,26 @@ class FeedsMapperFileTestCase extends FeedsMapperTestCase { public function setUp() { parent::setUp(array('dblog')); - } - /** - * Basic test loading a single entry CSV file. - */ - public function test() { // If this is unset (or FALSE) http_request.inc will use curl, and will - // generate a 404 for this feel url provided by feeds_tests. However, if + // generate a 404 for the feed url provided by feeds_tests. However, if // feeds_tests was enabled in your site before running the test, it will // work fine. Since it is truly screwy, lets just force it to use - // drupal_http_request for this test case. + // drupal_http_request() for this test case. variable_set('feeds_never_use_curl', TRUE); + // Get our defined constants and any helper functions. + module_load_include('inc', 'feeds', 'mappers/file'); + } + + /** + * Basic test loading a single entry CSV file. + */ + public function test() { // Only download simplepie if the plugin doesn't already exist somewhere. // People running tests locally might have it. - if (!feeds_simplepie_exists()) { - $this->downloadExtractSimplePie('1.3'); - $this->assertTrue(feeds_simplepie_exists()); - // Reset all the caches! - $this->resetAll(); - } + $this->requireSimplePie(); + $typename = $this->createContentType(array(), array( 'files' => array( 'type' => 'file', @@ -70,7 +69,7 @@ class FeedsMapperFileTestCase extends FeedsMapperTestCase { 'target' => 'field_files:uri', ), )); - $nid = $this->createFeedNode('syndication', $GLOBALS['base_url'] . '/testing/feeds/flickr.xml'); + $nid = $this->createFeedNode('syndication', $GLOBALS['base_url'] . '/testing/feeds/flickr.xml', 'Test Title'); $this->assertText('Created 5 nodes'); $files = $this->listTestFiles(); @@ -162,6 +161,479 @@ class FeedsMapperFileTestCase extends FeedsMapperTestCase { } } + /** + * Test mapping of local resources with the file exists "Rename" setting. + * + * In this test, files to import should be renamed if files with the same name + * already exist in the destination folder. + * Example: on the destination folder there exist a file named 'foo.jpg'. When + * importing a file with the same name, that file should be renamed to + * 'foo_0.jpg'. + */ + public function testFileExistsRename() { + // Copy the files to import to the folder 'images'. + $this->copyDir($this->absolutePath() . '/tests/feeds/assets', 'public://images'); + + // Create a content type. Save imported files into the directory + // 'destination_rename'. + $typename = $this->createContentTypeWithFileField('destination_rename'); + + // Copy files with the same names to the destination folder. These files + // should remain intact, while the files to import should get renamed. + $this->copyDir($this->absolutePath() . '/tests/feeds/assets', 'public://destination_rename'); + + // Create a CSV importer configuration. + $this->createImporterConfiguration('Node import from CSV -- File Exists Rename', 'node_rename'); + $this->setSettings('node_rename', NULL, array('content_type' => '')); + $this->setPlugin('node_rename', 'FeedsCSVParser'); + $this->setSettings('node_rename', 'FeedsNodeProcessor', array('bundle' => $typename)); + $this->addMappings('node_rename', array( + 0 => array( + 'source' => 'title', + 'target' => 'title', + ), + 1 => array( + 'source' => 'file', + 'target' => 'field_files:uri', + 'file_exists' => FILE_EXISTS_RENAME, + ), + )); + + // Perform the import. + $edit = array( + 'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/testing/feeds/files.csv', + ); + $this->drupalPost('import/node_rename', $edit, 'Import'); + $this->assertText('Created 5 nodes'); + + // Assert: all imported files should be renamed. + $files = $this->listTestFiles(); + $entities = db_select('feeds_item') + ->fields('feeds_item', array('entity_id')) + ->condition('id', 'node_rename') + ->execute(); + foreach ($entities as $entity) { + $this->drupalGet('node/' . $entity->entity_id . '/edit'); + $f = new FeedsEnclosure(array_shift($files), NULL); + $renamed_file = str_replace('.jpeg', '_0.jpeg', $f->getUrlEncodedValue()); + $this->assertRaw('destination_rename/' . $renamed_file); + } + + // Clean up the last import. + $this->drupalPost('import/node_rename/delete-items', array(), 'Delete'); + } + + /** + * Test mapping of local resources with the file exists "Replace" setting. + * + * In this test, files to import should be replaced if files with the same + * name already exist in the destination folder. + * Example: on the destination folder there exist a file named 'foo.jpg'. + * When importing a file with the same name, that file should replace the + * existing 'foo.jpg'. + */ + public function testFileExistsReplace() { + $source = 'public://images'; + $dest = 'public://destination_replace'; + + // Copy the files to import to the folder 'images'. + $this->copyDir($this->absolutePath() . '/tests/feeds/assets', $source); + + // Create a content type. Save imported files into the directory + // 'destination_replace'. + $typename = $this->createContentTypeWithFileField('destination_replace'); + + // Copy files with the same name to the destination folder, but make sure + // that the files are different by shuffling the file names. These files + // should get overwritten upon import. + $this->copyDir($this->absolutePath() . '/tests/feeds/assets', $dest, $this->listTestFilesNameMap()); + + // Confirm the files from the source folder are all different from the + // destination folder. + foreach (@scandir($source) as $file) { + if (is_file("$source/$file")) { + $message = "$source/$file is not the same as $dest/$file"; + $this->assertFalse(file_feeds_file_compare("$source/$file", "$dest/$file"), $message); + } + } + + // Create a CSV importer configuration. + $this->createImporterConfiguration('Node import from CSV -- File Exists Replace', 'node_replace'); + $this->setSettings('node_replace', NULL, array('content_type' => '')); + $this->setPlugin('node_replace', 'FeedsCSVParser'); + $this->setSettings('node_replace', 'FeedsNodeProcessor', array('bundle' => $typename)); + $this->addMappings('node_replace', array( + 0 => array( + 'source' => 'title', + 'target' => 'title', + ), + 1 => array( + 'source' => 'file', + 'target' => 'field_files:uri', + 'file_exists' => FILE_EXISTS_REPLACE, + ), + )); + + // Perform the import. + $edit = array( + 'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/testing/feeds/files.csv', + ); + $this->drupalPost('import/node_replace', $edit, 'Import'); + $this->assertText('Created 5 nodes'); + + // Assert: all files in the destination folder should be exactly the same as + // the files in the source folder. + foreach (@scandir($source) as $file) { + if (is_file("$source/$file")) { + $message = "$source/$file is the same as $dest/$file"; + $this->assertTrue(file_feeds_file_compare("$source/$file", "$dest/$file"), $message); + } + } + + // Clean up the last import. + $this->drupalPost('import/node_replace/delete-items', array(), 'Delete'); + } + + /** + * Test mapping of local resources with the file exists "Rename if different" + * setting. + * + * In this test, files to import should only be renamed under the following + * circumstances: + * - A file the same name already exist in the destination folder; + * - AND this file is different. + * + * Example: on the destination folder there exist two files: one called + * 'foo.jpg' and an other called 'bar.jpg'. On an import two files with the + * same name are imported. The 'foo.jpg' is exactly the same as the one that + * already exist on the destination, but 'bar.jpg' is different. In this case, + * only 'bar.jpg' should get imported and it should be renamed to 'bar_0.jpg'. + * Importing 'foo.jpg' should be skipped as it is already there. The file's + * timestamp will remain the same. + */ + public function testFileExistsRenameIfDifferent() { + $source = 'public://images'; + $dest = 'public://destination_rename_diff'; + + // Copy the files to import to the folder 'images'. + $this->copyDir($this->absolutePath() . '/tests/feeds/assets', $source); + + // Create a content type. Save imported files into the directory + // 'destination_rename_diff'. + $typename = $this->createContentTypeWithFileField('destination_rename_diff'); + + // Shuffle a couple of the file names so the files appear to be different. + // Leave a few others the same. + $same = array( + 'foosball.jpeg' => 'foosball.jpeg', + 'attersee.jpeg' => 'attersee.jpeg', + 'hstreet.jpeg' => 'hstreet.jpeg', + ); + $different = array( + 'la fayette.jpeg' => 'tubing.jpeg', + 'tubing.jpeg' => 'la fayette.jpeg', + ); + + // Copy files with the same name to the destination folder. A few of them + // however, will be different. Only these files should get renamed upon + // import. + $this->copyDir($this->absolutePath() . '/tests/feeds/assets', $dest, $same + $different); + + // Note the timestamps that the files got in the destination folder. + $file_timestamps = array(); + foreach (@scandir($dest) as $file) { + $file_timestamps[$file] = filemtime("$dest/$file"); + } + + // Confirm that some of the files are the same. + foreach ($same as $file) { + if (is_file("$source/$file")) { + $message = "$source/$file IS the same as $dest/$file"; + $this->assertTrue(file_feeds_file_compare("$source/$file", "$dest/$file"), $message); + } + } + + // Confirm that some of the files are different. + foreach ($different as $file) { + if (is_file("$source/$file")) { + $message = "$source/$file is NOT the same as $dest/$file"; + $this->assertFalse(file_feeds_file_compare("$source/$file", "$dest/$file"), $message); + } + } + + // Create a CSV importer configuration. + $this->createImporterConfiguration('Node import from CSV -- File Exists Rename if Different', 'node_rename_diff'); + $this->setSettings('node_rename_diff', NULL, array('content_type' => '')); + $this->setPlugin('node_rename_diff', 'FeedsCSVParser'); + $this->setSettings('node_rename_diff', 'FeedsNodeProcessor', array('bundle' => $typename)); + $this->addMappings('node_rename_diff', array( + 0 => array( + 'source' => 'title', + 'target' => 'title', + ), + 1 => array( + 'source' => 'file', + 'target' => 'field_files:uri', + 'file_exists' => FEEDS_FILE_EXISTS_RENAME_DIFFERENT, + ), + )); + + // Perform the import. + $edit = array( + 'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/testing/feeds/files.csv', + ); + $this->drupalPost('import/node_rename_diff', $edit, 'Import'); + $this->assertText('Created 5 nodes'); + + // Assert that only files that were different should have been renamed. + $files = $this->listTestFiles(); + $entities = db_select('feeds_item') + ->fields('feeds_item', array('entity_id')) + ->condition('id', 'node_rename_diff') + ->execute(); + foreach ($entities as $entity) { + $this->drupalGet('node/' . $entity->entity_id . '/edit'); + $f = new FeedsEnclosure(array_shift($files), NULL); + $original_file = $f->getUrlEncodedValue(); + $renamed_file = str_replace('.jpeg', '_0.jpeg', $f->getUrlEncodedValue()); + + if (isset($same[$original_file])) { + // Assert that the file still has the same name. + $this->assertRaw('destination_rename_diff/' . $original_file); + } + else { + // Assert that the file still has been renamed. + $this->assertRaw('destination_rename_diff/' . $renamed_file); + } + } + + // Assert that some files have been kept the same. + foreach ($same as $file) { + if (is_file("$source/$file")) { + $message = "$source/$file is STILL the same as $dest/$file"; + $this->assertTrue(file_feeds_file_compare("$source/$file", "$dest/$file"), $message); + $message = "$dest/$file was not replaced (modification time is the same as before import)"; + $this->assertEqual(filemtime("$dest/$file"), $file_timestamps[$file], $message); + } + } + + // Clean up the last import. + $this->drupalPost('import/node_rename_diff/delete-items', array(), 'Delete'); + } + + /** + * Test mapping of local resources with the file exists "Replace if different" + * setting. + * + * In this test, files to import should only be replaced under the following + * circumstances: + * - A file the same name already exist in the destination folder; + * - AND this file is different. + * + * Example: on the destination folder there exist two files: one called + * 'foo.jpg' and an other called 'bar.jpg'. On an import two files with the + * same name are imported. The 'foo.jpg' is exactly the same as the one that + * already exist on the destination, but 'bar.jpg' is different. In this case, + * only 'bar.jpg' should get imported and it should overwrite the existing + * 'bar.jpg'. Importing 'foo.jpg' should be skipped as it is already there. + * The file's timestamp will remain the same. + */ + public function testFileExistsReplaceIfDifferent() { + $source = 'public://images'; + $dest = 'public://destination_replace_diff'; + + // Copy the files to import to the folder 'images'. + $this->copyDir($this->absolutePath() . '/tests/feeds/assets', $source); + + // Create a content type. Save imported files into the directory + // 'destination_replace_diff'. + $typename = $this->createContentTypeWithFileField('destination_replace_diff'); + + // Shuffle a couple of the file names so the files appear to be different. + // Leave a few others the same. + $same = array( + 'foosball.jpeg' => 'foosball.jpeg', + 'attersee.jpeg' => 'attersee.jpeg', + 'hstreet.jpeg' => 'hstreet.jpeg', + ); + $different = array( + 'la fayette.jpeg' => 'tubing.jpeg', + 'tubing.jpeg' => 'la fayette.jpeg', + ); + + // Copy files with the same name to the destination folder. A few of them + // however, will be different. Only these files should get replaced upon + // import. + $this->copyDir($this->absolutePath() . '/tests/feeds/assets', $dest, $same + $different); + + // Note the timestamps that the files got in the destination folder. + $file_timestamps = array(); + foreach (@scandir($dest) as $file) { + $file_timestamps[$file] = filemtime("$dest/$file"); + } + + // Confirm that some of the files are the same. + foreach ($same as $file) { + if (is_file("$source/$file")) { + $message = "$source/$file IS the same as $dest/$file"; + $this->assertTrue(file_feeds_file_compare("$source/$file", "$dest/$file"), $message); + } + } + + // Confirm that some of the files are different. + foreach ($different as $file) { + if (is_file("$source/$file")) { + $message = "$source/$file is NOT the same as $dest/$file"; + $this->assertFalse(file_feeds_file_compare("$source/$file", "$dest/$file"), $message); + } + } + + // Create a CSV importer configuration. + $this->createImporterConfiguration('Node import from CSV -- File Exists Replace if Different', 'node_replace_diff'); + $this->setSettings('node_replace_diff', NULL, array('content_type' => '')); + $this->setPlugin('node_replace_diff', 'FeedsCSVParser'); + $this->setSettings('node_replace_diff', 'FeedsNodeProcessor', array('bundle' => $typename)); + $this->addMappings('node_replace_diff', array( + 0 => array( + 'source' => 'title', + 'target' => 'title', + ), + 1 => array( + 'source' => 'file', + 'target' => 'field_files:uri', + 'file_exists' => FEEDS_FILE_EXISTS_REPLACE_DIFFERENT, + ), + )); + + // Perform the import. + $edit = array( + 'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/testing/feeds/files.csv', + ); + $this->drupalPost('import/node_replace_diff', $edit, 'Import'); + $this->assertText('Created 5 nodes'); + + // Assert that some files have been kept the same. + foreach ($same as $file) { + if (is_file("$source/$file")) { + $message = "$source/$file is STILL the same as $dest/$file"; + $this->assertTrue(file_feeds_file_compare("$source/$file", "$dest/$file"), $message); + $message = "$dest/$file was not replaced (modification time is the same as before import)"; + $this->assertEqual(filemtime("$dest/$file"), $file_timestamps[$file], $message); + } + } + + // Assert that some files were replaced. + foreach ($different as $file) { + if (is_file("$source/$file")) { + $message = "$source/$file successfully replaced $dest/$file"; + $this->assertTrue(file_feeds_file_compare("$source/$file", "$dest/$file"), $message); + $this->assertNotEqual(filemtime("$dest/$file"), $file_timestamps[$file], $message); + } + } + + // Clean up the last import. + $this->drupalPost('import/node_replace_diff/delete-items', array(), 'Delete'); + } + + /** + * Test mapping of local resources with the file exists "Skip existig" + * setting. + * + * In this test, files should only be imported if no file exist yet with the + * given name. + * Example: on the destination folder there exist a file named 'foo.jpg'. When + * importing a file with the same name, that file should not be imported + * as there already is a file with that name. + */ + public function testFileExistsSkip() { + $source = 'public://images'; + $dest = 'public://destination_skip'; + + // Copy the files to import to the folder 'images'. + $this->copyDir($this->absolutePath() . '/tests/feeds/assets', $source); + + // Create a content type. Save imported files into the directory + // 'destination_skip'. + $typename = $this->createContentTypeWithFileField('destination_skip'); + + // Copy a few images also to the destination directory. + $same = array( + 'foosball.jpeg' => 'foosball.jpeg', + 'attersee.jpeg' => 'attersee.jpeg', + 'hstreet.jpeg' => 'hstreet.jpeg', + ); + $different = array( + 'la fayette.jpeg' => FALSE, + 'tubing.jpeg' => FALSE, + ); + $this->copyDir($this->absolutePath() . '/tests/feeds/assets', $dest, $same + $different); + + // Note the timestamps that the files got in the destination folder. + $file_timestamps = array(); + foreach (@scandir($dest) as $file) { + $file_timestamps[$file] = filemtime("$dest/$file"); + } + + // Confirm that some of the files are the same. + foreach ($same as $file) { + if (is_file("$source/$file")) { + $message = "$source/$file IS the same as $dest/$file"; + $this->assertTrue(file_feeds_file_compare("$source/$file", "$dest/$file"), $message); + } + } + + // Confirm that some of the files do not exist. + foreach ($different as $file => $value) { + $message = "$dest/$file does not exist."; + $this->assertFalse(file_exists("$dest/$file"), $message); + } + + // Create a CSV importer configuration. + $this->createImporterConfiguration('Node import from CSV -- File Exists Replace if Different', 'node_skip'); + $this->setSettings('node_skip', NULL, array('content_type' => '')); + $this->setPlugin('node_skip', 'FeedsCSVParser'); + $this->setSettings('node_skip', 'FeedsNodeProcessor', array('bundle' => $typename)); + $this->addMappings('node_skip', array( + 0 => array( + 'source' => 'title', + 'target' => 'title', + ), + 1 => array( + 'source' => 'file', + 'target' => 'field_files:uri', + 'file_exists' => FEEDS_FILE_EXISTS_SKIP, + ), + )); + + // Perform the import. + $edit = array( + 'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/testing/feeds/files.csv', + ); + $this->drupalPost('import/node_skip', $edit, 'Import'); + $this->assertText('Created 5 nodes'); + + // Assert that files that were already in the destination folder were not + // overwritten. + foreach ($same as $file) { + if (is_file("$source/$file")) { + $message = "$dest/$file was skipped (modification time is the same as before import)"; + $this->assertEqual(filemtime("$dest/$file"), $file_timestamps[$file], $message); + } + } + + // Assert that the other files were added with the expected names. + $files = $this->listTestFiles(); + $entities = db_select('feeds_item') + ->fields('feeds_item', array('entity_id')) + ->condition('id', 'node_skip') + ->execute(); + foreach ($entities as $entity) { + $this->drupalGet('node/' . $entity->entity_id . '/edit'); + $f = new FeedsEnclosure(array_shift($files), NULL); + $this->assertRaw('destination_skip/' . $f->getUrlEncodedValue()); + } + } + /** * Tests mapping to an image field. */ @@ -398,6 +870,48 @@ class FeedsMapperFileTestCase extends FeedsMapperTestCase { } } + /** + * Creates a content type with a file field. + * + * @param string $dest + * The folder to save files to. Leave empty to not set that. + * + * @return string + * The name of the content type that was created. + */ + protected function createContentTypeWithFileField($dest = '') { + $typename = $this->createContentType(array(), array( + 'files' => array( + 'type' => 'file', + 'instance_settings' => array( + 'instance[settings][file_extensions]' => 'png, gif, jpg, jpeg', + ), + ), + )); + + // Set a destination folder, if given. + if ($dest) { + $edit = array( + 'instance[settings][file_directory]' => $dest, + ); + $this->drupalPost('admin/structure/types/manage/' . $typename . '/fields/field_files', $edit, t('Save settings')); + } + + return $typename; + } + + /** + * Checks if SimplePie is available and eventually downloads it. + */ + protected function requireSimplePie() { + if (!feeds_simplepie_exists()) { + $this->downloadExtractSimplePie('1.3'); + $this->assertTrue(feeds_simplepie_exists()); + // Reset all the caches! + $this->resetAll(); + } + } + /** * Lists test files. */ @@ -411,4 +925,22 @@ class FeedsMapperFileTestCase extends FeedsMapperTestCase { ); } + /** + * Lists test files mapping. + * + * Used to rename images so the ::testFileExistsReplace() test can check if + * they are replaced on import. + * + * @see testFileExistsReplace() + */ + protected function listTestFilesNameMap() { + return array( + 'la fayette.jpeg' => 'tubing.jpeg', + 'tubing.jpeg' => 'foosball.jpeg', + 'foosball.jpeg' => 'attersee.jpeg', + 'attersee.jpeg' => 'hstreet.jpeg', + 'hstreet.jpeg' => 'la fayette.jpeg', + ); + } + } diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds_parser_csv.test b/www7/sites/all/modules/contrib/feeds/tests/feeds_parser_csv.test index 581d80245..5e8826f47 100644 --- a/www7/sites/all/modules/contrib/feeds/tests/feeds_parser_csv.test +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds_parser_csv.test @@ -97,4 +97,199 @@ class FeedsCSVParserTestCase extends FeedsWebTestCase { $this->assertNoText('Failed importing 4 nodes.'); $this->assertText('Source file is not in UTF-8 encoding.'); } + + /** + * Tests if a CSV template is generated properly using various settings. + * + * @see ::getTemplateDataProvider() + */ + public function testGetTemplate() { + // Create node type. + $node_type = $this->drupalCreateContentType(); + + foreach ($this->getTemplateDataProvider() as $key => $testdata) { + // Prepend 'csv' to importer machine name as '0' is not a valid machine + // name. + $key = 'csv' . $key; + + // Create and configure importer. + $this->createImporterConfiguration('Content CSV', $key); + $this->setPlugin($key, 'FeedsCSVParser'); + $this->setSettings($key, 'FeedsCSVParser', array( + 'delimiter' => $testdata['delimiter'], + )); + $this->setSettings($key, 'FeedsNodeProcessor', array('bundle' => $node_type->type)); + $this->addMappings($key, $testdata['mapping']); + + // Get CSV template and assert result. + $this->drupalGet('import/' . $key . '/template'); + $this->assertRaw($testdata['expected']); + } + } + + /** + * Data provider for ::testGetTemplate(). + */ + protected function getTemplateDataProvider() { + return array( + // Delimiter ',' test. Source keys containing a ',' should be wrapped in + // quotes. + array( + 'delimiter' => ',', + 'mapping' => array( + array( + 'source' => 'title+;|', + 'target' => 'title', + ), + array( + 'source' => 'alpha, beta + gamma', + 'target' => 'body', + ), + array( + 'source' => 'guid', + 'target' => 'guid', + ), + ), + 'expected' => 'title+;|,"alpha, beta + gamma",guid', + ), + + // Delimiter ';' test. Source keys containing a ';' should be wrapped in + // quotes. + array( + 'delimiter' => ';', + 'mapping' => array( + array( + 'source' => 'title;)', + 'target' => 'title', + ), + array( + 'source' => 'alpha, beta + gamma', + 'target' => 'body', + ), + array( + 'source' => 'guid', + 'target' => 'guid', + ), + ), + 'expected' => '"title;)";alpha, beta + gamma;guid', + ), + + // Delimiter 'TAB' test. + array( + 'delimiter' => 'TAB', + 'mapping' => array( + array( + 'source' => 'title,;|', + 'target' => 'title', + ), + array( + 'source' => 'alpha, beta + gamma', + 'target' => 'body', + ), + array( + 'source' => 'guid', + 'target' => 'guid', + ), + ), + 'expected' => 'title,;| alpha, beta + gamma guid', + ), + + // Delimiter '|' test. Source keys containing a '|' should be wrapped in + // quotes. + array( + 'delimiter' => '|', + 'mapping' => array( + array( + 'source' => 'title+;,', + 'target' => 'title', + ), + array( + 'source' => 'alpha|beta|gamma', + 'target' => 'body', + ), + array( + 'source' => 'guid', + 'target' => 'guid', + ), + ), + 'expected' => 'title+;,|"alpha|beta|gamma"|guid', + ), + + // Delimiter '+' test. Source keys containing a '+' should be wrapped in + // quotes. + array( + 'delimiter' => '+', + 'mapping' => array( + array( + 'source' => 'title,;|', + 'target' => 'title', + ), + array( + 'source' => 'alpha, beta + gamma', + 'target' => 'body', + ), + array( + 'source' => 'guid', + 'target' => 'guid', + ), + ), + 'expected' => 'title,;|+"alpha, beta + gamma"+guid', + ), + + // Ensure that when a source key is used multiple times in mapping, the + // key is only printed once in the CSV template. + array( + 'delimiter' => ',', + 'mapping' => array( + array( + 'source' => 'text', + 'target' => 'title', + ), + array( + 'source' => 'guid', + 'target' => 'guid', + ), + array( + 'source' => 'date', + 'target' => 'created', + ), + array( + 'source' => 'date', + 'target' => 'changed', + ), + array( + 'source' => 'text', + 'target' => 'body', + ), + ), + 'expected' => 'text,guid,date', + ), + + // Special characters. Things like '&' shouldn't be converted to '&' + // for example. + array( + 'delimiter' => ',', + 'mapping' => array( + array( + 'source' => '&', + 'target' => 'title', + ), + array( + 'source' => 'alpha&beta', + 'target' => 'body', + ), + array( + 'source' => '', + 'target' => 'created', + ), + array( + 'source' => '\'guid\'', + 'target' => 'guid', + ), + ), + 'expected' => '&,alpha&beta,,\'guid\'', + ), + ); + } + } diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds_parser_syndication.test b/www7/sites/all/modules/contrib/feeds/tests/feeds_parser_syndication.test index a62759f83..83f4bf3aa 100644 --- a/www7/sites/all/modules/contrib/feeds/tests/feeds_parser_syndication.test +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds_parser_syndication.test @@ -8,7 +8,7 @@ /** * Test single feeds. */ -class FeedsSyndicationParserTestCase extends FeedsWebTestCase { +class FeedsSyndicationParserTestCase extends FeedsMapperTestCase { public static function getInfo() { return array( @@ -66,4 +66,68 @@ class FeedsSyndicationParserTestCase extends FeedsWebTestCase { ); } + /** + * Tests if the "" element of a RSS feed is parsed correctly. + * + * This element is optional according to the RSS 2.0 specification. + */ + public function testRSSSourceElement() { + // Do not use curl as that will result into HTTP requests returning a 404. + variable_set('feeds_never_use_curl', TRUE); + + // Create content type with two text fields. + $typename = $this->createContentType(array(), array( + 'source_title' => 'text', + 'source_url' => 'text', + )); + + // Create importer and map sources from source element to text fields. + $this->createImporterConfiguration('Syndication', 'syndication'); + $this->setSettings('syndication', 'FeedsNodeProcessor', array('bundle' => $typename)); + $this->addMappings('syndication', + array( + 0 => array( + 'source' => 'title', + 'target' => 'title', + 'unique' => FALSE, + ), + 1 => array( + 'source' => 'source:title', + 'target' => 'field_source_title', + ), + 2 => array( + 'source' => 'source:url', + 'target' => 'field_source_url', + ), + ) + ); + + // Import url. + $url = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/developmentseed.rss2'; + $this->createFeedNode('syndication', $url); + + // Assert that the contents for the source element were imported for the + // first imported node. + $node = node_load(2); + $fields = array( + 'field_source_title' => array( + 'expected' => 'Technological Solutions for Progressive Organizations', + 'actual' => $node->field_source_title[LANGUAGE_NONE][0]['value'], + ), + 'field_source_url' => array( + 'expected' => 'http://developmentseed.org/node/974', + 'actual' => $node->field_source_url[LANGUAGE_NONE][0]['value'], + ), + ); + foreach ($fields as $field_name => $value) { + $this->assertEqual($value['expected'], $value['actual'], format_string('The field %field has the expected value (actual: @actual).', array('%field' => $field_name, '@actual' => $value['actual']))); + } + + // Assert that for the second imported node, no values were imported, + // because the second item does not contain a source element. + $node = node_load(3); + foreach ($fields as $field_name => $value) { + $this->assertTrue(!isset($node->{$field_name}[LANGUAGE_NONE][0]['value']), format_string('The field %field does not contain a value (actual: @actual).', array('%field' => $field_name, '@actual' => $value['actual']))); + } + } } diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds_processor_user.test b/www7/sites/all/modules/contrib/feeds/tests/feeds_processor_user.test index 4bc82d510..a1921d04e 100644 --- a/www7/sites/all/modules/contrib/feeds/tests/feeds_processor_user.test +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds_processor_user.test @@ -18,9 +18,14 @@ class FeedsCSVtoUsersTest extends FeedsWebTestCase { } /** - * Test node creation, refreshing/deleting feeds and feed items. + * {@inheritdoc} */ - public function test() { + public function setUp() { + parent::setUp(); + + // Include FeedsProcessor.inc to make its constants available. + module_load_include('inc', 'feeds', 'plugins/FeedsProcessor'); + // Create an importer. $this->createImporterConfiguration('User import', 'user_import'); @@ -57,7 +62,12 @@ class FeedsCSVtoUsersTest extends FeedsWebTestCase { 'content_type' => '', ); $this->drupalPost('admin/structure/feeds/user_import/settings', $edit, 'Save'); + } + /** + * Test user creation, refreshing/deleting feeds and feed items. + */ + public function test() { // Create roles and assign one of them to the users to be imported. $manager_rid = $this->drupalCreateRole(array('access content'), 'manager'); $admin_rid = $this->drupalCreateRole(array('access content'), 'administrator'); @@ -114,10 +124,7 @@ class FeedsCSVtoUsersTest extends FeedsWebTestCase { $this->assertText('Failed importing 2 user'); // Attempt to log in as one of the imported users. - $account = user_load_by_name('Fester'); - $this->assertTrue($account, 'Imported user account loaded.'); - $account->pass_raw = 'fest'; - $this->drupalLogin($account); + $this->feedsLoginUser('Fester', 'fest'); // Login as admin. $this->drupalLogin($this->admin_user); @@ -134,4 +141,874 @@ class FeedsCSVtoUsersTest extends FeedsWebTestCase { $this->assertText('Failed importing 2 user'); } + /** + * Tests mapping to user ID. + */ + public function testUidTarget() { + // Set to update existing users. + $this->setSettings('user_import', 'FeedsUserProcessor', array('update_existing' => FEEDS_UPDATE_EXISTING)); + + // Add mapping to user ID. + $this->addMappings('user_import', array( + 4 => array( + 'source' => 'uid', + 'target' => 'uid', + 'unique' => TRUE, + ), + )); + + // Create account with uid 202. The username and mail address of this account + // should be updated. + user_save(drupal_anonymous_user(), array( + 'uid' => 202, + 'name' => 'Joe', + 'mail' => 'joe@example.com', + 'pass' => 'joe', + 'status' => 1, + )); + + // Import CSV file. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users.csv'); + $this->assertText('Created 2 users'); + $this->assertText('Updated 1 user'); + + // Assert user ID's. + $account = user_load_by_name('Morticia'); + $this->assertEqual(201, $account->uid, 'Morticia got user ID 201.'); + $account = user_load_by_name('Gomez'); + $this->assertEqual(203, $account->uid, 'Gomez got user ID 203.'); + + // Assert that the username and mail address of account 202 were changed. + $account = user_load(202); + $values = array( + 'name' => array( + 'expected' => 'Fester', + 'actual' => $account->name, + ), + 'mail' => array( + 'expected' => 'fester@example.com', + 'actual' => $account->mail, + ), + ); + $this->assertEqual($values['name']['expected'], $values['name']['actual'], format_string('Username of account 202 changed in @expected (actual: @actual).', array( + '@expected' => $values['name']['expected'], + '@actual' => $values['name']['actual'], + ))); + $this->assertEqual($values['mail']['expected'], $values['mail']['actual'], format_string('Mail address of account 202 changed in @expected (actual: @actual).', array( + '@expected' => $values['mail']['expected'], + '@actual' => $values['mail']['actual'], + ))); + + // Assert that user Joe no longer exists in the system. + $this->assertFalse(user_load_by_name('Joe'), 'No user with username Joe exists.'); + $this->assertFalse(user_load_by_mail('joe@example.com'), 'No user with mail address joe@example.com exists.'); + } + + /** + * Tests if user ID's can be changed using the user ID target. + * + * Also checks if a clear error is reported when trying to change the + * user ID to something that is already in use. + */ + public function testUidUpdating() { + // Set to update existing users. + $this->setSettings('user_import', 'FeedsUserProcessor', array('update_existing' => FEEDS_UPDATE_EXISTING)); + + // Add mapping to user ID, but do not mark target as unique. + $this->addMappings('user_import', array( + 4 => array( + 'source' => 'uid', + 'target' => 'uid', + ), + )); + + // Create an account which user ID should be updated. + user_save(drupal_anonymous_user(), array( + 'uid' => 54, + 'name' => 'Morticia', + 'mail' => 'morticia@example.com', + 'pass' => 'mort', + 'status' => 1, + )); + + // Create account with uid 202. Importing an other account with uid 202 + // should fail. + user_save(drupal_anonymous_user(), array( + 'uid' => 202, + 'name' => 'Joe', + 'mail' => 'joe@example.com', + 'pass' => 'joe', + 'status' => 1, + )); + + // Import CSV file. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users.csv'); + $this->assertText('Created 1 user'); + $this->assertText('Updated 1 user'); + $this->assertText('Failed importing 3 users.'); + $this->assertText('Could not update user ID to 202 since that ID is already in use.'); + + // Assert Morticia's user ID got updated. + $account = user_load_by_name('Morticia'); + $this->assertEqual(201, $account->uid, 'Morticia now got user ID 201.'); + // Assert that Fester failed to import. + $this->assertFalse(user_load_by_name('Fester'), 'The account for Fester was not imported.'); + // Assert that user 202 did not change. + $account = user_load(202); + $this->assertEqual('Joe', $account->name, 'The user name of account 202 is still Joe.'); + $this->assertEqual('joe@example.com', $account->mail, 'The mail address of account 202 is still joe@example.com.'); + } + + /** + * Tests mapping to role without automatically creating new roles. + */ + public function testRoleTargetWithoutRoleCreation() { + // Add mapping to role. + $this->addMappings('user_import', array( + 4 => array( + 'source' => 'roles', + 'target' => 'roles_list', + ), + )); + + // Create manager role. + $manager_rid = $this->drupalCreateRole(array('access content'), 'manager'); + + // Import CSV file. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users_roles.csv'); + + // Assert that Morticia did not get the editor role and has one role in + // total. + $account = user_load_by_name('Morticia'); + $this->assertFalse(in_array('editor', $account->roles), 'Morticia does not have the editor role.'); + $this->assertEqual(1, count($account->roles), 'Morticia has one role.'); + + // Assert that Fester got the manager role and two roles in total. + $account = user_load_by_name('Fester'); + $this->assertTrue(isset($account->roles[$manager_rid]), 'Fester has the manager role.'); + $this->assertEqual(2, count($account->roles), 'Fester has two roles.'); + + // Assert that Gomez got the manager role but not the tester role, since + // that role doesn't exist on the system. + $account = user_load_by_name('Gomez'); + $this->assertTrue(isset($account->roles[$manager_rid]), 'Gomez has the manager role.'); + $this->assertFalse(in_array('tester', $account->roles), 'Gomez does not have the tester role.'); + $this->assertEqual(2, count($account->roles), 'Gomez has two roles.'); + + // Assert that Pugsley only has one role. + $account = user_load_by_name('Pugsley'); + $this->assertEqual(1, count($account->roles), 'Pugsley has one role.'); + + // Assert that only three roles exist: + // - authenticated user + // - role from the admin user + // - manager + $roles = user_roles(TRUE); + $this->assertEqual(3, count($roles), 'Only three roles exist.'); + } + + /** + * Tests mapping to role with automatically creating new roles. + */ + public function testRoleTargetWithRoleCreation() { + // Add mapping to role. + $this->addMappings('user_import', array( + 4 => array( + 'source' => 'roles', + 'target' => 'roles_list', + 'autocreate' => TRUE, + ), + )); + + // Create manager role. + $manager_rid = $this->drupalCreateRole(array('access content'), 'manager'); + + // Import CSV file. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users_roles.csv'); + + // Assert that Morticia got the editor role and two roles in total. + $account = user_load_by_name('Morticia'); + $this->assertTrue(in_array('editor', $account->roles), 'Morticia has the editor role.'); + $this->assertEqual(2, count($account->roles), 'Morticia has two roles.'); + + // Assert that Fester got the manager role and two roles in total. + $account = user_load_by_name('Fester'); + $this->assertTrue(isset($account->roles[$manager_rid]), 'Fester has the manager role.'); + $this->assertEqual(2, count($account->roles), 'Fester has two roles.'); + + // Assert that Gomez got the manager, the editor role and three roles in + // total. + $account = user_load_by_name('Gomez'); + $this->assertTrue(isset($account->roles[$manager_rid]), 'Gomez has the manager role.'); + $this->assertTrue(in_array('tester', $account->roles), 'Gomez has the tester role.'); + $this->assertEqual(3, count($account->roles), 'Gomez has three roles.'); + + // Assert that Pugsley only has one role. + $account = user_load_by_name('Pugsley'); + $this->assertEqual(1, count($account->roles), 'Pugsley has one role.'); + + // Assert that five roles exist: + // - authenticated user + // - role from the admin user + // - manager + // - editor + // - tester + $roles = user_roles(TRUE); + $this->assertEqual(5, count($roles), 'Five roles exist.'); + } + + /** + * Tests mapping to role using role ID's. + */ + public function testRoleTargetRids() { + // Add mapping to role. + $this->addMappings('user_import', array( + 4 => array( + 'source' => 'rids', + 'target' => 'roles_list', + 'role_search' => FeedsUserProcessor::ROLE_SEARCH_RID, + ), + )); + + // Create manager and tester roles. + $manager_rid = $this->drupalCreateRole(array('access content'), 'manager'); + $tester_rid = $this->drupalCreateRole(array('access content'), 'tester'); + // Ensure expected ID's of these roles. + $this->assertEqual(4, $manager_rid); + $this->assertEqual(5, $tester_rid); + + // Import CSV file. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users_roles.csv'); + + // Assert that Morticia did not get the editor role and has one role in + // total. + $account = user_load_by_name('Morticia'); + $this->assertFalse(in_array('editor', $account->roles), 'Morticia does not have the editor role.'); + $this->assertEqual(1, count($account->roles), 'Morticia has one role.'); + + // Assert that Fester got the manager role and two roles in total. + $account = user_load_by_name('Fester'); + $this->assertTrue(isset($account->roles[$manager_rid]), 'Fester has the manager role.'); + $this->assertEqual(2, count($account->roles), 'Fester has two roles.'); + + // Assert that Gomez got the manager and tester roles. + $account = user_load_by_name('Gomez'); + $this->assertTrue(isset($account->roles[$manager_rid]), 'Gomez has the manager role.'); + $this->assertTrue(isset($account->roles[$manager_rid]), 'Gomez has the tester role.'); + $this->assertEqual(3, count($account->roles), 'Gomez has two roles.'); + + // Assert that Pugsley only has one role. + $account = user_load_by_name('Pugsley'); + $this->assertEqual(1, count($account->roles), 'Pugsley has one role.'); + + // Assert that four roles exist: + // - authenticated user + // - role from the admin user + // - manager + // - tester + $roles = user_roles(TRUE); + $this->assertEqual(4, count($roles), 'Four roles exist.'); + } + + /** + * Tests mapping to role using only allowed roles. + */ + public function testRoleTargetWithAllowedRoles() { + // Create manager role. + $manager_rid = $this->drupalCreateRole(array('access content'), 'manager'); + // Create editor role. + $editor_rid = $this->drupalCreateRole(array('access content'), 'editor'); + + // Add mapping to role. + // The manager role may not be assigned to the user by the feed. + $this->addMappings('user_import', array( + 4 => array( + 'source' => 'roles', + 'target' => 'roles_list', + 'allowed_roles' => array( + $manager_rid => FALSE, + $editor_rid => $editor_rid, + ), + 'autocreate' => TRUE, + ), + )); + + // Import CSV file. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users_roles.csv'); + + // Assert that Morticia got the editor role and two roles in total. + $account = user_load_by_name('Morticia'); + $this->assertTrue(in_array('editor', $account->roles), 'Morticia has the editor role.'); + $this->assertEqual(2, count($account->roles), 'Morticia has two roles.'); + + // Assert that Fester did not got the manager role, because that role was + // not an allowed value. + $account = user_load_by_name('Fester'); + $this->assertFalse(isset($account->roles[$manager_rid]), 'Fester does not have the manager role.'); + $this->assertEqual(1, count($account->roles), 'Fester has one role.'); + + // Assert that Gomez only got the tester role and not the manager role. + $account = user_load_by_name('Gomez'); + $this->assertFalse(isset($account->roles[$manager_rid]), 'Gomez does not have the manager role.'); + $this->assertTrue(in_array('tester', $account->roles), 'Gomez has the tester role.'); + $this->assertEqual(2, count($account->roles), 'Gomez has two roles.'); + } + + /** + * Tests that roles can be revoked and that only allowed roles are revoked. + */ + public function testRoleTargetRevokeRoles() { + // Create manager role. + $manager_rid = $this->drupalCreateRole(array('access content'), 'manager'); + // Create editor role. + $editor_rid = $this->drupalCreateRole(array('access content'), 'editor'); + // Create tester role. + $tester_rid = $this->drupalCreateRole(array('access content'), 'tester'); + + // Set to update existing users. + $this->setSettings('user_import', 'FeedsUserProcessor', array('update_existing' => FEEDS_UPDATE_EXISTING)); + + // Add mapping to role. + // The manager role may not be revoked, but the editor role may. + $this->addMappings('user_import', array( + 4 => array( + 'source' => 'roles', + 'target' => 'roles_list', + 'allowed_roles' => array( + $manager_rid => FALSE, + $editor_rid => $editor_rid, + $tester_rid => $tester_rid, + ), + ), + )); + + // Create account for Morticia with roles "manager" and "editor". In the + // source only "editor" is specified. Morticia should keep both roles. + user_save(drupal_anonymous_user(), array( + 'name' => 'Morticia', + 'mail' => 'morticia@example.com', + 'pass' => 'mort', + 'status' => 1, + 'roles' => array( + $manager_rid => $manager_rid, + $editor_rid => $editor_rid, + ), + )); + // Create account for Pugsley with roles "manager", "editor" and "tester". + // Pugsley has no roles in the source so should only keep the "manager" + // role. + user_save(drupal_anonymous_user(), array( + 'name' => 'Pugsley', + 'mail' => 'pugsley@example.com', + 'pass' => 'pugs', + 'status' => 1, + 'roles' => array( + $manager_rid => $manager_rid, + $editor_rid => $editor_rid, + $tester_rid => $tester_rid, + ), + )); + // Create account for Gomez and give it the "editor" role. Gomez has roles + // "tester" and "manager" in the source, so it should lose the "editor" role + // and gain the "tester" role. + user_save(drupal_anonymous_user(), array( + 'name' => 'Gomez', + 'mail' => 'gomez@example.com', + 'pass' => 'gome', + 'status' => 1, + 'roles' => array( + $editor_rid => $editor_rid, + ), + )); + + // Import CSV file. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users_roles.csv'); + + // Assert that Morticia kept the manager and editor roles. + $account = user_load_by_name('Morticia'); + $this->assertTrue(isset($account->roles[$manager_rid]), 'Morticia still has the manager role.'); + $this->assertTrue(isset($account->roles[$editor_rid]), 'Morticia has the editor role.'); + $this->assertEqual(3, count($account->roles), 'Morticia has three roles.'); + + // Assert that Pugsley only kept the manager role. + $account = user_load_by_name('Pugsley'); + $this->assertTrue(isset($account->roles[$manager_rid]), 'Pugsley still has the manager role.'); + $this->assertFalse(isset($account->roles[$editor_rid]), 'Pugsley no longer has the editor role.'); + $this->assertFalse(isset($account->roles[$tester_rid]), 'Pugsley no longer has the tester role.'); + $this->assertEqual(2, count($account->roles), 'Pugsley has two roles.'); + + // Assert that Gomez lost the editor role, and gained the tester role. + $account = user_load_by_name('Gomez'); + $this->assertFalse(isset($account->roles[$editor_rid]), 'Gomez no longer has the editor role.'); + $this->assertTrue(isset($account->roles[$tester_rid]), 'Gomez has the tester role.'); + $this->assertEqual(2, count($account->roles), 'Gomez has two roles.'); + } + + /** + * Tests if no roles are revoked if the option "Revoke roles" is disabled. + */ + public function testRoleTargetNoRevokeRoles() { + // Create manager role. + $manager_rid = $this->drupalCreateRole(array('access content'), 'manager'); + // Create editor role. + $editor_rid = $this->drupalCreateRole(array('access content'), 'editor'); + + // Set to update existing users. + $this->setSettings('user_import', 'FeedsUserProcessor', array('update_existing' => FEEDS_UPDATE_EXISTING)); + + // Add mapping to role. Set option to not revoke roles. + $this->addMappings('user_import', array( + 4 => array( + 'source' => 'roles', + 'target' => 'roles_list', + 'allowed_roles' => array( + $manager_rid => FALSE, + $editor_rid => $editor_rid, + ), + 'revoke_roles' => FALSE, + ), + )); + + // Create account for Pugsley with roles "manager" and "editor". Pugsley has + // no roles, but roles should not be revoked, so Pugsley should keep all + // roles. + user_save(drupal_anonymous_user(), array( + 'name' => 'Pugsley', + 'mail' => 'pugsley@example.com', + 'pass' => 'pugs', + 'status' => 1, + 'roles' => array( + $manager_rid => $manager_rid, + $editor_rid => $editor_rid, + ), + )); + + // Import CSV file. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users_roles.csv'); + + // Assert that Pugsley kept all roles. + $account = user_load_by_name('Pugsley'); + $this->assertTrue(isset($account->roles[$manager_rid]), 'Pugsley still has the manager role.'); + $this->assertTrue(isset($account->roles[$editor_rid]), 'Pugsley still has the editor role.'); + $this->assertEqual(3, count($account->roles), 'Pugsley has three roles.'); + } + + /** + * Tests if additional roles are assigned when creating or updating users. + */ + public function testAdditionalRolesSetting() { + // Create manager role. + $manager_rid = $this->drupalCreateRole(array('access content'), 'manager'); + // Create editor role. + $editor_rid = $this->drupalCreateRole(array('access content'), 'editor'); + + // Set that the "manager" role should be assigned to every user that is + // imported. + $this->setSettings('user_import', 'FeedsUserProcessor', array( + "roles[$manager_rid]" => TRUE, + 'update_existing' => FEEDS_UPDATE_EXISTING, + )); + + // Create account for Gomez and give it the "editor" role. After import + // Gomez should have the roles "editor" and "manager". + user_save(drupal_anonymous_user(), array( + 'name' => 'Gomez', + 'mail' => 'gomez@example.com', + 'pass' => 'gome', + 'status' => 1, + 'roles' => array( + $editor_rid => $editor_rid, + ), + )); + + // Import CSV file. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users_roles.csv'); + + // Assert that every imported user has gained the "manager" role. + $user_names = array( + 'Morticia', + 'Fester', + 'Pugsley', + ); + foreach ($user_names as $user_name) { + $vars = array( + '@user' => $user_name, + ); + // Assert that this user has the "manager" role. + $account = user_load_by_name($user_name); + $this->assertTrue(isset($account->roles[$manager_rid]), format_string('@user has the manager role.', $vars)); + $this->assertEqual(2, count($account->roles), format_string('@user has two roles.', $vars)); + } + + // Assert that Gomez has gained the role "manager" and still has the + // "editor" role. + $account = user_load_by_name('Gomez'); + $this->assertTrue(isset($account->roles[$editor_rid]), 'Gomez still has the editor role.'); + $this->assertTrue(isset($account->roles[$manager_rid]), 'Gomez has the manager role.'); + $this->assertEqual(3, count($account->roles), 'Gomez has three roles.'); + } + + /** + * Tests if additional roles are assigned when also the role mapper is used. + */ + public function testAdditionalRolesSettingWithRoleTarget() { + // Create manager role. + $manager_rid = $this->drupalCreateRole(array('access content'), 'manager'); + // Create editor role. + $editor_rid = $this->drupalCreateRole(array('access content'), 'editor'); + // Create tester role. + $tester_rid = $this->drupalCreateRole(array('access content'), 'tester'); + + // Set that the "manager" role should be assigned to every user that is + // imported. + $this->setSettings('user_import', 'FeedsUserProcessor', array( + "roles[$manager_rid]" => TRUE, + 'update_existing' => FEEDS_UPDATE_EXISTING, + )); + // Add mapping to role. + $this->addMappings('user_import', array( + 4 => array( + 'source' => 'roles', + 'target' => 'roles_list', + ), + )); + + // Create account for Morticia with roles "manager" and "tester". In the + // source, Morticia does not have the "manager" role, but because on the + // user processor settings that is an additional role to add, that role + // should not be revoked. The "tester" role, on the other hand, should be + // revoked. + user_save(drupal_anonymous_user(), array( + 'name' => 'Morticia', + 'mail' => 'morticia@example.com', + 'pass' => 'mort', + 'status' => 1, + 'roles' => array( + $manager_rid => $manager_rid, + $tester_rid => $tester_rid, + ), + )); + + // Import CSV file. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users_roles.csv'); + + // Assert that Morticia kept the "manager" role, lost the "tester" role and + // gained the "editor" role. + $account = user_load_by_name('Morticia'); + $this->assertTrue(isset($account->roles[$manager_rid]), 'Morticia still has the manager role.'); + $this->assertTrue(isset($account->roles[$editor_rid]), 'Morticia has the editor role.'); + $this->assertFalse(isset($account->roles[$tester_rid]), 'Morticia no longer has the tester role.'); + $this->assertEqual(3, count($account->roles), 'Morticia has three roles.'); + + // Assert that all other imported users got the "manager" role as well. + $user_names = array( + 'Fester', + 'Gomez', + 'Pugsley', + ); + foreach ($user_names as $user_name) { + $vars = array( + '@user' => $user_name, + ); + // Assert that this user has the "manager" role. + $account = user_load_by_name($user_name); + $this->assertTrue(isset($account->roles[$manager_rid]), format_string('@user has the manager role.', $vars)); + } + } + + /** + * Tests if roles are replaced when replacing users. + */ + public function testAdditionalRolesSettingWhenReplacingUsers() { + // Create manager role. + $manager_rid = $this->drupalCreateRole(array('access content'), 'manager'); + // Create editor role. + $editor_rid = $this->drupalCreateRole(array('access content'), 'editor'); + + // Set that the "manager" role should be assigned to every user that is + // imported. Other roles should be revoked. + $this->setSettings('user_import', 'FeedsUserProcessor', array( + "roles[$manager_rid]" => TRUE, + 'update_existing' => FEEDS_REPLACE_EXISTING, + )); + + // Create account for Morticia with no roles. Morticia should gain the + // "manager" role. + user_save(drupal_anonymous_user(), array( + 'name' => 'Morticia', + 'mail' => 'morticia@example.com', + 'pass' => 'mort', + 'status' => 1, + )); + + // Create account for Gomez and give it the "editor" role. After import + // Gomez should have lost the role "editor" and gained the role "manager". + user_save(drupal_anonymous_user(), array( + 'name' => 'Gomez', + 'mail' => 'gomez@example.com', + 'pass' => 'gome', + 'status' => 1, + 'roles' => array( + $editor_rid => $editor_rid, + ), + )); + + // Import CSV file. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users_roles.csv'); + + // Assert that Morticia has gained the role "manager". + $account = user_load_by_name('Morticia'); + $this->assertTrue(isset($account->roles[$manager_rid]), 'Morticia has the manager role.'); + $this->assertEqual(2, count($account->roles), 'Morticia has two roles.'); + + // Assert that Gomez has gained the role "manager" and but no longer has the + // "editor" role. + $account = user_load_by_name('Gomez'); + $this->assertFalse(isset($account->roles[$editor_rid]), 'Gomez no longer has the editor role.'); + $this->assertTrue(isset($account->roles[$manager_rid]), 'Gomez has the manager role.'); + $this->assertEqual(2, count($account->roles), 'Gomez has two roles.'); + + // Now remove all default roles and import again. + $this->setSettings('user_import', 'FeedsUserProcessor', array( + "roles[$manager_rid]" => FALSE, + 'skip_hash_check' => TRUE, + )); + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users_roles.csv'); + + // Reset loaded users cache. + entity_get_controller('user')->resetCache(); + + // Assert that Morticia no longer has the role "manager". + $account = user_load_by_name('Morticia'); + $this->assertFalse(isset($account->roles[$manager_rid]), 'Morticia no longer has the manager role.'); + $this->assertEqual(1, count($account->roles), 'Morticia has one role.'); + } + + /** + * Test if users with md5 passwords can login after import. + */ + public function testMD5() { + // Set to update existing users. + $this->setSettings('user_import', 'FeedsUserProcessor', array('update_existing' => FEEDS_UPDATE_EXISTING)); + + // Replace password mapper. + $this->removeMappings('user_import', array( + 3 => array( + 'source' => 'password', + 'target' => 'pass', + ), + )); + $this->addMappings('user_import', array( + 3 => array( + 'source' => 'password_md5', + 'target' => 'pass', + 'pass_encryption' => 'md5', + ), + )); + + // Create an account for Gomez, to ensure passwords can also be imported for + // existing users. Give Gomez a password different from the one that gets + // imported to ensure that his password gets updated. + user_save(drupal_anonymous_user(), array( + 'name' => 'Gomez', + 'mail' => 'gomez@example.com', + 'pass' => 'temporary', + 'status' => 1, + )); + + // Import CSV file. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users.csv'); + + // Assert result. + $this->assertText('Created 2 users'); + $this->assertText('Updated 1 user'); + + // Try to login as each successful imported user. + $this->feedsLoginUser('Morticia', 'mort'); + $this->feedsLoginUser('Fester', 'fest'); + $this->feedsLoginUser('Gomez', 'gome'); + } + + /** + * Test if users with sha512 passwords can login after import. + */ + public function testSha512() { + // Set to update existing users. + $this->setSettings('user_import', 'FeedsUserProcessor', array('update_existing' => FEEDS_UPDATE_EXISTING)); + + // Replace password mapper. + $this->removeMappings('user_import', array( + 3 => array( + 'source' => 'password', + 'target' => 'pass', + ), + )); + $this->addMappings('user_import', array( + 3 => array( + 'source' => 'password_sha512', + 'target' => 'pass', + 'pass_encryption' => 'sha512', + ), + )); + + // Create an account for Gomez, to ensure passwords can also be imported for + // existing users. Give Gomez a password different from the one that gets + // imported to ensure that his password gets updated. + user_save(drupal_anonymous_user(), array( + 'name' => 'Gomez', + 'mail' => 'gomez@example.com', + 'pass' => 'temporary', + 'status' => 1, + )); + + // Import CSV file. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users.csv'); + + // Assert result. + $this->assertText('Created 2 users'); + $this->assertText('Updated 1 user'); + + // Try to login as each successful imported user. + $this->feedsLoginUser('Morticia', 'mort'); + $this->feedsLoginUser('Fester', 'fest'); + $this->feedsLoginUser('Gomez', 'gome'); + } + + /** + * Tests mapping to timezone. + */ + public function testTimezoneTarget() { + // Set to update existing users. + $this->setSettings('user_import', 'FeedsUserProcessor', array('update_existing' => FEEDS_UPDATE_EXISTING)); + + // Add mapping to timezone. + $this->addMappings('user_import', array( + 4 => array( + 'source' => 'timezone', + 'target' => 'timezone', + ), + )); + + // Create an account for Fester, to ensure that the timezone can be emptied. + user_save(drupal_anonymous_user(), array( + 'name' => 'Fester', + 'mail' => 'fester@example.com', + 'pass' => 'fest', + 'status' => 1, + 'timezone' => 'Europe/Lisbon', + )); + + // Import CSV file. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users.csv'); + + // Assert that Morticia got the UTC timezone. + $account = user_load_by_name('Morticia'); + $this->assertEqual('UTC', $account->timezone, 'Morticia has the UTC timezone.'); + + // Assert that Fester did not get any timezone. + $account = user_load_by_name('Fester'); + $this->assertFalse($account->timezone, 'Fester does not have any timezone'); + + // Assert that Gomez doesn't exist after import and appropriate message is + // displayed. + $account = user_load_by_name('Gomez'); + $this->assertFalse($account, "Gomez doesn't exist after import."); + $this->assertText("Failed importing 'Gomez'. User's timezone is not valid."); + } + + /** + * Tests if user 1 cannot be deleted using the delete non-existing feature. + */ + public function testUser1ProtectionWhenDeletingNonExistent() { + // Set to delete non-existing users. + $this->setSettings('user_import', 'FeedsFileFetcher', array()); + $this->setSettings('user_import', 'FeedsUserProcessor', array( + 'update_existing' => FEEDS_UPDATE_EXISTING, + 'update_non_existent' => 'delete', + )); + + // Set mail address of user 1 to "fester@example.com". An user with this + // mail address is missing in the feed later. + $account = user_load(1); + $edit['mail'] = 'fester@example.com'; + user_save($account, $edit); + + // Import the first file, which contains the mail address of user 1. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users.csv'); + $this->assertText('Updated 1 user'); + // Ensure the username of user 1 was updated. + $account = user_load(1, TRUE); + $this->assertEqual('Fester', $account->name); + + // Now import the second file, where the mail address of user 1 is missing. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users2.csv'); + $this->assertNoText('Removed 1 user'); + + // Ensure that user 1 still exists. + $account = db_select('users') + ->fields('users') + ->condition('uid', 1) + ->execute() + ->fetch(); + $this->assertTrue(is_object($account), 'User 1 still exists.'); + } + + /** + * Tests if user 1 cannot be deleted using the delete form. + */ + public function testUser1ProtectionWhenDeletingAll() { + // Set to update existing users. + $this->setSettings('user_import', 'FeedsFileFetcher', array()); + $this->setSettings('user_import', 'FeedsUserProcessor', array( + 'update_existing' => FEEDS_UPDATE_EXISTING, + )); + + // Set mail address of user 1 to "fester@example.com". + $account = user_load(1); + $edit['mail'] = 'fester@example.com'; + user_save($account, $edit); + + // Import a file that contains the mail address of user 1. + $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users.csv'); + $this->assertText('Updated 1 user'); + // Ensure the username of user 1 was updated. + $account = user_load(1, TRUE); + $this->assertEqual('Fester', $account->name); + + // Now delete all items. User 1 should not be deleted. + $this->drupalPost('import/user_import/delete-items', array(), 'Delete'); + + // Ensure that user 1 still exists. + $account = db_select('users') + ->fields('users') + ->condition('uid', 1) + ->execute() + ->fetch(); + $this->assertTrue(is_object($account), 'User 1 still exists.'); + + // But ensure that the associated feeds item did got deleted. + $count = db_select('feeds_item') + ->fields('feeds_item') + ->condition('entity_type', 'user') + ->condition('entity_id', 1) + ->countQuery() + ->execute() + ->fetchField(); + $this->assertEqual(0, $count, 'The feeds item for user 1 was deleted.'); + } + + /** + * Log in an imported user. + * + * @param string $username + * The user's username. + * @param string $password + * The user's password. + */ + protected function feedsLoginUser($username, $password) { + $account = user_load_by_name($username); + $this->assertTrue($account, 'Imported user account loaded.'); + $account->pass_raw = $password; + $this->drupalLogin($account); + } } diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds_rules.test b/www7/sites/all/modules/contrib/feeds/tests/feeds_rules.test new file mode 100644 index 000000000..5e8031e83 --- /dev/null +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds_rules.test @@ -0,0 +1,185 @@ + 'Rules integration', + 'description' => 'Tests for Rules integration.', + 'group' => 'Feeds', + 'dependencies' => array('rules'), + ); + } + + /** + * Set up test. + */ + public function setUp() { + parent::setUp(array('rules')); + + // Create an importer configuration. + $this->createImporterConfiguration('Node import', 'node'); + $this->setSettings('node', NULL, array('content_type' => '')); + $this->setPlugin('node', 'FeedsHTTPFetcher'); + $this->setPlugin('node', 'FeedsCSVParser'); + $this->addMappings('node', + array( + 0 => array( + 'source' => 'title', + 'target' => 'title', + 'unique' => FALSE, + ), + 1 => array( + 'source' => 'guid', + 'target' => 'guid', + 'unique' => TRUE, + ), + ) + ); + + // Clear static cache to make dynamic events available to Rules. + drupal_static_reset(); + } + + /** + * Creates a test rule. + * + * @param string $event + * The event to react on. + * @param bool $action + * If a dummy action should be executed. + * + * @return RulesReactionRule + * An instance of RulesReactionRule. + */ + protected function createTestRule($event, $action = TRUE) { + $rule = rules_reaction_rule(); + $rule->event($event); + if ($action) { + $rule->action('feeds_tests_create_node'); + } + return $rule; + } + + /** + * Tests if the Rules event 'feeds_before_import' is invoked. + */ + public function testFeedsBeforeImportEvent() { + $rule = $this->createTestRule('feeds_before_import'); + $rule->condition('data_is', array( + 'data:select' => 'source:id', + 'value' => 'node', + )); + $rule->integrityCheck()->save(); + + // Set source file to import. + $source_url = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/content.csv'; + $edit = array( + 'feeds[FeedsHTTPFetcher][source]' => $source_url, + ); + $this->drupalPost('import/node', $edit, t('Import')); + $this->assertText('Created 2 nodes'); + + // Assert that a test node was created *before* the import. + $node = node_load(1); + $this->assertEqual('Test node', $node->title); + + // Assert titles of imported nodes as well. + $node = node_load(2); + $this->assertEqual('Lorem ipsum', $node->title); + $node = node_load(3); + $this->assertEqual('Ut wisi enim ad minim veniam', $node->title); + } + + /** + * Tests if the Rules event 'feeds_after_import' is invoked. + */ + public function testFeedsAfterImportEvent() { + $rule = $this->createTestRule('feeds_after_import'); + $rule->condition('data_is', array( + 'data:select' => 'source:id', + 'value' => 'node', + )); + $rule->integrityCheck()->save(); + + // Set source file to import. + $source_url = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/content.csv'; + $edit = array( + 'feeds[FeedsHTTPFetcher][source]' => $source_url, + ); + $this->drupalPost('import/node', $edit, t('Import')); + $this->assertText('Created 2 nodes'); + + // Assert that a test node was created *after* the import. + $node = node_load(3); + $this->assertEqual('Test node', $node->title); + + // Assert titles of imported nodes as well. + $node = node_load(1); + $this->assertEqual('Lorem ipsum', $node->title); + $node = node_load(2); + $this->assertEqual('Ut wisi enim ad minim veniam', $node->title); + } + + /** + * Tests if the Rules event 'feeds_import_IMPORTER_ID' is invoked. + */ + public function testFeedsBeforeSavingItemEvent() { + $rule = $this->createTestRule('feeds_import_node'); + // Act before saving the second node. + $rule->condition('data_is', array( + 'data:select' => 'node:title', + 'value' => 'Ut wisi enim ad minim veniam', + )); + $rule->integrityCheck()->save(); + + // Set source file to import. + $source_url = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/content.csv'; + $edit = array( + 'feeds[FeedsHTTPFetcher][source]' => $source_url, + ); + $this->drupalPost('import/node', $edit, t('Import')); + $this->assertText('Created 2 nodes'); + + // Assert that a test node was created before importing the second item. + $node = node_load(2); + $this->assertEqual('Test node', $node->title); + + // Assert titles of imported nodes as well. + $node = node_load(1); + $this->assertEqual('Lorem ipsum', $node->title); + $node = node_load(3); + $this->assertEqual('Ut wisi enim ad minim veniam', $node->title); + } + + /** + * Tests the Rules action 'feeds_skip_item'. + */ + public function testFeedsSkipItemAction() { + $rule = $this->createTestRule('feeds_import_node', FALSE); + // Setup rule to not save the first item (which title is 'Lorem Ipsum'). + $rule->condition('data_is', array( + 'data:select' => 'node:title', + 'value' => 'Lorem ipsum', + )); + $rule->action('feeds_skip_item', array( + 'entity:select' => 'node', + )); + $rule->integrityCheck()->save(); + + // Set source file to import. + $source_url = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/content.csv'; + $edit = array( + 'feeds[FeedsHTTPFetcher][source]' => $source_url, + ); + $this->drupalPost('import/node', $edit, t('Import')); + $this->assertText('Created 1 node'); + + // Assert that only the second item was imported. + $node = node_load(1); + $this->assertEqual('Ut wisi enim ad minim veniam', $node->title); + } +} diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds_tests.info b/www7/sites/all/modules/contrib/feeds/tests/feeds_tests.info index dcf1e0dde..da7e0e049 100644 --- a/www7/sites/all/modules/contrib/feeds/tests/feeds_tests.info +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds_tests.info @@ -5,9 +5,9 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by Drupal.org packaging script on 2016-02-21 -version = "7.x-2.0-beta2" +; Information added by Drupal.org packaging script on 2016-11-24 +version = "7.x-2.0-beta3" core = "7.x" project = "feeds" -datestamp = "1456055647" +datestamp = "1479993785" diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds_tests.module b/www7/sites/all/modules/contrib/feeds/tests/feeds_tests.module index 79df5875d..34e4a75bd 100644 --- a/www7/sites/all/modules/contrib/feeds/tests/feeds_tests.module +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds_tests.module @@ -60,6 +60,32 @@ function feeds_tests_theme() { ); } +/** + * Implements hook_node_load(). + */ +function feeds_tests_node_load($nodes) { + // Eventually keep track of nodes that get loaded. + if (variable_get('feeds_track_node_loads', FALSE)) { + $loads = variable_get('feeds_loaded_nodes', array()); + $loads = array_merge($loads, array_keys($nodes)); + variable_set('feeds_loaded_nodes', $loads); + } +} + +/** + * Implements hook_cron_queue_alter(). + * + * Changes runtime limit for feeds_source_import queue. + * + * @see FeedsFileFetcherTestCase::testRemoveFileAfterImportInBackground() + */ +function feeds_tests_cron_queue_info_alter(&$queues) { + $feeds_source_import_queue_time = variable_get('feeds_tests_feeds_source_import_queue_time', FALSE); + if ($feeds_source_import_queue_time && isset($queues['feeds_source_import'])) { + $queues['feeds_source_import']['time'] = $feeds_source_import_queue_time; + } +} + /** * Outputs flickr test feed. */ @@ -352,20 +378,47 @@ function feeds_tests_mapper_unique(FeedsSource $source, $entity_type, $bundle, $ /** * Implements hook_feeds_after_parse(). - * - * Empties the list of items to import in case the test says that there are - * items in there with encoding issues. These items can not be processed during - * tests without having a test failure because in < PHP 5.4 that would produce - * the following warning: - * htmlspecialchars(): Invalid multibyte sequence in argument - * - * @see FeedsCSVParserTestCase::testMbstringExtensionDisabled() */ function feeds_tests_feeds_after_parse(FeedsSource $source, FeedsParserResult $result) { + // Empties the list of items to import in case the test says that there are + // items in there with encoding issues. These items can not be processed + // during tests without having a test failure because in < PHP 5.4 that would + // produce the following warning: + // htmlspecialchars(): Invalid multibyte sequence in argument + // @see FeedsCSVParserTestCase::testMbstringExtensionDisabled() if (variable_get('feeds_tests_feeds_after_parse_empty_items', FALSE)) { // Remove all items. No items will be processed. $result->items = array(); } + + if ($source->id == 'user_import') { + foreach ($result->items as &$item) { + if (!empty($item['roles']) && strpos($item['roles'], '|')) { + // Convert roles value to multiple values. + // @see FeedsCSVtoUsersTest::testRoleTargetWithoutRoleCreation() + // @see FeedsCSVtoUsersTest::testRoleTargetWithRoleCreation() + // @see FeedsCSVtoUsersTest::testRoleTargetWithAllowedRoles() + $item['roles'] = explode('|', $item['roles']); + } + if (!empty($item['rids']) && strpos($item['rids'], '|')) { + // Convert roles value to multiple values. + // @see FeedsCSVtoUsersTest::testRoleTargetRids() + $item['rids'] = explode('|', $item['rids']); + } + } + } +} + +/** + * Implements hook_feeds_after_save(). + * + * @see FeedsFileFetcherTestCase::testRemoveFileAfterImportInBackground() + */ +function feeds_tests_feeds_after_save() { + $sleep = variable_get('feeds_tests_feeds_after_save_sleep', FALSE); + if ($sleep) { + sleep($sleep); + } } /** diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds_tests.rules.inc b/www7/sites/all/modules/contrib/feeds/tests/feeds_tests.rules.inc new file mode 100644 index 000000000..ca3cf4e1e --- /dev/null +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds_tests.rules.inc @@ -0,0 +1,30 @@ + t('Create a node'), + 'group' => t('Rules test'), + ); + return $items; +} + +/** + * Rules action callback: creates a node. + */ +function feeds_tests_create_node() { + $node = new stdClass(); + $node->title = 'Test node'; + $node->type = 'page'; + $node->status = 1; + $node->uid = 0; + node_object_prepare($node); + node_save($node); +} diff --git a/www7/sites/all/modules/contrib/feeds/tests/feeds_tokens.test b/www7/sites/all/modules/contrib/feeds/tests/feeds_tokens.test new file mode 100644 index 000000000..dca614424 --- /dev/null +++ b/www7/sites/all/modules/contrib/feeds/tests/feeds_tokens.test @@ -0,0 +1,94 @@ + 'Feeds token tests', + 'description' => 'Test the Feeds tokens.', + 'group' => 'Feeds', + ); + } + + public function setUp() { + parent::setUp(); + + // Create an importer configuration. + $this->createImporterConfiguration('Syndication', 'syndication'); + $this->addMappings('syndication', + array( + 0 => array( + 'source' => 'title', + 'target' => 'title', + 'unique' => FALSE, + ), + ) + ); + } + + /** + * Test if tokens defined by Feeds work. + */ + public function testFeedsTokens() { + // Import a RSS feed. + $edit = array( + 'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/developmentseed.rss2', + 'title' => 'RSS Feed title', + ); + $this->drupalPost('node/add/page', $edit, 'Save'); + + // Load an imported node. + $data = array( + 'node' => node_load(2), + ); + + // Setup tokens to test for replacement. + $texts = array( + 'Source: [node:feed-source]' => 'Source: RSS Feed title', + 'Nid: [node:feed-source:nid]' => 'Nid: 1', + 'Title: [node:feed-source:title]' => 'Title: RSS Feed title', + ); + + // Replace tokens and assert result. + foreach ($texts as $text => $expected) { + $replaced = token_replace($text, $data); + $this->assertEqual($expected, $replaced, format_string('The tokens for "@text" got replaced correctly with "@expected". Actual: "@replaced".', array( + '@text' => $text, + '@expected' => $expected, + '@replaced' => $replaced, + ))); + } + } + + /** + * Tests if a feed node does not get loaded if *not* replacing tokens like + * [node:feeds-source:x]. + */ + public function testPerformance() { + // Import a RSS feed. + $edit = array( + 'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/developmentseed.rss2', + ); + $this->drupalPost('node/add/page', $edit, 'Save'); + + // Keep track of loaded nodes from now on. + variable_set('feeds_track_node_loads', TRUE); + + // Load an imported node. + $data = array( + 'node' => node_load(2), + ); + + // Replace a single token. + token_replace('[node:title]', $data); + + // Ensure only node 2 was loaded. + $loaded_nodes = variable_get('feeds_loaded_nodes'); + $this->assertEqual(array(2), $loaded_nodes, format_string('The feed node (1) did not get loaded during token replacement, only node 2. Actual: @actual', array( + '@actual' => var_export($loaded_nodes, TRUE), + ))); + } +} From 8699575e4b345e7ff6ec922d0fc7850373a6efd9 Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Sat, 10 Dec 2016 11:47:07 +0100 Subject: [PATCH 09/16] Update commerce_checkout_redirect to 7.x-2.0 --- .../commerce_checkout_redirect.info | 6 +- .../commerce_checkout_redirect.module | 167 +++++++++--------- 2 files changed, 91 insertions(+), 82 deletions(-) diff --git a/www7/sites/all/modules/contrib/commerce_checkout_redirect/commerce_checkout_redirect.info b/www7/sites/all/modules/contrib/commerce_checkout_redirect/commerce_checkout_redirect.info index 68ca457e2..dc5e01f11 100644 --- a/www7/sites/all/modules/contrib/commerce_checkout_redirect/commerce_checkout_redirect.info +++ b/www7/sites/all/modules/contrib/commerce_checkout_redirect/commerce_checkout_redirect.info @@ -5,9 +5,9 @@ dependencies[] = commerce_cart core = 7.x configure = admin/commerce/config/checkout_redirect -; Information added by Drupal.org packaging script on 2014-07-23 -version = "7.x-2.0-rc1" +; Information added by Drupal.org packaging script on 2016-11-29 +version = "7.x-2.0" core = "7.x" project = "commerce_checkout_redirect" -datestamp = "1406127529" +datestamp = "1480426089" diff --git a/www7/sites/all/modules/contrib/commerce_checkout_redirect/commerce_checkout_redirect.module b/www7/sites/all/modules/contrib/commerce_checkout_redirect/commerce_checkout_redirect.module index 0ebef14fd..c8208945a 100644 --- a/www7/sites/all/modules/contrib/commerce_checkout_redirect/commerce_checkout_redirect.module +++ b/www7/sites/all/modules/contrib/commerce_checkout_redirect/commerce_checkout_redirect.module @@ -69,7 +69,7 @@ function commerce_checkout_redirect_settings($form, &$form_state) { '#default_value' => variable_get('commerce_checkout_redirect_username_as_order_email', FALSE), '#states' => array ( 'visible' => array( - ':input[name="commerce_checkout_redirect_anonymous"]' => array('checked' => TRUE), + ':input[name="commerce_checkout_redirect_anonymous"]' => array('checked' => true), ), ), ); @@ -80,7 +80,7 @@ function commerce_checkout_redirect_settings($form, &$form_state) { '#default_value' => variable_get('commerce_checkout_redirect_anonymous_as_login_option', FALSE), '#states' => array ( 'visible' => array( - ':input[name="commerce_checkout_redirect_anonymous"]' => array('checked' => TRUE), + ':input[name="commerce_checkout_redirect_anonymous"]' => array('checked' => true), ), ), ); @@ -109,11 +109,11 @@ function commerce_checkout_redirect_commerce_checkout_router($order, $checkout_p end($checkout_pages); $last_checkout_page = key($checkout_pages); // Check if the user's shopping cart order exists with something in the cart - if (commerce_cart_order_load() && commerce_checkout_redirect_items_in_cart()) { - if (($checkout_page['page_id'] == $first_checkout_page)) { + if (($checkout_page['page_id'] == $first_checkout_page)) { + if (commerce_cart_order_load() && commerce_checkout_redirect_items_in_cart()) { if (user_is_anonymous() && empty($_SESSION['commerce_checkout_redirect_bypass'])) { $_SESSION['commerce_checkout_redirect_anonymous'] = TRUE; - $commerce_checkout_redirect_message = variable_get('commerce_checkout_redirect_message', t('You need to be logged in to be able to checkout.')); + $commerce_checkout_redirect_message = variable_get('commerce_checkout_redirect_message', t('You need to be logged in to be able to checkout.')); if (!empty($commerce_checkout_redirect_message)) { drupal_set_message($commerce_checkout_redirect_message); } @@ -175,84 +175,93 @@ function commerce_checkout_redirect_user_login(&$edit, &$account) { */ function commerce_checkout_redirect_form_alter(&$form, &$form_state, $form_id) { $commerce_checkout_redirect_anonymous = variable_get('commerce_checkout_redirect_anonymous', FALSE); - // Check if user has an active cart order. - if ($order = commerce_cart_order_load()) { - // Check if there's anything in the cart and if user has not yet selected checkout method. - if (commerce_checkout_redirect_items_in_cart() && empty($_SESSION['commerce_checkout_redirect_bypass']) && !empty($_SESSION['commerce_checkout_redirect_anonymous'])) { - if (in_array($form_id, array('user_login', 'user_register_form', 'user_login_block', 'user_profile_form'))) { - // Append the checkout redirect function on user's forms. - $form['#submit'][] = 'commerce_checkout_redirect_redirect_anonymous_submit'; - unset($form['#action']); - // Anonymous checkout button. - if (variable_get('commerce_checkout_redirect_anonymous', FALSE)) { - $form_state['#order'] = $order; - $form['actions']['continue_button'] = array( - '#name' => 'continue_button', - '#type' => 'submit', - '#value' => t('Checkout without an account'), - '#limit_validation_errors' => array(), - '#submit' => array('commerce_checkout_redirect_anonymous_continue_checkout'), - '#states' => array ( - 'visible' => array( - ':input[name="have_pass"]' => array('value' => 0), - ), - ), - ); - // Anonymous checkout as alternative to login form. - if (variable_get('commerce_checkout_redirect_anonymous_as_login_option', FALSE)) { - $form['have_pass'] = array( - '#type' => 'radios', - '#title' => t('Do you have a password?'), - '#options' => array(0 => t('No (You can create an account later)'), 1 => t('Yes')), - '#weight' => 10, - '#default_value' => 0, - ); - $form['pass']['#states'] = array( - 'visible' => array( - ':input[name="have_pass"]' => array('value' => 1), - ), - ); - $form['actions']['submit']['#states'] = array( - 'visible' => array( - ':input[name="have_pass"]' => array('value' => 1), - ), - ); - $form['pass']['#weight'] = 10; - $form['actions']['continue_button']['#value'] = t('Continue'); - $form['actions']['continue_button']['#states'] = array ( - 'visible' => array( - ':input[name="have_pass"]' => array('value' => 0), + $user_forms = array( + 'user_login', + 'user_register_form', + 'user_login_block', + 'user_profile_form', + ); + $all_user_forms = $user_forms + array('user_pass_reset'); + if (in_array($form_id, $all_user_forms)) { + // Check if user has an active cart order. + if ($order = commerce_cart_order_load()) { + // Check if there's anything in the cart and if user has not yet selected checkout method. + if (commerce_checkout_redirect_items_in_cart() && empty($_SESSION['commerce_checkout_redirect_bypass']) && !empty($_SESSION['commerce_checkout_redirect_anonymous'])) { + if (in_array($form_id, $all_user_forms)) { + // Append the checkout redirect function on user's forms. + $form['#submit'][] = 'commerce_checkout_redirect_redirect_anonymous_submit'; + unset($form['#action']); + // Anonymous checkout button. + if (variable_get('commerce_checkout_redirect_anonymous', FALSE)) { + $form_state['#order'] = $order; + $form['actions']['continue_button'] = array( + '#name' => 'continue_button', + '#type' => 'submit', + '#value' => t('Checkout without an account'), + '#limit_validation_errors' => array(), + '#submit' => array('commerce_checkout_redirect_anonymous_continue_checkout'), + '#states' => array ( + 'visible' => array( + ':input[name="have_pass"]' => array('value' => '0'), + ), ), ); - } - // Use the username as order email. - // Email validation for the username form element - if (variable_get('commerce_checkout_redirect_username_as_order_email', FALSE)) { - $form['name']['#title'] = t('Email'); - $form['actions']['continue_button']['#limit_validation_errors'] = array(array('name')); - $form['actions']['continue_button']['#validate'][] = 'commerce_checkout_redirect_username_as_order_email_form_validate'; + // Anonymous checkout as alternative to login form. + if (variable_get('commerce_checkout_redirect_anonymous_as_login_option', FALSE)) { + $form['have_pass'] = array( + '#type' => 'radios', + '#title' => t('Do you have a password?'), + '#options' => array(0 => t('No (You can create an account later)'), 1 => t('Yes')), + '#weight' => 10, + '#default_value' => 0, + ); + $form['pass']['#states'] = array( + 'visible' => array( + ':input[name="have_pass"]' => array('value' => '1'), + ), + ); + $form['actions']['submit']['#states'] = array( + 'visible' => array( + ':input[name="have_pass"]' => array('value' => '1'), + ), + ); + $form['pass']['#weight'] = 10; + $form['actions']['continue_button']['#value'] = t('Continue'); + $form['actions']['continue_button']['#states'] = array ( + 'visible' => array( + ':input[name="have_pass"]' => array('value' => '0'), + ), + ); + } + // Use the username as order email. + // Email validation for the username form element + if (variable_get('commerce_checkout_redirect_username_as_order_email', FALSE)) { + $form['name']['#title'] = t('Email'); + $form['actions']['continue_button']['#limit_validation_errors'] = array(array('name')); + $form['actions']['continue_button']['#validate'][] = 'commerce_checkout_redirect_username_as_order_email_form_validate'; + } } } - } - // Reset password form. - // E-mail verification when a visitor creates an account. - elseif ($form_id == 'user_pass_reset' && !empty($form['actions'])) { - // Provide the checkout as an alternative to the new account - // reset password process. - // Message (help text) for the "Continue with checkout" button. - $checkout_redirect_reset_password_message = variable_get('commerce_checkout_redirect_reset_password_message', t('You can also continue with the checkout process.')); - if (!empty($checkout_redirect_reset_password_message)) { - $form['actions']['checkout_message']['#markup'] = '

      ' . $checkout_redirect_reset_password_message . '

      '; + // Reset password form. + // E-mail verification when a visitor creates an account. + elseif ($form_id == 'user_pass_reset' && !empty($form['actions'])) { + // Provide the checkout as an alternative to the new account + // reset password process. + // Message (help text) for the "Continue with checkout" button. + $checkout_redirect_reset_password_message = variable_get('commerce_checkout_redirect_reset_password_message', t('You can also continue with the checkout process.')); + if (!empty($checkout_redirect_reset_password_message)) { + $form['actions']['checkout_message']['#markup'] = '

      ' . $checkout_redirect_reset_password_message . '

      '; + } + // "Continue with checkout" submit button. + $form['actions']['checkout'] = array( + '#type' => 'submit', + '#value' => t('Continue with checkout'), + ); + // Append the checkout redirect function on user's forms. + $form['#submit'][] = 'commerce_checkout_redirect_redirect_anonymous_submit'; + // Unset the action, use submit form function(s) instead. + unset($form['#action']); } - // "Continue with checkout" submit button. - $form['actions']['checkout'] = array( - '#type' => 'submit', - '#value' => t('Continue with checkout'), - ); - // Append the checkout redirect function on user's forms. - $form['#submit'][] = 'commerce_checkout_redirect_redirect_anonymous_submit'; - // Unset the action, use submit form function(s) instead. - unset($form['#action']); } } } @@ -346,7 +355,7 @@ function commerce_checkout_redirect_anonymous_continue_checkout($form, &$form_st $order->mail = $form_state['values']['name']; commerce_order_save($order); } - $form_state['redirect'] = 'checkout/'; + $form_state['redirect'] = 'checkout'; } /** From f147df05ce4dfe8c9a19c8fbe103353199538134 Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Sat, 10 Dec 2016 11:47:32 +0100 Subject: [PATCH 10/16] Update menu_trail_by_path to 7.x-3.2 --- .../menu_trail_by_path.admin.inc | 64 ++++++++ .../menu_trail_by_path.api.php | 26 ++++ .../menu_trail_by_path.info | 12 +- .../menu_trail_by_path.install | 22 +++ .../menu_trail_by_path.module | 132 +++++----------- .../menu_trail_by_path.test | 73 +++++---- .../src/MenutrailbypathActivetrail.inc | 90 +++++++++++ .../src/MenutrailbypathBreadcrumb.inc | 147 ++++++++++++++++++ .../src/MenutrailbypathConfig.inc | 30 ++++ .../src/MenutrailbypathMenuHelper.inc | 120 ++++++++++++++ .../src/MenutrailbypathPathHelper.inc | 37 +++++ .../src/MenutrailbypathUsortMenulinks.inc | 14 ++ 12 files changed, 637 insertions(+), 130 deletions(-) create mode 100644 www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.admin.inc create mode 100644 www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.api.php create mode 100644 www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.install create mode 100644 www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathActivetrail.inc create mode 100644 www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathBreadcrumb.inc create mode 100644 www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathConfig.inc create mode 100644 www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathMenuHelper.inc create mode 100644 www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathPathHelper.inc create mode 100644 www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathUsortMenulinks.inc diff --git a/www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.admin.inc b/www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.admin.inc new file mode 100644 index 000000000..fbd5c8c00 --- /dev/null +++ b/www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.admin.inc @@ -0,0 +1,64 @@ + 'fieldset', + '#title' => t('Menu-trail'), + ); + $form['menu_trail_by_path_menu_trail']['menu_trail_by_path_menu_trail_active_on_admin_paths'] = array( + '#type' => 'checkbox', + '#title' => t('Active on admin paths'), + '#description' => t("If checked, menu-trail handling will also be active on the administrative section of the site."), + '#default_value' => MenutrailbypathConfig::get('menu_trail_active_on_admin_paths'), + ); + $form['menu_trail_by_path_menu_trail']['menu_trail_by_path_menu_trail_active_on_ajax_requests'] = array( + '#type' => 'checkbox', + '#title' => t('Active on ajax requests'), + '#description' => t("If checked, menu-trail handling will also be active on ajax requests."), + '#default_value' => MenutrailbypathConfig::get('menu_trail_active_on_ajax_requests'), + ); + + // Breadcrumb + $form['menu_trail_by_path_breadcrumb'] = array( + '#type' => 'fieldset', + '#title' => t('Breadcrumb'), + ); + $form['menu_trail_by_path_breadcrumb']['menu_trail_by_path_breadcrumb_handling'] = array( + '#type' => 'checkbox', + '#title' => t('Enable breadcrumb handling'), + '#description' => t("If checked, breadcrumb will be set according to url path."), + '#default_value' => MenutrailbypathConfig::get('breadcrumb_handling'), + ); + $form['menu_trail_by_path_breadcrumb']['menu_trail_by_path_breadcrumb_active_on_admin_paths'] = array( + '#type' => 'checkbox', + '#title' => t('Active on admin paths'), + '#description' => t("If checked, breadcrumb handling will also be active on the administrative section of the site."), + '#default_value' => MenutrailbypathConfig::get('breadcrumb_active_on_admin_paths'), + ); + $form['menu_trail_by_path_breadcrumb']['menu_trail_by_path_breadcrumb_active_on_ajax_requests'] = array( + '#type' => 'checkbox', + '#title' => t('Active on ajax requests'), + '#description' => t("If checked, breadcrumb handling will also be active on ajax requests."), + '#default_value' => MenutrailbypathConfig::get('breadcrumb_active_on_ajax_requests'), + ); + $form['menu_trail_by_path_breadcrumb']['menu_trail_by_path_breadcrumb_display_current_page'] = array( + '#title' => t('Display current page in the breadcrumb trail'), + '#type' => 'radios', + '#options' => array( + 'no' => t('No, don\'t show the current page in the breadcrumb trail.'), + 'yes_span' => t('Yes, show the current page as plain text.'), + 'yes_link' => t('Yes, show the current page as a active link.') + ), + '#default_value' => MenutrailbypathConfig::get('breadcrumb_display_current_page'), + ); + + return system_settings_form($form); +} diff --git a/www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.api.php b/www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.api.php new file mode 100644 index 000000000..81e66c4dd --- /dev/null +++ b/www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.api.php @@ -0,0 +1,26 @@ +=7.12) files[] = menu_trail_by_path.test +files[] = src/MenutrailbypathConfig.inc +files[] = src/MenutrailbypathActivetrail.inc +files[] = src/MenutrailbypathBreadcrumb.inc +files[] = src/MenutrailbypathMenuHelper.inc +files[] = src/MenutrailbypathPathHelper.inc +files[] = src/MenutrailbypathUsortMenulinks.inc configure = admin/config/search/menu_trail_by_path -; Information added by Drupal.org packaging script on 2016-07-13 -version = "7.x-2.1" +; Information added by Drupal.org packaging script on 2016-11-29 +version = "7.x-3.2" core = "7.x" project = "menu_trail_by_path" -datestamp = "1468445040" +datestamp = "1480429986" diff --git a/www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.install b/www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.install new file mode 100644 index 000000000..7960d9d1b --- /dev/null +++ b/www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.install @@ -0,0 +1,22 @@ +fields('ml', array('menu_name', 'mlid', 'link_path', 'link_title', 'depth', 'weight')) - ->condition('link_path', $parent_candidates, 'IN') - // Do not touch admin menu. - ->condition('menu_name', 'management', '!=') - // Only consider normal, visible menu links. - ->condition('hidden', 0) - ->execute(); - foreach ($results as $record) { - // If there is more than one matched link in a menu, - // use the deepest, heaviest. - if (!isset($matched_menus[$record->menu_name]) || $record->depth > $matched_menus[$record->menu_name]['depth'] || ($record->depth == $matched_menus[$record->menu_name]['depth'] && $record->weight > $matched_menus[$record->menu_name]['weight'])) { - $matched_menus[$record->menu_name]['link_path'] = $record->link_path; - $matched_menus[$record->menu_name]['depth'] = $record->depth; - $matched_menus[$record->menu_name]['weight'] = $record->weight; - } + menu_trail_by_path_fix_cache_after_upgrade(); - // Get the Link Title if it can be found in a menu item. - if ($record->link_title && !isset($matched_link_titles[$record->link_path])) { - $matched_link_titles[$record->link_path] = $record->link_title; - if (module_exists('i18n_menu')) { - $matched_link_titles[$record->link_path] = _i18n_menu_link_title((array)$record, $language->language); - } - } - } + $pathHelper = new MenutrailbypathPathHelper(); + $menuHelper = new MenutrailbypathMenuHelper($language); // Set the active-trail for each menu containing one of the candidates. - foreach ($matched_menus as $menu_name => $menu_link) { - menu_tree_set_path($menu_name, $menu_link['link_path']); + if (menu_trail_by_path_is_active('menu_trail')) { + $activetrail = new MenutrailbypathActivetrail($pathHelper, $menuHelper); + $activetrail->setActivetrails(); } // Set the breadcrumbs according to path URL if it is enabled in the UI. - if (variable_get('menu_trail_by_path_breadcrumb_handling', TRUE)) { - // First breadcrumb is always Home. - $breadcrumbs[] = l(t('Home'), ''); + if (menu_trail_by_path_is_active('breadcrumb')) { + $breadcrumb = new MenutrailbypathBreadcrumb($pathHelper, $menuHelper); + $breadcrumb->setBreadcrumb(); + } +} - // Remove current page from breadcrumb. - array_pop($parent_candidates); +/** + * Prevent fatal error after upgrade + * @see https://www.drupal.org/node/2793777 + * + * @deprecated (to be removed in 7.x-4.x) + */ +function menu_trail_by_path_fix_cache_after_upgrade() { + if (!class_exists('MenutrailbypathPathHelper') || !class_exists('MenutrailbypathActivetrail') || !class_exists('MenutrailbypathUsortMenulinks')) { + watchdog('menu_trail_by_path', 'Fixing invalid cache, you probably forgot to clear the cache after menu_trail_by_path upgrade..', array(), WATCHDOG_ERROR); + drupal_flush_all_caches(); + } +} - foreach ($parent_candidates as $link_path) { - // If the page title is found on a menu item, use it. - if (isset($matched_link_titles[$link_path])) { - $breadcrumbs[] = l($matched_link_titles[$link_path], $link_path); - } - // Otherwise, use slow method to find out the title of a page. - elseif ($menu_item = menu_get_item($link_path)) { - if (!empty($menu_item['title'])) { - $breadcrumbs[] = l($menu_item['title'], $link_path); - } - } - } - drupal_set_breadcrumb($breadcrumbs); +/** + * @param $type + * @return bool + */ +function menu_trail_by_path_is_active($type) { + switch ($type) { + case 'breadcrumb': + return ( + (MenutrailbypathConfig::get('breadcrumb_handling')) + && (!path_is_admin(current_path()) || MenutrailbypathConfig::get('breadcrumb_active_on_admin_paths')) + && (!(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') || MenutrailbypathConfig::get('breadcrumb_active_on_ajax_requests')) + ); + break; + default: + return ( + (!path_is_admin(current_path()) || MenutrailbypathConfig::get('menu_trail_active_on_admin_paths')) + && (!(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') || MenutrailbypathConfig::get('menu_trail_active_on_ajax_requests')) + ); + break; } } @@ -98,43 +87,8 @@ function menu_trail_by_path_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('menu_trail_by_path_form'), 'access arguments' => array('administer site configuration'), + 'file' => 'menu_trail_by_path.admin.inc', 'type' => MENU_NORMAL_ITEM, ); return $items; } - -/** - * Form builder; create and display the admin configuration settings form. - */ -function menu_trail_by_path_form($form, &$form_state) { - $form['menu_trail_by_path_breadcrumb_handling'] = array( - '#type' => 'checkbox', - '#title' => t('Enable breadcrumb handling'), - '#description' => t("If checked, breadcrumb will be set according to url path."), - '#default_value' => variable_get('menu_trail_by_path_breadcrumb_handling', TRUE), - ); - return system_settings_form($form); -} - -/** - * Returns an array of parent candidates - * - * e.g. given the argument 'foo/bar/zee', this returns an array of - * internal Drupal paths for 'foo', 'foo/bar', 'foo/bar/zee'. - * - * @param string $path - * A Drupal path alias. - * - * @return array - * An array of internal Drupal paths. - */ -function _menu_trail_by_path_get_parent_candidates($path) { - $pieces = explode('/', $path); - $path = ''; - $parent_candidates = array(); - foreach ($pieces as $piece) { - $path .= $piece . '/'; - $parent_candidates[] = drupal_get_normal_path(rtrim($path, '/')); - } - return $parent_candidates; -} diff --git a/www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.test b/www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.test index 277af6d94..4b8cfc110 100755 --- a/www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.test +++ b/www7/sites/all/modules/contrib/menu_trail_by_path/menu_trail_by_path.test @@ -72,44 +72,41 @@ class MenuTrailByPathTestCase extends DrupalWebTestCase { $this->moveDrupalBlock('system_main-menu', 'header'); } - // TODO: CURRENTLY THE MODULE IS NOT CAPABLE OF PASSING THIS TEST - ///** - // * Test url: Home - // */ - //public function testUrlHome() { - // $this->drupalGet($this->menuUrls['Home']); - // $this->assertMenuActiveTrail( - // array( - // $this->menuUrlBasePath('Home') => 'Home', - // ), TRUE - // ); - //} - - // TODO: CURRENTLY THE MODULE IS NOT CAPABLE OF PASSING THIS TEST - ///** - // * Test url: User password - // */ - //public function testUrlUserPassword() { - // $this->drupalGet($this->menuUrls['User password']); - // $this->assertMenuActiveTrail( - // array( - // $this->menuUrlBasePath('User password') => 'User password', - // ), TRUE - // ); - //} - - // TODO: CURRENTLY THE MODULE IS NOT CAPABLE OF PASSING THIS TEST - ///** - // * Test url: User login - // */ - //public function testUrlUserLogin() { - // $this->drupalGet($this->menuUrls['User login']); - // $this->assertMenuActiveTrail( - // array( - // $this->menuUrlBasePath('User login') => 'User login', - // ), TRUE - // ); - //} + /** + * Test url: Home + */ + public function testUrlHome() { + $this->drupalGet($this->menuUrls['Home']); + $this->assertMenuActiveTrail( + array( + $this->menuUrlBasePath('Home') => 'Home', + ), TRUE + ); + } + + /** + * Test url: User password + */ + public function testUrlUserPassword() { + $this->drupalGet($this->menuUrls['User password']); + $this->assertMenuActiveTrail( + array( + $this->menuUrlBasePath('User password') => 'User password', + ), TRUE + ); + } + + /** + * Test url: User login + */ + public function testUrlUserLogin() { + $this->drupalGet($this->menuUrls['User login']); + $this->assertMenuActiveTrail( + array( + $this->menuUrlBasePath('User login') => 'User login', + ), TRUE + ); + } /** * Test url: User diff --git a/www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathActivetrail.inc b/www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathActivetrail.inc new file mode 100644 index 000000000..830388352 --- /dev/null +++ b/www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathActivetrail.inc @@ -0,0 +1,90 @@ +pathHelper = $pathHelper; + $this->menuHelper = $menuHelper; + } + + /** + * Set the active trail for all menu's + */ + public function setActivetrails() { + $menu_names = $this->menuHelper->getActiveMenuNames(); + foreach ($menu_names as $menu_name) { + $this->setActivetrail($menu_name); + } + } + + /** + * Set the active trail for the specified menu + * + * @param $menu_name + */ + public function setActivetrail($menu_name) { + // The only way to override the default preferred menu link for a path is to + // inject it into the static cache of the function menu_link_get_preferred(). + $preferred_links = &drupal_static('menu_link_get_preferred'); + $path = $_GET['q']; + + // If the regular menu_link_get_preferred isn't called yet, we need to call it get a + // clean menu_link_get_preferred static cache (and thus avoiding any unpredictable behaviours) + if (!isset($preferred_links[$path][MENU_PREFERRED_LINK])) { + menu_link_get_preferred(); + } + + if ($menu_link = $this->getActiveTrailLink($menu_name)) { + $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC)); + $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path'); + $query->fields('ml'); + // Weight must be taken from {menu_links}, not {menu_router}. + $query->addField('ml', 'weight', 'link_weight'); + $query->fields('m'); + $query->condition('ml.mlid', $menu_link->mlid, '='); + + $candidate_item = $query->execute()->fetchAssoc(); + $candidate_item['weight'] = $candidate_item['link_weight']; + + // TODO: The menu_links doesn't always have a 1:1 relation to the a menu_router, is it ok to skip the _menu_translate? + if (!empty($candidate_item['path'])) { + $map = explode('/', $path); + _menu_translate($candidate_item, $map); + } + + $preferred_links[$path][$menu_name] = $candidate_item; + } + } + + /** + * Fetches the deepest, heaviest menu link which matches the deepest trail path url. + * + * @param string $menu_name + * The menu within which to find the active trail link. + * + * @return stdClass|NULL + * The menu link for the given menu, or NULL if there is no matching menu link. + */ + protected function getActiveTrailLink($menu_name) { + $menu_links = $this->menuHelper->getMenuLinks($menu_name); + $trail_paths = $this->pathHelper->getPaths(); + + foreach (array_reverse($trail_paths) as $trail_path) { + foreach (array_reverse($menu_links) as $menu_link) { + if (url($menu_link->link_path) == url($trail_path)) { + return $menu_link; + } + } + } + + return NULL; + } +} diff --git a/www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathBreadcrumb.inc b/www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathBreadcrumb.inc new file mode 100644 index 000000000..b7f84eb02 --- /dev/null +++ b/www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathBreadcrumb.inc @@ -0,0 +1,147 @@ +pathHelper = $pathHelper; + $this->menuHelper = $menuHelper; + } + + /** + * Sets the breadcrumb by path + * + * @see menu_get_active_breadcrumb() + */ + public function setBreadcrumb() { + $breadcrumb = array(); + $this->setActiveTrail(); + + // No breadcrumb for the front page. + if (drupal_is_front_page()) { + return; + } + + $active_trail = menu_get_active_trail(); + $item = end($active_trail); + if (!empty($item['href'])) { + // Allow modules to alter the breadcrumb, if possible, as that is much + // faster than rebuilding an entirely new active trail. + drupal_alter('menu_breadcrumb', $active_trail, $item); + + // Don't show a link to the current page in the breadcrumb trail. + $end = end($active_trail); + if ($item['href'] == $end['href']) { + $current_page_link = array_pop($active_trail); + } + + // Remove the tab root (parent) if the current path links to its parent. + // Normally, the tab root link is included in the breadcrumb, as soon as we + // are on a local task or any other child link. However, if we are on a + // default local task (e.g., node/%/view), then we do not want the tab root + // link (e.g., node/%) to appear, as it would be identical to the current + // page. Since this behavior also needs to work recursively (i.e., on + // default local tasks of default local tasks), and since the last non-task + // link in the trail is used as page title (see menu_get_active_title()), + // this condition cannot be cleanly integrated into menu_get_active_trail(). + // menu_get_active_trail() already skips all links that link to their parent + // (commonly MENU_DEFAULT_LOCAL_TASK). In order to also hide the parent link + // itself, we always remove the last link in the trail, if the current + // router item links to its parent. + if (($item['type'] & MENU_LINKS_TO_PARENT) == MENU_LINKS_TO_PARENT) { + array_pop($active_trail); + } + + foreach ($active_trail as $parent) { + $breadcrumb[] = l($parent['title'], $parent['href'], $parent['localized_options']); + } + + if ($current_page_link) { + $drupal_page_title = drupal_get_title(); + if (!empty($drupal_page_title) && $current_page_link['href'] == current_path()) { + $current_page_link['title'] = $drupal_page_title; + } + if (MenutrailbypathConfig::get('breadcrumb_display_current_page') == 'yes_link') { + $link_options = $current_page_link['localized_options']; + $link_options['attributes']['class'][] = 'breadcrumb__item--current-page'; + $link_options['attributes']['class'][] = 'active'; + $breadcrumb[] = l($current_page_link['title'], $current_page_link['href'], $link_options); + } elseif(MenutrailbypathConfig::get('breadcrumb_display_current_page') == 'yes_span') { + $breadcrumb[] = '' . $current_page_link['title'] . ''; + } + } + } + + drupal_set_breadcrumb($breadcrumb); + } + + /** + * Sets the active_trail by path + */ + protected function setActiveTrail() { + $active_trail = array(); + $trail_paths = $this->pathHelper->getPaths(); + $trail_menu_links = $this->menuHelper->getMenuLinksByPaths($trail_paths); + $breadcrumb_menu_links = $this->groupMenuLinksByPath($trail_menu_links); + + // First breadcrumb is always Home. + $active_trail[] = array( + 'title' => t('Home'), + 'href' => '', + 'localized_options' => array(), + 'type' => 0, + ); + // Add links for the trail-paths + foreach ($trail_paths as $trail_path) { + $menu_link = NULL; + $router_item = menu_get_item($trail_path); + + if (!empty($breadcrumb_menu_links[$trail_path]->link_title)) { + $menu_link = (array) $breadcrumb_menu_links[$trail_path]; + $menu_link['external'] = 1; + $menu_link['type'] = $router_item['type']; + _menu_link_translate($menu_link); + } + elseif (!empty($router_item['title'])) { + $menu_link = array( + 'title' => $router_item['title'], + 'href' => $trail_path, + 'localized_options' => array(), + 'type' => MENU_NORMAL_ITEM, + ); + } + + if (!empty($menu_link)) { + $active_trail[] = $menu_link; + } + } + + menu_set_active_trail($active_trail); + } + + /** + * Group MenuLinks by path, preferring menu_links by menu preference order, menu_link depth, menu_link weight + * + * @param array $menu_links + * @return array + */ + protected function groupMenuLinksByPath(array $menu_links) { + $menu_links = array_reverse($menu_links); + $this->menuHelper->sortMenuLinksByMenuPreference($menu_links); + + $breadcrumb_menu_links = array(); + foreach ($menu_links as $menu_link) { + if (!isset($breadcrumb_menu_links[$menu_link->link_path]) && !empty($menu_link->link_title)) { + $breadcrumb_menu_links[$menu_link->link_path] = $menu_link; + } + } + return $breadcrumb_menu_links; + } +} diff --git a/www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathConfig.inc b/www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathConfig.inc new file mode 100644 index 000000000..5c2cc9809 --- /dev/null +++ b/www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathConfig.inc @@ -0,0 +1,30 @@ +language = $language; + } + + /** + * Find link items matching the given link_paths in (almost) all menus + * + * @param $link_paths + * @return array + */ + public function getMenuLinksByPaths(array $link_paths) { + if (empty($link_paths)) { + return array(); + } + + $query = db_select('menu_links', 'ml') + ->fields('ml') + ->condition('link_path', $link_paths, 'IN') + ->condition('hidden', 0) // Only consider normal, visible menu links. + ->orderBy('depth') + ->orderBy('weight') + ->orderBy('mlid'); + + if (module_exists('i18n_menu')) { + $query->condition('language', array(LANGUAGE_NONE, $this->language->language), 'IN'); + } + $results = $query->execute(); + return ($results instanceof DatabaseStatementInterface) ? $this->translateMenuLinkTitles($results->fetchAll()) : array(); + } + + /** + * Get menu_links for a given menu_name + * + * @param $menu_name + * @return array + */ + public function getMenuLinks($menu_name) { + $query = db_select('menu_links', 'ml') + ->fields('ml') + ->condition('menu_name', $menu_name, '=') // Do not touch admin menu. + ->condition('hidden', 0) // Only consider normal, visible menu links. + ->orderBy('depth') + ->orderBy('weight') + ->orderBy('mlid'); + + if (module_exists('i18n_menu')) { + $query->condition('language', array(LANGUAGE_NONE, $this->language->language), 'IN'); + } + $results = $query->execute(); + return ($results instanceof DatabaseStatementInterface) ? $this->translateMenuLinkTitles($results->fetchAll()) : array(); + } + + /** + * translateMenuLinkTitles + * + * @param array $menu_links + * @return array + */ + protected function translateMenuLinkTitles(array $menu_links) { + foreach ($menu_links as $k => $menu_link) { + if (module_exists('i18n_menu')) { + $menu_link->link_title = _i18n_menu_link_title((array) $menu_link, $this->language->language); + } + } + return $menu_links; + } + + /** + * Sort menu_links by the menu preference order, see menu_set_active_menu_names() + * Stable sorting based on https://github.com/vanderlee/PHP-stable-sort-functions + * + * @param array $menu_links + */ + public function sortMenuLinksByMenuPreference(array &$menu_links) { + $menu_preference = array_flip(menu_get_active_menu_names()); + $menu_preference_max = count($menu_preference); + + $index = 0; + foreach ($menu_links as &$item) { + if (!isset($menu_preference[$item->menu_name])) { + $menu_preference[$item->menu_name] = $menu_preference_max; + } + $item = array($index++, $item); + } + $usort_result = usort($menu_links, array(new MenutrailbypathUsortMenulinks($menu_preference), 'compare')); + foreach ($menu_links as &$item) { + $item = $item[1]; + } + return $usort_result; + } + + /** + * Make sure all custom menus are present in the active menus variable so that + * their items may appear in the active trail. + * @see https://www.drupal.org/node/2830385 + * @see menu_update_7003() + * + * @return array + */ + public function getActiveMenuNames() { + $active_menus = menu_get_active_menu_names(); + foreach (menu_get_names() as $menu_name) { + if (!in_array($menu_name, $active_menus) && (strpos($menu_name, 'menu-') === 0)) { + $active_menus[] = $menu_name; + } + } + + return $active_menus; + } +} diff --git a/www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathPathHelper.inc b/www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathPathHelper.inc new file mode 100644 index 000000000..1b7f1e57c --- /dev/null +++ b/www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathPathHelper.inc @@ -0,0 +1,37 @@ +'); + } + + include_once DRUPAL_ROOT . '/includes/language.inc'; + list($request_language, $request_path) = language_url_split_prefix(request_path(), language_list()); + + $paths = array(); + $path_elements = explode('/', $request_path); + while (count($path_elements)) { + $path = drupal_get_normal_path(implode('/', $path_elements)); + if ($router_item = menu_get_item($path)) { + $paths[] = $path; + } + array_pop($path_elements); + } + $paths = array_reverse($paths); + + // Allow other modules to alter the paths (formerly known as "parent candidates"). + drupal_alter('menu_trail_by_path_parent_candidates', $request_path, $paths); + + return $paths; + } +} diff --git a/www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathUsortMenulinks.inc b/www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathUsortMenulinks.inc new file mode 100644 index 000000000..17cab7253 --- /dev/null +++ b/www7/sites/all/modules/contrib/menu_trail_by_path/src/MenutrailbypathUsortMenulinks.inc @@ -0,0 +1,14 @@ +menu_preference = $menu_preference; + } + + public function compare($a, $b) { + $result = ($this->menu_preference[$a[1]->menu_name] == $this->menu_preference[$b[1]->menu_name]) ? 0 : (($this->menu_preference[$a[1]->menu_name] < $this->menu_preference[$b[1]->menu_name]) ? -1 : 1); + return ($result == 0) ? ($a[0] - $b[0]) : $result; + } +} From 752ee49fb91a95d8e4b2891595cd0f21861c39b4 Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Sat, 24 Dec 2016 12:36:38 +0100 Subject: [PATCH 11/16] Update diff to 7.x-3.3 --- .../all/modules/contrib/diff/CHANGELOG.txt | 166 ---------- .../all/modules/contrib/diff/DiffEngine.php | 33 +- .../modules/contrib/diff/css/diff.boxes.css | 61 ++-- .../modules/contrib/diff/css/diff.default.css | 55 +++- .../all/modules/contrib/diff/diff.admin.inc | 50 ++- .../all/modules/contrib/diff/diff.api.php | 62 +++- www7/sites/all/modules/contrib/diff/diff.css | 54 ++-- .../all/modules/contrib/diff/diff.diff.inc | 82 ++--- www7/sites/all/modules/contrib/diff/diff.info | 7 +- .../all/modules/contrib/diff/diff.install | 43 ++- .../all/modules/contrib/diff/diff.module | 167 +++++++++- .../all/modules/contrib/diff/diff.pages.inc | 171 ++++++----- .../all/modules/contrib/diff/diff.theme.inc | 21 +- .../all/modules/contrib/diff/diff.tokens.inc | 11 +- .../modules/contrib/diff/includes/file.inc | 20 +- .../modules/contrib/diff/includes/image.inc | 20 +- .../modules/contrib/diff/includes/node.inc | 287 ++++++++++++------ .../modules/contrib/diff/includes/user.inc | 148 +++++++++ .../sites/all/modules/contrib/diff/js/diff.js | 101 +++--- .../sites/all/modules/contrib/diff/readme.txt | 5 +- 20 files changed, 1006 insertions(+), 558 deletions(-) delete mode 100644 www7/sites/all/modules/contrib/diff/CHANGELOG.txt create mode 100644 www7/sites/all/modules/contrib/diff/includes/user.inc diff --git a/www7/sites/all/modules/contrib/diff/CHANGELOG.txt b/www7/sites/all/modules/contrib/diff/CHANGELOG.txt deleted file mode 100644 index 386964320..000000000 --- a/www7/sites/all/modules/contrib/diff/CHANGELOG.txt +++ /dev/null @@ -1,166 +0,0 @@ - -CHANGELOG for Diff 7.x-2.0+13-dev to 7.x-3.x -============================================ - -1) System variable names have been changed ------------------------------------------- - -Considerable changes have occurred. - -2) hook_diff() was removed --------------------------- - -This has been replaced by hook_entity_diff() as of Diff 7.x-3.x. - -3) Field diffs are handled independently by Diff and the field module ---------------------------------------------------------------------- - -Field modules SHOULD NOT implement hook_entity_diff(). - -This is complicated and costly in terms of performance. - -Two new field callbacks are defined to handle these. - - a) MODULE_field_diff_view_prepare() - - Optional: If you need to load data, use MODULE_field_diff_view_prepare(). - - b) MODULE_field_diff_view() - - Recommended: You should implement this to generate the compared data. - -If there is no corresponding hook for a field, the field comparison will try -to guess the value using $item['safe_value'] or $item['value'] properties. - -If you need to make this configurable, there are two additional hooks: - - c) MODULE_field_diff_default_options($field_type) - - You should define any additioal settings here. This shares a global namespace - of the diff module, so you can overwrite core Diff settings here too. - - In saying that, take care not to accidentially do this. - - d) MODULE_field_diff_options_form($field_type, $settings) - - This is where you insert Form API elements to configure your option settings. - -4) Field diffs are now configurable ------------------------------------ - -Each field type defined by core have configurable settings to control the -rendering of the comparison. - - a) Global configuration - - An administration page has been added to handle field type default settings. - - This is the preferred way to configure field settings are these are global to - all fields of this type. - - b) View mode display options - - The display "Diff comparison" is used to control the fields that are displayed - when comparing different revisions. - - The following is a walk-through on how you would configure the Basic page - (page) content types field configuration. - - - Enable "Diff comparison" custom view mode - - Navigate to admin/structure/types/manage/page/display and look at the - Custom Display Settings for this view mode. Check and save. - - - Configure the display - - After Saving this page, a new tab appears "Diff comparison", click this or - navigate directly to admin/structure/types/manage/page/display/diff_standard - - - You can hide or show the fields that you want to display when doing - comparisons. - - If the field has no inbuilt diff support, then the renderred field items - will be compared. - -5) Standard comparison preview / Inline diff view setting ---------------------------------------------------------- - -You can set the view modes used to compare the rendered node. This can be found -in the Diff settings in the Content Type settings page. - -6) Optional CSS and new Boxes styles ------------------------------------- - -This takes the styles from WikiPedia to really spice up the diff page. - -7) Optional JScript extras --------------------------- - -This spices up the revision checkboxes on the revisions page. - -8) Simple past revision token support -------------------------------------- - -Use-case, email notifications when content has changes. If these support tokens, -then you can embed Diffs into these emails. - -9) Extensive string review --------------------------- -See http://drupal.org/node/1785742 - - -10) Inline block settings changes ---------------------------------- -The inline block settings are now in the block configuration page. - -11) And much more... --------------------- - -The complete change log follows: - -Diff 7.x-2.x - o #888680 by Deciphered, Alan D.: Allow modules to interact via drupal_alter() - o #1280892 by Alan D., crea: Diff should track the variables that it defines - o #1304658 by Alan D., kari.kaariainen: Remove links and comments from the comparison preview - o #1122206 by binford2k, Alan D.: Notices thrown by DiffEngine::process_chunk() - o #1175064 by zilverdistel, Alan D.: Provide variables for leading and trailing context - o #1673864 by Alan D.: Allow users to bypass the admin theme when viewing comparisons - o #1673876 by Alan D.: Use Drupal autoloading for classes - o #1673856 by Alan D.: Use hook_form_BASE_FORM_ID_alter() rather than hook_form_alter() - o #1673856 by Alan D.: Normalise line endings - o #114308 by Alan D.: add jQuery for hiding radios that shouldn't show diffs - o #1688840 by Alan D.: Enable new JScript behaviour by default - o #372957 by erykmynn, JuliaKM, lsrzj, andrew_rs, alexpott, et al: HTML Strip for Diff, WYSIWYG Friendly - (This was refactored in the 7.x-3.x branch from the commited 7.x-2.x code) - o #521212 by Alan D., blakehall: Make diff comparison page themable - o #1671484 by Alan D.: Show number of lines changed on revisions page - o #114699 by smokris, Alan D.: Diff module should support Token - o #372957 by c31ck: display either Hide or Show based on what clicking it will do at any time (HTML Strip for Diff) - This was altered for the 7.x-3.x branch. - o #1807510 & #1825202: Simplify Diff administration - o #1812162 by mitchell, Alan D.: 'Highlight changes' block appears on edit form - - Node to Entity changes - ---------------------- - These are roughly tracked in the meta issue #1365750 Generalize API and Integrate with core field types - - o (no issue) by Alan D.: Use entity specific system variables. - o (no issue) by Alan D.: View mode code, new hooks, new API. Massive patch! - - Resolves: - o #248778: Taxonomy diff - o #1550698: Diff of "select from list" fields shows change in key, not change in value - o #1458814: File (and image) field support - o #1418760: Optional setting to honour the display settings - o #1347316: Selectable view mode for inline diffs and "Current revision" display view mode - o #1458906: Improve performances (of existing 7.x-2.x field rendering) - o #1424162: Diff in Taxonomy term description - o #1211282: Image diff support - -The following patches will be posted in the corresponding project queues once -the 7.x-3.x branch is released: - o #1595702 by Alan D., mbilbille: Support of field collection module - o #1350604 by Alan D., johaziel: Datetime diff - o (no issue) by Alan D.: Email field Diff support - o (no issue) by Alan D.: Countries Diff support - o (no issue) by Alan D.: Name field Diff support - o (no issue) by Alan D.: Link field Diff support diff --git a/www7/sites/all/modules/contrib/diff/DiffEngine.php b/www7/sites/all/modules/contrib/diff/DiffEngine.php index 123661072..04234b764 100644 --- a/www7/sites/all/modules/contrib/diff/DiffEngine.php +++ b/www7/sites/all/modules/contrib/diff/DiffEngine.php @@ -41,7 +41,7 @@ function nclosing() { class _DiffOp_Copy extends _DiffOp { var $type = 'copy'; - function _DiffOp_Copy($orig, $closing = FALSE) { + function __construct($orig, $closing = FALSE) { if (!is_array($closing)) { $closing = $orig; } @@ -62,7 +62,7 @@ function reverse() { class _DiffOp_Delete extends _DiffOp { var $type = 'delete'; - function _DiffOp_Delete($lines) { + function __construct($lines) { $this->orig = $lines; $this->closing = FALSE; } @@ -80,7 +80,7 @@ function reverse() { class _DiffOp_Add extends _DiffOp { var $type = 'add'; - function _DiffOp_Add($lines) { + function __construct($lines) { $this->closing = $lines; $this->orig = FALSE; } @@ -98,7 +98,7 @@ function reverse() { class _DiffOp_Change extends _DiffOp { var $type = 'change'; - function _DiffOp_Change($orig, $closing) { + function __construct($orig, $closing) { $this->orig = $orig; $this->closing = $closing; } @@ -215,11 +215,17 @@ function diff($from_lines, $to_lines) { // Find deletes & adds. $delete = array(); while ($xi < $n_from && $this->xchanged[$xi]) { - $delete[] = $from_lines[$xi++]; + $_fl = $from_lines[$xi++]; + if (strlen($_fl)) { + $delete[] = $_fl; + } } $add = array(); while ($yi < $n_to && $this->ychanged[$yi]) { - $add[] = $to_lines[$yi++]; + $_tl = $to_lines[$yi++]; + if (strlen($_tl)) { + $add[] = $_tl; + } } if ($delete && $add) { $edits[] = new _DiffOp_Change($delete, $add); @@ -576,7 +582,7 @@ class Diff { * (Typically these are lines from a file.) * @param $to_lines array An array of strings. */ - function Diff($from_lines, $to_lines) { + function __construct($from_lines, $to_lines) { $eng = new _DiffEngine; $this->edits = $eng->diff($from_lines, $to_lines); //$this->_check($from_lines, $to_lines); @@ -735,12 +741,11 @@ class MappedDiff extends Diff { * @param $mapped_to_lines array This array should * have the same number of elements as $to_lines. */ - function MappedDiff($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) { - + function __construct($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) { assert(sizeof($from_lines) == sizeof($mapped_from_lines)); assert(sizeof($to_lines) == sizeof($mapped_to_lines)); - $this->Diff($mapped_from_lines, $mapped_to_lines); + parent::__construct($mapped_from_lines, $mapped_to_lines); $xi = $yi = 0; for ($i = 0; $i < sizeof($this->edits); $i++) { @@ -950,7 +955,7 @@ function _changed($orig, $closing) { * @subpackage DifferenceEngine */ class _HWLDF_WordAccumulator { - function _HWLDF_WordAccumulator() { + function __construct() { $this->_lines = array(); $this->_line = ''; $this->_group = ''; @@ -1016,11 +1021,11 @@ function MAX_LINE_LENGTH() { return 10000; } - function WordLevelDiff($orig_lines, $closing_lines) { + function __construct($orig_lines, $closing_lines) { list($orig_words, $orig_stripped) = $this->_split($orig_lines); list($closing_words, $closing_stripped) = $this->_split($closing_lines); - $this->MappedDiff($orig_words, $closing_words, $orig_stripped, $closing_stripped); + parent::__construct($orig_words, $closing_words, $orig_stripped, $closing_stripped); } function _split($lines) { @@ -1095,7 +1100,7 @@ class DrupalDiffFormatter extends DiffFormatter { 'offset' => array('x' => 0, 'y' => 0), ); - function DrupalDiffFormatter() { + function __construct() { $this->leading_context_lines = variable_get('diff_context_lines_leading', 2); $this->trailing_context_lines = variable_get('diff_context_lines_trailing', 2); } diff --git a/www7/sites/all/modules/contrib/diff/css/diff.boxes.css b/www7/sites/all/modules/contrib/diff/css/diff.boxes.css index ee1b31162..4af7a48fc 100644 --- a/www7/sites/all/modules/contrib/diff/css/diff.boxes.css +++ b/www7/sites/all/modules/contrib/diff/css/diff.boxes.css @@ -1,5 +1,6 @@ - -html.js .diff-js-hidden { display: none; } +html.js .diff-js-hidden { + display: none; +} /* Reset as many core themes as possible */ table.diff { @@ -8,7 +9,7 @@ table.diff { border: 0 none; width: 98%; border-spacing: 5px; - table-layout: fixed ; + table-layout: fixed; border-collapse: separate; } table.diff tr td:last-child { @@ -24,10 +25,13 @@ table.diff th { border-spacing: 4px; padding: 4px 8px; } -table.diff tr, table.diff tr.even { +table.diff tr, +table.diff tr.even { background: none; } -table.diff tr th, table.diff tr th a, table.diff tr th a:hover { +table.diff tr th, +table.diff tr th a, +table.diff tr th a:hover { color: inherit; font-weight: bold; } @@ -37,28 +41,34 @@ table.diff tr.odd { border-style: none; background: transparent; } -table.diff th a { display: inline; } +table.diff th a { + display: inline; +} /* Main theming */ -table.diff, td.diff-number { - background-color: white +table.diff, +td.diff-number { + background-color: white; } table.diff td.diff-lineno { - font-weight: bold + font-weight: bold; } -table.diff td.diff-addedline, table.diff td.diff-deletedline, table.diff td.diff-context { +table.diff td.diff-addedline, +table.diff td.diff-deletedline, +table.diff td.diff-context { font-size: 88%; vertical-align: top; white-space: -moz-pre-wrap; - white-space: pre-wrap + white-space: pre-wrap; } -table.diff td.diff-addedline, table.diff td.diff-deletedline { +table.diff td.diff-addedline, +table.diff td.diff-deletedline { border-style: solid; border-width: 1px 1px 1px 4px; - border-radius: 0.33em + border-radius: 0.33em; } table.diff td.diff-context { @@ -76,45 +86,46 @@ table.diff td.diff-addedline { } table.diff td.diff-deletedline { - border-color: #ffe49c + border-color: #ffe49c; } .diffchange { font-weight: bold; - text-decoration: none + text-decoration: none; } -table.diff td.diff-addedline .diffchange, table.diff td.diff-deletedline .diffchange { +table.diff td.diff-addedline .diffchange, +table.diff td.diff-deletedline .diffchange { border-radius: 0.33em; - padding: 0.25em 0 + padding: 0.25em 0; } table.diff td.diff-addedline .diffchange { - background: #d8ecff + background: #d8ecff; } table.diff td.diff-deletedline .diffchange { - background: #feeec8 + background: #feeec8; } table.diff table.diff td { - padding: 0.33em 0.66em + padding: 0.33em 0.66em; } table.diff td.diff-marker { width: 2%; text-align: right; font-weight: bold; - font-size: 1.25em + font-size: 1.25em; } table.diff col.diff-content { - width: 48% + width: 48%; } table.diff table.diff td div { word-wrap: break-word; - overflow: auto + overflow: auto; } td.diff-prevlink { text-align: left; @@ -122,3 +133,7 @@ td.diff-prevlink { td.diff-nextlink { text-align: right; } + +table.diff-revisions tr.revision-published td { + background-color: #aaffaa; +} diff --git a/www7/sites/all/modules/contrib/diff/css/diff.default.css b/www7/sites/all/modules/contrib/diff/css/diff.default.css index a7ab7ffd2..78337b931 100644 --- a/www7/sites/all/modules/contrib/diff/css/diff.default.css +++ b/www7/sites/all/modules/contrib/diff/css/diff.default.css @@ -1,30 +1,47 @@ - -html.js .diff-js-hidden { display: none; } +html.js .diff-js-hidden { + display: none; +} /** * Inline diff metadata */ .diff-inline-metadata { - padding:4px; - border:1px solid #ddd; - background:#fff; - margin:0px 0px 10px; + padding: 4px; + border: 1px solid #ddd; + background: #fff; + margin: 0 0 10px; } -.diff-inline-legend { font-size:11px; } +.diff-inline-legend { + font-size: 11px; +} .diff-inline-legend span, -.diff-inline-legend label { margin-right:5px; } +.diff-inline-legend label { + margin-right: 5px; +} /** * Inline diff markup */ -span.diff-deleted { color:#ccc; } -span.diff-deleted img { border: solid 2px #ccc; } -span.diff-changed { background:#ffb; } -span.diff-changed img { border:solid 2px #ffb; } -span.diff-added { background:#cfc; } -span.diff-added img { border: solid 2px #cfc; } +span.diff-deleted { + color: #ccc; +} +span.diff-deleted img { + border: solid 2px #ccc; +} +span.diff-changed { + background: #ffb; +} +span.diff-changed img { + border: solid 2px #ffb; +} +span.diff-added { + background: #cfc; +} +span.diff-added img { + border: solid 2px #cfc; +} /** * Traditional split diff theming @@ -35,7 +52,8 @@ table.diff { table-layout: fixed; width: 100%; } -table.diff tr.even, table.diff tr.odd { +table.diff tr.even, +table.diff tr.odd { background-color: inherit; border: none; } @@ -45,7 +63,8 @@ td.diff-prevlink { td.diff-nextlink { text-align: right; } -td.diff-section-title, div.diff-section-title { +td.diff-section-title, +div.diff-section-title { background-color: #f0f0ff; font-size: 0.83em; font-weight: bold; @@ -84,3 +103,7 @@ table.diff td div { table.diff td { padding: 0.1ex 0.4em; } + +table.diff-revisions tr.revision-published td { + background-color: #aaffaa; +} diff --git a/www7/sites/all/modules/contrib/diff/diff.admin.inc b/www7/sites/all/modules/contrib/diff/diff.admin.inc index a9df19ed5..8c5202f27 100644 --- a/www7/sites/all/modules/contrib/diff/diff.admin.inc +++ b/www7/sites/all/modules/contrib/diff/diff.admin.inc @@ -20,17 +20,6 @@ function diff_admin_settings($form, $form_state) { '#empty_option' => t('- None -'), '#description' => t('Alter the CSS used when displaying diff results.'), ); - $form['diff_default_state_node'] = array( - '#type' => 'select', - '#title' => t('Diff default state'), - '#default_value' => variable_get('diff_default_state_node', 'raw'), - '#options' => array( - 'raw' => t('HTML view'), - 'raw_plain' => t('Plain view'), - ), - '#empty_option' => t('- None -'), - '#description' => t('Default display to show when viewing a diff, html tags in diffed result or as plain text.'), - ); $form['diff_radio_behavior'] = array( '#type' => 'select', '#title' => t('Diff radio behavior'), @@ -68,17 +57,50 @@ function diff_admin_settings($form, $form_state) { function diff_admin_global_entity_settings($form, $form_state, $entity_type) { $entity_info = entity_get_info($entity_type); drupal_set_title(t('Diff settings for %entity_label entities', array('%entity_label' => $entity_info['label'])), PASS_THROUGH); + + if ($options = module_invoke_all('entity_diff_options', $entity_type)) { + $form['diff_additional_options_' . $entity_type] = array( + '#type' => 'checkboxes', + '#title' => t('Property options'), + '#default_value' => variable_get('diff_additional_options_' . $entity_type, array()), + '#options' => $options, + ); + } + else { + $form['diff_additional_options_' . $entity_type] = array( + '#type' => 'value', + '#value' => array(), + ); + } + $form['diff_show_header_' . $entity_type] = array( '#type' => 'checkbox', - '#title' => t('Show entity label header'), + '#title' => t('Show entity label row header'), '#default_value' => variable_get('diff_show_header_' . $entity_type, 1), ); + if (user_access('administer permissions')) { + $admin_link = l(t('View the administration theme'), 'admin/people/permissions', array('fragment' => 'edit-view-the-administration-theme')); + } + else { + $admin_link = t('View the administration theme'); + } $form['diff_admin_path_' . $entity_type] = array( '#type' => 'checkbox', - '#title' => t('Treat diff pages as administrative'), - '#description' => t('Diff pages are treated as administrative pages by default, although it is up to each module to enforce this and to implement this optional setting.'), + '#title' => t('Use administration theme'), + '#description' => t('This option will enable users with the !link permission to use the admin theme when doing comparisons.', array('!link' => $admin_link)), '#default_value' => variable_get('diff_admin_path_' . $entity_type, 1), ); + $form['diff_default_state_' . $entity_type] = array( + '#type' => 'select', + '#title' => t('Diff default state'), + '#default_value' => variable_get('diff_default_state_' . $entity_type, 'raw'), + '#options' => array( + 'raw' => t('HTML view'), + 'raw_plain' => t('Plain view'), + ), + '#empty_option' => t('- None -'), + '#description' => t('Default display to show when viewing a diff, html tags in diffed result or as plain text.'), + ); return system_settings_form($form); } diff --git a/www7/sites/all/modules/contrib/diff/diff.api.php b/www7/sites/all/modules/contrib/diff/diff.api.php index 507293a1c..e2b6f8485 100644 --- a/www7/sites/all/modules/contrib/diff/diff.api.php +++ b/www7/sites/all/modules/contrib/diff/diff.api.php @@ -11,27 +11,75 @@ */ /** - * Allow modules to provide a comparison about entities. + * Allow modules to provide a comparison about entity properties. * * @param object $old_entity * The older entity revision. + * * @param object $new_entity * The newer entity revision. + * * @param array $context * An associative array containing: * - entity_type: The entity type; e.g., 'node' or 'user'. - * - view_mode: The view mode to use. Defaults to FALSE. + * - old_entity: The older entity. + * - new_entity: The newer entity. + * - view_mode: The view mode to use. Defaults to FALSE. If no view mode is + * given, the recommended fallback view mode is 'default'. + * - states: An array of view states. These could be one of: + * - raw: The raw value of the diff, the classic 7.x-2.x view. + * - rendered: The rendered HTML as determined by the view mode. Only + * return markup for this state if the value is normally shown + * by this view mode. The user will most likely be able to see + * the raw or raw_plain state, so this is optional. + * + * The rendering state is a work in progress. + * + * Conditionally, you can get these states, but setting these will override + * the user selectable markdown method. + * + * - raw_plain: As raw, but text should be markdowned. + * - rendered_plain: As rendered, but text should be markdowned. * * @return array * An associative array of values keyed by the entity property. * - * @todo - * Investiagate options and document these. + * This is effectively an unnested Form API-like structure. + * + * States are returned as follows: + * + * $results['line'] = array( + * '#name' => t('Line'), + * '#states' => array( + * 'raw' => array( + * '#old' => '

      This was the old line number [tag].

      ', + * '#new' => '

      This is the new line [tag].

      ', + * ), + * 'rendered' => array( + * '#old' => '

      This was the old line number 57.

      ', + * '#new' => '

      This is the new line 57.

      ', + * ), + * ), + * ); + * + * For backwards compatibility, no changes are required to support states, + * but it is recommended to provide a better UI for end users. + * + * For example, the following example is equivalent to returning the raw + * state from the example above. + * + * $results['line'] = array( + * '#name' => t('Line'), + * '#old' => '

      This was the old line number [tag].

      ', + * '#new' => '

      This is the new line [tag].

      ', + * ); */ function hook_entity_diff($old_entity, $new_entity, $context) { + $results = array(); + if ($context['entity_type'] == 'node') { $type = node_type_get_type($new_entity); - $result['title'] = array( + $results['title'] = array( '#name' => $type->title_label, '#old' => array($old_entity->title), '#new' => array($new_entity->title), @@ -41,6 +89,8 @@ function hook_entity_diff($old_entity, $new_entity, $context) { ), ); } + + return $results; } /** @@ -57,7 +107,7 @@ function hook_entity_diff($old_entity, $new_entity, $context) { * * @see hook_entity_diff() */ -function hook_entity_diff_alter($entity_diffs, $context) { +function hook_entity_diff_alter(&$entity_diffs, $context) { } /** diff --git a/www7/sites/all/modules/contrib/diff/diff.css b/www7/sites/all/modules/contrib/diff/diff.css index a09147c11..8c634a916 100644 --- a/www7/sites/all/modules/contrib/diff/diff.css +++ b/www7/sites/all/modules/contrib/diff/diff.css @@ -1,30 +1,46 @@ - -html.js .diff-js-hidden { display:none; } +html.js .diff-js-hidden { + display:none; +} /** * Inline diff metadata */ .diff-inline-metadata { - padding:4px; - border:1px solid #ddd; - background:#fff; - margin:0px 0px 10px; - } - -.diff-inline-legend { font-size:11px; } + padding: 4px; + border: 1px solid #ddd; + background: #fff; + margin: 0 0 10px; +} +.diff-inline-legend { + font-size: 11px; +} .diff-inline-legend span, -.diff-inline-legend label { margin-right:5px; } +.diff-inline-legend label { + margin-right: 5px; +} /** * Inline diff markup */ -span.diff-deleted { color:#ccc; } -span.diff-deleted img { border: solid 2px #ccc; } -span.diff-changed { background:#ffb; } -span.diff-changed img { border:solid 2px #ffb; } -span.diff-added { background:#cfc; } -span.diff-added img { border: solid 2px #cfc; } +span.diff-deleted { + color: #ccc; +} +span.diff-deleted img { + border: solid 2px #ccc; +} +span.diff-changed { + background: #ffb; +} +span.diff-changed img { + border: solid 2px #ffb; +} +span.diff-added { + background: #cfc; +} +span.diff-added img { + border: solid 2px #cfc; +} /** * Traditional split diff theming @@ -35,7 +51,8 @@ table.diff { table-layout: fixed; width: 100%; } -table.diff tr.even, table.diff tr.odd { +table.diff tr.even, +table.diff tr.odd { background-color: inherit; border: none; } @@ -45,7 +62,8 @@ td.diff-prevlink { td.diff-nextlink { text-align: right; } -td.diff-section-title, div.diff-section-title { +td.diff-section-title, +div.diff-section-title { background-color: #f0f0ff; font-size: 0.83em; font-weight: bold; diff --git a/www7/sites/all/modules/contrib/diff/diff.diff.inc b/www7/sites/all/modules/contrib/diff/diff.diff.inc index 63c01b44e..8e7f682a0 100644 --- a/www7/sites/all/modules/contrib/diff/diff.diff.inc +++ b/www7/sites/all/modules/contrib/diff/diff.diff.inc @@ -12,17 +12,6 @@ * * This manually invokes hook_diff() to avoid a function name clash with the * PHP 5 (>= 5.3.0) date_diff() function or the Dates modules implementation. - * - * @param object $old_entity - * The older node revision. - * @param object $new_entity - * The newer node revision. - * @param array $context - * An associative array containing: - * - entity_type: The entity type; e.g., 'node' or 'user'. - * - old_entity: The older entity. - * - new_entity: The newer entity. - * - view_mode: The view mode to use. Defaults to FALSE. */ function diff_entity_diff($old_entity, $new_entity, $context) { $return = array(); @@ -52,11 +41,13 @@ function diff_entity_diff($old_entity, $new_entity, $context) { * - old_entity: The older entity. * - new_entity: The newer entity. * - view_mode: The view mode to use. Defaults to FALSE. + * @param string $default_langcode + * (optional) Language code to force comparison in. * * @return array * An associative array of values keyed by the field name and delta value. */ -function diff_entity_fields_diff($old_entity, $new_entity, $context) { +function diff_entity_fields_diff($old_entity, $new_entity, $context, $default_langcode = NULL) { $result = array(); $entity_type = $context['entity_type']; @@ -65,7 +56,7 @@ function diff_entity_fields_diff($old_entity, $new_entity, $context) { $field_context = $context; $actual_mode = FALSE; - list(,, $bundle_name) = entity_extract_ids($entity_type, $new_entity); + list(, , $bundle_name) = entity_extract_ids($entity_type, $new_entity); $instances = field_info_instances($entity_type, $bundle_name); // Some fields piggy back the display settings, so we need to fake these by @@ -98,7 +89,7 @@ function diff_entity_fields_diff($old_entity, $new_entity, $context) { // We provide a loose check on the field access. if (field_access('view', $field, $entity_type) || field_access('edit', $field, $entity_type)) { - $langcode = field_language($entity_type, $new_entity, $field_name); + $langcode = $default_langcode ? $default_langcode : field_language($entity_type, $new_entity, $field_name); $field_context['language'] = $langcode; $field_context['field'] = $field; @@ -136,10 +127,18 @@ function diff_entity_fields_diff($old_entity, $new_entity, $context) { $func = 'diff_field_diff_view'; } + // Copy the static ID cache to ensure this is the same for each comparison. + $original_html_ids = drupal_static('drupal_html_id'); + $html_ids = &drupal_static('drupal_html_id'); + // These callbacks should be independent of revision. $old_context = $field_context; $old_context['entity'] = $old_entity; $old_values = $func($old_items, $old_context); + + // Restores the ID cache to the original. + $html_ids = $original_html_ids; + $new_context = $field_context; $new_context['entity'] = $new_entity; $new_values = $func($new_items, $new_context); @@ -200,22 +199,29 @@ function diff_entity_fields_diff($old_entity, $new_entity, $context) { * An array of strings representing the value, keyed by delta index. */ function diff_field_diff_view($items, $context) { + // Prevent unnecessary rendering of the field. This also prevents issues + // where field_view_field() will use a language fallback for display that + // may not match the requested diff comparison language. + if (!$items) { + return array(); + } + $diff_items = array(); - $entity = clone $context['entity']; - $langcode = field_language($context['entity_type'], $entity, $context['field']['field_name']); - $view_mode = empty($context['view_mode']) ? 'diff_standard' : $context['view_mode']; - $element = field_view_field($context['entity_type'], $entity, $context['field']['field_name'], $view_mode, $langcode); - - foreach (element_children($element) as $delta) { - $diff_items[$delta] = drupal_render($element[$delta]); - } + $entity = clone $context['entity']; + $langcode = field_language($context['entity_type'], $entity, $context['field']['field_name']); + $view_mode = empty($context['view_mode']) ? 'diff_standard' : $context['view_mode']; + $element = field_view_field($context['entity_type'], $entity, $context['field']['field_name'], $view_mode, $langcode); + + foreach (element_children($element) as $delta) { + $diff_items[$delta] = drupal_render($element[$delta]); + } return $diff_items; } /** * Helper function to get the settings for a given field or formatter. * - * @param array $context + * @param array $field_context * This will get the settings for a field. * - field (required): The field that the items belong to. * - entity: The entity that we are looking up. @@ -274,31 +280,6 @@ function diff_global_settings_form(&$subform, $form_state, $type, $settings) { ), ); - /* -This would be cool, but to do anything else than inline with the text appears -to be very hard, requiring a refactoring of both the modules API but also the -DiffFormatter and Diff classes. Diff 8.x-4.x maybe. - - $subform['show_delta'] = array( - '#type' => 'checkbox', - '#title' => t('Show delta values'), - '#default_value' => $settings['show_delta'], - ); - $subform['delta_format'] = array( - '#type' => 'radios', - '#title' => t('Delta insertion method'), - '#default_value' => $settings['delta_format'], - '#options' => array( - 'inline' => t('Prefix to item'), - 'row' => t('Individual row'), - ), - '#states' => array( - 'invisible' => array( - "input[id$='show-delta']" => array('checked' => FALSE), - ), - ), - ); - */ } /** @@ -323,11 +304,8 @@ function _diff_field_default_settings($module, $field_type, $settings = array()) 'markdown' => function_exists($func) ? '' : 'drupal_html_to_text', 'line_counter' => '', 'show_header' => 1, - // Can we? This seems too hard to track in the DiffFormatter as all we - // have is a string or an array of strings. - //'show_delta' => 0, - //'delta_format' => 'row', ); + return $settings; } diff --git a/www7/sites/all/modules/contrib/diff/diff.info b/www7/sites/all/modules/contrib/diff/diff.info index 5ae077e80..77b731686 100644 --- a/www7/sites/all/modules/contrib/diff/diff.info +++ b/www7/sites/all/modules/contrib/diff/diff.info @@ -1,12 +1,13 @@ name = Diff description = Show differences between content revisions. core = 7.x +configure = admin/config/content/diff files[] = DiffEngine.php -; Information added by drupal.org packaging script on 2012-11-13 -version = "7.x-3.2" +; Information added by Drupal.org packaging script on 2016-12-20 +version = "7.x-3.3" core = "7.x" project = "diff" -datestamp = "1352784357" +datestamp = "1482211686" diff --git a/www7/sites/all/modules/contrib/diff/diff.install b/www7/sites/all/modules/contrib/diff/diff.install index 16f1d27c5..9d8b585dd 100644 --- a/www7/sites/all/modules/contrib/diff/diff.install +++ b/www7/sites/all/modules/contrib/diff/diff.install @@ -5,6 +5,14 @@ * Provides uninstallation functions. */ +/** + * Implements hook_install(). + */ +function diff_install() { + user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('diff view changes')); + user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('diff view changes')); +} + /** * Implements hook_uninstall(). */ @@ -16,6 +24,7 @@ function diff_uninstall() { 'diff_view_mode_', 'diff_admin_path_', 'diff_default_state_', + 'diff_additional_options_', ); foreach ($prefixes as $prefix) { db_delete('variable') @@ -55,27 +64,19 @@ function diff_update_7300() { } } -/** - * Removed diff_update_7301(). - */ - -/** - * Removed diff_update_7302(). - */ - /** * Renames some internal settings names. */ function diff_update_7303() { - // Get current values + // Get current values. $radio = variable_get('diff_script_revisioning', 'simple'); $leading = variable_get('diff_leading_context_lines', 2); $trailing = variable_get('diff_trailing_context_lines', 2); - // Create new variable names + // Create new variable names. variable_set('diff_radio_behavior', $radio); variable_set('diff_context_lines_leading', $leading); variable_set('diff_context_lines_trailing', $trailing); - // Delete old variables + // Delete old variables. variable_del('diff_script_revisioning'); variable_del('diff_leading_context_lines'); variable_del('diff_trailing_context_lines'); @@ -88,8 +89,8 @@ function diff_update_7304() { // This is now always applied to text fields. variable_del('diff_normalise_text'); - // Merge the content type settings for the inline diff block into a single variable. - // diff_update_7300() - show_diff_inline_TYPE to diff_show_diff_inline_node_TYPE + // Merge the content type settings for the inline diff block into a single + // variable. $node_types = array_keys(node_type_get_types()); $enabled_types = array(); foreach ($node_types as $node_type) { @@ -122,3 +123,19 @@ function diff_update_7305() { ->condition('name', db_like('diff_view_mode_inline_') . '%', 'LIKE') ->execute(); } + +/** + * Sets the optional additional node properties to render so that the title + * still shows by default when doing node comparisons. + */ +function diff_update_7306() { + variable_set('diff_additional_options_node', array('title' => 'title')); +} + +/** + * Grants access to the Diff "View Changes" button permission to all users. + */ +function diff_update_7307() { + user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('diff view changes')); + user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('diff view changes')); +} diff --git a/www7/sites/all/modules/contrib/diff/diff.module b/www7/sites/all/modules/contrib/diff/diff.module index f58e1d721..d3050e3bb 100644 --- a/www7/sites/all/modules/contrib/diff/diff.module +++ b/www7/sites/all/modules/contrib/diff/diff.module @@ -39,11 +39,14 @@ function diff_help($path, $arg) { case 'admin/help#diff': $output = '

      ' . t('The Diff module replaces the normal Revisions node tab. Diff enhances the listing of revisions with an option to view the differences between any two content revisions. Access to this feature is controlled with the View revisions permission. The feature can be disabled for an entire content type on the content type configuration page. Diff also provides an optional View changes button while editing a node.') . '

      '; return $output; + case 'node/%/revisions/%/view': // The translated strings should match node_help('node/%/revisions'). return '

      ' . t('Revisions allow you to track differences between multiple versions of your content, and revert back to older versions.') . '

      '; + case 'node/%/revisions/view/%/%': return '

      ' . t('Comparing two revisions:') . '

      '; + } } @@ -104,8 +107,7 @@ function diff_menu() { 'page callback' => 'diff_latest', 'page arguments' => array(1), 'type' => MENU_LOCAL_TASK, - 'access callback' => 'diff_node_revision_access', - 'access arguments' => array(1), + 'access arguments' => array('access content'), 'tab_parent' => 'node/%/revisions/view', 'file' => 'diff.pages.inc', ); @@ -152,10 +154,20 @@ function diff_menu() { ); $items['admin/config/content/diff/entities/node'] = array( - 'title' => 'Node', + 'title' => 'Nodes', + 'description' => 'Node comparison settings.', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, ); + $items['admin/config/content/diff/entities/user'] = array( + 'title' => 'Users', + 'description' => 'User diff settings.', + 'file' => 'diff.admin.inc', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('diff_admin_global_entity_settings', 'user'), + 'access arguments' => array('administer site configuration'), + 'type' => MENU_LOCAL_TASK, + ); return $items; } @@ -197,6 +209,18 @@ function diff_node_revision_access($node, $op = 'view') { return $may_revision_this_type && _node_revision_access($node, $op); } +/** + * Implements hook_permission(). + */ +function diff_permission() { + return array( + 'diff view changes' => array( + 'title' => t('Access %view button', array('%view' => t('View changes'))), + 'description' => t('Controls access to the %view button when editing content.', array('%view' => t('View changes'))), + ), + ); +} + /** * Implements hook_hook_info(). */ @@ -238,6 +262,28 @@ function diff_entity_info_alter(&$entity_info) { } } +/** + * Returns a list of all the existing revision numbers. + * + * Clone of node_revision_list() with revision status included. This would be + * an additional join in Drupal 8.x to the {node_field_revision} table. + * + * @param object $node + * The node object. + * + * @return array + * An associative array keyed by node revision number. + */ +function diff_node_revision_list($node) { + $revisions = array(); + $result = db_query('SELECT r.vid, r.title, r.log, r.uid, n.vid AS current_vid, r.status AS status, r.timestamp, u.name FROM {node_revision} r LEFT JOIN {node} n ON n.vid = r.vid INNER JOIN {users} u ON u.uid = r.uid WHERE r.nid = :nid ORDER BY r.vid DESC', array(':nid' => $node->nid)); + foreach ($result as $revision) { + $revisions[$revision->vid] = $revision; + } + + return $revisions; +} + /** * Implements hook_block_info(). */ @@ -287,7 +333,7 @@ function diff_block_view($delta) { $enabled_types = variable_get('diff_show_diff_inline_node_bundles', array()); if (!empty($enabled_types[$node->type])) { $block = array(); - $revisions = node_revision_list($node); + $revisions = diff_node_revision_list($node); if (count($revisions) > 1) { $block['subject'] = t('Highlight changes'); $block['content'] = drupal_get_form('diff_inline_form', $node, $revisions); @@ -302,7 +348,7 @@ function diff_block_view($delta) { */ function diff_node_view_alter(&$build) { $node = $build['#node']; - if (user_access('view revisions') && in_array($node->type, variable_get('diff_show_diff_inline_node_bundles', array()))) { + if (user_access('view revisions') && in_array($node->type, variable_get('diff_show_diff_inline_node_bundles', array()), TRUE)) { // Ugly but cheap way to check that we are viewing a node's revision page. if (arg(2) === 'revisions' && arg(3) === $node->vid) { module_load_include('inc', 'diff', 'diff.pages'); @@ -320,7 +366,9 @@ function diff_node_view_alter(&$build) { function diff_form_node_form_alter(&$form, $form_state) { // Add a 'View changes' button on the node edit form. $node = $form['#node']; - if (variable_get('diff_show_preview_changes_node_' . $node->type, TRUE) && !empty($node->nid)) { + if (variable_get('diff_show_preview_changes_node_' . $node->type, TRUE) + && user_access('diff view changes') + && !empty($node->nid)) { $form['actions']['preview_changes'] = array( '#type' => 'submit', '#value' => t('View changes'), @@ -347,6 +395,9 @@ function diff_form_node_type_form_alter(&$form, $form_state) { '#title' => t('Show View changes button on node edit form'), '#weight' => 10, '#default_value' => variable_get('diff_show_preview_changes_node_' . $type->type, TRUE), + '#description' => t('You can refine access using the "!perm" permission.', array( + '!perm' => t('Access %view button', array('%view' => t('View changes'))), + )), ); $form['diff']['diff_enable_revisions_page_node'] = array( '#type' => 'checkbox', @@ -430,7 +481,7 @@ function diff_node_form_build_preview_changes($form, &$form_state) { $changes = theme('table__diff__preview', array( 'header' => $header, 'rows' => $rows, - 'attributes' => array('class' => 'diff'), + 'attributes' => array('class' => array('diff')), 'colgroups' => _diff_default_cols(), 'sticky' => FALSE, )); @@ -440,6 +491,24 @@ function diff_node_form_build_preview_changes($form, &$form_state) { $form_state['rebuild'] = TRUE; } +/** + * Implementation of hook_features_pipe_COMPONENT_alter(). + */ +function diff_features_pipe_node_alter(&$pipe, $data, $export) { + if (!empty($data)) { + $variables = array( + 'diff_show_preview_changes_node', + 'diff_enable_revisions_page_node', + 'diff_view_mode_preview_node', + ); + foreach ($data as $node_type) { + foreach ($variables as $variable_name) { + $pipe['variable'][] = $variable_name . '_' . $node_type; + } + } + } +} + /** * Implements hook_theme(). */ @@ -483,7 +552,7 @@ function diff_theme() { * The source string to compare from. * @param string $b * The target string to compare to. - * @param boolean $show_header + * @param bool $show_header * Display diff context headers. For example, "Line x". * @param array $line_stats * This structure tracks line numbers across multiple calls to DiffFormatter. @@ -621,3 +690,85 @@ function diff_build_attachments($jscript = FALSE) { } return $attachments; } + +/** + * Implements hook_entity_diff() on behalf of the Node module. + */ +function node_entity_diff($old_node, $new_node, $context) { + $result = array(); + if ($context['entity_type'] == 'node') { + module_load_include('inc', 'diff', 'includes/node'); + $options = variable_get('diff_additional_options_node', array('title' => 'title')); + foreach (node_entity_diff_options('node') as $key => $option_label) { + if (!empty($options[$key])) { + $func = '_node_entity_diff_additional_options_' . $key; + $result[$key] = $func($old_node, $new_node, $context); + } + } + } + return $result; +} + +/** + * Implements hook_entity_diff_options() on behalf of the Node module. + */ +function node_entity_diff_options($entity_type) { + if ($entity_type == 'node') { + $options = array( + 'title' => t('Title field'), + // Author field is either the owner or revision creator, neither capture + // a change in the author field. + 'author' => t('Author'), + 'revision_author' => t('Revision author'), + 'type' => t('Node type'), + 'publishing_flags' => t('Publishing options'), + // More fields that currently can not be tracked. + 'created' => t('Created date'), + 'changed' => t('Updated date'), + 'revision_timestamp' => t('Revision timestamp'), + ); + if (module_exists('comment')) { + $options['comment'] = t('Comment setting'); + } + return $options; + } +} + +/** + * Implements hook_entity_diff() on behalf of the User module. + */ +function user_entity_diff($old_user, $new_user, $context) { + $result = array(); + if ($context['entity_type'] == 'user') { + module_load_include('inc', 'diff', 'includes/user'); + $options = variable_get('diff_additional_options_user', array( + 'name' => 'name', + 'mail' => 'mail', + 'status' => 'status', + )); + foreach (user_entity_diff_options('user') as $key => $option_label) { + if (!empty($options[$key])) { + $func = '_user_entity_diff_additional_options_' . $key; + $result[$key] = $func($old_user, $new_user, $context); + } + } + } + return $result; +} + +/** + * Implements hook_entity_diff_options() on behalf of the User module. + */ +function user_entity_diff_options($entity_type) { + if ($entity_type == 'user') { + $options = array( + 'name' => t('Username'), + 'mail' => t('E-mail address'), + 'roles' => t('Roles'), + 'status' => t('Status'), + 'timezone' => t('Time zone'), + 'password' => t('Password Hash'), + ); + return $options; + } +} diff --git a/www7/sites/all/modules/contrib/diff/diff.pages.inc b/www7/sites/all/modules/contrib/diff/diff.pages.inc index 1cd14419e..285eb1ed3 100644 --- a/www7/sites/all/modules/contrib/diff/diff.pages.inc +++ b/www7/sites/all/modules/contrib/diff/diff.pages.inc @@ -10,6 +10,9 @@ */ function diff_latest($node) { $revisions = node_revision_list($node); + if (count($revisions) < 2 || !diff_node_revision_access($node, 'view')) { + drupal_goto('node/' . $node->nid); + } $new = array_shift($revisions); $old = array_shift($revisions); drupal_goto("node/{$node->nid}/revisions/view/{$old->vid}/{$new->vid}"); @@ -35,19 +38,20 @@ function diff_node_revisions($form, $form_state, $node) { '#value' => $node->nid, ); - $revision_list = node_revision_list($node); + $revision_list = diff_node_revision_list($node); + $revision_count = count($revision_list); - if (count($revision_list) > REVISION_LIST_SIZE) { + if ($revision_count > REVISION_LIST_SIZE) { // If the list of revisions is longer than the number shown on one page // split the array. $page = isset($_GET['page']) ? $_GET['page'] : '0'; - $revision_chunks = array_chunk(node_revision_list($node), REVISION_LIST_SIZE); + $revision_chunks = array_chunk($revision_list, REVISION_LIST_SIZE); $revisions = $revision_chunks[$page]; // Set up global pager variables as would 'pager_query' do. // These variables are then used in the theme('pager') call later. global $pager_page_array, $pager_total, $pager_total_items; - $pager_total_items[0] = count($revision_list); - $pager_total[0] = ceil(count($revision_list) / REVISION_LIST_SIZE); + $pager_total_items[0] = $revision_count; + $pager_total[0] = ceil($revision_count / REVISION_LIST_SIZE); $pager_page_array[0] = max(0, min($page, ((int) $pager_total[0]) - 1)); } else { @@ -73,6 +77,7 @@ function diff_node_revisions($form, $form_state, $node) { '#markup' => t('!date by !username', array( '!date' => l(format_date($revision->timestamp, 'small'), "node/$node->nid"), '!username' => theme('username', array('account' => $revision)))) . $revision_log, + '#revision' => $revision, ); } else { @@ -82,6 +87,7 @@ function diff_node_revisions($form, $form_state, $node) { '!date' => $diff_date, '!username' => theme('username', array('account' => $revision))) ) . $revision_log, + '#revision' => $revision, ); if ($revert_permission) { $operations[] = array( @@ -117,23 +123,13 @@ function diff_node_revisions($form, $form_state, $node) { $form['submit'] = array('#type' => 'submit', '#value' => t('Compare')); - if (count($revision_list) > REVISION_LIST_SIZE) { + if ($revision_count > REVISION_LIST_SIZE) { $form['#suffix'] = theme('pager'); } $form['#attached'] = diff_build_attachments(TRUE); return $form; } -/** - * Submit code for input form to select two revisions. - */ -function diff_node_revisions_submit($form, &$form_state) { - // The ids are ordered so the old revision is always on the left. - $old_vid = min($form_state['values']['old'], $form_state['values']['new']); - $new_vid = max($form_state['values']['old'], $form_state['values']['new']); - $form_state['redirect'] = 'node/' . $form_state['values']['nid'] . '/revisions/view/' . $old_vid . '/' . $new_vid; -} - /** * Validation for input form to select two revisions. */ @@ -145,14 +141,27 @@ function diff_node_revisions_validate($form, &$form_state) { } } +/** + * Submit code for input form to select two revisions. + */ +function diff_node_revisions_submit($form, &$form_state) { + // The ids are ordered so the old revision is always on the left. + $old_vid = min($form_state['values']['old'], $form_state['values']['new']); + $new_vid = max($form_state['values']['old'], $form_state['values']['new']); + if (isset($_GET['destination'])) { + unset($_GET['destination']); + } + $form_state['redirect'] = 'node/' . $form_state['values']['nid'] . '/revisions/view/' . $old_vid . '/' . $new_vid; +} + /** * Create a comparison for the node between versions 'old_vid' and 'new_vid'. * * @param object $node - * Node on which to perform comparison - * @param integer $old_vid + * Node on which to perform comparison. + * @param int $old_vid * Version ID of the old revision. - * @param integer $new_vid + * @param int $new_vid * Version ID of the new revision. */ function diff_diffs_show($node, $old_vid, $new_vid, $state = NULL) { @@ -161,7 +170,7 @@ function diff_diffs_show($node, $old_vid, $new_vid, $state = NULL) { $default_state = variable_get('diff_default_state_node', 'raw'); if (empty($state)) { - $state = $default_state; + $state = $default_state; } $state = str_replace('-', '_', $state); if (!array_key_exists($state, diff_available_states())) { @@ -279,7 +288,7 @@ function diff_diffs_show($node, $old_vid, $new_vid, $state = NULL) { } $build['diff_preview']['header']['#markup'] = $header; // Don't include node links or comments when viewing the diff. - $build['diff_preview']['content'] = node_view($new_node, $view_mode); + $build['diff_preview']['content'] = function_exists('entity_view') ? entity_view('node', array($new_node), $view_mode) : node_view($new_node, $view_mode); if (isset($build['diff_preview']['content']['links'])) { unset($build['diff_preview']['content']['links']); } @@ -291,33 +300,33 @@ function diff_diffs_show($node, $old_vid, $new_vid, $state = NULL) { } /** - * Creates an array of rows which represent the difference between nodes. + * Creates an array of rows which represent the difference between two entities. * - * @param object $old_node - * Node for comparison which will be displayed on the left side. - * @param object $new_node - * Node for comparison which will be displayed on the right side. - * @param boolean $state - * The state to render for the diff. + * @param object $left_entity + * Entity for comparison which will be displayed on the left side. + * @param object $right_entity + * Entity for comparison which will be displayed on the right side. + * @param array $context + * The context used to render the diff. */ -function _diff_body_rows($old_node, $new_node, $state = 'raw') { +function diff_entity_body_rows($entity_type, $left_entity, $right_entity, $context = array()) { // This is an unique index only, so no need for drupal_static(). static $table_row_counter = 0; if ($theme = variable_get('diff_theme', 'default')) { drupal_add_css(drupal_get_path('module', 'diff') . "/css/diff.{$theme}.css"); } - module_load_include('inc', 'diff', 'includes/node'); $rows = array(); $any_visible_change = FALSE; - $context = array( - 'entity_type' => 'node', - 'states' => array($state), + $context += array( + 'entity_type' => $entity_type, + 'states' => array('raw'), 'view_mode' => 'diff_standard', ); + $state = current($context['states']); - $node_diffs = diff_compare_entities($old_node, $new_node, $context); + $entity_diffs = diff_compare_entities($left_entity, $right_entity, $context); // Track line numbers between multiple diffs. $line_stats = array( @@ -326,19 +335,19 @@ function _diff_body_rows($old_node, $new_node, $state = 'raw') { ); // Render diffs for each. - foreach ($node_diffs as $node_diff) { - $show_header = !empty($node_diff['#name']); + foreach ($entity_diffs as $entity_diff) { + $show_header = !empty($entity_diff['#name']); // These are field level settings. - if ($show_header && isset($node_diff['#settings']['show_header'])) { - $show_header = $show_header && $node_diff['#settings']['show_header']; + if ($show_header && isset($entity_diff['#settings']['show_header'])) { + $show_header = $show_header && $entity_diff['#settings']['show_header']; } // Line counting and line header options. - if (empty($node_diff['#settings']['line_counter'])) { + if (empty($entity_diff['#settings']['line_counter'])) { $line_counter = FALSE; } else { - $line_counter = $node_diff['#settings']['line_counter']; + $line_counter = $entity_diff['#settings']['line_counter']; } // Every call to 'line' resets the counters. if ($line_counter) { @@ -354,8 +363,8 @@ function _diff_body_rows($old_node, $new_node, $state = 'raw') { $line_stats_ref = NULL; } - list($old, $new) = diff_extract_state($node_diff, $state); - if ($node_diff_rows = diff_get_rows($old, $new, $line_counter && $line_counter != 'hidden', $line_stats_ref)) { + list($left, $right) = diff_extract_state($entity_diff, $state); + if ($entity_diff_rows = diff_get_rows($left, $right, $line_counter && $line_counter != 'hidden', $line_stats_ref)) { if ($line_counter && $line_counter != 'line') { $line_stats['offset']['x'] += $line_stats_ref['counter']['x']; $line_stats['offset']['y'] += $line_stats_ref['counter']['y']; @@ -363,7 +372,7 @@ function _diff_body_rows($old_node, $new_node, $state = 'raw') { if ($show_header) { $rows['diff-header-' . $table_row_counter++] = array( array( - 'data' => t('Changes to %name', array('%name' => $node_diff['#name'])), + 'data' => t('Changes to %name', array('%name' => $entity_diff['#name'])), 'class' => 'diff-section-title', 'colspan' => 4, ), @@ -371,7 +380,7 @@ function _diff_body_rows($old_node, $new_node, $state = 'raw') { } // To avoid passing counter to the Diff engine, index rows manually here // to allow modules to interact with the table. i.e. no array_merge(). - foreach ($node_diff_rows as $row) { + foreach ($entity_diff_rows as $row) { $rows['diff-row-' . $table_row_counter++] = $row; } $any_visible_change = TRUE; @@ -385,19 +394,28 @@ function _diff_body_rows($old_node, $new_node, $state = 'raw') { 'colspan' => 4, ), ); - // @todo: revise this. - // Needed to keep safari happy. - $rows['diff-empty-' . $table_row_counter++] = array( - array('data' => ''), - array('data' => ''), - array('data' => ''), - array('data' => ''), - ); } - return $rows; } +/** + * Creates an array of rows which represent the difference between nodes. + * + * @param object $old_node + * Node for comparison which will be displayed on the left side. + * @param object $new_node + * Node for comparison which will be displayed on the right side. + * @param bool $state + * The state to render for the diff. + */ +function _diff_body_rows($old_node, $new_node, $state = 'raw') { + $context = array( + 'states' => array($state), + 'view_mode' => 'diff_standard', + ); + return diff_entity_body_rows('node', $old_node, $new_node, $context); +} + /** * Generic callback to compare two entities. */ @@ -460,6 +478,9 @@ function diff_compare_entities($left_entity, $right_entity, $context) { if (!isset($diff['#sorted'])) { uasort($diff, 'element_sort'); } + else { + unset($diff['#sorted']); + } // Process the array and get line counts per field. array_walk($diff, 'diff_process_state_lines'); @@ -467,6 +488,9 @@ function diff_compare_entities($left_entity, $right_entity, $context) { return $diff; } +/** + * Helper function to get line counts per field. + */ function diff_process_state_lines(&$diff, $key) { foreach ($diff['#states'] as $state => $data) { if (isset($data['#old'])) { @@ -509,20 +533,29 @@ function diff_markdown_state(&$diff, $state) { } if (!isset($plain_old) && isset($old)) { - if (is_array($old)) { - $diff['#states'][$state . '_plain']['#old'] = $markdown ? array_map($markdown, $old) : $old; - } - else { - $diff['#states'][$state . '_plain']['#old'] = $markdown ? $markdown($old) : $old; - } + $diff['#states'][$state . '_plain']['#old'] = _diff_apply_markdown($markdown, $old); } if (!isset($plain_new) && isset($new)) { - if (is_array($new)) { - $diff['#states'][$state . '_plain']['#new'] = $markdown ? array_map($markdown, $new) : $new; - } - else { - $diff['#states'][$state . '_plain']['#new'] = $markdown ? $markdown($new) : $new; + $diff['#states'][$state . '_plain']['#new'] = _diff_apply_markdown($markdown, $new); + } +} + +/** + * Helper function to clear newlines from the content. + */ +function _diff_apply_markdown($markdown, $items) { + if (!$markdown) { + return $items; + } + if (is_array($items)) { + $items = array_map($markdown, $items); + foreach ($items as &$item) { + $item = trim($item, "\n"); } + return $items; + } + else { + return trim($markdown($items), "\n"); } } @@ -534,7 +567,7 @@ function diff_markdown_state(&$diff, $state) { * @param int $vid * Version ID to look for. * - * @return boolean|integer + * @return bool|int * Returns FALSE if $vid is the last entry. */ function _diff_get_next_vid($node_revisions, $vid) { @@ -553,10 +586,10 @@ function _diff_get_next_vid($node_revisions, $vid) { * * @param array $node_revisions * Array of node revision IDs in descending order. - * @param integer $vid + * @param int $vid * Version ID to look for. * - * @return boolean|integer + * @return bool|int * Returns FALSE if $vid is the first entry. */ function _diff_get_previous_vid($node_revisions, $vid) { @@ -615,13 +648,13 @@ function _diff_default_header($old_header = '', $new_header = '') { * normally rendered content of the specified revision. */ function diff_inline_show($node, $vid = 0, $metadata = TRUE) { - $new_node = $vid ? node_load($node->nid, $vid, TRUE) : clone $node; + $new_node = $vid ? node_load($node->nid, $vid) : clone $node; node_build_content($new_node); $new = drupal_render($new_node->content); $old = $vid ? _diff_get_previous_vid(node_revision_list($node), $vid) : 0; if ($old) { - $old_node = node_load($node->nid, $old, TRUE); + $old_node = node_load($node->nid, $old); node_build_content($old_node); $old = drupal_render($old_node->content); $output = $metadata ? theme('diff_inline_metadata', array('node' => $new_node)) : ''; diff --git a/www7/sites/all/modules/contrib/diff/diff.theme.inc b/www7/sites/all/modules/contrib/diff/diff.theme.inc index 96d20b3af..aee2581c9 100644 --- a/www7/sites/all/modules/contrib/diff/diff.theme.inc +++ b/www7/sites/all/modules/contrib/diff/diff.theme.inc @@ -48,14 +48,21 @@ function theme_diff_node_revisions($vars) { 'data' => drupal_render($form['diff']['new'][$key]), 'class' => array('revision-current'), ); + $revision = $form['info'][$key]['#revision']; + if ($revision && !empty($revision->status)) { + $message = t('This is the published revision.'); + } + else { + $message = t('This is the current revision.'); + } $row[] = array( - 'data' => t('current revision'), + 'data' => '' . $message . '', 'class' => array('revision-current'), 'colspan' => '2', ); $rows[] = array( 'data' => $row, - 'class' => array('error diff-revision'), + 'class' => array('revision-published diff-revision'), ); } } @@ -64,17 +71,13 @@ function theme_diff_node_revisions($vars) { 'header' => $header, 'rows' => $rows, 'sticky' => FALSE, - 'attributes' => array('class' => 'diff-revisions'), + 'attributes' => array('class' => array('diff-revisions')), )); $output .= drupal_render_children($form); return $output; } -/** - * Theme functions - */ - /** * Theme function for a header line in the diff. */ @@ -139,11 +142,15 @@ function theme_diff_inline_chunk($vars) { switch ($vars['type']) { case 'add': return "{$vars['text']}"; + case 'change': return "{$vars['text']}"; + case 'delete': return "{$vars['text']}"; + default: return $vars['text']; + } } diff --git a/www7/sites/all/modules/contrib/diff/diff.tokens.inc b/www7/sites/all/modules/contrib/diff/diff.tokens.inc index 96dbd80ac..605d2e433 100644 --- a/www7/sites/all/modules/contrib/diff/diff.tokens.inc +++ b/www7/sites/all/modules/contrib/diff/diff.tokens.inc @@ -38,13 +38,13 @@ function diff_tokens($type, $tokens, array $data = array(), array $options = arr // Basic diff standard comparison information. case 'diff': case 'diff-markdown': - $revisons = node_revision_list($node); - if (count($revisons) == 1) { + $revisions = node_revision_list($node); + if (count($revisions) == 1) { $replacements[$original] = t('(No previous revision available.)'); } else { module_load_include('inc', 'diff', 'diff.pages'); - $old_vid = _diff_get_previous_vid($revisons, $node->vid); + $old_vid = _diff_get_previous_vid($revisions, $node->vid); $state = $name == 'diff' ? 'raw' : 'raw_plain'; $build = diff_diffs_show($node, $old_vid, $node->vid, $state); unset($build['diff_table']['#rows']['states']); @@ -52,7 +52,10 @@ function diff_tokens($type, $tokens, array $data = array(), array $options = arr unset($build['diff_preview']); $output = drupal_render_children($build); - $replacements[$original] = $sanitize ? check_plain($output) : $output; + if ($sanitize) { + $output = filter_xss($output, array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd', 'table', 'tr', 'th', 'td')); + } + $replacements[$original] = $output; } break; diff --git a/www7/sites/all/modules/contrib/diff/includes/file.inc b/www7/sites/all/modules/contrib/diff/includes/file.inc index 678ff4666..575e8498c 100644 --- a/www7/sites/all/modules/contrib/diff/includes/file.inc +++ b/www7/sites/all/modules/contrib/diff/includes/file.inc @@ -67,7 +67,8 @@ function file_field_diff_view($items, $context) { if ($settings['compare_display_field'] && !empty($field['settings']['display_field'])) { $output['display'] = $item['display'] ? t('Displayed') : t('Hidden'); } - $diff_items[$delta] = implode('; ', $output); + $separator = $settings['property_separator'] == 'nl' ? "\n" : $settings['property_separator']; + $diff_items[$delta] = implode($separator, $output); } } @@ -82,6 +83,7 @@ function file_field_diff_default_options($field_type) { 'show_id' => 0, 'compare_display_field' => 0, 'compare_description_field' => 0, + 'property_separator' => '; ', ); } @@ -107,5 +109,21 @@ function file_field_diff_options_form($field_type, $settings) { '#default_value' => $settings['compare_display_field'], '#description' => t('This is only used if the "Enable Display field" is checked in the field settings.'), ); + $options_form['property_separator'] = array( + '#type' => 'select', + '#title' => t('Property separator'), + '#default_value' => $settings['property_separator'], + '#description' => t('Provides the ability to show properties inline or across multiple lines.'), + '#options' => array( + ', ' => t('Comma (,)'), + '; ' => t('Semicolon (;)'), + ' ' => t('Space'), + 'nl' => t('New line'), + ), + ); + // Allow users to set their own separator using variable_set(). + if (!isset($options_form['#options'][$settings['property_separator']])) { + $options_form['#options'][$settings['property_separator']] = $settings['property_separator']; + } return $options_form; } diff --git a/www7/sites/all/modules/contrib/diff/includes/image.inc b/www7/sites/all/modules/contrib/diff/includes/image.inc index cb93616d7..b41753e18 100644 --- a/www7/sites/all/modules/contrib/diff/includes/image.inc +++ b/www7/sites/all/modules/contrib/diff/includes/image.inc @@ -68,7 +68,8 @@ function image_field_diff_view($items, $context) { if ($settings['show_id']) { $output[] = t('File ID: !fid', $t_args); } - $diff_items[$delta] = implode('; ', $output); + $separator = $settings['property_separator'] == 'nl' ? "\n" : $settings['property_separator']; + $diff_items[$delta] = implode($separator, $output); } } @@ -83,6 +84,7 @@ function image_field_diff_default_options($field_type) { 'show_id' => 0, 'compare_alt_field' => 0, 'compare_title_field' => 0, + 'property_separator' => '; ', ); } @@ -108,5 +110,21 @@ function image_field_diff_options_form($field_type, $settings) { '#default_value' => $settings['compare_title_field'], '#description' => t('This is only used if the "Enable Title field" is checked in the instance settings.'), ); + $options_form['property_separator'] = array( + '#type' => 'select', + '#title' => t('Property separator'), + '#default_value' => $settings['property_separator'], + '#description' => t('Provides the ability to show properties inline or across multiple lines.'), + '#options' => array( + ', ' => t('Comma (,)'), + '; ' => t('Semicolon (;)'), + ' ' => t('Space'), + 'nl' => t('New line'), + ), + ); + // Allow users to set their own separator using variable_set(). + if (!isset($options_form['#options'][$settings['property_separator']])) { + $options_form['#options'][$settings['property_separator']] = $settings['property_separator']; + } return $options_form; } diff --git a/www7/sites/all/modules/contrib/diff/includes/node.inc b/www7/sites/all/modules/contrib/diff/includes/node.inc index 3f0bca33d..9cab7a68c 100644 --- a/www7/sites/all/modules/contrib/diff/includes/node.inc +++ b/www7/sites/all/modules/contrib/diff/includes/node.inc @@ -6,102 +6,199 @@ */ /** - * Implements hook_entity_diff(). - * - * This function compares core node properties. This is currently limited to: - * - title: The title of the node. - * - * @param object $old_node - * The older node revision. - * @param object $new_node - * The newer node revision. - * @param array $context - * An associative array containing: - * - entity_type: The entity type; e.g., 'node' or 'user'. - * - old_entity: The older entity. - * - new_entity: The newer entity. - * - view_mode: The view mode to use. Defaults to FALSE. If no view mode is - * given, the recommended fallback view mode is 'default'. - * - states: An array of view states. These could be one of: - * - raw: The raw value of the diff, the classic 7.x-2.x view. - * - rendered: The rendered HTML as determined by the view mode. Only - * return markup for this state if the value is normally shown - * by this view mode. The user will most likely be able to see - * the raw or raw_plain state, so this is optional. - * - * The rendering state is a work in progress. - * - * Conditionally, you can get these states, but setting these will override - * the user selectable markdown method. - * - * - raw_plain: As raw, but text should be markdowned. - * - rendered_plain: As rendered, but text should be markdowned. - * - * @return array - * An associative array of values keyed by the entity property. - * - * This is effectively an unnested Form API-like structure. - * - * States are returned as follows: - * - * $results['line'] = array( - * '#name' => t('Line'), - * '#states' => array( - * 'raw' => array( - * '#old' => '

      This was the old line number [tag].

      ', - * '#new' => '

      This is the new line [tag].

      ', - * ), - * 'rendered' => array( - * '#old' => '

      This was the old line number 57.

      ', - * '#new' => '

      This is the new line 57.

      ', - * ), - * ), - * ); - * - * For backwards compatability, no changes are required to support states, - * but it is recommended to provide a better UI for end users. - * - * For example, the following example is equivalent to returning the raw - * state from the example above. - * - * $results['line'] = array( - * '#name' => t('Line'), - * '#old' => '

      This was the old line number [tag].

      ', - * '#new' => '

      This is the new line [tag].

      ', - * ); + * Private callback function to render the title field. */ -function node_entity_diff($old_node, $new_node, $context) { - $result = array(); - if ($context['entity_type'] == 'node') { - $type = node_type_get_type($new_node); - $result['title'] = array( - '#name' => $type->title_label, - '#states' => array(), - '#weight' => -5, - '#settings' => array( - // Global setting - 'diff_show_header_' . $entity_type - 'show_header' => variable_get('diff_show_header_node', 1), - ), - ); - foreach ($context['states'] as $state) { - switch ($state) { - case 'rendered': - $result['title']['#states'][$state] = array( - '#old' => l($old_node->title, 'node/' . $old_node->title), - '#new' => l($new_node->title, 'node/' . $new_node->title), - ); - break; - - // We specify a default so that the title is allows compared. - case 'raw': - default: - $result['title']['#states'][$state] = array( - '#old' => array($old_node->title), - '#new' => array($new_node->title), - ); - break; - } +function _node_entity_diff_additional_options_title($old_node, $new_node, $context) { + $type = node_type_get_type($new_node); + $row = array( + '#name' => $type->title_label, + '#states' => array(), + '#weight' => -5, + '#settings' => array( + 'show_header' => variable_get('diff_show_header_node', 1), + ), + ); + foreach ($context['states'] as $state) { + switch ($state) { + case 'rendered': + $row['#states'][$state] = array( + '#old' => l($old_node->title, 'node/' . $old_node->title), + '#new' => l($new_node->title, 'node/' . $new_node->title), + ); + break; + + // We specify a default so that the title is allows compared. + case 'raw': + default: + $row['#states'][$state] = array( + '#old' => array($old_node->title), + '#new' => array($new_node->title), + ); + break; } } - return $result; + return $row; +} + +/** + * Private callback function to render the type field. + */ +function _node_entity_diff_additional_options_type($old_node, $new_node, $context) { + $row = array( + '#name' => t('Content type'), + '#states' => array(), + '#weight' => -4, + '#settings' => array(), + ); + $old_type = node_type_get_type($old_node); + $new_type = node_type_get_type($new_node); + + foreach ($context['states'] as $state) { + $row['#states'][$state] = array( + '#old' => array($old_type ? $old_type->name : t('Deleted type !type', array('!type' => $old_node->type))), + '#new' => array($new_type ? $new_type->name : t('Deleted type !type', array('!type' => $new_node->type))), + ); + } + return $row; +} + +/** + * Private callback function to render the author field. + */ +function _node_entity_diff_additional_options_author($old_node, $new_node, $context) { + $old_author = user_load($old_node->uid); + $new_author = user_load($new_node->uid); + return _node_entity_diff_additional_options_account(t('Author'), $old_author, $new_author, $context, -4); +} + +/** + * Private callback function to render the revision_author field. + */ +function _node_entity_diff_additional_options_revision_author($old_node, $new_node, $context) { + $old_author = user_load($old_node->revision_uid); + $new_author = user_load($new_node->revision_uid); + return _node_entity_diff_additional_options_account(t('Revision author'), $old_author, $new_author, $context, -3.9); +} + +/** + * Private callback function to render the author field. + */ +function _node_entity_diff_additional_options_account($label, $old_author, $new_author, $context, $weight = 0) { + $row = array( + '#name' => $label, + '#states' => array(), + '#weight' => $weight, + '#settings' => array(), + ); + foreach ($context['states'] as $state) { + $row['#states'][$state] = array( + '#old' => array($old_author ? format_username($old_author) : t('Deleted user')), + '#new' => array($new_author ? format_username($new_author) : t('Deleted user')), + ); + } + return $row; +} + +/** + * Private callback function to render the status, sticky and published field. + */ +function _node_entity_diff_additional_options_publishing_flags($old_node, $new_node, $context) { + $row = array( + '#name' => t('Publishing options'), + '#states' => array(), + '#weight' => -3, + '#settings' => array(), + ); + $old_options = array($old_node->status ? t('Published') : t('Unpublished')); + if ($old_node->promote) { + $old_options[] = t('Promoted to front page'); + } + if ($old_node->sticky) { + $old_options[] = t('Sticky at top of lists'); + } + + $new_options = array($new_node->status ? t('Published') : t('Unpublished')); + if ($new_node->promote) { + $new_options[] = t('Promoted to front page'); + } + if ($new_node->sticky) { + $new_options[] = t('Sticky at top of lists'); + } + + foreach ($context['states'] as $state) { + $row['#states'][$state] = array( + '#old' => $old_options, + '#new' => $new_options, + ); + } + return $row; +} + +/** + * Private callback function to render the created field. + */ +function _node_entity_diff_additional_options_created($old_node, $new_node, $context) { + return _node_entity_diff_additional_options_date_field(t('Created timestamp'), $old_node->created, $new_node->created, $context, -1); +} + +/** + * Private callback function to render the changed field. + */ +function _node_entity_diff_additional_options_changed($old_node, $new_node, $context) { + return _node_entity_diff_additional_options_date_field(t('Changed timestamp'), $old_node->changed, $new_node->changed, $context, -1); +} + +/** + * Private callback function to render the revision_timestamp field. + */ +function _node_entity_diff_additional_options_revision_timestamp($old_node, $new_node, $context) { + return _node_entity_diff_additional_options_date_field(t('Revision timestamp'), $old_node->revision_timestamp, $new_node->revision_timestamp, $context, -1); +} + +/** + * Helper function to render the date flags. + */ +function _node_entity_diff_additional_options_date_field($label, $old_date, $new_date, $context, $weight = 0) { + $row = array( + '#name' => $label, + '#states' => array(), + '#weight' => $weight, + '#settings' => array(), + ); + + foreach ($context['states'] as $state) { + $row['#states'][$state] = array( + '#old' => array(format_date($old_date)), + '#new' => array(format_date($new_date)), + ); + } + return $row; +} + +/** + * Private callback function to render the comment field. + */ +function _node_entity_diff_additional_options_comment($old_node, $new_node, $context) { + if (!module_exists('comment')) { + return array(); + } + $row = array( + '#name' => t('Comment setting'), + '#states' => array(), + '#weight' => -1, + '#settings' => array(), + ); + $options = array( + COMMENT_NODE_OPEN => t('Open'), + COMMENT_NODE_CLOSED => t('Closed'), + COMMENT_NODE_HIDDEN => t('Hidden'), + ); + + foreach ($context['states'] as $state) { + $row['#states'][$state] = array( + '#old' => array($options[$old_node->comment]), + '#new' => array($options[$new_node->comment]), + ); + } + return $row; } diff --git a/www7/sites/all/modules/contrib/diff/includes/user.inc b/www7/sites/all/modules/contrib/diff/includes/user.inc new file mode 100644 index 000000000..7ebd5664d --- /dev/null +++ b/www7/sites/all/modules/contrib/diff/includes/user.inc @@ -0,0 +1,148 @@ + t('Username'), + '#states' => array(), + '#weight' => -5, + '#settings' => array( + 'show_header' => variable_get('diff_show_header_user', 1), + ), + ); + foreach ($context['states'] as $state) { + switch ($state) { + case 'rendered': + $row['#states'][$state] = array( + '#old' => theme('username', array('account' => $old_user)), + '#new' => theme('username', array('account' => $old_user)), + ); + break; + + // We specify a default so that the name is always compared. + case 'raw': + default: + $row['#states'][$state] = array( + '#old' => array($old_user->name), + '#new' => array($new_user->name), + ); + break; + } + } + return $row; +} + +/** + * Private callback function to render the mail field. + */ +function _user_entity_diff_additional_options_mail($old_user, $new_user, $context) { + $row = array( + '#name' => t('E-mail address'), + '#states' => array(), + '#weight' => -4, + '#settings' => array(), + ); + + foreach ($context['states'] as $state) { + $row['#states'][$state] = array( + '#old' => array($old_user->mail), + '#new' => array($new_user->mail), + ); + } + return $row; +} + +/** + * Private callback function to render the status field. + */ +function _user_entity_diff_additional_options_status($old_user, $new_user, $context) { + $row = array( + '#name' => t('Status'), + '#states' => array(), + '#weight' => -3, + '#settings' => array(), + ); + + foreach ($context['states'] as $state) { + $row['#states'][$state] = array( + '#old' => array($old_user->status ? t('Active') : t('Blocked')), + '#new' => array($new_user->status ? t('Active') : t('Blocked')), + ); + } + return $row; +} + +/** + * Private callback function to render the timezone field. + */ +function _user_entity_diff_additional_options_timezone($old_user, $new_user, $context) { + $row = array( + '#name' => t('Time zone'), + '#states' => array(), + '#weight' => -1, + '#settings' => array(), + ); + $system_time_zones = system_time_zones(TRUE); + $old_zone = isset($old_user->timezone) ? $old_user->timezone : ''; + $new_zone = isset($new_user->timezone) ? $new_user->timezone : ''; + + foreach ($context['states'] as $state) { + $row['#states'][$state] = array( + '#old' => array(isset($system_time_zones[$old_zone]) ? $system_time_zones[$old_zone] : t('- None selected -')), + '#new' => array(isset($system_time_zones[$new_zone]) ? $system_time_zones[$new_zone] : t('- None selected -')), + ); + } + return $row; +} + +/** + * Private callback function to render the password field. + */ +function _user_entity_diff_additional_options_password($old_user, $new_user, $context) { + $row = array( + '#name' => t('Password Hash'), + '#states' => array(), + '#weight' => -1, + '#settings' => array(), + ); + + foreach ($context['states'] as $state) { + $row['#states'][$state] = array( + '#old' => array($old_user->pass), + '#new' => array($new_user->pass), + ); + } + return $row; +} + +/** + * Private callback function to render the roles field. + */ +function _user_entity_diff_additional_options_roles($old_user, $new_user, $context) { + $row = array( + '#name' => t('Roles'), + '#states' => array(), + '#weight' => -1, + '#settings' => array(), + ); + + $roles = user_roles(TRUE); + unset($roles[DRUPAL_AUTHENTICATED_RID]); + foreach ($context['states'] as $state) { + $row['#states'][$state] = array( + '#old' => array(implode("\n", array_intersect_key($roles, $old_user->roles))), + '#new' => array(implode("\n", array_intersect_key($roles, $new_user->roles))), + ); + } + return $row; +} diff --git a/www7/sites/all/modules/contrib/diff/js/diff.js b/www7/sites/all/modules/contrib/diff/js/diff.js index 2c873e9fb..5b63d7b1d 100644 --- a/www7/sites/all/modules/contrib/diff/js/diff.js +++ b/www7/sites/all/modules/contrib/diff/js/diff.js @@ -1,58 +1,65 @@ (function ($) { -Drupal.behaviors.diffRevisions = { - attach: function (context, settings) { - var $rows = $('table.diff-revisions tbody tr'); - function updateDiffRadios() { - var newTd = false; - var oldTd = false; - if (!$rows.length) { - return true; - } - $rows.removeClass('selected').each(function() { - var $row = $(this); - $row.removeClass('selected'); - var $inputs = $row.find('input[type="radio"]'); - var $oldRadio = $inputs.filter('[name="old"]').eq(0); - var $newRadio = $inputs.filter('[name="new"]').eq(0); - if (!$oldRadio.length || !$newRadio.length) { + "use strict"; + + Drupal.behaviors.diffRevisions = { + attach: function (context, settings) { + var $rows = $('table.diff-revisions tbody tr'); + function updateDiffRadios() { + var newTd = false; + var oldTd = false; + if (!$rows.length) { return true; } - if ($oldRadio.attr('checked')) { - oldTd = true; - $row.addClass('selected'); - $oldRadio.css('visibility', 'visible'); - $newRadio.css('visibility', 'hidden'); - } else if ($newRadio.attr('checked')) { - newTd = true; - $row.addClass('selected'); - $oldRadio.css('visibility', 'hidden'); - $newRadio.css('visibility', 'visible'); - } else { - if (Drupal.settings.diffRevisionRadios == 'linear') { - if (newTd && oldTd) { - $oldRadio.css('visibility', 'visible'); - $newRadio.css('visibility', 'hidden'); - } else if (newTd) { + $rows.removeClass('selected').each(function() { + var $row = $(this); + $row.removeClass('selected'); + var $inputs = $row.find('input[type="radio"]'); + var $oldRadio = $inputs.filter('[name="old"]').eq(0); + var $newRadio = $inputs.filter('[name="new"]').eq(0); + if (!$oldRadio.length || !$newRadio.length) { + return true; + } + if ($oldRadio.attr('checked')) { + oldTd = true; + $row.addClass('selected'); + $oldRadio.css('visibility', 'visible'); + $newRadio.css('visibility', 'hidden'); + } + else if ($newRadio.attr('checked')) { + newTd = true; + $row.addClass('selected'); + $oldRadio.css('visibility', 'hidden'); + $newRadio.css('visibility', 'visible'); + } + else { + if (Drupal.settings.diffRevisionRadios == 'linear') { + if (newTd && oldTd) { + $oldRadio.css('visibility', 'visible'); + $newRadio.css('visibility', 'hidden'); + } + else if (newTd) { + $newRadio.css('visibility', 'visible'); + $oldRadio.css('visibility', 'visible'); + } + else { + $newRadio.css('visibility', 'visible'); + $oldRadio.css('visibility', 'hidden'); + } + } + else { $newRadio.css('visibility', 'visible'); $oldRadio.css('visibility', 'visible'); - } else { - $newRadio.css('visibility', 'visible'); - $oldRadio.css('visibility', 'hidden'); } - } else { - $newRadio.css('visibility', 'visible'); - $oldRadio.css('visibility', 'visible'); } - } - }); - return true; - } - if (Drupal.settings.diffRevisionRadios) { - $rows.find('input[name="new"], input[name="old"]').click(updateDiffRadios); - updateDiffRadios(); + }); + return true; + } + if (Drupal.settings.diffRevisionRadios) { + $rows.find('input[name="new"], input[name="old"]').click(updateDiffRadios); + updateDiffRadios(); + } } - } -}; + }; })(jQuery); diff --git a/www7/sites/all/modules/contrib/diff/readme.txt b/www7/sites/all/modules/contrib/diff/readme.txt index f82db821f..f5164666c 100644 --- a/www7/sites/all/modules/contrib/diff/readme.txt +++ b/www7/sites/all/modules/contrib/diff/readme.txt @@ -58,13 +58,16 @@ e.g. http://www.example.com/admin/structure/types/manage/page i) "Show View changes button on node edit form" adds a new "Preview" like submit button to node editing pages. This shows a diff preview. + + This can be conditionally restricted per role using the user permission + "Access View changes button". ii) "Enable the Revisions page for this content type" adds the revisioning tab to content. This allows users to compare between various revisions that they have access to. iii) "Standard comparison preview" option allows you to control how the most - current revision is show on the revision comparision page. + current revision is shown on the revision comparison page. b) Publishing options From 3cf426e148d7c47fd853c15e1d29e6720555d2f4 Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Sat, 7 Jan 2017 12:17:17 +0100 Subject: [PATCH 12/16] Update metatag to 7.x-1.19 --- .../all/modules/contrib/metatag/CHANGELOG.txt | 25 +++ .../modules/contrib/metatag/metatag.api.php | 17 ++ .../all/modules/contrib/metatag/metatag.info | 12 +- .../modules/contrib/metatag/metatag.install | 31 +++ .../modules/contrib/metatag/metatag.module | 59 +---- .../metatag_app_links/metatag_app_links.info | 6 +- .../tests/metatag_app_links.tags.test | 31 ++- .../tests/metatag_app_links.test | 3 +- .../metatag_context/metatag_context.info | 6 +- .../tests/metatag_context.i18n.test | 4 +- .../tests/metatag_context.test | 7 +- .../tests/metatag_context_tests.info | 6 +- .../metatag/metatag_dc/metatag_dc.info | 6 +- .../metatag_dc/tests/metatag_dc.tags.test | 14 +- .../metatag/metatag_dc/tests/metatag_dc.test | 3 +- .../metatag_dc_advanced.info | 6 +- .../tests/metatag_dc_advanced.tags.test | 10 +- .../tests/metatag_dc_advanced.test | 3 +- .../metatag/metatag_devel/metatag_devel.info | 6 +- .../metatag_devel/tests/metatag_devel.test | 3 +- .../metatag_facebook/metatag_facebook.info | 6 +- .../tests/metatag_facebook.tags.test | 21 +- .../tests/metatag_facebook.test | 3 +- .../metatag_favicons/metatag_favicons.info | 8 +- .../metatag_favicons/metatag_favicons.module | 21 ++ .../tests/metatag_favicons.tags.test | 194 ++++++++++++++++- .../tests/metatag_favicons.test | 3 +- .../metatag_google_cse.info | 8 +- .../metatag_google_cse.metatag.inc | 7 +- .../tests/metatag_google_cse.tags.test | 30 ++- .../tests/metatag_google_cse.test | 8 +- .../metatag/metatag_google_plus/README.txt | 2 + .../metatag_google_plus.inc | 4 + .../metatag_google_plus.info | 8 +- .../metatag_google_plus.metatag.inc | 2 + .../tests/metatag_google_plus.tags.test | 67 +++++- .../tests/metatag_google_plus.test | 3 +- .../metatag_hreflang/metatag_hreflang.info | 6 +- .../tests/metatag_hreflang.tags.test | 33 ++- .../tests/metatag_hreflang.test | 3 +- ...atag_hreflang.with_entity_translation.test | 5 +- .../metatag_importer/metatag_importer.info | 6 +- .../tests/metatag_importer.test | 3 +- .../contrib/metatag/metatag_mobile/README.txt | 58 ++--- .../metatag_mobile/metatag_mobile.info | 6 +- .../metatag_mobile/metatag_mobile.metatag.inc | 6 +- .../metatag_mobile/metatag_mobile.module | 4 +- .../tests/metatag_mobile.tags.test | 156 ++++++++++++- .../metatag_mobile/tests/metatag_mobile.test | 3 +- .../metatag_opengraph/metatag_opengraph.info | 6 +- .../metatag_opengraph.metatag.inc | 2 + .../tests/metatag_opengraph.tags.test | 57 ++++- .../tests/metatag_opengraph.test | 3 +- .../metatag_opengraph_products.info | 8 +- .../metatag_opengraph_products.metatag.inc | 2 +- .../metatag_opengraph_products.tags.test | 27 ++- .../tests/metatag_opengraph_products.test | 4 +- .../metatag_panels/metatag_panels.info | 6 +- .../tests/metatag_panels.i18n.test | 4 +- .../metatag_panels/tests/metatag_panels.test | 4 +- .../tests/metatag_panels_tests.info | 6 +- .../metatag_twitter_cards.info | 6 +- .../tests/metatag_twitter_cards.tags.test | 55 ++++- .../tests/metatag_twitter_cards.test | 3 +- .../metatag_verification.info | 6 +- .../tests/metatag_verification.tags.test | 13 +- .../tests/metatag_verification.test | 3 +- .../metatag/metatag_views/metatag_views.info | 6 +- .../tests/metatag_views.i18n.test | 4 +- .../metatag_views/tests/metatag_views.test | 4 +- .../tests/metatag_views_tests.info | 6 +- .../metatag/tests/metatag.bulk_revert.test | 4 +- .../tests/metatag.core_tag_removal.test | 4 +- .../contrib/metatag/tests/metatag.helper.test | 18 +- .../contrib/metatag/tests/metatag.image.test | 4 +- .../contrib/metatag/tests/metatag.locale.test | 3 +- .../contrib/metatag/tests/metatag.node.test | 3 +- .../metatag/tests/metatag.node.with_i18n.test | 4 +- .../tests/metatag.string_handling.test | 6 +- .../metatag.string_handling_with_i18n.test | 6 +- .../contrib/metatag/tests/metatag.tags.test | 179 +++++++++++++-- .../metatag/tests/metatag.tags_helper.test | 205 ++++++++++++++++-- .../contrib/metatag/tests/metatag.term.test | 4 +- .../metatag/tests/metatag.term.with_i18n.test | 4 +- .../contrib/metatag/tests/metatag.unit.test | 26 ++- .../contrib/metatag/tests/metatag.user.test | 6 +- .../tests/metatag.with_i18n_config.test | 6 +- .../tests/metatag.with_i18n_disabled.test | 6 +- .../tests/metatag.with_i18n_output.test | 6 +- .../metatag/tests/metatag.with_me.test | 3 +- .../metatag/tests/metatag.with_media.test | 3 +- .../metatag/tests/metatag.with_panels.test | 4 +- .../metatag/tests/metatag.with_profile2.test | 8 +- .../tests/metatag.with_search_api.test | 6 +- .../metatag/tests/metatag.with_views.test | 4 +- .../metatag.with_workbench_moderation.test | 113 ++++++++++ .../contrib/metatag/tests/metatag.xss.test | 5 - .../metatag/tests/metatag_search_test.info | 6 +- .../contrib/metatag/tests/metatag_test.info | 6 +- 99 files changed, 1461 insertions(+), 368 deletions(-) create mode 100644 www7/sites/all/modules/contrib/metatag/tests/metatag.with_workbench_moderation.test diff --git a/www7/sites/all/modules/contrib/metatag/CHANGELOG.txt b/www7/sites/all/modules/contrib/metatag/CHANGELOG.txt index 20d4be896..d93024799 100644 --- a/www7/sites/all/modules/contrib/metatag/CHANGELOG.txt +++ b/www7/sites/all/modules/contrib/metatag/CHANGELOG.txt @@ -1,3 +1,28 @@ +Metatag 7.x-1.19, 2017-01-01 +---------------------------- +#2832427 by dmitry.kazberovich, e2thex, DamienMcKenna: Allow the metatag cache + expiration time to be modified. +#2780025 by DamienMcKenna: Backported output tests from D8. Also fixes the + output of the shortcut icon, ios-app, android-app, author, publisher, and made + the Google CSE thumbnail tag an 'image'. Left some others to be fixed later. +#2832476 by czigor; Added the 'product.group' and 'place' og:type options. +#2835614 by drumm: metatag_metatags_load_multiple() doesn't need to sort the + results. +By DamienMcKenna: Noted in the metatag_google_plus info file and README.txt that + it includes the Author and Publisher meta tags. +By DamienMcKenna: Tweaked the favicons module description. +By DamienMcKenna: Updated main tests to match the latest coding standards. +By DamienMcKenna: Minor updates to various Google CSE labels. +By DamienMcKenna: A string in metatag_opengraph_products wasn't using an + argument that was being passed to it. +By DamienMcKenna: Minor adjustment to metatag_mobile strings. +By DamienMcKenna: Updated submodule tests to match the latest coding standards. +#2838198 by DamienMcKenna, Mixologic: Test dependency changes to workaround + changes in the DrupalCI platform. +#2831073 by dxvargas, DamienMcKenna: Remove old workarounds due to Workbench + Moderation 3.x API changes, warn if older version installed. + + Metatag 7.x-1.18, 2016-11-30 ---------------------------- #2761817 by DamienMcKenna: Fixed metatag_update_replace_config() so it isn't diff --git a/www7/sites/all/modules/contrib/metatag/metatag.api.php b/www7/sites/all/modules/contrib/metatag/metatag.api.php index 579e7d52f..f356140fc 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag.api.php +++ b/www7/sites/all/modules/contrib/metatag/metatag.api.php @@ -435,3 +435,20 @@ function hook_metatag_i18n_context_alter(&$context, $tag_name) { $context = ''; } } + +/** + * Allow modules to overide the expiration of metatag caches. + * + * By default Metatag caches everything as CACHE_PERMANENT, this alter allows to + * change that. + * + * @param $expire + * The expire value to change. + * @param $cid + * The cid about to be cached. + * @param $data + * The data to be cached. + */ +function hook_metatag_cache_set_expire_alter(&$expire, $cid, $data) { + $expire = CACHE_TEMPORARY; +} diff --git a/www7/sites/all/modules/contrib/metatag/metatag.info b/www7/sites/all/modules/contrib/metatag/metatag.info index fd43f5153..5dc5d54ca 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag.info +++ b/www7/sites/all/modules/contrib/metatag/metatag.info @@ -75,7 +75,7 @@ files[] = tests/metatag.with_me.test ; Basic integration with Media. test_dependencies[] = file_entity -test_dependencies[] = media +test_dependencies[] = media:media (>= 2.0, < 3.0) files[] = tests/metatag.with_media.test ; Basic integration with Panels. @@ -91,9 +91,9 @@ test_dependencies[] = entity test_dependencies[] = search_api files[] = tests/metatag.with_search_api.test -; Integration with Workbench Moderation +; Integration with Workbench Moderation. test_dependencies[] = workbench_moderation -;files[] = tests/metatag.with_workbench_moderation,test +files[] = tests/metatag.with_workbench_moderation.test ; Basic integration with Views. test_dependencies[] = views @@ -102,9 +102,9 @@ files[] = tests/metatag.with_views.test ; Other test dependencies. test_dependencies[] = context -; Information added by Drupal.org packaging script on 2016-11-30 -version = "7.x-1.18" +; Information added by Drupal.org packaging script on 2017-01-01 +version = "7.x-1.19" core = "7.x" project = "metatag" -datestamp = "1480524802" +datestamp = "1483294745" diff --git a/www7/sites/all/modules/contrib/metatag/metatag.install b/www7/sites/all/modules/contrib/metatag/metatag.install index 2e1c46924..989634929 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag.install +++ b/www7/sites/all/modules/contrib/metatag/metatag.install @@ -181,6 +181,37 @@ function metatag_requirements($phase) { ); } } + + // If Workbench Moderation is installed, this only works with v3. + if (module_exists('workbench_moderation')) { + $wm_module = $module_data['workbench_moderation']; + // If the version string is not present then it means the module is + // running from git, which means it can't be compared against. + // Alternatively, look for the test file, which was the last commit of + // the 1.6 release. + if (!empty($wm_module->info['version'])) { + // Versions are in the format 7.x-1.y, so split the string up to find + // the 'y' portion. + $version = explode('-', $wm_module->info['version']); + if (isset($version[1])) { + list($major, $minor) = explode('.', $version[1]); + } + // If the version string couldn't be extracted correctly, assume that + // an incorrect version is installed. + else { + $major = 0; + } + } + // If v3.x is not installed, give an error message. + if ($major < 3) { + $requirements['metatag_wm_version'] = array( + 'severity' => REQUIREMENT_ERROR, + 'title' => 'Metatag', + 'value' => $t('Workbench Moderation module is out of date.'), + 'description' => $t('Metatag only works with Workbench Moderation module v7.x-3.0 or newer, otherwise there will be problems when content is changed.'), + ); + } + } } return $requirements; diff --git a/www7/sites/all/modules/contrib/metatag/metatag.module b/www7/sites/all/modules/contrib/metatag/metatag.module index 8363fb40a..42125891d 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag.module +++ b/www7/sites/all/modules/contrib/metatag/metatag.module @@ -526,9 +526,7 @@ function metatag_metatags_load_multiple($entity_type, array $entity_ids, array $ // Get all translations of tag data for this entity. $query = db_select('metatag', 'm') ->fields('m', array('entity_id', 'revision_id', 'language', 'data')) - ->condition('m.entity_type', $entity_type) - ->orderBy('entity_id') - ->orderBy('revision_id'); + ->condition('m.entity_type', $entity_type); // Filter by revision_ids if they are available. If not, filter by entity_ids. if (!empty($revision_ids)) { $query->condition('m.revision_id', $revision_ids, 'IN'); @@ -587,7 +585,6 @@ function metatag_metatags_load_multiple($entity_type, array $entity_ids, array $ * @param string|null $bundle * The bundle of the entity that is being saved. Optional. */ - function metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags, $bundle = NULL) { // Check that $entity_id is numeric because of Entity API and string IDs. if (!is_numeric($entity_id)) { @@ -896,11 +893,6 @@ function metatag_entity_insert($entity, $entity_type) { unset($entity->metatags[LANGUAGE_NONE]); } - // Support for Workbench Moderation v1. - if ($entity_type == 'node' && _metatag_isdefaultrevision($entity)) { - return; - } - metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags, $bundle); } } @@ -956,11 +948,6 @@ function metatag_entity_update($entity, $entity_type) { } } - // Support for Workbench Moderation v1. - if ($entity_type == 'node' && _metatag_isdefaultrevision($entity)) { - return; - } - // Save the record. metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags, $bundle); } @@ -2566,42 +2553,6 @@ function metatag_ctools_render_alter(&$info, $page, $context) { } } -/** - * Checks if this entity is the default revision (published). - * - * @param object $entity - * The entity object, e.g., $node. - * - * @return bool - * TRUE if the entity is the default revision, FALSE otherwise. - */ -function _metatag_isdefaultrevision($entity) { - // D7 "Forward revisioning" is complex and causes a node_save() with the - // future node in node table. This fires hook_node_update() twice and cause - // abnormal behaviour in metatag. - // - // The steps taken by Workbench Moderation is to save the forward revision - // first and overwrite this with the live version in a shutdown function in - // a second step. This will confuse metatag. D7 has no generic property - // in the node object, if the node that is updated is the 'published' version - // or only a draft of a future version. - // - // This behaviour will change in D8 where $node->isDefaultRevision has been - // introduced. See below links for more details. - // - https://www.drupal.org/node/1879482 - // - https://www.drupal.org/node/218755 - // - https://www.drupal.org/node/1522154 - // - // Every moderation module saving a forward revision needs to return FALSE. - // @todo: Refactor this workaround under D8. - // Support for Workbench Moderation v1 - if this is a node, check if the - // content type supports moderation. - if (function_exists('workbench_moderation_node_type_moderated') && workbench_moderation_node_type_moderated($entity->type) === TRUE) { - return !empty($entity->workbench_moderation['updating_live_revision']); - } - return FALSE; -} - /** * Generate the cache ID to use with metatag_cache_get/metatag_cache_set calls. * @@ -2657,8 +2608,12 @@ function metatag_cache_default_cid_parts(array $cid_parts = array()) { * @see cache_set() */ function metatag_cache_set($cid, $data) { - // Cache the data for later. - return cache_set($cid, $data, 'cache_metatag'); + // By default the cached data will not expire. + $expire = CACHE_PERMANENT; + + // Triggers hook_metatag_cache_set_expire_alter(). + drupal_alter("metatag_cache_set_expire", $expire, $cid, $data); + return cache_set($cid, $data, 'cache_metatag', $expire); } /** diff --git a/www7/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info b/www7/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info index 8fbf5bc30..917ce1242 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info @@ -8,9 +8,9 @@ dependencies[] = metatag files[] = tests/metatag_app_links.test files[] = tests/metatag_app_links.tags.test -; Information added by Drupal.org packaging script on 2016-11-30 -version = "7.x-1.18" +; Information added by Drupal.org packaging script on 2017-01-01 +version = "7.x-1.19" core = "7.x" project = "metatag" -datestamp = "1480524802" +datestamp = "1483294745" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.tags.test index 87ab2e8bf..cff79c25f 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.tags.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.tags.test @@ -1,9 +1,8 @@ $element) { + if (isset($element['#tag']) && $element['#tag'] == 'link') { + if (isset($element['#attributes']) && is_array($element['#attributes'])) { + if (isset($element['#attributes']['rel'])) { + if ($element['#attributes']['rel'] == 'shortcut icon') { + unset($elements[$key]); + } + } + } + } + } + } +} + /** * Theme callback for a favicon meta tag. * diff --git a/www7/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.tags.test index b56073f4f..cc25003c4 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.tags.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.tags.test @@ -1,9 +1,8 @@ randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'icon_16x16', + */ + public function icon_16x16_test_output_xpath() { + return "//link[@rel='icon' and @sizes='16x16']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'icon_192x192', + */ + public function icon_192x192_test_output_xpath() { + return "//link[@rel='icon' and @sizes='192x192']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'icon_32x32', + */ + public function icon_32x32_test_output_xpath() { + return "//link[@rel='icon' and @sizes='32x32']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'icon_96x96', + */ + public function icon_96x96_test_output_xpath() { + return "//link[@rel='icon' and @sizes='96x96']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed', + */ + public function apple_touch_icon_precomposed_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and not(@sizes)]"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed_114x114', + */ + public function apple_touch_icon_precomposed_114x114_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and @sizes='114x114']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed_120x120', + */ + public function apple_touch_icon_precomposed_120x120_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and @sizes='120x120']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed_144x144', + */ + public function apple_touch_icon_precomposed_144x144_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and @sizes='144x144']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed_152x152', + */ + public function apple_touch_icon_precomposed_152x152_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and @sizes='152x152']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed_180x180', + */ + public function apple_touch_icon_precomposed_180x180_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and @sizes='180x180']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed_72x72', + */ + public function apple_touch_icon_precomposed_72x72_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and @sizes='72x72']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed_76x76', + */ + public function apple_touch_icon_precomposed_76x76_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and @sizes='76x76']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'apple_touch_icon', + */ + public function apple_touch_icon_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and not(@sizes)]"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_114x114', + */ + public function apple_touch_icon_114x114_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and @sizes='114x114']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_120x120', + */ + public function apple_touch_icon_120x120_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and @sizes='120x120']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_144x144', + */ + public function apple_touch_icon_144x144_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and @sizes='144x144']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_152x152', + */ + public function apple_touch_icon_152x152_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and @sizes='152x152']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_180x180', + */ + public function apple_touch_icon_180x180_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and @sizes='180x180']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_72x72', + */ + public function apple_touch_icon_72x72_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and @sizes='72x72']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_76x76', + */ + public function apple_touch_icon_76x76_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and @sizes='76x76']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath for 'mask-icon'. + */ + public function mask_icon_test_tag_name() { + return 'mask-icon'; + } + + /** + * Implements {meta_tag_name}_test_tag_name for 'shortcut icon'. + */ + public function shortcut_icon_test_tag_name() { + return 'shortcut icon'; + } + } diff --git a/www7/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.test b/www7/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.test index 31d53ca04..2be8daf28 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.test @@ -1,9 +1,8 @@ t('Thumbnail'), 'description' => t('Use a url of a valid image.'), + 'image' => TRUE, 'weight' => ++$weight, ) + $tag_info_defaults; @@ -41,19 +42,19 @@ function metatag_google_cse_metatag_info() { $info['tags']['audience'] = array( 'label' => t('Content audience'), - 'description' => t('The conten audience, for example: all'), + 'description' => t('The content audience, e.g. "all".'), 'weight' => ++$weight, ) + $tag_info_defaults; $info['tags']['doc_status'] = array( 'label' => t('Document status'), - 'description' => t('The Document status, for example: draft.'), + 'description' => t('The document status, e.g. "draft".'), 'weight' => ++$weight, ) + $tag_info_defaults; $info['tags']['google_rating'] = array( 'label' => t('Results sorting'), - 'description' => t('Works only with numeric values'), + 'description' => t('Works only with numeric values.'), 'weight' => ++$weight, ) + $tag_info_defaults; diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.tags.test index ed1883f52..26bd4c7b4 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.tags.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.tags.test @@ -1,21 +1,17 @@ 'Metatag Google CSE tests', - 'description' => 'Test the Metatag:Google CSE module.', + 'name' => 'Metatag tags: Google CSE', + 'description' => 'Test the Metatag:Google CSE meta tags.', 'group' => 'Metatag', ); } @@ -24,11 +20,11 @@ class MetatagMobileTagsTest extends MetatagTagsTestBase { * {@inheritdoc} */ public $tags = array( - 'thumbnail', - 'department', 'audience', + 'department', 'doc_status', 'google_rating', + 'thumbnail', ); /** @@ -39,4 +35,18 @@ class MetatagMobileTagsTest extends MetatagTagsTestBase { parent::setUp($modules); } + /** + * Implements {meta_tag_name}_test_tag_name() for 'google_rating'. + */ + public function google_rating_test_tag_name() { + return 'rating'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'thumbnail'. + */ + public function thumbnail_test_value() { + return $this->randomImageUrl(); + } + } diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.test b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.test index 890d4ef67..c10af5172 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.test @@ -1,13 +1,9 @@ getValue($options); $element['#attached']['metatag_set_preprocess_variable'][] = array('html', 'itemtype', $value); return $element; } + } diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info index 88e9e4145..2babfa155 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info @@ -1,5 +1,5 @@ name = Metatag: Google+ -description = "Provides support for Google+ 'itemscope' meta tags." +description = "Provides support for Google+ 'itemscope', 'author' and 'publisher' meta tags." package = SEO core = 7.x @@ -11,9 +11,9 @@ files[] = metatag_google_plus.inc files[] = tests/metatag_google_plus.test files[] = tests/metatag_google_plus.tags.test -; Information added by Drupal.org packaging script on 2016-11-30 -version = "7.x-1.18" +; Information added by Drupal.org packaging script on 2017-01-01 +version = "7.x-1.19" core = "7.x" project = "metatag" -datestamp = "1480524802" +datestamp = "1483294745" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.metatag.inc b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.metatag.inc index 6e46b2e1a..ed9a04787 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.metatag.inc +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.metatag.inc @@ -133,6 +133,7 @@ function metatag_google_plus_metatag_info() { 'description' => t("Used by some search engines to confirm authorship of the content on a page. Should be either the full URL for the author's Google+ profile page or a local page with information about the author."), 'class' => 'DrupalLinkMetaTag', 'weight' => ++$weight, + 'element' => array(), 'devel_generate' => array( 'type' => 'url', ), @@ -142,6 +143,7 @@ function metatag_google_plus_metatag_info() { 'description' => t("Used by some search engines to confirm publication of the content on a page. Should be the full URL for the publication's Google+ profile page."), 'class' => 'DrupalLinkMetaTag', 'weight' => ++$weight, + 'element' => array(), 'devel_generate' => array( 'type' => 'url', ), diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.tags.test index 43ff023c4..0ba0a5ca2 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.tags.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.tags.test @@ -1,9 +1,8 @@ randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_field_xpath() for 'itemtype'. */ - public function itemtype_test_xpath() { + public function itemtype_test_field_xpath() { return "//select[@name='metatags[und][itemtype][value]']"; } + /** + * Implements {meta_tag_name}_test_output_xpath() for 'itemtype'. + */ + public function itemtype_test_output_xpath() { + return "//html[@rel='itemtype']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'publisher'. + */ + public function publisher_test_output_xpath() { + return "//link[@rel='publisher']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'publisher'. + */ + public function publisher_test_value_attribute() { + return 'href'; + } + } diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.test b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.test index a0e4a6109..1394bb0d2 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.test @@ -1,9 +1,8 @@ randomMachineName() . '/' . $this->randomMachineName(); + } + + /** + * {@inheritdoc} + */ + public function getTestTagName($tag_name) { + $tag_name = str_replace('xdefault', 'x-default', $tag_name); + return str_replace('hreflang_', '', $tag_name); + } + } diff --git a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.test b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.test index c27052f8c..baf7b42cc 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.test @@ -1,9 +1,8 @@ - - - + + + + - + iOS: @@ -17,37 +17,37 @@ iOS: - + Android: - - + + Windows: - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + Configuration -------------------------------------------------------------------------------- -By default the two link alternative meta tags include a prefix - "android-app://" and "ios-app://". To remove this prefix just change the theme +By default the two link alternate meta tags include a prefix - "android-app://" and "ios-app://". To remove this prefix just change the theme functions, e.g.: /** @@ -57,7 +57,7 @@ functions, e.g.: */ function MYTHEME_metatag_mobile_android_app($variables) { // Pass everything through to the normal 'link' tag theme. - $variables['element']['#name'] = 'alternative'; + $variables['element']['#name'] = 'alternate'; // Don't actually want this. // $variables['element']['#value'] = 'android-app://' . $variables['element']['#value']; @@ -72,7 +72,7 @@ function MYTHEME_metatag_mobile_android_app($variables) { */ function MYTHEME_metatag_mobile_ios_app($variables) { // Pass everything through to the normal 'link' tag theme. - $variables['element']['#name'] = 'alternative'; + $variables['element']['#name'] = 'alternate'; // Don't actually want this. // $variables['element']['#value'] = 'ios-app://' . $variables['element']['#value']; diff --git a/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info b/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info index d4d9c7dfe..815af8f6b 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info @@ -8,9 +8,9 @@ dependencies[] = metatag files[] = tests/metatag_mobile.test files[] = tests/metatag_mobile.tags.test -; Information added by Drupal.org packaging script on 2016-11-30 -version = "7.x-1.18" +; Information added by Drupal.org packaging script on 2017-01-01 +version = "7.x-1.19" core = "7.x" project = "metatag" -datestamp = "1480524802" +datestamp = "1483294745" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.metatag.inc b/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.metatag.inc index 5eed54996..2d4f50e10 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.metatag.inc +++ b/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.metatag.inc @@ -10,7 +10,7 @@ function metatag_mobile_metatag_info() { $info['groups']['mobile'] = array( 'label' => t('Mobile & UI Adjustments'), - 'description' => t("Meta tags used to control the mobile browser experience. Some of these meta tags have been replaced by newer mobile browsers. These meta tags usually only need to be set globally, rather than per-page."), + 'description' => t('Meta tags used to control the mobile browser experience. Some of these meta tags have been replaced by newer mobile browsers. These meta tags usually only need to be set globally, rather than per-page.'), 'form' => array( '#weight' => 80, ), @@ -24,14 +24,14 @@ function metatag_mobile_metatag_info() { ); $info['groups']['android_mobile'] = array( 'label' => t('Android'), - 'description' => t("Custom meta tags used by the Android OS, browser, etc."), + 'description' => t('Custom meta tags used by the Android OS, browser, etc.'), 'form' => array( '#weight' => 82, ), ); $info['groups']['windows_mobile'] = array( 'label' => t('Windows & Windows Mobile'), - 'description' => t("Custom meta tags used by the Windows and Windows Mobile OSes, IE browser, etc."), + 'description' => t('Custom meta tags used by the Windows and Windows Mobile OSes, IE browser, etc.'), 'form' => array( '#weight' => 83, ), diff --git a/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.module b/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.module index 4d7f3d6e9..6451b27af 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.module +++ b/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.module @@ -38,7 +38,7 @@ function metatag_mobile_theme() { */ function theme_metatag_mobile_android_app($variables) { // Pass everything through to the normal 'link' tag theme. - $variables['element']['#name'] = 'alternative'; + $variables['element']['#name'] = 'alternate'; $variables['element']['#value'] = 'android-app://' . $variables['element']['#value']; return theme('metatag_link_rel', $variables); @@ -52,7 +52,7 @@ function theme_metatag_mobile_android_app($variables) { */ function theme_metatag_mobile_ios_app($variables) { // Pass everything through to the normal 'link' tag theme. - $variables['element']['#name'] = 'alternative'; + $variables['element']['#name'] = 'alternate'; $variables['element']['#value'] = 'ios-app://' . $variables['element']['#value']; return theme('metatag_link_rel', $variables); diff --git a/www7/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.tags.test index f8a3c4425..40806883b 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.tags.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.tags.test @@ -1,9 +1,8 @@ randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'msapplication-square310x310logo'. + */ + public function msapplication_square310x310logo_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'msapplication-square70x70logo'. + */ + public function msapplication_square70x70logo_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'msapplication-tileimage'. + */ + public function msapplication_tileimage_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'msapplication-wide310x150logo'. + */ + public function msapplication_wide310x150logo_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_name_attribute() for 'x-ua-compatible'. + */ + public function x_ua_compatible_test_name_attribute() { + return 'http-equiv'; + } + } diff --git a/www7/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.test b/www7/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.test index 83c1985ab..ba18baad1 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.test @@ -1,9 +1,8 @@ t('City'), 'country' => t('Country'), 'landmark' => t('Landmark'), + 'place' => t('Place'), 'state_province' => t('State or province'), ), t('Products and Entertainment') => array( @@ -612,6 +613,7 @@ function _metatag_opengraph_type_options() { 'food' => t('Food'), 'game' => t('Game'), 'product' => t('Product'), + 'product.group' => t('Product group'), 'song' => t('Song'), 'video.movie' => t('Movie'), 'video.tv_show' => t('TV show'), diff --git a/www7/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.tags.test index d6e28244d..4f30767e2 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.tags.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.tags.test @@ -1,9 +1,8 @@ randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'og:image:url'. + */ + public function og_image_url_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'og:image:secure_url'. + */ + public function og_image_secure_url_test_value() { + return str_replace('http://', 'https://', $this->randomImageUrl()); + } + } diff --git a/www7/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.test b/www7/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.test index b57653582..4d9399503 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.test @@ -1,9 +1,8 @@ t('Open Graph - Products'), - 'description' => t("These Open Graph meta tags for describing products.", array('@ogp' => 'http://ogp.me/')), + 'description' => t("These Open Graph meta tags for describing products."), 'form' => array( '#weight' => 51, ), diff --git a/www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.tags.test b/www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.tags.test index 067d72db6..d0d5673ab 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.tags.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.tags.test @@ -1,9 +1,8 @@ randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'twitter:image0'. + */ + public function twitter_image0_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'twitter:image1'. + */ + public function twitter_image1_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'twitter:image2'. + */ + public function twitter_image2_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'twitter:image3'. + */ + public function twitter_image3_test_value() { + return $this->randomImageUrl(); + } + } diff --git a/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.test b/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.test index 01ca1bcc5..0125dd707 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.test +++ b/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.test @@ -1,9 +1,8 @@ assertEqual($xpath[0]['content'], $user->name . " ponies"); } + /** + * Generate a string that is allowable as a machine name. + * + * @param int $length + * How long the machine name will be, defaults to eight characters. + * + * @return string + * A string that contains lowercase letters and numbers, with a letter as + * the first character. + */ + function randomMachineName($length = 8) { + return strtolower($this->randomName($length)); + } + } diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.image.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.image.test index 547a98198..1a2b09155 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.image.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.image.test @@ -1,10 +1,10 @@ tags as $tag) { // Convert tag names to something more suitable for a function name. - $tagname = str_replace(array('.', '-', ':'), '_', $tag); + $tag_name = str_replace(array('.', '-', ':'), '_', $tag); - // Look for a custom method named "{$tagname}_test_xpath", if found use - // that method to get the xpath definition for this meta tag, otherwise it - // defaults to just looking for a text input field. - $method = "{$tagname}_test_xpath"; + // Look for a custom method named "{$tag_name}_test_field_xpath", if found + // use that method to get the xpath definition for this meta tag, + // otherwise it defaults to just looking for a text input field. + $method = "{$tag_name}_test_field_xpath"; if (method_exists($this, $method)) { $xpath = $this->$method(); } @@ -50,45 +65,197 @@ abstract class MetatagTagsTestBase extends MetatagTestHelper { } /** - * Confirm that the meta tags can be saved. + * Confirm that each tag can be saved and that the output of each tag is + * correct. */ - function testTagsAreSaveable() { + function testTagsInputOutput() { // Load the global config. $this->drupalGet('admin/config/search/metatags/config/global'); $this->assertResponse(200); // Update the Global defaults and test them. - $values = array(); - foreach ($this->tags as $tag) { + $all_values = $values = array(); + foreach ($this->tags as $tag_raw) { // Convert tag names to something more suitable for a function name. - $tagname = str_replace(array('.', '-', ':', ' '), '_', $tag); + $tag_name = str_replace(array('.', '-', ':', ' '), '_', $tag_raw); - // Look for a custom method named "{$tagname}_test_key", if found use + // Look for a custom method named "{$tag_name}_test_key", if found use // that method to get the test string for this meta tag, otherwise it // defaults to the meta tag's name. - $method = "{$tagname}_test_key"; + $method = "{$tag_name}_test_key"; if (method_exists($this, $method)) { $test_key = $this->$method(); } else { - $test_key = "metatags[und][{$tag}][value]"; + $test_key = "metatags[und][{$tag_raw}][value]"; } - // Look for a custom method named "{$tagname}_test_value", if found use + // Look for a custom method named "{$tag_name}_test_value", if found use // that method to get the test string for this meta tag, otherwise it // defaults to just generating a random string. - $method = "{$tagname}_test_value"; + $method = "{$tag_name}_test_value"; if (method_exists($this, $method)) { $test_value = $this->$method(); } else { - $test_value = $this->randomString(); + // Generate a random string. + $test_value = $this->getTestTagValue(); } $values[$test_key] = $test_value; + + // Look for a custom method named "{$tag_name}_test_preprocess_output", if + // found use that method provide any additional processing on the value + // e.g. adding a prefix. + $method = "{$tag_name}_test_preprocess_output"; + if (method_exists($this, $method)) { + $test_value = $this->$method($test_value); + } + + $all_values[$tag_name] = $test_value; } $this->drupalPost(NULL, $values, 'Save'); $this->assertText(strip_tags(t('The meta tag defaults for @label have been saved.', array('@label' => 'Global')))); + + // Load the test page. + $this->drupalGet('moosqueakoinkmeow'); + $this->assertResponse(200); + $this->assertText(t('Test page.')); + + // Look for the values. + foreach ($this->tags as $tag_raw) { + // Convert tag names to something more suitable for a function name. + $tag_name = str_replace(array('.', '-', ':', ' '), '_', $tag_raw); + + // Verify this meta tag was output. + $this->assertTrue(!empty($all_values[$tag_name])); + + // Look for a custom method named "{$tag_name}_test_output_xpath", if + // found use that method to get the xpath definition for this meta tag, + // otherwise it defaults to just looking for a meta tag matching: + // <$test_tag $test_name_attribute=$tag_name $test_value_attribute=$value /> + $method = "{$tag_name}_test_output_xpath"; + if (method_exists($this, $method)) { + $xpath_string = $this->$method(); + } + else { + // Look for a custom method named "{$tag_name}_test_tag", if + // found use that method to get the xpath definition for this meta tag, + // otherwise it defaults to $this->test_tag. + $method = "{$tag_name}_test_tag"; + if (method_exists($this, $method)) { + $xpath_tag = $this->$method(); + } + else { + $xpath_tag = $this->test_tag; + } + + // Look for a custom method named "{$tag_name}_test_name_attribute", if + // found use that method to get the xpath definition for this meta tag, + // otherwise it defaults to $this->test_name_attribute. + $method = "{$tag_name}_test_name_attribute"; + if (method_exists($this, $method)) { + $xpath_name_attribute = $this->$method(); + } + else { + $xpath_name_attribute = $this->test_name_attribute; + } + + // Look for a custom method named "{$tag_name}_test_tag_name", if + // found use that method to get the xpath definition for this meta tag, + // otherwise it defaults to $tag_name. + $method = "{$tag_name}_test_tag_name"; + if (method_exists($this, $method)) { + $xpath_name_tag = $this->$method(); + } + else { + $xpath_name_tag = $this->getTestTagName($tag_name); + } + + // Compile the xpath. + $xpath_string = "//{$xpath_tag}[@{$xpath_name_attribute}='{$xpath_name_tag}']"; + } + + // Something should have been found. + $this->assertTrue(!empty($xpath_string)); + + // Look for a custom method named "{$tag_name}_test_value_attribute", if + // found use that method to get the xpath definition for this meta tag, + // otherwise it defaults to $this->test_value_attribute. + $method = "{$tag_name}_test_value_attribute"; + if (method_exists($this, $method)) { + $xpath_value_attribute = $this->$method(); + } + else { + $xpath_value_attribute = $this->test_value_attribute; + } + + // Extract the meta tag from the HTML. + $xpath = $this->xpath($xpath_string); + $this->assertEqual(count($xpath), 1, format_string('One @name tag found.', array('@name' => $tag_name))); + + // Most meta tags have an attribute, but some don't. + if (!empty($xpath_value_attribute)) { + $this->assertTrue($xpath_value_attribute); + $this->assertTrue(isset($xpath[0][$xpath_value_attribute])); + // Help with debugging. + if (!isset($xpath[0][$xpath_value_attribute])) { + $this->verbose($xpath, $tag_name . ': ' . $xpath_string); + } + else { + if ((string)$xpath[0][$xpath_value_attribute] != $all_values[$tag_name]) { + $this->verbose($xpath, $tag_name . ': ' . $xpath_string); + } + $this->assertTrue($xpath[0][$xpath_value_attribute]); + $this->assertEqual($xpath[0][$xpath_value_attribute], $all_values[$tag_name]);//, "The meta tag was found with the expected value."); + } + } + else { + $this->verbose($xpath, $tag_name . ': ' . $xpath_string); + $this->assertTrue((string)$xpath[0]); + $this->assertEqual((string)$xpath[0], $all_values[$tag_name], "The meta tag was found with the expected value."); + } + } + } + + /** + * Convert a tag's internal name to the string which is actually used in HTML. + * + * The meta tag internal name will be machine names, i.e. only contain a-z, + * A-Z, 0-9 and the underline character. Meta tag names will actually contain + * any possible character. + * + * @param string $tag_name + * The tag name to be converted. + * + * @return string + * The converted tag name. + */ + public function getTestTagName($tag_name) { + return $tag_name; + } + + /** + * Generate a random value for testing meta tag fields. + * + * As a reasonable default, this will generating two words of 8 characters + * each with simple machine name -style strings. + * + * @return string + * A normal string. + */ + public function getTestTagValue() { + return $this->randomMachineName() . ' ' . $this->randomMachineName(); + } + + /** + * Generate a URL for an image. + * + * @return string + * An absolute URL to a non-existant image. + */ + public function randomImageUrl() { + return 'http://www.example.com/images/' . $this->randomMachineName() . '.png'; } } diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.term.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.term.test index e235d9912..460eb232a 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.term.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.term.test @@ -1,10 +1,10 @@ 'Metatag unit tests', @@ -35,6 +37,9 @@ class MetatagCoreUnitTest extends MetatagTestHelper { $this->assertEqual($defaults, $new_values); } + /** + * Test the basic entity handling. + */ public function testEntitySupport() { $test_cases[1] = array('type' => 'node', 'bundle' => 'article', 'expected' => TRUE); $test_cases[2] = array('type' => 'node', 'bundle' => 'page', 'expected' => TRUE); @@ -60,6 +65,19 @@ class MetatagCoreUnitTest extends MetatagTestHelper { } } + /** + * Confirm an entity supports meta tags. + * + * @param string $entity_type + * The name of the entity type to test. + * @param string $bundle + * The name of the entity bundle to test. + * @param array $expected + * The expected results. + * + * @return object + * An assertion. + */ function assertMetatagEntitySupportsMetatags($entity_type, $bundle, $expected) { $entity = entity_create_stub_entity($entity_type, array(0, NULL, $bundle)); return $this->assertEqual( diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.user.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.user.test index 21e7b370e..ea083a3ce 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.user.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.user.test @@ -1,10 +1,10 @@ 'Metatag core tests with Workbench Moderation', + 'description' => 'Test Metatag integration with the Workbench Moderation module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'workbench_moderation'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'workbench_moderation'; + + parent::setUp($modules); + } + + /** + * Confirm that WM-based node edit workflows work properly. + */ + public function testNodeEdit() { + // Create a new content type and enable moderation on it. + $content_type = 'metatag_test'; + $content_type_path = str_replace('_', '-', $content_type); + $label = 'Test'; + $this->createContentType($content_type, $label); + variable_set('node_options_' . $content_type, array('revision', 'moderation')); + + // Create a brand new unpublished node programmatically. + $settings = array( + 'title' => 'Who likes magic', + 'type' => $content_type, + 'metatags' => array( + LANGUAGE_NONE => array( + 'abstract' => array('value' => '[node:title] ponies'), + ), + ), + 'status' => NODE_NOT_PUBLISHED, + ); + $node = $this->drupalCreateNode($settings); + + // Check that page is not published. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(403); + + // Create and login user. + $moderator_user = $this->drupalCreateUser(array( + 'access content', + 'view revisions', + 'view all unpublished content', + 'view moderation history', + 'view moderation messages', + 'bypass workbench moderation', + "create {$content_type} content", + "edit any {$content_type} content", + )); + $this->drupalLogin($moderator_user); + + // Publish the node via the moderation form. + $moderate = array('state' => workbench_moderation_state_published()); + $this->drupalPost("node/{$node->nid}/moderation", $moderate, t('Apply')); + + // Create draft with different node title. + $edit = array( + 'title' => 'I like magic', + ); + $this->drupalPost("node/{$node->nid}/edit", $edit, t('Save')); + + // Logout user. + $this->drupalLogout(); + + // Check that page is already published. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200); + + // Verify the title is using the custom default for this content type. + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'Who likes magic ponies'); + + // Login user again. + $this->drupalLogin($moderator_user); + + // Publish draft via the moderation form. + $moderate = array('state' => workbench_moderation_state_published()); + $this->drupalPost("node/{$node->nid}/moderation", $moderate, t('Apply')); + + // Logout user. + $this->drupalLogout(); + + // Check that page is already published. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200); + + // Verify the title is using the custom default for this content type. + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'I like magic ponies'); + } + +} diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.xss.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.xss.test index 595812e9c..9d2deb0c8 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.xss.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.xss.test @@ -1,13 +1,8 @@ Date: Sat, 21 Jan 2017 11:35:39 +0100 Subject: [PATCH 13/16] Update views_pdf to 7.x-1.7 --- .../libraries/leaflet/images/layers-2x.png | Bin 2898 -> 0 bytes .../all/libraries/leaflet/images/layers.png | Bin 1502 -> 0 bytes .../leaflet/images/marker-icon-2x.png | Bin 4033 -> 0 bytes .../libraries/leaflet/images/marker-icon.png | Bin 1747 -> 0 bytes .../leaflet/images/marker-shadow.png | Bin 797 -> 0 bytes .../all/libraries/leaflet/leaflet-src.js | 9180 ----------------- www7/sites/all/libraries/leaflet/leaflet.js | 9 - .../modules/views_append/views_append.info | 6 +- .../views_view_field/views_view_field.info | 6 +- .../modules/contrib/views_pdf/views_pdf.info | 6 +- .../contrib/views_pdf/views_pdf.install | 27 + ...{views_pdf.make => views_pdf.make.example} | 0 .../contrib/views_pdf/views_pdf.rules.inc | 2 +- .../contrib/views_pdf/views_pdf.views.inc | 2 +- .../views_pdf/views_pdf_plugin_row_fields.inc | 12 + .../contrib/views_pdf/views_pdf_template.php | 26 + 16 files changed, 76 insertions(+), 9200 deletions(-) delete mode 100644 www7/sites/all/libraries/leaflet/images/layers-2x.png delete mode 100644 www7/sites/all/libraries/leaflet/images/layers.png delete mode 100644 www7/sites/all/libraries/leaflet/images/marker-icon-2x.png delete mode 100644 www7/sites/all/libraries/leaflet/images/marker-icon.png delete mode 100644 www7/sites/all/libraries/leaflet/images/marker-shadow.png delete mode 100644 www7/sites/all/libraries/leaflet/leaflet-src.js delete mode 100644 www7/sites/all/libraries/leaflet/leaflet.js rename www7/sites/all/modules/contrib/views_pdf/{views_pdf.make => views_pdf.make.example} (100%) diff --git a/www7/sites/all/libraries/leaflet/images/layers-2x.png b/www7/sites/all/libraries/leaflet/images/layers-2x.png deleted file mode 100644 index a2cf7f9efef65d2e021f382f47ef50d51d51a0df..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2898 zcmV-Y3$65tP)?AfzNU07Ji0>J$I zyy*J%>jA&t|KY2zz8cz!dNXf;;xfzYhMv6otBB#?C3IqawZEtV)Ws@UgL!F(S zVuQi(g3)MfC@U-DvZ*wkrlzJCm&-NacDq09>gq~l5}T2sGiS~m&}cNz)Ya8VDT)#l zNC*+dVzFibkV>Wf6h#RdO+pCebUI^xzyIT7$BqeRmmotYPo7ln-o5)Lb#-+Wt4tB1 zL?WS%$KwYGA#wnqC~8q6kz5js#Q~u?=I7@{PN#EXe0=;bLfDnk&?-~(di{aQ%F2}6 z@Otq)pTDxQa)9Ug-O2u^X?k2HlU<@|dP!(bpU+2oJf2JG*tMadci(-tUaeLiZfIyI zNXL}*ZH>iZbu7y^5kgWvyHOOC5Q#)KsZ{C&ASge}vh={fz(ODpIRDBkuQ-zCz2DG@ z6DQ<4o$iRqWHRj7u|x2JWLdT}9*;l4^Za(9F#tf*^mh`8#Vh4?g(dDVl2B@enN;WQv=CFQPhf9EWRp{ zNIXJgB9Vy5;c(oXn3y=%-rnw`&Ye4V)Mzv|l$VzaHo|e-_E;?T1kdxO*)=`2Xqpa6 zrP7NG!+a++W^!^;hrf`@B%%6jB1%hvEb zFJ>4fL{U`QO=E0qtk7<^KSgzPbPxbBg+g)p>8GEbC@wBeYV3ZdJSwGQ*R5N(WS@NU zNkupuZUrD^T3cIt2q6ce(P*R7=`5L>n_JN7bW0RVDKOzL<*owE|)*| z=9_Ph+_P37C(~njkHQ666opafyd+FS(c>%d`Sp- z`JH#(8C@+SS|9N2v(JVZh6&ubaf8_Hc6w-N2$PeOXliOgb#?V4H?UqKBO|ccY?z;) zhfF4;&1N%EsZ;@u*D=RA~Dk?%tOA8c=4VUv}hGC8|TCMgUDwV34 zrs<>$B{w%0TCEl`nGC^T5K~iA2m}Ji&(FuUZQHiQ%*4b5KL7l4_AkZ2nK`j`Fyy2 z`!Kkw^p=FJ44nUmup2m!VRr@Z^(ELa9_@6(h;y^ZEL^ySv4Ui;H!u96I#v zx8Iulet&Oyc{weSNRq-+EEYqhQlX@z1T!-;2nK`jdc6PurBeA&W*iO&zWVAbghCjHZwG}lrH7Pr5d3kyIv(G*o9v>e!1DK_0`Y=TZ!5eS9AzNHr{1t#-0$?jED{U<; zEss+aCE6$%&+`}>8iL#H2FGzIEiJ{qefu&t77B&X)6;`sFbIZWU@#a^TU(oQjS@oG zzP`RIKA*1%cXsNx<#PF3ufP8K%7z@u%gc+I&1Px31}-ctz-F@{6beBs7DKPs-EPOq$_fe#3sbV|KBl0tu@My&6)E$_Vlnjh z_hWK$5)z37)z#HdDwY2N(B9V8Hu->|?(XjA0i48L4zVl?uh+Ylz+^I^s;VmG;!MXb z0Ze&7gb<95j$&|d5UU-m)9D}*t*wS70KWlns;#Y!r7m2!Py^tP0KT6r;ljcKTrL+D z7Z-)F0KkLns;#XB01OQc31!LydE|0Aj7DRsDR~{hPnqiK>c8#Sv12d8FgeLeNu^Sh zm6bsvksuTb!RPZK8jWJ-&Yc@B++^&Uo}L!W6qaRSx7%T}*^o#iP*qh0qtOVNY~vSW zj^pG`r&CXLbaW&DENHb_w??CRe8ULbna3WF2RCotL{3f)_U_#awOXAj1kq>|cDo$_ z(Ae0BoSdZnwx&QJfNR&Tt#z7SuTQ&vr>Cd;T`pHCA*77z=;&wz@E(9lu~_VEYHG@t z%jK1+5`@EH3=a>lRcbbyk)NNRveI-~T3SMHZ|_=X)zs9aos!XLblPUKO-7?pGXNie zmnlLBEEbClz$%C6l9G}ud-m*UVHjq^dBO8M{C+h5~JRXF@VdUrMqot)qFkC~S5c>N1u(Y%Ug+c+nUXQ%Iyp%EFaCp$+a7a0hs{-&P zfS0XSYjO^)Gxi*S-vij0latfi)YMd-lasS6UE@YZMj(V;8!#oMkwhXfXSdsj78Vv- z0n7mSxz%d@`~BrMJPNj0EQJ8N02~7lEh{Ut84QM$k3;F$C4ebO<@ft9kByDh0N4iL z41i9n)jFT7Y}(rgi^bA>H%SA-Fr)SL^)ZD)VM-N~j9maSVG00XadFXSv)Pssi9{WM z0RYFWR%?H%7(v%57K?=ea2&vI0musq3NAM`Hr9&8;tgM42_cxAoW$7J7 zXf#RRbXT>?E&v%b1;9T6{LE^#3O>ls>W z1%Om4^+QKT$He~%>hA6?ZftBk<8ry0&1N$IV0CpB>2x|AjYe;Fc6L7h&!E1(zLV9} z)u*ghYw33S?Ck9Fgo=++wEZ(=B3H#x{g#TB~MOH_MSa^ zc4|)`Ns{=6hK6>J$8)^2w3OYbQA&$)x!mgjU^1EhAcSN$>dVW^nk>r$u~@866vh0G zpj)?YHF`XrckFh1+18Bm`FyRSC@qvyBLEOW)(i&25YO}DTWx1%W}eBi{Nw42!K@e0==o zxpU{{$nD#=-|~9BZwP{5+EOON+S*#Ps;cz>Ufv`?=QwW6Xf%ciA<9N!VPPScOeTM2 z-EQ}HPN#E85Cpv-DvILC<#KQ7y6yx(c7Xr@(RKZxs;V`FkY$!-7Yf4T$B&Ed-o1N< zZE9+oefaR<2dPx*`JqFH463TWsVGVi0KW&o*2Qa@R;_7TrK+m4y}iAba5&toD9UGq zQi`6Qp4W6;?^|76J$~%iG2-=lUxD$@N+y%IckdoGo6Q3Z!?d42e}0ifqtTO;(yIXc zOG`@#hr=i-DM4#%D-IkuurEL+lfmHNAXZjZ(A?Y%i^T!}aYD$4ti$2>-r;b#3kZ@&v(P5LT;o-DhrY4v|QNvMf8u^L+b-3m2Y|J9qB10=NpGer06^@pv5N<>feX zg(&*Cs5aQjE#+9YHA8TpAUi{Y=lqVzkffYD9SGYK9?lv`KH@j6va9K z-w1+$Kp+s{IIgtNqjWlrr%#_E5C{MOMn*5}%e7uUP19CmvDon3+#Ch)u_Q@< z7GnSFJrYHc0C=AeBKmy3#j2{RmV%bcAKzn;9E(O zHU-}Cg%w4y9Ke@Gqw#Ps7_=4_7gud(m(6BpB9X|WY&JU%;8RJG=C`xk_0J%RVjCgk zE1S)hsjI7NVHm~;0F+WS9*+-BPfwdErJa%_gh876I}?PQWpJLz%)x;}A1s3+;FijJ6nrW+Pl4)+EiN1Z`Z};D5lx0BtvZnmddk_DqORVPG3@A z|MUAQ5d8CyG`n3U%W5w|$1lmUI>14Eit;<8S?vK{s*?{-Ss+T)u_t92ZJTA8?H?iF zR>;v&x7=gkU3dZlw!Q;_2%o}};F13pC@6@Z$Rj?JWwli(vf7`Uv_M3vmPaI6ZRyg? zwr>!?ft(K4bi>Np0r=D2_w3@8-GdNOt_Q!(r!eStxP|AMG^4f1MRn*m6B>vlqxDrZ z^e+Su+;WdVxV9T!t{sF|>)yKqtLo0f%X=)K?{|}VWzP^q==9)`cMLdQ#3#~>wy4qc zkwZdrRrSA+s#>ZLK#*s&!Gi5)Vb$&-com)GuwvIBL{{}fScMrv%gqq1Gu;L{wqS=D zA}ae~dCefKx&Wue^ipzWJZ7j zXOrbS%~*l+4B-|15TG$lD8hF1;}EmhTVCA{%ItO^Ul121NsW&?6bK%9NRoQ!5CUZB zO|YcG$Vgw>H3Xqp1%I_^QV@c+R-jF?y|mH7qa2-(C z0ugQ8pDRw<4{n()NIJyegIV${HQGfO5|ixWN;7!nv;%PvB8%H$$MGRJ`}fQ6#kbes z>h&MMcTZrm#Ts3`fhrQak0q-hmbwneh)8_kw~}aV#&vv&0DQ zTMfe^L}O-h6u4_rJ&^vk4ik*_)7p25=@J%{bu-Se@_xIv$v4hVrK*YPiWBP+oJ5Ir zr3moEi=@SPav_d;H&n2Pu<`*W>zjWJNOw_DD_r~j28`tsSACjsxMemoPU@AB>{HW| ztXJMqrYlUW(>mdwMq$Dp@GE$mom`;n2e&N-yI52)$YiOCq+5IXJdE|zd*KS>5aSRb z&c)UdVb4DKNOFD!$C<8h{hnqg;riV@!i3$}=UGTOZpIU)>0{iquGsT|d?Y#Yne-5SPQrxRe+$>w;#JvMh{Q|>l$k-X z*)S}8wwajRf-*gjo*13Ddi{I2mrq!J6XOcRiG#RlA-3m(|8_HzBcDkRaoI^2U;8Bj zLQ1_>oIw~*j8y0k)gb88Fw%SV$TO(&Ik0F^e6@= zLHw>E1o&f_sL`n+G87&T9yqi}E?j2>(j)xilP|{{#Ely_L7r5{ctW;yF>b25Js}>`iO75R6BpgcE9|%%7ZRzD#1@K!W4(uK@LfLHB`NAX3qZf^YwSvp;i9@cqQ*)vIMW(V~k@y^(GFR zk?hjYBY8Jfi-jYuvcKGw#YY%vDItj}3 z7Q|uPsUF8INEZfRw#oQYFK+5{*aoL3O>O}4)g`9<@EtcFTw-*g{8$|m2r9KG(G1~; z5e{y}MqI4=Zwu&dpd`7ElAEf=5>(R5d?a55G39=D1mdJp{meN=dkKNp1|7_pf2kQ< za(hP&%AULsujtTO-x4$UA&=)46DW!dAjWf}ei8-FW91wTuZPe2cpnffC0y4@sv2)Mw;_ci|bZ`gPMKR{MfO zKlGq*A1TRFnjioxLQU_S-3#-w^pgr|akh3F*-@`3{jraTr2X0$DxU9J6 zonZ#3S7xR6ObDnNWJ8&AnybbQ=UC0Wae1hQ7p*{c(l)9RmncZ49Yhd#w`%) zJK~gOp5Ur+-DQnt#)LdUN8^=@2-enu2QF9ys>*XI-S-6QHw&K;_-m@Idn%23!X5>r z@k-;CZ74HNf_oumFy8=wOzyrX$n%YiOPc-`SB%=YvR_CYcdtRU%#lH0jzd^#(k@-di-hx~al>I_R&DnN#rm07DYJ+aF!NQPu( zbl)m=2e-pbn6kGOq%ozxMkhXFRl&@1RiUgum3Vj1u#)6jsv%5j<*IR6^t$emDShpN z7o|>QRl&?k@XAh_XN1|9@o5QNcLkjz8A*rcE*n}g+c*p5 z7~m;%`pNaTgO1TTk`ZiZ=Bn}0^D(8ryf5D9p^RE?AC-e7yN3;(S*bnf{JGme)u3~( zS$ORcqqFvg`t|$f)g;O&W!6%aW^l!m_k7b2$D02GPgh9AD1`()~cZ8Oj2AQyau(pP%|J;>TN`^P;r=4@@A|s=UjbU%Sr& zOCYBon0Iw=*%^D@^5cwU6_3(-JaBP001cn1^@s6z>|W`000J>NklgF+#9zZY7a#;@J(5X0e&McXK2n7+jhR}<0i-1U5t`>D@ zJSJ*^swjdwq0keUf9!BETXZhVyjqS4&z|?2HdJnOU-HYF_xSyu=XsCkdtVv=(53>u zME@3F*5J;OHwJNJdWK(ivQ??rr&t7M)1yRas=d_yYH>g+p#{( zm+NoyW%|8bNfUkAMrabri(FY#Dqr5%zhZA&e^iALHXiJOFYA7Qt##L_a?_z6SW{&J zVeyp#G&snW>SO{*%d9CGVM}xic~V`MU$)*JU1Nbw2YX?ywi}|VZ4g;$g)p^+DoLHR zZ^Zr$S_=f^oU`+!4K^?NsU;H{;bhhex#H7(!s52U&FJ}OHQf-VvVd?Btj2MhF|zQI z%l~jBr~6T7^_WIHC1>8j&bv`c18g|Z3*l-jgeoml1{oh++Y75JI)RgU>LEY<%)C)X zI2rZ2kb>s^4cZuYeq3!A}DS`X~>Nd;+A$4e;ZwyD<1@2!8$ZKJ3w%!6)+sCALy+bKwyk zqKCS6qEGWmJ)97b-QXY|`<0lS5THkEtGgjE>ojOvuftfM&Ugd-rQg9C+|FdGM)HXs z(IxsA$&r(xg_j^4=hC;>s;1UF*Wp1I-2~sEF zZYgb?&`4bM1qjM*hR`yr3qJ(;L>Kj2XpBUy+)t((6z;bIr@-ihFNVAl4<#?{TWIaQ zIi>;YjXS_iIfNb?!N1t-!Y6vZvW5ZXE{%l7imzV9NvV4nf#G`Pcex;#@}?EINwsk7 z>UC=SlJC*b5a>-mgHP%q2+qF;cbNx ztCV@{s&fPsSt#;i@#G-m$as&$gLaG}ebOrtS5*22&glbhMH_fz8(~qVVN!VIVCKzg z1$U9^93(E%Ur9v_R*h#!t)Ce+#)+m(q^zCq%g&L-!E zC&et9WrT(49pl0S`?=DK7=`+;`CB!wP3ta97b)XdJ8K=@`DXOk0Q0};7zNT!`k4t@ z+)=9S)4p(jEGm5!qq)PDTmXiw3qDM19|fiylc@LtiQ=}Kfb#w&ckv^7tBj;cfwtY$q?IdliYlg zqh@4;IyW)OFPQPw4z|JsAEb7`+@yA@Q8SXQT#;upV`QNJ59Bg5m(jci3`0T4X-&^GU6)x7$Vi0XMWB(2hrdK^!hq0 zt!bDg$Hh)-9L62h`&{0PBf%7vM>69o`k4~kx^Wc)?lG!}=WgV2x-rq?HN#jMr^B0; p5zMeb2q5MEX5{g&Aa%N&e*pr!t%ZZ}>w*9P002ovPDHLkV1gpUS8xCT diff --git a/www7/sites/all/libraries/leaflet/images/marker-shadow.png b/www7/sites/all/libraries/leaflet/images/marker-shadow.png deleted file mode 100644 index d1e773c715a9b508ebea055c4bb4b0a2ad7f6e52..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 797 zcmV+&1LFLNP)oNwbRQ6Eq$4M3RDU@$ z<4cV9zWLV=bA&uX9wCpA{{f^4$D#k>GcX53-UQqf>_LzMU@frMz|MwbfQGbY0?ccG zBj_wh0?6Tv;HWR0`x;m^Bm<;sCm_85SGspFBn6|A!tDh$nR`wGorGkyL7j?F3#OJq zIswLIz;iF7f|LMnF(pXPAY*GYpsw%&e_WjlnV`C$6@#Q7GZu1$Q8>&p8=(iJj8o|T~0u%hM*Yg_d(Av{WS$h&pM%nlEAonVL0;DkN|xc zn)9F+aMDk#VtAMb0c=kIb1pU-$e4$3pwo&qVh(Umlw3_IU_dFcFe(In6*x}D4LHLhFZ4N=V2ZR+>XHU5D&uY$npJ7Eu?{iAK>UxC?4uyg4+iD z!nst**H%2zhOBxc7C7Tv{f^`%hqT1KpU@Vf6+C2|bGaR(1~TU5D-1;&HXT~PMc2Lu z{Q%^i6vvox&EMFT7I_)R$xq1779I8kE@?|D*cLWnP0a@a)xJA`o*^$^V(yN)b`kV7 z=o@jbFF4j{KeuQh - var sources = Array.prototype.slice.call(arguments, 1), - i, j, len, src; - - for (j = 0, len = sources.length; j < len; j++) { - src = sources[j] || {}; - for (i in src) { - if (src.hasOwnProperty(i)) { - dest[i] = src[i]; - } - } - } - return dest; - }, - - bind: function (fn, obj) { // (Function, Object) -> Function - var args = arguments.length > 2 ? Array.prototype.slice.call(arguments, 2) : null; - return function () { - return fn.apply(obj, args || arguments); - }; - }, - - stamp: (function () { - var lastId = 0, - key = '_leaflet_id'; - return function (obj) { - obj[key] = obj[key] || ++lastId; - return obj[key]; - }; - }()), - - invokeEach: function (obj, method, context) { - var i, args; - - if (typeof obj === 'object') { - args = Array.prototype.slice.call(arguments, 3); - - for (i in obj) { - method.apply(context, [i, obj[i]].concat(args)); - } - return true; - } - - return false; - }, - - limitExecByInterval: function (fn, time, context) { - var lock, execOnUnlock; - - return function wrapperFn() { - var args = arguments; - - if (lock) { - execOnUnlock = true; - return; - } - - lock = true; - - setTimeout(function () { - lock = false; - - if (execOnUnlock) { - wrapperFn.apply(context, args); - execOnUnlock = false; - } - }, time); - - fn.apply(context, args); - }; - }, - - falseFn: function () { - return false; - }, - - formatNum: function (num, digits) { - var pow = Math.pow(10, digits || 5); - return Math.round(num * pow) / pow; - }, - - trim: function (str) { - return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ''); - }, - - splitWords: function (str) { - return L.Util.trim(str).split(/\s+/); - }, - - setOptions: function (obj, options) { - obj.options = L.extend({}, obj.options, options); - return obj.options; - }, - - getParamString: function (obj, existingUrl, uppercase) { - var params = []; - for (var i in obj) { - params.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i])); - } - return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&'); - }, - template: function (str, data) { - return str.replace(/\{ *([\w_]+) *\}/g, function (str, key) { - var value = data[key]; - if (value === undefined) { - throw new Error('No value provided for variable ' + str); - } else if (typeof value === 'function') { - value = value(data); - } - return value; - }); - }, - - isArray: Array.isArray || function (obj) { - return (Object.prototype.toString.call(obj) === '[object Array]'); - }, - - emptyImageUrl: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=' -}; - -(function () { - - // inspired by http://paulirish.com/2011/requestanimationframe-for-smart-animating/ - - function getPrefixed(name) { - var i, fn, - prefixes = ['webkit', 'moz', 'o', 'ms']; - - for (i = 0; i < prefixes.length && !fn; i++) { - fn = window[prefixes[i] + name]; - } - - return fn; - } - - var lastTime = 0; - - function timeoutDefer(fn) { - var time = +new Date(), - timeToCall = Math.max(0, 16 - (time - lastTime)); - - lastTime = time + timeToCall; - return window.setTimeout(fn, timeToCall); - } - - var requestFn = window.requestAnimationFrame || - getPrefixed('RequestAnimationFrame') || timeoutDefer; - - var cancelFn = window.cancelAnimationFrame || - getPrefixed('CancelAnimationFrame') || - getPrefixed('CancelRequestAnimationFrame') || - function (id) { window.clearTimeout(id); }; - - - L.Util.requestAnimFrame = function (fn, context, immediate, element) { - fn = L.bind(fn, context); - - if (immediate && requestFn === timeoutDefer) { - fn(); - } else { - return requestFn.call(window, fn, element); - } - }; - - L.Util.cancelAnimFrame = function (id) { - if (id) { - cancelFn.call(window, id); - } - }; - -}()); - -// shortcuts for most used utility functions -L.extend = L.Util.extend; -L.bind = L.Util.bind; -L.stamp = L.Util.stamp; -L.setOptions = L.Util.setOptions; - - -/* - * L.Class powers the OOP facilities of the library. - * Thanks to John Resig and Dean Edwards for inspiration! - */ - -L.Class = function () {}; - -L.Class.extend = function (props) { - - // extended class with the new prototype - var NewClass = function () { - - // call the constructor - if (this.initialize) { - this.initialize.apply(this, arguments); - } - - // call all constructor hooks - if (this._initHooks) { - this.callInitHooks(); - } - }; - - // instantiate class without calling constructor - var F = function () {}; - F.prototype = this.prototype; - - var proto = new F(); - proto.constructor = NewClass; - - NewClass.prototype = proto; - - //inherit parent's statics - for (var i in this) { - if (this.hasOwnProperty(i) && i !== 'prototype') { - NewClass[i] = this[i]; - } - } - - // mix static properties into the class - if (props.statics) { - L.extend(NewClass, props.statics); - delete props.statics; - } - - // mix includes into the prototype - if (props.includes) { - L.Util.extend.apply(null, [proto].concat(props.includes)); - delete props.includes; - } - - // merge options - if (props.options && proto.options) { - props.options = L.extend({}, proto.options, props.options); - } - - // mix given properties into the prototype - L.extend(proto, props); - - proto._initHooks = []; - - var parent = this; - // jshint camelcase: false - NewClass.__super__ = parent.prototype; - - // add method for calling all hooks - proto.callInitHooks = function () { - - if (this._initHooksCalled) { return; } - - if (parent.prototype.callInitHooks) { - parent.prototype.callInitHooks.call(this); - } - - this._initHooksCalled = true; - - for (var i = 0, len = proto._initHooks.length; i < len; i++) { - proto._initHooks[i].call(this); - } - }; - - return NewClass; -}; - - -// method for adding properties to prototype -L.Class.include = function (props) { - L.extend(this.prototype, props); -}; - -// merge new default options to the Class -L.Class.mergeOptions = function (options) { - L.extend(this.prototype.options, options); -}; - -// add a constructor hook -L.Class.addInitHook = function (fn) { // (Function) || (String, args...) - var args = Array.prototype.slice.call(arguments, 1); - - var init = typeof fn === 'function' ? fn : function () { - this[fn].apply(this, args); - }; - - this.prototype._initHooks = this.prototype._initHooks || []; - this.prototype._initHooks.push(init); -}; - - -/* - * L.Mixin.Events is used to add custom events functionality to Leaflet classes. - */ - -var eventsKey = '_leaflet_events'; - -L.Mixin = {}; - -L.Mixin.Events = { - - addEventListener: function (types, fn, context) { // (String, Function[, Object]) or (Object[, Object]) - - // types can be a map of types/handlers - if (L.Util.invokeEach(types, this.addEventListener, this, fn, context)) { return this; } - - var events = this[eventsKey] = this[eventsKey] || {}, - contextId = context && context !== this && L.stamp(context), - i, len, event, type, indexKey, indexLenKey, typeIndex; - - // types can be a string of space-separated words - types = L.Util.splitWords(types); - - for (i = 0, len = types.length; i < len; i++) { - event = { - action: fn, - context: context || this - }; - type = types[i]; - - if (contextId) { - // store listeners of a particular context in a separate hash (if it has an id) - // gives a major performance boost when removing thousands of map layers - - indexKey = type + '_idx'; - indexLenKey = indexKey + '_len'; - - typeIndex = events[indexKey] = events[indexKey] || {}; - - if (!typeIndex[contextId]) { - typeIndex[contextId] = []; - - // keep track of the number of keys in the index to quickly check if it's empty - events[indexLenKey] = (events[indexLenKey] || 0) + 1; - } - - typeIndex[contextId].push(event); - - - } else { - events[type] = events[type] || []; - events[type].push(event); - } - } - - return this; - }, - - hasEventListeners: function (type) { // (String) -> Boolean - var events = this[eventsKey]; - return !!events && ((type in events && events[type].length > 0) || - (type + '_idx' in events && events[type + '_idx_len'] > 0)); - }, - - removeEventListener: function (types, fn, context) { // ([String, Function, Object]) or (Object[, Object]) - - if (!this[eventsKey]) { - return this; - } - - if (!types) { - return this.clearAllEventListeners(); - } - - if (L.Util.invokeEach(types, this.removeEventListener, this, fn, context)) { return this; } - - var events = this[eventsKey], - contextId = context && context !== this && L.stamp(context), - i, len, type, listeners, j, indexKey, indexLenKey, typeIndex, removed; - - types = L.Util.splitWords(types); - - for (i = 0, len = types.length; i < len; i++) { - type = types[i]; - indexKey = type + '_idx'; - indexLenKey = indexKey + '_len'; - - typeIndex = events[indexKey]; - - if (!fn) { - // clear all listeners for a type if function isn't specified - delete events[type]; - delete events[indexKey]; - delete events[indexLenKey]; - - } else { - listeners = contextId && typeIndex ? typeIndex[contextId] : events[type]; - - if (listeners) { - for (j = listeners.length - 1; j >= 0; j--) { - if ((listeners[j].action === fn) && (!context || (listeners[j].context === context))) { - removed = listeners.splice(j, 1); - // set the old action to a no-op, because it is possible - // that the listener is being iterated over as part of a dispatch - removed[0].action = L.Util.falseFn; - } - } - - if (context && typeIndex && (listeners.length === 0)) { - delete typeIndex[contextId]; - events[indexLenKey]--; - } - } - } - } - - return this; - }, - - clearAllEventListeners: function () { - delete this[eventsKey]; - return this; - }, - - fireEvent: function (type, data) { // (String[, Object]) - if (!this.hasEventListeners(type)) { - return this; - } - - var event = L.Util.extend({}, data, { type: type, target: this }); - - var events = this[eventsKey], - listeners, i, len, typeIndex, contextId; - - if (events[type]) { - // make sure adding/removing listeners inside other listeners won't cause infinite loop - listeners = events[type].slice(); - - for (i = 0, len = listeners.length; i < len; i++) { - listeners[i].action.call(listeners[i].context, event); - } - } - - // fire event for the context-indexed listeners as well - typeIndex = events[type + '_idx']; - - for (contextId in typeIndex) { - listeners = typeIndex[contextId].slice(); - - if (listeners) { - for (i = 0, len = listeners.length; i < len; i++) { - listeners[i].action.call(listeners[i].context, event); - } - } - } - - return this; - }, - - addOneTimeEventListener: function (types, fn, context) { - - if (L.Util.invokeEach(types, this.addOneTimeEventListener, this, fn, context)) { return this; } - - var handler = L.bind(function () { - this - .removeEventListener(types, fn, context) - .removeEventListener(types, handler, context); - }, this); - - return this - .addEventListener(types, fn, context) - .addEventListener(types, handler, context); - } -}; - -L.Mixin.Events.on = L.Mixin.Events.addEventListener; -L.Mixin.Events.off = L.Mixin.Events.removeEventListener; -L.Mixin.Events.once = L.Mixin.Events.addOneTimeEventListener; -L.Mixin.Events.fire = L.Mixin.Events.fireEvent; - - -/* - * L.Browser handles different browser and feature detections for internal Leaflet use. - */ - -(function () { - - var ie = 'ActiveXObject' in window, - ielt9 = ie && !document.addEventListener, - - // terrible browser detection to work around Safari / iOS / Android browser bugs - ua = navigator.userAgent.toLowerCase(), - webkit = ua.indexOf('webkit') !== -1, - chrome = ua.indexOf('chrome') !== -1, - phantomjs = ua.indexOf('phantom') !== -1, - android = ua.indexOf('android') !== -1, - android23 = ua.search('android [23]') !== -1, - gecko = ua.indexOf('gecko') !== -1, - - mobile = typeof orientation !== undefined + '', - msPointer = window.navigator && window.navigator.msPointerEnabled && - window.navigator.msMaxTouchPoints && !window.PointerEvent, - pointer = (window.PointerEvent && window.navigator.pointerEnabled && window.navigator.maxTouchPoints) || - msPointer, - retina = ('devicePixelRatio' in window && window.devicePixelRatio > 1) || - ('matchMedia' in window && window.matchMedia('(min-resolution:144dpi)') && - window.matchMedia('(min-resolution:144dpi)').matches), - - doc = document.documentElement, - ie3d = ie && ('transition' in doc.style), - webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23, - gecko3d = 'MozPerspective' in doc.style, - opera3d = 'OTransition' in doc.style, - any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d) && !phantomjs; - - - // PhantomJS has 'ontouchstart' in document.documentElement, but doesn't actually support touch. - // https://github.com/Leaflet/Leaflet/pull/1434#issuecomment-13843151 - - var touch = !window.L_NO_TOUCH && !phantomjs && (function () { - - var startName = 'ontouchstart'; - - // IE10+ (We simulate these into touch* events in L.DomEvent and L.DomEvent.Pointer) or WebKit, etc. - if (pointer || (startName in doc)) { - return true; - } - - // Firefox/Gecko - var div = document.createElement('div'), - supported = false; - - if (!div.setAttribute) { - return false; - } - div.setAttribute(startName, 'return;'); - - if (typeof div[startName] === 'function') { - supported = true; - } - - div.removeAttribute(startName); - div = null; - - return supported; - }()); - - - L.Browser = { - ie: ie, - ielt9: ielt9, - webkit: webkit, - gecko: gecko && !webkit && !window.opera && !ie, - - android: android, - android23: android23, - - chrome: chrome, - - ie3d: ie3d, - webkit3d: webkit3d, - gecko3d: gecko3d, - opera3d: opera3d, - any3d: any3d, - - mobile: mobile, - mobileWebkit: mobile && webkit, - mobileWebkit3d: mobile && webkit3d, - mobileOpera: mobile && window.opera, - - touch: touch, - msPointer: msPointer, - pointer: pointer, - - retina: retina - }; - -}()); - - -/* - * L.Point represents a point with x and y coordinates. - */ - -L.Point = function (/*Number*/ x, /*Number*/ y, /*Boolean*/ round) { - this.x = (round ? Math.round(x) : x); - this.y = (round ? Math.round(y) : y); -}; - -L.Point.prototype = { - - clone: function () { - return new L.Point(this.x, this.y); - }, - - // non-destructive, returns a new point - add: function (point) { - return this.clone()._add(L.point(point)); - }, - - // destructive, used directly for performance in situations where it's safe to modify existing point - _add: function (point) { - this.x += point.x; - this.y += point.y; - return this; - }, - - subtract: function (point) { - return this.clone()._subtract(L.point(point)); - }, - - _subtract: function (point) { - this.x -= point.x; - this.y -= point.y; - return this; - }, - - divideBy: function (num) { - return this.clone()._divideBy(num); - }, - - _divideBy: function (num) { - this.x /= num; - this.y /= num; - return this; - }, - - multiplyBy: function (num) { - return this.clone()._multiplyBy(num); - }, - - _multiplyBy: function (num) { - this.x *= num; - this.y *= num; - return this; - }, - - round: function () { - return this.clone()._round(); - }, - - _round: function () { - this.x = Math.round(this.x); - this.y = Math.round(this.y); - return this; - }, - - floor: function () { - return this.clone()._floor(); - }, - - _floor: function () { - this.x = Math.floor(this.x); - this.y = Math.floor(this.y); - return this; - }, - - distanceTo: function (point) { - point = L.point(point); - - var x = point.x - this.x, - y = point.y - this.y; - - return Math.sqrt(x * x + y * y); - }, - - equals: function (point) { - point = L.point(point); - - return point.x === this.x && - point.y === this.y; - }, - - contains: function (point) { - point = L.point(point); - - return Math.abs(point.x) <= Math.abs(this.x) && - Math.abs(point.y) <= Math.abs(this.y); - }, - - toString: function () { - return 'Point(' + - L.Util.formatNum(this.x) + ', ' + - L.Util.formatNum(this.y) + ')'; - } -}; - -L.point = function (x, y, round) { - if (x instanceof L.Point) { - return x; - } - if (L.Util.isArray(x)) { - return new L.Point(x[0], x[1]); - } - if (x === undefined || x === null) { - return x; - } - return new L.Point(x, y, round); -}; - - -/* - * L.Bounds represents a rectangular area on the screen in pixel coordinates. - */ - -L.Bounds = function (a, b) { //(Point, Point) or Point[] - if (!a) { return; } - - var points = b ? [a, b] : a; - - for (var i = 0, len = points.length; i < len; i++) { - this.extend(points[i]); - } -}; - -L.Bounds.prototype = { - // extend the bounds to contain the given point - extend: function (point) { // (Point) - point = L.point(point); - - if (!this.min && !this.max) { - this.min = point.clone(); - this.max = point.clone(); - } else { - this.min.x = Math.min(point.x, this.min.x); - this.max.x = Math.max(point.x, this.max.x); - this.min.y = Math.min(point.y, this.min.y); - this.max.y = Math.max(point.y, this.max.y); - } - return this; - }, - - getCenter: function (round) { // (Boolean) -> Point - return new L.Point( - (this.min.x + this.max.x) / 2, - (this.min.y + this.max.y) / 2, round); - }, - - getBottomLeft: function () { // -> Point - return new L.Point(this.min.x, this.max.y); - }, - - getTopRight: function () { // -> Point - return new L.Point(this.max.x, this.min.y); - }, - - getSize: function () { - return this.max.subtract(this.min); - }, - - contains: function (obj) { // (Bounds) or (Point) -> Boolean - var min, max; - - if (typeof obj[0] === 'number' || obj instanceof L.Point) { - obj = L.point(obj); - } else { - obj = L.bounds(obj); - } - - if (obj instanceof L.Bounds) { - min = obj.min; - max = obj.max; - } else { - min = max = obj; - } - - return (min.x >= this.min.x) && - (max.x <= this.max.x) && - (min.y >= this.min.y) && - (max.y <= this.max.y); - }, - - intersects: function (bounds) { // (Bounds) -> Boolean - bounds = L.bounds(bounds); - - var min = this.min, - max = this.max, - min2 = bounds.min, - max2 = bounds.max, - xIntersects = (max2.x >= min.x) && (min2.x <= max.x), - yIntersects = (max2.y >= min.y) && (min2.y <= max.y); - - return xIntersects && yIntersects; - }, - - isValid: function () { - return !!(this.min && this.max); - } -}; - -L.bounds = function (a, b) { // (Bounds) or (Point, Point) or (Point[]) - if (!a || a instanceof L.Bounds) { - return a; - } - return new L.Bounds(a, b); -}; - - -/* - * L.Transformation is an utility class to perform simple point transformations through a 2d-matrix. - */ - -L.Transformation = function (a, b, c, d) { - this._a = a; - this._b = b; - this._c = c; - this._d = d; -}; - -L.Transformation.prototype = { - transform: function (point, scale) { // (Point, Number) -> Point - return this._transform(point.clone(), scale); - }, - - // destructive transform (faster) - _transform: function (point, scale) { - scale = scale || 1; - point.x = scale * (this._a * point.x + this._b); - point.y = scale * (this._c * point.y + this._d); - return point; - }, - - untransform: function (point, scale) { - scale = scale || 1; - return new L.Point( - (point.x / scale - this._b) / this._a, - (point.y / scale - this._d) / this._c); - } -}; - - -/* - * L.DomUtil contains various utility functions for working with DOM. - */ - -L.DomUtil = { - get: function (id) { - return (typeof id === 'string' ? document.getElementById(id) : id); - }, - - getStyle: function (el, style) { - - var value = el.style[style]; - - if (!value && el.currentStyle) { - value = el.currentStyle[style]; - } - - if ((!value || value === 'auto') && document.defaultView) { - var css = document.defaultView.getComputedStyle(el, null); - value = css ? css[style] : null; - } - - return value === 'auto' ? null : value; - }, - - getViewportOffset: function (element) { - - var top = 0, - left = 0, - el = element, - docBody = document.body, - docEl = document.documentElement, - pos; - - do { - top += el.offsetTop || 0; - left += el.offsetLeft || 0; - - //add borders - top += parseInt(L.DomUtil.getStyle(el, 'borderTopWidth'), 10) || 0; - left += parseInt(L.DomUtil.getStyle(el, 'borderLeftWidth'), 10) || 0; - - pos = L.DomUtil.getStyle(el, 'position'); - - if (el.offsetParent === docBody && pos === 'absolute') { break; } - - if (pos === 'fixed') { - top += docBody.scrollTop || docEl.scrollTop || 0; - left += docBody.scrollLeft || docEl.scrollLeft || 0; - break; - } - - if (pos === 'relative' && !el.offsetLeft) { - var width = L.DomUtil.getStyle(el, 'width'), - maxWidth = L.DomUtil.getStyle(el, 'max-width'), - r = el.getBoundingClientRect(); - - if (width !== 'none' || maxWidth !== 'none') { - left += r.left + el.clientLeft; - } - - //calculate full y offset since we're breaking out of the loop - top += r.top + (docBody.scrollTop || docEl.scrollTop || 0); - - break; - } - - el = el.offsetParent; - - } while (el); - - el = element; - - do { - if (el === docBody) { break; } - - top -= el.scrollTop || 0; - left -= el.scrollLeft || 0; - - el = el.parentNode; - } while (el); - - return new L.Point(left, top); - }, - - documentIsLtr: function () { - if (!L.DomUtil._docIsLtrCached) { - L.DomUtil._docIsLtrCached = true; - L.DomUtil._docIsLtr = L.DomUtil.getStyle(document.body, 'direction') === 'ltr'; - } - return L.DomUtil._docIsLtr; - }, - - create: function (tagName, className, container) { - - var el = document.createElement(tagName); - el.className = className; - - if (container) { - container.appendChild(el); - } - - return el; - }, - - hasClass: function (el, name) { - if (el.classList !== undefined) { - return el.classList.contains(name); - } - var className = L.DomUtil._getClass(el); - return className.length > 0 && new RegExp('(^|\\s)' + name + '(\\s|$)').test(className); - }, - - addClass: function (el, name) { - if (el.classList !== undefined) { - var classes = L.Util.splitWords(name); - for (var i = 0, len = classes.length; i < len; i++) { - el.classList.add(classes[i]); - } - } else if (!L.DomUtil.hasClass(el, name)) { - var className = L.DomUtil._getClass(el); - L.DomUtil._setClass(el, (className ? className + ' ' : '') + name); - } - }, - - removeClass: function (el, name) { - if (el.classList !== undefined) { - el.classList.remove(name); - } else { - L.DomUtil._setClass(el, L.Util.trim((' ' + L.DomUtil._getClass(el) + ' ').replace(' ' + name + ' ', ' '))); - } - }, - - _setClass: function (el, name) { - if (el.className.baseVal === undefined) { - el.className = name; - } else { - // in case of SVG element - el.className.baseVal = name; - } - }, - - _getClass: function (el) { - return el.className.baseVal === undefined ? el.className : el.className.baseVal; - }, - - setOpacity: function (el, value) { - - if ('opacity' in el.style) { - el.style.opacity = value; - - } else if ('filter' in el.style) { - - var filter = false, - filterName = 'DXImageTransform.Microsoft.Alpha'; - - // filters collection throws an error if we try to retrieve a filter that doesn't exist - try { - filter = el.filters.item(filterName); - } catch (e) { - // don't set opacity to 1 if we haven't already set an opacity, - // it isn't needed and breaks transparent pngs. - if (value === 1) { return; } - } - - value = Math.round(value * 100); - - if (filter) { - filter.Enabled = (value !== 100); - filter.Opacity = value; - } else { - el.style.filter += ' progid:' + filterName + '(opacity=' + value + ')'; - } - } - }, - - testProp: function (props) { - - var style = document.documentElement.style; - - for (var i = 0; i < props.length; i++) { - if (props[i] in style) { - return props[i]; - } - } - return false; - }, - - getTranslateString: function (point) { - // on WebKit browsers (Chrome/Safari/iOS Safari/Android) using translate3d instead of translate - // makes animation smoother as it ensures HW accel is used. Firefox 13 doesn't care - // (same speed either way), Opera 12 doesn't support translate3d - - var is3d = L.Browser.webkit3d, - open = 'translate' + (is3d ? '3d' : '') + '(', - close = (is3d ? ',0' : '') + ')'; - - return open + point.x + 'px,' + point.y + 'px' + close; - }, - - getScaleString: function (scale, origin) { - - var preTranslateStr = L.DomUtil.getTranslateString(origin.add(origin.multiplyBy(-1 * scale))), - scaleStr = ' scale(' + scale + ') '; - - return preTranslateStr + scaleStr; - }, - - setPosition: function (el, point, disable3D) { // (HTMLElement, Point[, Boolean]) - - // jshint camelcase: false - el._leaflet_pos = point; - - if (!disable3D && L.Browser.any3d) { - el.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(point); - } else { - el.style.left = point.x + 'px'; - el.style.top = point.y + 'px'; - } - }, - - getPosition: function (el) { - // this method is only used for elements previously positioned using setPosition, - // so it's safe to cache the position for performance - - // jshint camelcase: false - return el._leaflet_pos; - } -}; - - -// prefix style property names - -L.DomUtil.TRANSFORM = L.DomUtil.testProp( - ['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform']); - -// webkitTransition comes first because some browser versions that drop vendor prefix don't do -// the same for the transitionend event, in particular the Android 4.1 stock browser - -L.DomUtil.TRANSITION = L.DomUtil.testProp( - ['webkitTransition', 'transition', 'OTransition', 'MozTransition', 'msTransition']); - -L.DomUtil.TRANSITION_END = - L.DomUtil.TRANSITION === 'webkitTransition' || L.DomUtil.TRANSITION === 'OTransition' ? - L.DomUtil.TRANSITION + 'End' : 'transitionend'; - -(function () { - if ('onselectstart' in document) { - L.extend(L.DomUtil, { - disableTextSelection: function () { - L.DomEvent.on(window, 'selectstart', L.DomEvent.preventDefault); - }, - - enableTextSelection: function () { - L.DomEvent.off(window, 'selectstart', L.DomEvent.preventDefault); - } - }); - } else { - var userSelectProperty = L.DomUtil.testProp( - ['userSelect', 'WebkitUserSelect', 'OUserSelect', 'MozUserSelect', 'msUserSelect']); - - L.extend(L.DomUtil, { - disableTextSelection: function () { - if (userSelectProperty) { - var style = document.documentElement.style; - this._userSelect = style[userSelectProperty]; - style[userSelectProperty] = 'none'; - } - }, - - enableTextSelection: function () { - if (userSelectProperty) { - document.documentElement.style[userSelectProperty] = this._userSelect; - delete this._userSelect; - } - } - }); - } - - L.extend(L.DomUtil, { - disableImageDrag: function () { - L.DomEvent.on(window, 'dragstart', L.DomEvent.preventDefault); - }, - - enableImageDrag: function () { - L.DomEvent.off(window, 'dragstart', L.DomEvent.preventDefault); - } - }); -})(); - - -/* - * L.LatLng represents a geographical point with latitude and longitude coordinates. - */ - -L.LatLng = function (lat, lng, alt) { // (Number, Number, Number) - lat = parseFloat(lat); - lng = parseFloat(lng); - - if (isNaN(lat) || isNaN(lng)) { - throw new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')'); - } - - this.lat = lat; - this.lng = lng; - - if (alt !== undefined) { - this.alt = parseFloat(alt); - } -}; - -L.extend(L.LatLng, { - DEG_TO_RAD: Math.PI / 180, - RAD_TO_DEG: 180 / Math.PI, - MAX_MARGIN: 1.0E-9 // max margin of error for the "equals" check -}); - -L.LatLng.prototype = { - equals: function (obj) { // (LatLng) -> Boolean - if (!obj) { return false; } - - obj = L.latLng(obj); - - var margin = Math.max( - Math.abs(this.lat - obj.lat), - Math.abs(this.lng - obj.lng)); - - return margin <= L.LatLng.MAX_MARGIN; - }, - - toString: function (precision) { // (Number) -> String - return 'LatLng(' + - L.Util.formatNum(this.lat, precision) + ', ' + - L.Util.formatNum(this.lng, precision) + ')'; - }, - - // Haversine distance formula, see http://en.wikipedia.org/wiki/Haversine_formula - // TODO move to projection code, LatLng shouldn't know about Earth - distanceTo: function (other) { // (LatLng) -> Number - other = L.latLng(other); - - var R = 6378137, // earth radius in meters - d2r = L.LatLng.DEG_TO_RAD, - dLat = (other.lat - this.lat) * d2r, - dLon = (other.lng - this.lng) * d2r, - lat1 = this.lat * d2r, - lat2 = other.lat * d2r, - sin1 = Math.sin(dLat / 2), - sin2 = Math.sin(dLon / 2); - - var a = sin1 * sin1 + sin2 * sin2 * Math.cos(lat1) * Math.cos(lat2); - - return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); - }, - - wrap: function (a, b) { // (Number, Number) -> LatLng - var lng = this.lng; - - a = a || -180; - b = b || 180; - - lng = (lng + b) % (b - a) + (lng < a || lng === b ? b : a); - - return new L.LatLng(this.lat, lng); - } -}; - -L.latLng = function (a, b) { // (LatLng) or ([Number, Number]) or (Number, Number) - if (a instanceof L.LatLng) { - return a; - } - if (L.Util.isArray(a)) { - if (typeof a[0] === 'number' || typeof a[0] === 'string') { - return new L.LatLng(a[0], a[1], a[2]); - } else { - return null; - } - } - if (a === undefined || a === null) { - return a; - } - if (typeof a === 'object' && 'lat' in a) { - return new L.LatLng(a.lat, 'lng' in a ? a.lng : a.lon); - } - if (b === undefined) { - return null; - } - return new L.LatLng(a, b); -}; - - - -/* - * L.LatLngBounds represents a rectangular area on the map in geographical coordinates. - */ - -L.LatLngBounds = function (southWest, northEast) { // (LatLng, LatLng) or (LatLng[]) - if (!southWest) { return; } - - var latlngs = northEast ? [southWest, northEast] : southWest; - - for (var i = 0, len = latlngs.length; i < len; i++) { - this.extend(latlngs[i]); - } -}; - -L.LatLngBounds.prototype = { - // extend the bounds to contain the given point or bounds - extend: function (obj) { // (LatLng) or (LatLngBounds) - if (!obj) { return this; } - - var latLng = L.latLng(obj); - if (latLng !== null) { - obj = latLng; - } else { - obj = L.latLngBounds(obj); - } - - if (obj instanceof L.LatLng) { - if (!this._southWest && !this._northEast) { - this._southWest = new L.LatLng(obj.lat, obj.lng); - this._northEast = new L.LatLng(obj.lat, obj.lng); - } else { - this._southWest.lat = Math.min(obj.lat, this._southWest.lat); - this._southWest.lng = Math.min(obj.lng, this._southWest.lng); - - this._northEast.lat = Math.max(obj.lat, this._northEast.lat); - this._northEast.lng = Math.max(obj.lng, this._northEast.lng); - } - } else if (obj instanceof L.LatLngBounds) { - this.extend(obj._southWest); - this.extend(obj._northEast); - } - return this; - }, - - // extend the bounds by a percentage - pad: function (bufferRatio) { // (Number) -> LatLngBounds - var sw = this._southWest, - ne = this._northEast, - heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio, - widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio; - - return new L.LatLngBounds( - new L.LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer), - new L.LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer)); - }, - - getCenter: function () { // -> LatLng - return new L.LatLng( - (this._southWest.lat + this._northEast.lat) / 2, - (this._southWest.lng + this._northEast.lng) / 2); - }, - - getSouthWest: function () { - return this._southWest; - }, - - getNorthEast: function () { - return this._northEast; - }, - - getNorthWest: function () { - return new L.LatLng(this.getNorth(), this.getWest()); - }, - - getSouthEast: function () { - return new L.LatLng(this.getSouth(), this.getEast()); - }, - - getWest: function () { - return this._southWest.lng; - }, - - getSouth: function () { - return this._southWest.lat; - }, - - getEast: function () { - return this._northEast.lng; - }, - - getNorth: function () { - return this._northEast.lat; - }, - - contains: function (obj) { // (LatLngBounds) or (LatLng) -> Boolean - if (typeof obj[0] === 'number' || obj instanceof L.LatLng) { - obj = L.latLng(obj); - } else { - obj = L.latLngBounds(obj); - } - - var sw = this._southWest, - ne = this._northEast, - sw2, ne2; - - if (obj instanceof L.LatLngBounds) { - sw2 = obj.getSouthWest(); - ne2 = obj.getNorthEast(); - } else { - sw2 = ne2 = obj; - } - - return (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) && - (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng); - }, - - intersects: function (bounds) { // (LatLngBounds) - bounds = L.latLngBounds(bounds); - - var sw = this._southWest, - ne = this._northEast, - sw2 = bounds.getSouthWest(), - ne2 = bounds.getNorthEast(), - - latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat), - lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng); - - return latIntersects && lngIntersects; - }, - - toBBoxString: function () { - return [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(','); - }, - - equals: function (bounds) { // (LatLngBounds) - if (!bounds) { return false; } - - bounds = L.latLngBounds(bounds); - - return this._southWest.equals(bounds.getSouthWest()) && - this._northEast.equals(bounds.getNorthEast()); - }, - - isValid: function () { - return !!(this._southWest && this._northEast); - } -}; - -//TODO International date line? - -L.latLngBounds = function (a, b) { // (LatLngBounds) or (LatLng, LatLng) - if (!a || a instanceof L.LatLngBounds) { - return a; - } - return new L.LatLngBounds(a, b); -}; - - -/* - * L.Projection contains various geographical projections used by CRS classes. - */ - -L.Projection = {}; - - -/* - * Spherical Mercator is the most popular map projection, used by EPSG:3857 CRS used by default. - */ - -L.Projection.SphericalMercator = { - MAX_LATITUDE: 85.0511287798, - - project: function (latlng) { // (LatLng) -> Point - var d = L.LatLng.DEG_TO_RAD, - max = this.MAX_LATITUDE, - lat = Math.max(Math.min(max, latlng.lat), -max), - x = latlng.lng * d, - y = lat * d; - - y = Math.log(Math.tan((Math.PI / 4) + (y / 2))); - - return new L.Point(x, y); - }, - - unproject: function (point) { // (Point, Boolean) -> LatLng - var d = L.LatLng.RAD_TO_DEG, - lng = point.x * d, - lat = (2 * Math.atan(Math.exp(point.y)) - (Math.PI / 2)) * d; - - return new L.LatLng(lat, lng); - } -}; - - -/* - * Simple equirectangular (Plate Carree) projection, used by CRS like EPSG:4326 and Simple. - */ - -L.Projection.LonLat = { - project: function (latlng) { - return new L.Point(latlng.lng, latlng.lat); - }, - - unproject: function (point) { - return new L.LatLng(point.y, point.x); - } -}; - - -/* - * L.CRS is a base object for all defined CRS (Coordinate Reference Systems) in Leaflet. - */ - -L.CRS = { - latLngToPoint: function (latlng, zoom) { // (LatLng, Number) -> Point - var projectedPoint = this.projection.project(latlng), - scale = this.scale(zoom); - - return this.transformation._transform(projectedPoint, scale); - }, - - pointToLatLng: function (point, zoom) { // (Point, Number[, Boolean]) -> LatLng - var scale = this.scale(zoom), - untransformedPoint = this.transformation.untransform(point, scale); - - return this.projection.unproject(untransformedPoint); - }, - - project: function (latlng) { - return this.projection.project(latlng); - }, - - scale: function (zoom) { - return 256 * Math.pow(2, zoom); - }, - - getSize: function (zoom) { - var s = this.scale(zoom); - return L.point(s, s); - } -}; - - -/* - * A simple CRS that can be used for flat non-Earth maps like panoramas or game maps. - */ - -L.CRS.Simple = L.extend({}, L.CRS, { - projection: L.Projection.LonLat, - transformation: new L.Transformation(1, 0, -1, 0), - - scale: function (zoom) { - return Math.pow(2, zoom); - } -}); - - -/* - * L.CRS.EPSG3857 (Spherical Mercator) is the most common CRS for web mapping - * and is used by Leaflet by default. - */ - -L.CRS.EPSG3857 = L.extend({}, L.CRS, { - code: 'EPSG:3857', - - projection: L.Projection.SphericalMercator, - transformation: new L.Transformation(0.5 / Math.PI, 0.5, -0.5 / Math.PI, 0.5), - - project: function (latlng) { // (LatLng) -> Point - var projectedPoint = this.projection.project(latlng), - earthRadius = 6378137; - return projectedPoint.multiplyBy(earthRadius); - } -}); - -L.CRS.EPSG900913 = L.extend({}, L.CRS.EPSG3857, { - code: 'EPSG:900913' -}); - - -/* - * L.CRS.EPSG4326 is a CRS popular among advanced GIS specialists. - */ - -L.CRS.EPSG4326 = L.extend({}, L.CRS, { - code: 'EPSG:4326', - - projection: L.Projection.LonLat, - transformation: new L.Transformation(1 / 360, 0.5, -1 / 360, 0.5) -}); - - -/* - * L.Map is the central class of the API - it is used to create a map. - */ - -L.Map = L.Class.extend({ - - includes: L.Mixin.Events, - - options: { - crs: L.CRS.EPSG3857, - - /* - center: LatLng, - zoom: Number, - layers: Array, - */ - - fadeAnimation: L.DomUtil.TRANSITION && !L.Browser.android23, - trackResize: true, - markerZoomAnimation: L.DomUtil.TRANSITION && L.Browser.any3d - }, - - initialize: function (id, options) { // (HTMLElement or String, Object) - options = L.setOptions(this, options); - - - this._initContainer(id); - this._initLayout(); - - // hack for https://github.com/Leaflet/Leaflet/issues/1980 - this._onResize = L.bind(this._onResize, this); - - this._initEvents(); - - if (options.maxBounds) { - this.setMaxBounds(options.maxBounds); - } - - if (options.center && options.zoom !== undefined) { - this.setView(L.latLng(options.center), options.zoom, {reset: true}); - } - - this._handlers = []; - - this._layers = {}; - this._zoomBoundLayers = {}; - this._tileLayersNum = 0; - - this.callInitHooks(); - - this._addLayers(options.layers); - }, - - - // public methods that modify map state - - // replaced by animation-powered implementation in Map.PanAnimation.js - setView: function (center, zoom) { - zoom = zoom === undefined ? this.getZoom() : zoom; - this._resetView(L.latLng(center), this._limitZoom(zoom)); - return this; - }, - - setZoom: function (zoom, options) { - if (!this._loaded) { - this._zoom = this._limitZoom(zoom); - return this; - } - return this.setView(this.getCenter(), zoom, {zoom: options}); - }, - - zoomIn: function (delta, options) { - return this.setZoom(this._zoom + (delta || 1), options); - }, - - zoomOut: function (delta, options) { - return this.setZoom(this._zoom - (delta || 1), options); - }, - - setZoomAround: function (latlng, zoom, options) { - var scale = this.getZoomScale(zoom), - viewHalf = this.getSize().divideBy(2), - containerPoint = latlng instanceof L.Point ? latlng : this.latLngToContainerPoint(latlng), - - centerOffset = containerPoint.subtract(viewHalf).multiplyBy(1 - 1 / scale), - newCenter = this.containerPointToLatLng(viewHalf.add(centerOffset)); - - return this.setView(newCenter, zoom, {zoom: options}); - }, - - fitBounds: function (bounds, options) { - - options = options || {}; - bounds = bounds.getBounds ? bounds.getBounds() : L.latLngBounds(bounds); - - var paddingTL = L.point(options.paddingTopLeft || options.padding || [0, 0]), - paddingBR = L.point(options.paddingBottomRight || options.padding || [0, 0]), - - zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR)), - paddingOffset = paddingBR.subtract(paddingTL).divideBy(2), - - swPoint = this.project(bounds.getSouthWest(), zoom), - nePoint = this.project(bounds.getNorthEast(), zoom), - center = this.unproject(swPoint.add(nePoint).divideBy(2).add(paddingOffset), zoom); - - zoom = options && options.maxZoom ? Math.min(options.maxZoom, zoom) : zoom; - - return this.setView(center, zoom, options); - }, - - fitWorld: function (options) { - return this.fitBounds([[-90, -180], [90, 180]], options); - }, - - panTo: function (center, options) { // (LatLng) - return this.setView(center, this._zoom, {pan: options}); - }, - - panBy: function (offset) { // (Point) - // replaced with animated panBy in Map.PanAnimation.js - this.fire('movestart'); - - this._rawPanBy(L.point(offset)); - - this.fire('move'); - return this.fire('moveend'); - }, - - setMaxBounds: function (bounds) { - bounds = L.latLngBounds(bounds); - - this.options.maxBounds = bounds; - - if (!bounds) { - return this.off('moveend', this._panInsideMaxBounds, this); - } - - if (this._loaded) { - this._panInsideMaxBounds(); - } - - return this.on('moveend', this._panInsideMaxBounds, this); - }, - - panInsideBounds: function (bounds, options) { - var center = this.getCenter(), - newCenter = this._limitCenter(center, this._zoom, bounds); - - if (center.equals(newCenter)) { return this; } - - return this.panTo(newCenter, options); - }, - - addLayer: function (layer) { - // TODO method is too big, refactor - - var id = L.stamp(layer); - - if (this._layers[id]) { return this; } - - this._layers[id] = layer; - - // TODO getMaxZoom, getMinZoom in ILayer (instead of options) - if (layer.options && (!isNaN(layer.options.maxZoom) || !isNaN(layer.options.minZoom))) { - this._zoomBoundLayers[id] = layer; - this._updateZoomLevels(); - } - - // TODO looks ugly, refactor!!! - if (this.options.zoomAnimation && L.TileLayer && (layer instanceof L.TileLayer)) { - this._tileLayersNum++; - this._tileLayersToLoad++; - layer.on('load', this._onTileLayerLoad, this); - } - - if (this._loaded) { - this._layerAdd(layer); - } - - return this; - }, - - removeLayer: function (layer) { - var id = L.stamp(layer); - - if (!this._layers[id]) { return this; } - - if (this._loaded) { - layer.onRemove(this); - } - - delete this._layers[id]; - - if (this._loaded) { - this.fire('layerremove', {layer: layer}); - } - - if (this._zoomBoundLayers[id]) { - delete this._zoomBoundLayers[id]; - this._updateZoomLevels(); - } - - // TODO looks ugly, refactor - if (this.options.zoomAnimation && L.TileLayer && (layer instanceof L.TileLayer)) { - this._tileLayersNum--; - this._tileLayersToLoad--; - layer.off('load', this._onTileLayerLoad, this); - } - - return this; - }, - - hasLayer: function (layer) { - if (!layer) { return false; } - - return (L.stamp(layer) in this._layers); - }, - - eachLayer: function (method, context) { - for (var i in this._layers) { - method.call(context, this._layers[i]); - } - return this; - }, - - invalidateSize: function (options) { - if (!this._loaded) { return this; } - - options = L.extend({ - animate: false, - pan: true - }, options === true ? {animate: true} : options); - - var oldSize = this.getSize(); - this._sizeChanged = true; - this._initialCenter = null; - - var newSize = this.getSize(), - oldCenter = oldSize.divideBy(2).round(), - newCenter = newSize.divideBy(2).round(), - offset = oldCenter.subtract(newCenter); - - if (!offset.x && !offset.y) { return this; } - - if (options.animate && options.pan) { - this.panBy(offset); - - } else { - if (options.pan) { - this._rawPanBy(offset); - } - - this.fire('move'); - - if (options.debounceMoveend) { - clearTimeout(this._sizeTimer); - this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200); - } else { - this.fire('moveend'); - } - } - - return this.fire('resize', { - oldSize: oldSize, - newSize: newSize - }); - }, - - // TODO handler.addTo - addHandler: function (name, HandlerClass) { - if (!HandlerClass) { return this; } - - var handler = this[name] = new HandlerClass(this); - - this._handlers.push(handler); - - if (this.options[name]) { - handler.enable(); - } - - return this; - }, - - remove: function () { - if (this._loaded) { - this.fire('unload'); - } - - this._initEvents('off'); - - try { - // throws error in IE6-8 - delete this._container._leaflet; - } catch (e) { - this._container._leaflet = undefined; - } - - this._clearPanes(); - if (this._clearControlPos) { - this._clearControlPos(); - } - - this._clearHandlers(); - - return this; - }, - - - // public methods for getting map state - - getCenter: function () { // (Boolean) -> LatLng - this._checkIfLoaded(); - - if (this._initialCenter && !this._moved()) { - return this._initialCenter; - } - return this.layerPointToLatLng(this._getCenterLayerPoint()); - }, - - getZoom: function () { - return this._zoom; - }, - - getBounds: function () { - var bounds = this.getPixelBounds(), - sw = this.unproject(bounds.getBottomLeft()), - ne = this.unproject(bounds.getTopRight()); - - return new L.LatLngBounds(sw, ne); - }, - - getMinZoom: function () { - return this.options.minZoom === undefined ? - (this._layersMinZoom === undefined ? 0 : this._layersMinZoom) : - this.options.minZoom; - }, - - getMaxZoom: function () { - return this.options.maxZoom === undefined ? - (this._layersMaxZoom === undefined ? Infinity : this._layersMaxZoom) : - this.options.maxZoom; - }, - - getBoundsZoom: function (bounds, inside, padding) { // (LatLngBounds[, Boolean, Point]) -> Number - bounds = L.latLngBounds(bounds); - - var zoom = this.getMinZoom() - (inside ? 1 : 0), - maxZoom = this.getMaxZoom(), - size = this.getSize(), - - nw = bounds.getNorthWest(), - se = bounds.getSouthEast(), - - zoomNotFound = true, - boundsSize; - - padding = L.point(padding || [0, 0]); - - do { - zoom++; - boundsSize = this.project(se, zoom).subtract(this.project(nw, zoom)).add(padding); - zoomNotFound = !inside ? size.contains(boundsSize) : boundsSize.x < size.x || boundsSize.y < size.y; - - } while (zoomNotFound && zoom <= maxZoom); - - if (zoomNotFound && inside) { - return null; - } - - return inside ? zoom : zoom - 1; - }, - - getSize: function () { - if (!this._size || this._sizeChanged) { - this._size = new L.Point( - this._container.clientWidth, - this._container.clientHeight); - - this._sizeChanged = false; - } - return this._size.clone(); - }, - - getPixelBounds: function () { - var topLeftPoint = this._getTopLeftPoint(); - return new L.Bounds(topLeftPoint, topLeftPoint.add(this.getSize())); - }, - - getPixelOrigin: function () { - this._checkIfLoaded(); - return this._initialTopLeftPoint; - }, - - getPanes: function () { - return this._panes; - }, - - getContainer: function () { - return this._container; - }, - - - // TODO replace with universal implementation after refactoring projections - - getZoomScale: function (toZoom) { - var crs = this.options.crs; - return crs.scale(toZoom) / crs.scale(this._zoom); - }, - - getScaleZoom: function (scale) { - return this._zoom + (Math.log(scale) / Math.LN2); - }, - - - // conversion methods - - project: function (latlng, zoom) { // (LatLng[, Number]) -> Point - zoom = zoom === undefined ? this._zoom : zoom; - return this.options.crs.latLngToPoint(L.latLng(latlng), zoom); - }, - - unproject: function (point, zoom) { // (Point[, Number]) -> LatLng - zoom = zoom === undefined ? this._zoom : zoom; - return this.options.crs.pointToLatLng(L.point(point), zoom); - }, - - layerPointToLatLng: function (point) { // (Point) - var projectedPoint = L.point(point).add(this.getPixelOrigin()); - return this.unproject(projectedPoint); - }, - - latLngToLayerPoint: function (latlng) { // (LatLng) - var projectedPoint = this.project(L.latLng(latlng))._round(); - return projectedPoint._subtract(this.getPixelOrigin()); - }, - - containerPointToLayerPoint: function (point) { // (Point) - return L.point(point).subtract(this._getMapPanePos()); - }, - - layerPointToContainerPoint: function (point) { // (Point) - return L.point(point).add(this._getMapPanePos()); - }, - - containerPointToLatLng: function (point) { - var layerPoint = this.containerPointToLayerPoint(L.point(point)); - return this.layerPointToLatLng(layerPoint); - }, - - latLngToContainerPoint: function (latlng) { - return this.layerPointToContainerPoint(this.latLngToLayerPoint(L.latLng(latlng))); - }, - - mouseEventToContainerPoint: function (e) { // (MouseEvent) - return L.DomEvent.getMousePosition(e, this._container); - }, - - mouseEventToLayerPoint: function (e) { // (MouseEvent) - return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(e)); - }, - - mouseEventToLatLng: function (e) { // (MouseEvent) - return this.layerPointToLatLng(this.mouseEventToLayerPoint(e)); - }, - - - // map initialization methods - - _initContainer: function (id) { - var container = this._container = L.DomUtil.get(id); - - if (!container) { - throw new Error('Map container not found.'); - } else if (container._leaflet) { - throw new Error('Map container is already initialized.'); - } - - container._leaflet = true; - }, - - _initLayout: function () { - var container = this._container; - - L.DomUtil.addClass(container, 'leaflet-container' + - (L.Browser.touch ? ' leaflet-touch' : '') + - (L.Browser.retina ? ' leaflet-retina' : '') + - (L.Browser.ielt9 ? ' leaflet-oldie' : '') + - (this.options.fadeAnimation ? ' leaflet-fade-anim' : '')); - - var position = L.DomUtil.getStyle(container, 'position'); - - if (position !== 'absolute' && position !== 'relative' && position !== 'fixed') { - container.style.position = 'relative'; - } - - this._initPanes(); - - if (this._initControlPos) { - this._initControlPos(); - } - }, - - _initPanes: function () { - var panes = this._panes = {}; - - this._mapPane = panes.mapPane = this._createPane('leaflet-map-pane', this._container); - - this._tilePane = panes.tilePane = this._createPane('leaflet-tile-pane', this._mapPane); - panes.objectsPane = this._createPane('leaflet-objects-pane', this._mapPane); - panes.shadowPane = this._createPane('leaflet-shadow-pane'); - panes.overlayPane = this._createPane('leaflet-overlay-pane'); - panes.markerPane = this._createPane('leaflet-marker-pane'); - panes.popupPane = this._createPane('leaflet-popup-pane'); - - var zoomHide = ' leaflet-zoom-hide'; - - if (!this.options.markerZoomAnimation) { - L.DomUtil.addClass(panes.markerPane, zoomHide); - L.DomUtil.addClass(panes.shadowPane, zoomHide); - L.DomUtil.addClass(panes.popupPane, zoomHide); - } - }, - - _createPane: function (className, container) { - return L.DomUtil.create('div', className, container || this._panes.objectsPane); - }, - - _clearPanes: function () { - this._container.removeChild(this._mapPane); - }, - - _addLayers: function (layers) { - layers = layers ? (L.Util.isArray(layers) ? layers : [layers]) : []; - - for (var i = 0, len = layers.length; i < len; i++) { - this.addLayer(layers[i]); - } - }, - - - // private methods that modify map state - - _resetView: function (center, zoom, preserveMapOffset, afterZoomAnim) { - - var zoomChanged = (this._zoom !== zoom); - - if (!afterZoomAnim) { - this.fire('movestart'); - - if (zoomChanged) { - this.fire('zoomstart'); - } - } - - this._zoom = zoom; - this._initialCenter = center; - - this._initialTopLeftPoint = this._getNewTopLeftPoint(center); - - if (!preserveMapOffset) { - L.DomUtil.setPosition(this._mapPane, new L.Point(0, 0)); - } else { - this._initialTopLeftPoint._add(this._getMapPanePos()); - } - - this._tileLayersToLoad = this._tileLayersNum; - - var loading = !this._loaded; - this._loaded = true; - - this.fire('viewreset', {hard: !preserveMapOffset}); - - if (loading) { - this.fire('load'); - this.eachLayer(this._layerAdd, this); - } - - this.fire('move'); - - if (zoomChanged || afterZoomAnim) { - this.fire('zoomend'); - } - - this.fire('moveend', {hard: !preserveMapOffset}); - }, - - _rawPanBy: function (offset) { - L.DomUtil.setPosition(this._mapPane, this._getMapPanePos().subtract(offset)); - }, - - _getZoomSpan: function () { - return this.getMaxZoom() - this.getMinZoom(); - }, - - _updateZoomLevels: function () { - var i, - minZoom = Infinity, - maxZoom = -Infinity, - oldZoomSpan = this._getZoomSpan(); - - for (i in this._zoomBoundLayers) { - var layer = this._zoomBoundLayers[i]; - if (!isNaN(layer.options.minZoom)) { - minZoom = Math.min(minZoom, layer.options.minZoom); - } - if (!isNaN(layer.options.maxZoom)) { - maxZoom = Math.max(maxZoom, layer.options.maxZoom); - } - } - - if (i === undefined) { // we have no tilelayers - this._layersMaxZoom = this._layersMinZoom = undefined; - } else { - this._layersMaxZoom = maxZoom; - this._layersMinZoom = minZoom; - } - - if (oldZoomSpan !== this._getZoomSpan()) { - this.fire('zoomlevelschange'); - } - }, - - _panInsideMaxBounds: function () { - this.panInsideBounds(this.options.maxBounds); - }, - - _checkIfLoaded: function () { - if (!this._loaded) { - throw new Error('Set map center and zoom first.'); - } - }, - - // map events - - _initEvents: function (onOff) { - if (!L.DomEvent) { return; } - - onOff = onOff || 'on'; - - L.DomEvent[onOff](this._container, 'click', this._onMouseClick, this); - - var events = ['dblclick', 'mousedown', 'mouseup', 'mouseenter', - 'mouseleave', 'mousemove', 'contextmenu'], - i, len; - - for (i = 0, len = events.length; i < len; i++) { - L.DomEvent[onOff](this._container, events[i], this._fireMouseEvent, this); - } - - if (this.options.trackResize) { - L.DomEvent[onOff](window, 'resize', this._onResize, this); - } - }, - - _onResize: function () { - L.Util.cancelAnimFrame(this._resizeRequest); - this._resizeRequest = L.Util.requestAnimFrame( - function () { this.invalidateSize({debounceMoveend: true}); }, this, false, this._container); - }, - - _onMouseClick: function (e) { - if (!this._loaded || (!e._simulated && - ((this.dragging && this.dragging.moved()) || - (this.boxZoom && this.boxZoom.moved()))) || - L.DomEvent._skipped(e)) { return; } - - this.fire('preclick'); - this._fireMouseEvent(e); - }, - - _fireMouseEvent: function (e) { - if (!this._loaded || L.DomEvent._skipped(e)) { return; } - - var type = e.type; - - type = (type === 'mouseenter' ? 'mouseover' : (type === 'mouseleave' ? 'mouseout' : type)); - - if (!this.hasEventListeners(type)) { return; } - - if (type === 'contextmenu') { - L.DomEvent.preventDefault(e); - } - - var containerPoint = this.mouseEventToContainerPoint(e), - layerPoint = this.containerPointToLayerPoint(containerPoint), - latlng = this.layerPointToLatLng(layerPoint); - - this.fire(type, { - latlng: latlng, - layerPoint: layerPoint, - containerPoint: containerPoint, - originalEvent: e - }); - }, - - _onTileLayerLoad: function () { - this._tileLayersToLoad--; - if (this._tileLayersNum && !this._tileLayersToLoad) { - this.fire('tilelayersload'); - } - }, - - _clearHandlers: function () { - for (var i = 0, len = this._handlers.length; i < len; i++) { - this._handlers[i].disable(); - } - }, - - whenReady: function (callback, context) { - if (this._loaded) { - callback.call(context || this, this); - } else { - this.on('load', callback, context); - } - return this; - }, - - _layerAdd: function (layer) { - layer.onAdd(this); - this.fire('layeradd', {layer: layer}); - }, - - - // private methods for getting map state - - _getMapPanePos: function () { - return L.DomUtil.getPosition(this._mapPane); - }, - - _moved: function () { - var pos = this._getMapPanePos(); - return pos && !pos.equals([0, 0]); - }, - - _getTopLeftPoint: function () { - return this.getPixelOrigin().subtract(this._getMapPanePos()); - }, - - _getNewTopLeftPoint: function (center, zoom) { - var viewHalf = this.getSize()._divideBy(2); - // TODO round on display, not calculation to increase precision? - return this.project(center, zoom)._subtract(viewHalf)._round(); - }, - - _latLngToNewLayerPoint: function (latlng, newZoom, newCenter) { - var topLeft = this._getNewTopLeftPoint(newCenter, newZoom).add(this._getMapPanePos()); - return this.project(latlng, newZoom)._subtract(topLeft); - }, - - // layer point of the current center - _getCenterLayerPoint: function () { - return this.containerPointToLayerPoint(this.getSize()._divideBy(2)); - }, - - // offset of the specified place to the current center in pixels - _getCenterOffset: function (latlng) { - return this.latLngToLayerPoint(latlng).subtract(this._getCenterLayerPoint()); - }, - - // adjust center for view to get inside bounds - _limitCenter: function (center, zoom, bounds) { - - if (!bounds) { return center; } - - var centerPoint = this.project(center, zoom), - viewHalf = this.getSize().divideBy(2), - viewBounds = new L.Bounds(centerPoint.subtract(viewHalf), centerPoint.add(viewHalf)), - offset = this._getBoundsOffset(viewBounds, bounds, zoom); - - return this.unproject(centerPoint.add(offset), zoom); - }, - - // adjust offset for view to get inside bounds - _limitOffset: function (offset, bounds) { - if (!bounds) { return offset; } - - var viewBounds = this.getPixelBounds(), - newBounds = new L.Bounds(viewBounds.min.add(offset), viewBounds.max.add(offset)); - - return offset.add(this._getBoundsOffset(newBounds, bounds)); - }, - - // returns offset needed for pxBounds to get inside maxBounds at a specified zoom - _getBoundsOffset: function (pxBounds, maxBounds, zoom) { - var nwOffset = this.project(maxBounds.getNorthWest(), zoom).subtract(pxBounds.min), - seOffset = this.project(maxBounds.getSouthEast(), zoom).subtract(pxBounds.max), - - dx = this._rebound(nwOffset.x, -seOffset.x), - dy = this._rebound(nwOffset.y, -seOffset.y); - - return new L.Point(dx, dy); - }, - - _rebound: function (left, right) { - return left + right > 0 ? - Math.round(left - right) / 2 : - Math.max(0, Math.ceil(left)) - Math.max(0, Math.floor(right)); - }, - - _limitZoom: function (zoom) { - var min = this.getMinZoom(), - max = this.getMaxZoom(); - - return Math.max(min, Math.min(max, zoom)); - } -}); - -L.map = function (id, options) { - return new L.Map(id, options); -}; - - -/* - * Mercator projection that takes into account that the Earth is not a perfect sphere. - * Less popular than spherical mercator; used by projections like EPSG:3395. - */ - -L.Projection.Mercator = { - MAX_LATITUDE: 85.0840591556, - - R_MINOR: 6356752.314245179, - R_MAJOR: 6378137, - - project: function (latlng) { // (LatLng) -> Point - var d = L.LatLng.DEG_TO_RAD, - max = this.MAX_LATITUDE, - lat = Math.max(Math.min(max, latlng.lat), -max), - r = this.R_MAJOR, - r2 = this.R_MINOR, - x = latlng.lng * d * r, - y = lat * d, - tmp = r2 / r, - eccent = Math.sqrt(1.0 - tmp * tmp), - con = eccent * Math.sin(y); - - con = Math.pow((1 - con) / (1 + con), eccent * 0.5); - - var ts = Math.tan(0.5 * ((Math.PI * 0.5) - y)) / con; - y = -r * Math.log(ts); - - return new L.Point(x, y); - }, - - unproject: function (point) { // (Point, Boolean) -> LatLng - var d = L.LatLng.RAD_TO_DEG, - r = this.R_MAJOR, - r2 = this.R_MINOR, - lng = point.x * d / r, - tmp = r2 / r, - eccent = Math.sqrt(1 - (tmp * tmp)), - ts = Math.exp(- point.y / r), - phi = (Math.PI / 2) - 2 * Math.atan(ts), - numIter = 15, - tol = 1e-7, - i = numIter, - dphi = 0.1, - con; - - while ((Math.abs(dphi) > tol) && (--i > 0)) { - con = eccent * Math.sin(phi); - dphi = (Math.PI / 2) - 2 * Math.atan(ts * - Math.pow((1.0 - con) / (1.0 + con), 0.5 * eccent)) - phi; - phi += dphi; - } - - return new L.LatLng(phi * d, lng); - } -}; - - - -L.CRS.EPSG3395 = L.extend({}, L.CRS, { - code: 'EPSG:3395', - - projection: L.Projection.Mercator, - - transformation: (function () { - var m = L.Projection.Mercator, - r = m.R_MAJOR, - scale = 0.5 / (Math.PI * r); - - return new L.Transformation(scale, 0.5, -scale, 0.5); - }()) -}); - - -/* - * L.TileLayer is used for standard xyz-numbered tile layers. - */ - -L.TileLayer = L.Class.extend({ - includes: L.Mixin.Events, - - options: { - minZoom: 0, - maxZoom: 18, - tileSize: 256, - subdomains: 'abc', - errorTileUrl: '', - attribution: '', - zoomOffset: 0, - opacity: 1, - /* - maxNativeZoom: null, - zIndex: null, - tms: false, - continuousWorld: false, - noWrap: false, - zoomReverse: false, - detectRetina: false, - reuseTiles: false, - bounds: false, - */ - unloadInvisibleTiles: L.Browser.mobile, - updateWhenIdle: L.Browser.mobile - }, - - initialize: function (url, options) { - options = L.setOptions(this, options); - - // detecting retina displays, adjusting tileSize and zoom levels - if (options.detectRetina && L.Browser.retina && options.maxZoom > 0) { - - options.tileSize = Math.floor(options.tileSize / 2); - options.zoomOffset++; - - if (options.minZoom > 0) { - options.minZoom--; - } - this.options.maxZoom--; - } - - if (options.bounds) { - options.bounds = L.latLngBounds(options.bounds); - } - - this._url = url; - - var subdomains = this.options.subdomains; - - if (typeof subdomains === 'string') { - this.options.subdomains = subdomains.split(''); - } - }, - - onAdd: function (map) { - this._map = map; - this._animated = map._zoomAnimated; - - // create a container div for tiles - this._initContainer(); - - // set up events - map.on({ - 'viewreset': this._reset, - 'moveend': this._update - }, this); - - if (this._animated) { - map.on({ - 'zoomanim': this._animateZoom, - 'zoomend': this._endZoomAnim - }, this); - } - - if (!this.options.updateWhenIdle) { - this._limitedUpdate = L.Util.limitExecByInterval(this._update, 150, this); - map.on('move', this._limitedUpdate, this); - } - - this._reset(); - this._update(); - }, - - addTo: function (map) { - map.addLayer(this); - return this; - }, - - onRemove: function (map) { - this._container.parentNode.removeChild(this._container); - - map.off({ - 'viewreset': this._reset, - 'moveend': this._update - }, this); - - if (this._animated) { - map.off({ - 'zoomanim': this._animateZoom, - 'zoomend': this._endZoomAnim - }, this); - } - - if (!this.options.updateWhenIdle) { - map.off('move', this._limitedUpdate, this); - } - - this._container = null; - this._map = null; - }, - - bringToFront: function () { - var pane = this._map._panes.tilePane; - - if (this._container) { - pane.appendChild(this._container); - this._setAutoZIndex(pane, Math.max); - } - - return this; - }, - - bringToBack: function () { - var pane = this._map._panes.tilePane; - - if (this._container) { - pane.insertBefore(this._container, pane.firstChild); - this._setAutoZIndex(pane, Math.min); - } - - return this; - }, - - getAttribution: function () { - return this.options.attribution; - }, - - getContainer: function () { - return this._container; - }, - - setOpacity: function (opacity) { - this.options.opacity = opacity; - - if (this._map) { - this._updateOpacity(); - } - - return this; - }, - - setZIndex: function (zIndex) { - this.options.zIndex = zIndex; - this._updateZIndex(); - - return this; - }, - - setUrl: function (url, noRedraw) { - this._url = url; - - if (!noRedraw) { - this.redraw(); - } - - return this; - }, - - redraw: function () { - if (this._map) { - this._reset({hard: true}); - this._update(); - } - return this; - }, - - _updateZIndex: function () { - if (this._container && this.options.zIndex !== undefined) { - this._container.style.zIndex = this.options.zIndex; - } - }, - - _setAutoZIndex: function (pane, compare) { - - var layers = pane.children, - edgeZIndex = -compare(Infinity, -Infinity), // -Infinity for max, Infinity for min - zIndex, i, len; - - for (i = 0, len = layers.length; i < len; i++) { - - if (layers[i] !== this._container) { - zIndex = parseInt(layers[i].style.zIndex, 10); - - if (!isNaN(zIndex)) { - edgeZIndex = compare(edgeZIndex, zIndex); - } - } - } - - this.options.zIndex = this._container.style.zIndex = - (isFinite(edgeZIndex) ? edgeZIndex : 0) + compare(1, -1); - }, - - _updateOpacity: function () { - var i, - tiles = this._tiles; - - if (L.Browser.ielt9) { - for (i in tiles) { - L.DomUtil.setOpacity(tiles[i], this.options.opacity); - } - } else { - L.DomUtil.setOpacity(this._container, this.options.opacity); - } - }, - - _initContainer: function () { - var tilePane = this._map._panes.tilePane; - - if (!this._container) { - this._container = L.DomUtil.create('div', 'leaflet-layer'); - - this._updateZIndex(); - - if (this._animated) { - var className = 'leaflet-tile-container'; - - this._bgBuffer = L.DomUtil.create('div', className, this._container); - this._tileContainer = L.DomUtil.create('div', className, this._container); - - } else { - this._tileContainer = this._container; - } - - tilePane.appendChild(this._container); - - if (this.options.opacity < 1) { - this._updateOpacity(); - } - } - }, - - _reset: function (e) { - for (var key in this._tiles) { - this.fire('tileunload', {tile: this._tiles[key]}); - } - - this._tiles = {}; - this._tilesToLoad = 0; - - if (this.options.reuseTiles) { - this._unusedTiles = []; - } - - this._tileContainer.innerHTML = ''; - - if (this._animated && e && e.hard) { - this._clearBgBuffer(); - } - - this._initContainer(); - }, - - _getTileSize: function () { - var map = this._map, - zoom = map.getZoom() + this.options.zoomOffset, - zoomN = this.options.maxNativeZoom, - tileSize = this.options.tileSize; - - if (zoomN && zoom > zoomN) { - tileSize = Math.round(map.getZoomScale(zoom) / map.getZoomScale(zoomN) * tileSize); - } - - return tileSize; - }, - - _update: function () { - - if (!this._map) { return; } - - var map = this._map, - bounds = map.getPixelBounds(), - zoom = map.getZoom(), - tileSize = this._getTileSize(); - - if (zoom > this.options.maxZoom || zoom < this.options.minZoom) { - return; - } - - var tileBounds = L.bounds( - bounds.min.divideBy(tileSize)._floor(), - bounds.max.divideBy(tileSize)._floor()); - - this._addTilesFromCenterOut(tileBounds); - - if (this.options.unloadInvisibleTiles || this.options.reuseTiles) { - this._removeOtherTiles(tileBounds); - } - }, - - _addTilesFromCenterOut: function (bounds) { - var queue = [], - center = bounds.getCenter(); - - var j, i, point; - - for (j = bounds.min.y; j <= bounds.max.y; j++) { - for (i = bounds.min.x; i <= bounds.max.x; i++) { - point = new L.Point(i, j); - - if (this._tileShouldBeLoaded(point)) { - queue.push(point); - } - } - } - - var tilesToLoad = queue.length; - - if (tilesToLoad === 0) { return; } - - // load tiles in order of their distance to center - queue.sort(function (a, b) { - return a.distanceTo(center) - b.distanceTo(center); - }); - - var fragment = document.createDocumentFragment(); - - // if its the first batch of tiles to load - if (!this._tilesToLoad) { - this.fire('loading'); - } - - this._tilesToLoad += tilesToLoad; - - for (i = 0; i < tilesToLoad; i++) { - this._addTile(queue[i], fragment); - } - - this._tileContainer.appendChild(fragment); - }, - - _tileShouldBeLoaded: function (tilePoint) { - if ((tilePoint.x + ':' + tilePoint.y) in this._tiles) { - return false; // already loaded - } - - var options = this.options; - - if (!options.continuousWorld) { - var limit = this._getWrapTileNum(); - - // don't load if exceeds world bounds - if ((options.noWrap && (tilePoint.x < 0 || tilePoint.x >= limit.x)) || - tilePoint.y < 0 || tilePoint.y >= limit.y) { return false; } - } - - if (options.bounds) { - var tileSize = options.tileSize, - nwPoint = tilePoint.multiplyBy(tileSize), - sePoint = nwPoint.add([tileSize, tileSize]), - nw = this._map.unproject(nwPoint), - se = this._map.unproject(sePoint); - - // TODO temporary hack, will be removed after refactoring projections - // https://github.com/Leaflet/Leaflet/issues/1618 - if (!options.continuousWorld && !options.noWrap) { - nw = nw.wrap(); - se = se.wrap(); - } - - if (!options.bounds.intersects([nw, se])) { return false; } - } - - return true; - }, - - _removeOtherTiles: function (bounds) { - var kArr, x, y, key; - - for (key in this._tiles) { - kArr = key.split(':'); - x = parseInt(kArr[0], 10); - y = parseInt(kArr[1], 10); - - // remove tile if it's out of bounds - if (x < bounds.min.x || x > bounds.max.x || y < bounds.min.y || y > bounds.max.y) { - this._removeTile(key); - } - } - }, - - _removeTile: function (key) { - var tile = this._tiles[key]; - - this.fire('tileunload', {tile: tile, url: tile.src}); - - if (this.options.reuseTiles) { - L.DomUtil.removeClass(tile, 'leaflet-tile-loaded'); - this._unusedTiles.push(tile); - - } else if (tile.parentNode === this._tileContainer) { - this._tileContainer.removeChild(tile); - } - - // for https://github.com/CloudMade/Leaflet/issues/137 - if (!L.Browser.android) { - tile.onload = null; - tile.src = L.Util.emptyImageUrl; - } - - delete this._tiles[key]; - }, - - _addTile: function (tilePoint, container) { - var tilePos = this._getTilePos(tilePoint); - - // get unused tile - or create a new tile - var tile = this._getTile(); - - /* - Chrome 20 layouts much faster with top/left (verify with timeline, frames) - Android 4 browser has display issues with top/left and requires transform instead - (other browsers don't currently care) - see debug/hacks/jitter.html for an example - */ - L.DomUtil.setPosition(tile, tilePos, L.Browser.chrome); - - this._tiles[tilePoint.x + ':' + tilePoint.y] = tile; - - this._loadTile(tile, tilePoint); - - if (tile.parentNode !== this._tileContainer) { - container.appendChild(tile); - } - }, - - _getZoomForUrl: function () { - - var options = this.options, - zoom = this._map.getZoom(); - - if (options.zoomReverse) { - zoom = options.maxZoom - zoom; - } - - zoom += options.zoomOffset; - - return options.maxNativeZoom ? Math.min(zoom, options.maxNativeZoom) : zoom; - }, - - _getTilePos: function (tilePoint) { - var origin = this._map.getPixelOrigin(), - tileSize = this._getTileSize(); - - return tilePoint.multiplyBy(tileSize).subtract(origin); - }, - - // image-specific code (override to implement e.g. Canvas or SVG tile layer) - - getTileUrl: function (tilePoint) { - return L.Util.template(this._url, L.extend({ - s: this._getSubdomain(tilePoint), - z: tilePoint.z, - x: tilePoint.x, - y: tilePoint.y - }, this.options)); - }, - - _getWrapTileNum: function () { - var crs = this._map.options.crs, - size = crs.getSize(this._map.getZoom()); - return size.divideBy(this._getTileSize())._floor(); - }, - - _adjustTilePoint: function (tilePoint) { - - var limit = this._getWrapTileNum(); - - // wrap tile coordinates - if (!this.options.continuousWorld && !this.options.noWrap) { - tilePoint.x = ((tilePoint.x % limit.x) + limit.x) % limit.x; - } - - if (this.options.tms) { - tilePoint.y = limit.y - tilePoint.y - 1; - } - - tilePoint.z = this._getZoomForUrl(); - }, - - _getSubdomain: function (tilePoint) { - var index = Math.abs(tilePoint.x + tilePoint.y) % this.options.subdomains.length; - return this.options.subdomains[index]; - }, - - _getTile: function () { - if (this.options.reuseTiles && this._unusedTiles.length > 0) { - var tile = this._unusedTiles.pop(); - this._resetTile(tile); - return tile; - } - return this._createTile(); - }, - - // Override if data stored on a tile needs to be cleaned up before reuse - _resetTile: function (/*tile*/) {}, - - _createTile: function () { - var tile = L.DomUtil.create('img', 'leaflet-tile'); - tile.style.width = tile.style.height = this._getTileSize() + 'px'; - tile.galleryimg = 'no'; - - tile.onselectstart = tile.onmousemove = L.Util.falseFn; - - if (L.Browser.ielt9 && this.options.opacity !== undefined) { - L.DomUtil.setOpacity(tile, this.options.opacity); - } - // without this hack, tiles disappear after zoom on Chrome for Android - // https://github.com/Leaflet/Leaflet/issues/2078 - if (L.Browser.mobileWebkit3d) { - tile.style.WebkitBackfaceVisibility = 'hidden'; - } - return tile; - }, - - _loadTile: function (tile, tilePoint) { - tile._layer = this; - tile.onload = this._tileOnLoad; - tile.onerror = this._tileOnError; - - this._adjustTilePoint(tilePoint); - tile.src = this.getTileUrl(tilePoint); - - this.fire('tileloadstart', { - tile: tile, - url: tile.src - }); - }, - - _tileLoaded: function () { - this._tilesToLoad--; - - if (this._animated) { - L.DomUtil.addClass(this._tileContainer, 'leaflet-zoom-animated'); - } - - if (!this._tilesToLoad) { - this.fire('load'); - - if (this._animated) { - // clear scaled tiles after all new tiles are loaded (for performance) - clearTimeout(this._clearBgBufferTimer); - this._clearBgBufferTimer = setTimeout(L.bind(this._clearBgBuffer, this), 500); - } - } - }, - - _tileOnLoad: function () { - var layer = this._layer; - - //Only if we are loading an actual image - if (this.src !== L.Util.emptyImageUrl) { - L.DomUtil.addClass(this, 'leaflet-tile-loaded'); - - layer.fire('tileload', { - tile: this, - url: this.src - }); - } - - layer._tileLoaded(); - }, - - _tileOnError: function () { - var layer = this._layer; - - layer.fire('tileerror', { - tile: this, - url: this.src - }); - - var newUrl = layer.options.errorTileUrl; - if (newUrl) { - this.src = newUrl; - } - - layer._tileLoaded(); - } -}); - -L.tileLayer = function (url, options) { - return new L.TileLayer(url, options); -}; - - -/* - * L.TileLayer.WMS is used for putting WMS tile layers on the map. - */ - -L.TileLayer.WMS = L.TileLayer.extend({ - - defaultWmsParams: { - service: 'WMS', - request: 'GetMap', - version: '1.1.1', - layers: '', - styles: '', - format: 'image/jpeg', - transparent: false - }, - - initialize: function (url, options) { // (String, Object) - - this._url = url; - - var wmsParams = L.extend({}, this.defaultWmsParams), - tileSize = options.tileSize || this.options.tileSize; - - if (options.detectRetina && L.Browser.retina) { - wmsParams.width = wmsParams.height = tileSize * 2; - } else { - wmsParams.width = wmsParams.height = tileSize; - } - - for (var i in options) { - // all keys that are not TileLayer options go to WMS params - if (!this.options.hasOwnProperty(i) && i !== 'crs') { - wmsParams[i] = options[i]; - } - } - - this.wmsParams = wmsParams; - - L.setOptions(this, options); - }, - - onAdd: function (map) { - - this._crs = this.options.crs || map.options.crs; - - this._wmsVersion = parseFloat(this.wmsParams.version); - - var projectionKey = this._wmsVersion >= 1.3 ? 'crs' : 'srs'; - this.wmsParams[projectionKey] = this._crs.code; - - L.TileLayer.prototype.onAdd.call(this, map); - }, - - getTileUrl: function (tilePoint) { // (Point, Number) -> String - - var map = this._map, - tileSize = this.options.tileSize, - - nwPoint = tilePoint.multiplyBy(tileSize), - sePoint = nwPoint.add([tileSize, tileSize]), - - nw = this._crs.project(map.unproject(nwPoint, tilePoint.z)), - se = this._crs.project(map.unproject(sePoint, tilePoint.z)), - bbox = this._wmsVersion >= 1.3 && this._crs === L.CRS.EPSG4326 ? - [se.y, nw.x, nw.y, se.x].join(',') : - [nw.x, se.y, se.x, nw.y].join(','), - - url = L.Util.template(this._url, {s: this._getSubdomain(tilePoint)}); - - return url + L.Util.getParamString(this.wmsParams, url, true) + '&BBOX=' + bbox; - }, - - setParams: function (params, noRedraw) { - - L.extend(this.wmsParams, params); - - if (!noRedraw) { - this.redraw(); - } - - return this; - } -}); - -L.tileLayer.wms = function (url, options) { - return new L.TileLayer.WMS(url, options); -}; - - -/* - * L.TileLayer.Canvas is a class that you can use as a base for creating - * dynamically drawn Canvas-based tile layers. - */ - -L.TileLayer.Canvas = L.TileLayer.extend({ - options: { - async: false - }, - - initialize: function (options) { - L.setOptions(this, options); - }, - - redraw: function () { - if (this._map) { - this._reset({hard: true}); - this._update(); - } - - for (var i in this._tiles) { - this._redrawTile(this._tiles[i]); - } - return this; - }, - - _redrawTile: function (tile) { - this.drawTile(tile, tile._tilePoint, this._map._zoom); - }, - - _createTile: function () { - var tile = L.DomUtil.create('canvas', 'leaflet-tile'); - tile.width = tile.height = this.options.tileSize; - tile.onselectstart = tile.onmousemove = L.Util.falseFn; - return tile; - }, - - _loadTile: function (tile, tilePoint) { - tile._layer = this; - tile._tilePoint = tilePoint; - - this._redrawTile(tile); - - if (!this.options.async) { - this.tileDrawn(tile); - } - }, - - drawTile: function (/*tile, tilePoint*/) { - // override with rendering code - }, - - tileDrawn: function (tile) { - this._tileOnLoad.call(tile); - } -}); - - -L.tileLayer.canvas = function (options) { - return new L.TileLayer.Canvas(options); -}; - - -/* - * L.ImageOverlay is used to overlay images over the map (to specific geographical bounds). - */ - -L.ImageOverlay = L.Class.extend({ - includes: L.Mixin.Events, - - options: { - opacity: 1 - }, - - initialize: function (url, bounds, options) { // (String, LatLngBounds, Object) - this._url = url; - this._bounds = L.latLngBounds(bounds); - - L.setOptions(this, options); - }, - - onAdd: function (map) { - this._map = map; - - if (!this._image) { - this._initImage(); - } - - map._panes.overlayPane.appendChild(this._image); - - map.on('viewreset', this._reset, this); - - if (map.options.zoomAnimation && L.Browser.any3d) { - map.on('zoomanim', this._animateZoom, this); - } - - this._reset(); - }, - - onRemove: function (map) { - map.getPanes().overlayPane.removeChild(this._image); - - map.off('viewreset', this._reset, this); - - if (map.options.zoomAnimation) { - map.off('zoomanim', this._animateZoom, this); - } - }, - - addTo: function (map) { - map.addLayer(this); - return this; - }, - - setOpacity: function (opacity) { - this.options.opacity = opacity; - this._updateOpacity(); - return this; - }, - - // TODO remove bringToFront/bringToBack duplication from TileLayer/Path - bringToFront: function () { - if (this._image) { - this._map._panes.overlayPane.appendChild(this._image); - } - return this; - }, - - bringToBack: function () { - var pane = this._map._panes.overlayPane; - if (this._image) { - pane.insertBefore(this._image, pane.firstChild); - } - return this; - }, - - setUrl: function (url) { - this._url = url; - this._image.src = this._url; - }, - - getAttribution: function () { - return this.options.attribution; - }, - - _initImage: function () { - this._image = L.DomUtil.create('img', 'leaflet-image-layer'); - - if (this._map.options.zoomAnimation && L.Browser.any3d) { - L.DomUtil.addClass(this._image, 'leaflet-zoom-animated'); - } else { - L.DomUtil.addClass(this._image, 'leaflet-zoom-hide'); - } - - this._updateOpacity(); - - //TODO createImage util method to remove duplication - L.extend(this._image, { - galleryimg: 'no', - onselectstart: L.Util.falseFn, - onmousemove: L.Util.falseFn, - onload: L.bind(this._onImageLoad, this), - src: this._url - }); - }, - - _animateZoom: function (e) { - var map = this._map, - image = this._image, - scale = map.getZoomScale(e.zoom), - nw = this._bounds.getNorthWest(), - se = this._bounds.getSouthEast(), - - topLeft = map._latLngToNewLayerPoint(nw, e.zoom, e.center), - size = map._latLngToNewLayerPoint(se, e.zoom, e.center)._subtract(topLeft), - origin = topLeft._add(size._multiplyBy((1 / 2) * (1 - 1 / scale))); - - image.style[L.DomUtil.TRANSFORM] = - L.DomUtil.getTranslateString(origin) + ' scale(' + scale + ') '; - }, - - _reset: function () { - var image = this._image, - topLeft = this._map.latLngToLayerPoint(this._bounds.getNorthWest()), - size = this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(topLeft); - - L.DomUtil.setPosition(image, topLeft); - - image.style.width = size.x + 'px'; - image.style.height = size.y + 'px'; - }, - - _onImageLoad: function () { - this.fire('load'); - }, - - _updateOpacity: function () { - L.DomUtil.setOpacity(this._image, this.options.opacity); - } -}); - -L.imageOverlay = function (url, bounds, options) { - return new L.ImageOverlay(url, bounds, options); -}; - - -/* - * L.Icon is an image-based icon class that you can use with L.Marker for custom markers. - */ - -L.Icon = L.Class.extend({ - options: { - /* - iconUrl: (String) (required) - iconRetinaUrl: (String) (optional, used for retina devices if detected) - iconSize: (Point) (can be set through CSS) - iconAnchor: (Point) (centered by default, can be set in CSS with negative margins) - popupAnchor: (Point) (if not specified, popup opens in the anchor point) - shadowUrl: (String) (no shadow by default) - shadowRetinaUrl: (String) (optional, used for retina devices if detected) - shadowSize: (Point) - shadowAnchor: (Point) - */ - className: '' - }, - - initialize: function (options) { - L.setOptions(this, options); - }, - - createIcon: function (oldIcon) { - return this._createIcon('icon', oldIcon); - }, - - createShadow: function (oldIcon) { - return this._createIcon('shadow', oldIcon); - }, - - _createIcon: function (name, oldIcon) { - var src = this._getIconUrl(name); - - if (!src) { - if (name === 'icon') { - throw new Error('iconUrl not set in Icon options (see the docs).'); - } - return null; - } - - var img; - if (!oldIcon || oldIcon.tagName !== 'IMG') { - img = this._createImg(src); - } else { - img = this._createImg(src, oldIcon); - } - this._setIconStyles(img, name); - - return img; - }, - - _setIconStyles: function (img, name) { - var options = this.options, - size = L.point(options[name + 'Size']), - anchor; - - if (name === 'shadow') { - anchor = L.point(options.shadowAnchor || options.iconAnchor); - } else { - anchor = L.point(options.iconAnchor); - } - - if (!anchor && size) { - anchor = size.divideBy(2, true); - } - - img.className = 'leaflet-marker-' + name + ' ' + options.className; - - if (anchor) { - img.style.marginLeft = (-anchor.x) + 'px'; - img.style.marginTop = (-anchor.y) + 'px'; - } - - if (size) { - img.style.width = size.x + 'px'; - img.style.height = size.y + 'px'; - } - }, - - _createImg: function (src, el) { - el = el || document.createElement('img'); - el.src = src; - return el; - }, - - _getIconUrl: function (name) { - if (L.Browser.retina && this.options[name + 'RetinaUrl']) { - return this.options[name + 'RetinaUrl']; - } - return this.options[name + 'Url']; - } -}); - -L.icon = function (options) { - return new L.Icon(options); -}; - - -/* - * L.Icon.Default is the blue marker icon used by default in Leaflet. - */ - -L.Icon.Default = L.Icon.extend({ - - options: { - iconSize: [25, 41], - iconAnchor: [12, 41], - popupAnchor: [1, -34], - - shadowSize: [41, 41] - }, - - _getIconUrl: function (name) { - var key = name + 'Url'; - - if (this.options[key]) { - return this.options[key]; - } - - if (L.Browser.retina && name === 'icon') { - name += '-2x'; - } - - var path = L.Icon.Default.imagePath; - - if (!path) { - throw new Error('Couldn\'t autodetect L.Icon.Default.imagePath, set it manually.'); - } - - return path + '/marker-' + name + '.png'; - } -}); - -L.Icon.Default.imagePath = (function () { - var scripts = document.getElementsByTagName('script'), - leafletRe = /[\/^]leaflet[\-\._]?([\w\-\._]*)\.js\??/; - - var i, len, src, matches, path; - - for (i = 0, len = scripts.length; i < len; i++) { - src = scripts[i].src; - matches = src.match(leafletRe); - - if (matches) { - path = src.split(leafletRe)[0]; - return (path ? path + '/' : '') + 'images'; - } - } -}()); - - -/* - * L.Marker is used to display clickable/draggable icons on the map. - */ - -L.Marker = L.Class.extend({ - - includes: L.Mixin.Events, - - options: { - icon: new L.Icon.Default(), - title: '', - alt: '', - clickable: true, - draggable: false, - keyboard: true, - zIndexOffset: 0, - opacity: 1, - riseOnHover: false, - riseOffset: 250 - }, - - initialize: function (latlng, options) { - L.setOptions(this, options); - this._latlng = L.latLng(latlng); - }, - - onAdd: function (map) { - this._map = map; - - map.on('viewreset', this.update, this); - - this._initIcon(); - this.update(); - this.fire('add'); - - if (map.options.zoomAnimation && map.options.markerZoomAnimation) { - map.on('zoomanim', this._animateZoom, this); - } - }, - - addTo: function (map) { - map.addLayer(this); - return this; - }, - - onRemove: function (map) { - if (this.dragging) { - this.dragging.disable(); - } - - this._removeIcon(); - this._removeShadow(); - - this.fire('remove'); - - map.off({ - 'viewreset': this.update, - 'zoomanim': this._animateZoom - }, this); - - this._map = null; - }, - - getLatLng: function () { - return this._latlng; - }, - - setLatLng: function (latlng) { - this._latlng = L.latLng(latlng); - - this.update(); - - return this.fire('move', { latlng: this._latlng }); - }, - - setZIndexOffset: function (offset) { - this.options.zIndexOffset = offset; - this.update(); - - return this; - }, - - setIcon: function (icon) { - - this.options.icon = icon; - - if (this._map) { - this._initIcon(); - this.update(); - } - - if (this._popup) { - this.bindPopup(this._popup); - } - - return this; - }, - - update: function () { - if (this._icon) { - var pos = this._map.latLngToLayerPoint(this._latlng).round(); - this._setPos(pos); - } - - return this; - }, - - _initIcon: function () { - var options = this.options, - map = this._map, - animation = (map.options.zoomAnimation && map.options.markerZoomAnimation), - classToAdd = animation ? 'leaflet-zoom-animated' : 'leaflet-zoom-hide'; - - var icon = options.icon.createIcon(this._icon), - addIcon = false; - - // if we're not reusing the icon, remove the old one and init new one - if (icon !== this._icon) { - if (this._icon) { - this._removeIcon(); - } - addIcon = true; - - if (options.title) { - icon.title = options.title; - } - - if (options.alt) { - icon.alt = options.alt; - } - } - - L.DomUtil.addClass(icon, classToAdd); - - if (options.keyboard) { - icon.tabIndex = '0'; - } - - this._icon = icon; - - this._initInteraction(); - - if (options.riseOnHover) { - L.DomEvent - .on(icon, 'mouseover', this._bringToFront, this) - .on(icon, 'mouseout', this._resetZIndex, this); - } - - var newShadow = options.icon.createShadow(this._shadow), - addShadow = false; - - if (newShadow !== this._shadow) { - this._removeShadow(); - addShadow = true; - } - - if (newShadow) { - L.DomUtil.addClass(newShadow, classToAdd); - } - this._shadow = newShadow; - - - if (options.opacity < 1) { - this._updateOpacity(); - } - - - var panes = this._map._panes; - - if (addIcon) { - panes.markerPane.appendChild(this._icon); - } - - if (newShadow && addShadow) { - panes.shadowPane.appendChild(this._shadow); - } - }, - - _removeIcon: function () { - if (this.options.riseOnHover) { - L.DomEvent - .off(this._icon, 'mouseover', this._bringToFront) - .off(this._icon, 'mouseout', this._resetZIndex); - } - - this._map._panes.markerPane.removeChild(this._icon); - - this._icon = null; - }, - - _removeShadow: function () { - if (this._shadow) { - this._map._panes.shadowPane.removeChild(this._shadow); - } - this._shadow = null; - }, - - _setPos: function (pos) { - L.DomUtil.setPosition(this._icon, pos); - - if (this._shadow) { - L.DomUtil.setPosition(this._shadow, pos); - } - - this._zIndex = pos.y + this.options.zIndexOffset; - - this._resetZIndex(); - }, - - _updateZIndex: function (offset) { - this._icon.style.zIndex = this._zIndex + offset; - }, - - _animateZoom: function (opt) { - var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round(); - - this._setPos(pos); - }, - - _initInteraction: function () { - - if (!this.options.clickable) { return; } - - // TODO refactor into something shared with Map/Path/etc. to DRY it up - - var icon = this._icon, - events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'contextmenu']; - - L.DomUtil.addClass(icon, 'leaflet-clickable'); - L.DomEvent.on(icon, 'click', this._onMouseClick, this); - L.DomEvent.on(icon, 'keypress', this._onKeyPress, this); - - for (var i = 0; i < events.length; i++) { - L.DomEvent.on(icon, events[i], this._fireMouseEvent, this); - } - - if (L.Handler.MarkerDrag) { - this.dragging = new L.Handler.MarkerDrag(this); - - if (this.options.draggable) { - this.dragging.enable(); - } - } - }, - - _onMouseClick: function (e) { - var wasDragged = this.dragging && this.dragging.moved(); - - if (this.hasEventListeners(e.type) || wasDragged) { - L.DomEvent.stopPropagation(e); - } - - if (wasDragged) { return; } - - if ((!this.dragging || !this.dragging._enabled) && this._map.dragging && this._map.dragging.moved()) { return; } - - this.fire(e.type, { - originalEvent: e, - latlng: this._latlng - }); - }, - - _onKeyPress: function (e) { - if (e.keyCode === 13) { - this.fire('click', { - originalEvent: e, - latlng: this._latlng - }); - } - }, - - _fireMouseEvent: function (e) { - - this.fire(e.type, { - originalEvent: e, - latlng: this._latlng - }); - - // TODO proper custom event propagation - // this line will always be called if marker is in a FeatureGroup - if (e.type === 'contextmenu' && this.hasEventListeners(e.type)) { - L.DomEvent.preventDefault(e); - } - if (e.type !== 'mousedown') { - L.DomEvent.stopPropagation(e); - } else { - L.DomEvent.preventDefault(e); - } - }, - - setOpacity: function (opacity) { - this.options.opacity = opacity; - if (this._map) { - this._updateOpacity(); - } - - return this; - }, - - _updateOpacity: function () { - L.DomUtil.setOpacity(this._icon, this.options.opacity); - if (this._shadow) { - L.DomUtil.setOpacity(this._shadow, this.options.opacity); - } - }, - - _bringToFront: function () { - this._updateZIndex(this.options.riseOffset); - }, - - _resetZIndex: function () { - this._updateZIndex(0); - } -}); - -L.marker = function (latlng, options) { - return new L.Marker(latlng, options); -}; - - -/* - * L.DivIcon is a lightweight HTML-based icon class (as opposed to the image-based L.Icon) - * to use with L.Marker. - */ - -L.DivIcon = L.Icon.extend({ - options: { - iconSize: [12, 12], // also can be set through CSS - /* - iconAnchor: (Point) - popupAnchor: (Point) - html: (String) - bgPos: (Point) - */ - className: 'leaflet-div-icon', - html: false - }, - - createIcon: function (oldIcon) { - var div = (oldIcon && oldIcon.tagName === 'DIV') ? oldIcon : document.createElement('div'), - options = this.options; - - if (options.html !== false) { - div.innerHTML = options.html; - } else { - div.innerHTML = ''; - } - - if (options.bgPos) { - div.style.backgroundPosition = - (-options.bgPos.x) + 'px ' + (-options.bgPos.y) + 'px'; - } - - this._setIconStyles(div, 'icon'); - return div; - }, - - createShadow: function () { - return null; - } -}); - -L.divIcon = function (options) { - return new L.DivIcon(options); -}; - - -/* - * L.Popup is used for displaying popups on the map. - */ - -L.Map.mergeOptions({ - closePopupOnClick: true -}); - -L.Popup = L.Class.extend({ - includes: L.Mixin.Events, - - options: { - minWidth: 50, - maxWidth: 300, - // maxHeight: null, - autoPan: true, - closeButton: true, - offset: [0, 7], - autoPanPadding: [5, 5], - // autoPanPaddingTopLeft: null, - // autoPanPaddingBottomRight: null, - keepInView: false, - className: '', - zoomAnimation: true - }, - - initialize: function (options, source) { - L.setOptions(this, options); - - this._source = source; - this._animated = L.Browser.any3d && this.options.zoomAnimation; - this._isOpen = false; - }, - - onAdd: function (map) { - this._map = map; - - if (!this._container) { - this._initLayout(); - } - - var animFade = map.options.fadeAnimation; - - if (animFade) { - L.DomUtil.setOpacity(this._container, 0); - } - map._panes.popupPane.appendChild(this._container); - - map.on(this._getEvents(), this); - - this.update(); - - if (animFade) { - L.DomUtil.setOpacity(this._container, 1); - } - - this.fire('open'); - - map.fire('popupopen', {popup: this}); - - if (this._source) { - this._source.fire('popupopen', {popup: this}); - } - }, - - addTo: function (map) { - map.addLayer(this); - return this; - }, - - openOn: function (map) { - map.openPopup(this); - return this; - }, - - onRemove: function (map) { - map._panes.popupPane.removeChild(this._container); - - L.Util.falseFn(this._container.offsetWidth); // force reflow - - map.off(this._getEvents(), this); - - if (map.options.fadeAnimation) { - L.DomUtil.setOpacity(this._container, 0); - } - - this._map = null; - - this.fire('close'); - - map.fire('popupclose', {popup: this}); - - if (this._source) { - this._source.fire('popupclose', {popup: this}); - } - }, - - getLatLng: function () { - return this._latlng; - }, - - setLatLng: function (latlng) { - this._latlng = L.latLng(latlng); - if (this._map) { - this._updatePosition(); - this._adjustPan(); - } - return this; - }, - - getContent: function () { - return this._content; - }, - - setContent: function (content) { - this._content = content; - this.update(); - return this; - }, - - update: function () { - if (!this._map) { return; } - - this._container.style.visibility = 'hidden'; - - this._updateContent(); - this._updateLayout(); - this._updatePosition(); - - this._container.style.visibility = ''; - - this._adjustPan(); - }, - - _getEvents: function () { - var events = { - viewreset: this._updatePosition - }; - - if (this._animated) { - events.zoomanim = this._zoomAnimation; - } - if ('closeOnClick' in this.options ? this.options.closeOnClick : this._map.options.closePopupOnClick) { - events.preclick = this._close; - } - if (this.options.keepInView) { - events.moveend = this._adjustPan; - } - - return events; - }, - - _close: function () { - if (this._map) { - this._map.closePopup(this); - } - }, - - _initLayout: function () { - var prefix = 'leaflet-popup', - containerClass = prefix + ' ' + this.options.className + ' leaflet-zoom-' + - (this._animated ? 'animated' : 'hide'), - container = this._container = L.DomUtil.create('div', containerClass), - closeButton; - - if (this.options.closeButton) { - closeButton = this._closeButton = - L.DomUtil.create('a', prefix + '-close-button', container); - closeButton.href = '#close'; - closeButton.innerHTML = '×'; - L.DomEvent.disableClickPropagation(closeButton); - - L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this); - } - - var wrapper = this._wrapper = - L.DomUtil.create('div', prefix + '-content-wrapper', container); - L.DomEvent.disableClickPropagation(wrapper); - - this._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper); - - L.DomEvent.disableScrollPropagation(this._contentNode); - L.DomEvent.on(wrapper, 'contextmenu', L.DomEvent.stopPropagation); - - this._tipContainer = L.DomUtil.create('div', prefix + '-tip-container', container); - this._tip = L.DomUtil.create('div', prefix + '-tip', this._tipContainer); - }, - - _updateContent: function () { - if (!this._content) { return; } - - if (typeof this._content === 'string') { - this._contentNode.innerHTML = this._content; - } else { - while (this._contentNode.hasChildNodes()) { - this._contentNode.removeChild(this._contentNode.firstChild); - } - this._contentNode.appendChild(this._content); - } - this.fire('contentupdate'); - }, - - _updateLayout: function () { - var container = this._contentNode, - style = container.style; - - style.width = ''; - style.whiteSpace = 'nowrap'; - - var width = container.offsetWidth; - width = Math.min(width, this.options.maxWidth); - width = Math.max(width, this.options.minWidth); - - style.width = (width + 1) + 'px'; - style.whiteSpace = ''; - - style.height = ''; - - var height = container.offsetHeight, - maxHeight = this.options.maxHeight, - scrolledClass = 'leaflet-popup-scrolled'; - - if (maxHeight && height > maxHeight) { - style.height = maxHeight + 'px'; - L.DomUtil.addClass(container, scrolledClass); - } else { - L.DomUtil.removeClass(container, scrolledClass); - } - - this._containerWidth = this._container.offsetWidth; - }, - - _updatePosition: function () { - if (!this._map) { return; } - - var pos = this._map.latLngToLayerPoint(this._latlng), - animated = this._animated, - offset = L.point(this.options.offset); - - if (animated) { - L.DomUtil.setPosition(this._container, pos); - } - - this._containerBottom = -offset.y - (animated ? 0 : pos.y); - this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x + (animated ? 0 : pos.x); - - // bottom position the popup in case the height of the popup changes (images loading etc) - this._container.style.bottom = this._containerBottom + 'px'; - this._container.style.left = this._containerLeft + 'px'; - }, - - _zoomAnimation: function (opt) { - var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center); - - L.DomUtil.setPosition(this._container, pos); - }, - - _adjustPan: function () { - if (!this.options.autoPan) { return; } - - var map = this._map, - containerHeight = this._container.offsetHeight, - containerWidth = this._containerWidth, - - layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom); - - if (this._animated) { - layerPos._add(L.DomUtil.getPosition(this._container)); - } - - var containerPos = map.layerPointToContainerPoint(layerPos), - padding = L.point(this.options.autoPanPadding), - paddingTL = L.point(this.options.autoPanPaddingTopLeft || padding), - paddingBR = L.point(this.options.autoPanPaddingBottomRight || padding), - size = map.getSize(), - dx = 0, - dy = 0; - - if (containerPos.x + containerWidth + paddingBR.x > size.x) { // right - dx = containerPos.x + containerWidth - size.x + paddingBR.x; - } - if (containerPos.x - dx - paddingTL.x < 0) { // left - dx = containerPos.x - paddingTL.x; - } - if (containerPos.y + containerHeight + paddingBR.y > size.y) { // bottom - dy = containerPos.y + containerHeight - size.y + paddingBR.y; - } - if (containerPos.y - dy - paddingTL.y < 0) { // top - dy = containerPos.y - paddingTL.y; - } - - if (dx || dy) { - map - .fire('autopanstart') - .panBy([dx, dy]); - } - }, - - _onCloseButtonClick: function (e) { - this._close(); - L.DomEvent.stop(e); - } -}); - -L.popup = function (options, source) { - return new L.Popup(options, source); -}; - - -L.Map.include({ - openPopup: function (popup, latlng, options) { // (Popup) or (String || HTMLElement, LatLng[, Object]) - this.closePopup(); - - if (!(popup instanceof L.Popup)) { - var content = popup; - - popup = new L.Popup(options) - .setLatLng(latlng) - .setContent(content); - } - popup._isOpen = true; - - this._popup = popup; - return this.addLayer(popup); - }, - - closePopup: function (popup) { - if (!popup || popup === this._popup) { - popup = this._popup; - this._popup = null; - } - if (popup) { - this.removeLayer(popup); - popup._isOpen = false; - } - return this; - } -}); - - -/* - * Popup extension to L.Marker, adding popup-related methods. - */ - -L.Marker.include({ - openPopup: function () { - if (this._popup && this._map && !this._map.hasLayer(this._popup)) { - this._popup.setLatLng(this._latlng); - this._map.openPopup(this._popup); - } - - return this; - }, - - closePopup: function () { - if (this._popup) { - this._popup._close(); - } - return this; - }, - - togglePopup: function () { - if (this._popup) { - if (this._popup._isOpen) { - this.closePopup(); - } else { - this.openPopup(); - } - } - return this; - }, - - bindPopup: function (content, options) { - var anchor = L.point(this.options.icon.options.popupAnchor || [0, 0]); - - anchor = anchor.add(L.Popup.prototype.options.offset); - - if (options && options.offset) { - anchor = anchor.add(options.offset); - } - - options = L.extend({offset: anchor}, options); - - if (!this._popupHandlersAdded) { - this - .on('click', this.togglePopup, this) - .on('remove', this.closePopup, this) - .on('move', this._movePopup, this); - this._popupHandlersAdded = true; - } - - if (content instanceof L.Popup) { - L.setOptions(content, options); - this._popup = content; - } else { - this._popup = new L.Popup(options, this) - .setContent(content); - } - - return this; - }, - - setPopupContent: function (content) { - if (this._popup) { - this._popup.setContent(content); - } - return this; - }, - - unbindPopup: function () { - if (this._popup) { - this._popup = null; - this - .off('click', this.togglePopup, this) - .off('remove', this.closePopup, this) - .off('move', this._movePopup, this); - this._popupHandlersAdded = false; - } - return this; - }, - - getPopup: function () { - return this._popup; - }, - - _movePopup: function (e) { - this._popup.setLatLng(e.latlng); - } -}); - - -/* - * L.LayerGroup is a class to combine several layers into one so that - * you can manipulate the group (e.g. add/remove it) as one layer. - */ - -L.LayerGroup = L.Class.extend({ - initialize: function (layers) { - this._layers = {}; - - var i, len; - - if (layers) { - for (i = 0, len = layers.length; i < len; i++) { - this.addLayer(layers[i]); - } - } - }, - - addLayer: function (layer) { - var id = this.getLayerId(layer); - - this._layers[id] = layer; - - if (this._map) { - this._map.addLayer(layer); - } - - return this; - }, - - removeLayer: function (layer) { - var id = layer in this._layers ? layer : this.getLayerId(layer); - - if (this._map && this._layers[id]) { - this._map.removeLayer(this._layers[id]); - } - - delete this._layers[id]; - - return this; - }, - - hasLayer: function (layer) { - if (!layer) { return false; } - - return (layer in this._layers || this.getLayerId(layer) in this._layers); - }, - - clearLayers: function () { - this.eachLayer(this.removeLayer, this); - return this; - }, - - invoke: function (methodName) { - var args = Array.prototype.slice.call(arguments, 1), - i, layer; - - for (i in this._layers) { - layer = this._layers[i]; - - if (layer[methodName]) { - layer[methodName].apply(layer, args); - } - } - - return this; - }, - - onAdd: function (map) { - this._map = map; - this.eachLayer(map.addLayer, map); - }, - - onRemove: function (map) { - this.eachLayer(map.removeLayer, map); - this._map = null; - }, - - addTo: function (map) { - map.addLayer(this); - return this; - }, - - eachLayer: function (method, context) { - for (var i in this._layers) { - method.call(context, this._layers[i]); - } - return this; - }, - - getLayer: function (id) { - return this._layers[id]; - }, - - getLayers: function () { - var layers = []; - - for (var i in this._layers) { - layers.push(this._layers[i]); - } - return layers; - }, - - setZIndex: function (zIndex) { - return this.invoke('setZIndex', zIndex); - }, - - getLayerId: function (layer) { - return L.stamp(layer); - } -}); - -L.layerGroup = function (layers) { - return new L.LayerGroup(layers); -}; - - -/* - * L.FeatureGroup extends L.LayerGroup by introducing mouse events and additional methods - * shared between a group of interactive layers (like vectors or markers). - */ - -L.FeatureGroup = L.LayerGroup.extend({ - includes: L.Mixin.Events, - - statics: { - EVENTS: 'click dblclick mouseover mouseout mousemove contextmenu popupopen popupclose' - }, - - addLayer: function (layer) { - if (this.hasLayer(layer)) { - return this; - } - - if ('on' in layer) { - layer.on(L.FeatureGroup.EVENTS, this._propagateEvent, this); - } - - L.LayerGroup.prototype.addLayer.call(this, layer); - - if (this._popupContent && layer.bindPopup) { - layer.bindPopup(this._popupContent, this._popupOptions); - } - - return this.fire('layeradd', {layer: layer}); - }, - - removeLayer: function (layer) { - if (!this.hasLayer(layer)) { - return this; - } - if (layer in this._layers) { - layer = this._layers[layer]; - } - - layer.off(L.FeatureGroup.EVENTS, this._propagateEvent, this); - - L.LayerGroup.prototype.removeLayer.call(this, layer); - - if (this._popupContent) { - this.invoke('unbindPopup'); - } - - return this.fire('layerremove', {layer: layer}); - }, - - bindPopup: function (content, options) { - this._popupContent = content; - this._popupOptions = options; - return this.invoke('bindPopup', content, options); - }, - - openPopup: function (latlng) { - // open popup on the first layer - for (var id in this._layers) { - this._layers[id].openPopup(latlng); - break; - } - return this; - }, - - setStyle: function (style) { - return this.invoke('setStyle', style); - }, - - bringToFront: function () { - return this.invoke('bringToFront'); - }, - - bringToBack: function () { - return this.invoke('bringToBack'); - }, - - getBounds: function () { - var bounds = new L.LatLngBounds(); - - this.eachLayer(function (layer) { - bounds.extend(layer instanceof L.Marker ? layer.getLatLng() : layer.getBounds()); - }); - - return bounds; - }, - - _propagateEvent: function (e) { - e = L.extend({ - layer: e.target, - target: this - }, e); - this.fire(e.type, e); - } -}); - -L.featureGroup = function (layers) { - return new L.FeatureGroup(layers); -}; - - -/* - * L.Path is a base class for rendering vector paths on a map. Inherited by Polyline, Circle, etc. - */ - -L.Path = L.Class.extend({ - includes: [L.Mixin.Events], - - statics: { - // how much to extend the clip area around the map view - // (relative to its size, e.g. 0.5 is half the screen in each direction) - // set it so that SVG element doesn't exceed 1280px (vectors flicker on dragend if it is) - CLIP_PADDING: (function () { - var max = L.Browser.mobile ? 1280 : 2000, - target = (max / Math.max(window.outerWidth, window.outerHeight) - 1) / 2; - return Math.max(0, Math.min(0.5, target)); - })() - }, - - options: { - stroke: true, - color: '#0033ff', - dashArray: null, - lineCap: null, - lineJoin: null, - weight: 5, - opacity: 0.5, - - fill: false, - fillColor: null, //same as color by default - fillOpacity: 0.2, - - clickable: true - }, - - initialize: function (options) { - L.setOptions(this, options); - }, - - onAdd: function (map) { - this._map = map; - - if (!this._container) { - this._initElements(); - this._initEvents(); - } - - this.projectLatlngs(); - this._updatePath(); - - if (this._container) { - this._map._pathRoot.appendChild(this._container); - } - - this.fire('add'); - - map.on({ - 'viewreset': this.projectLatlngs, - 'moveend': this._updatePath - }, this); - }, - - addTo: function (map) { - map.addLayer(this); - return this; - }, - - onRemove: function (map) { - map._pathRoot.removeChild(this._container); - - // Need to fire remove event before we set _map to null as the event hooks might need the object - this.fire('remove'); - this._map = null; - - if (L.Browser.vml) { - this._container = null; - this._stroke = null; - this._fill = null; - } - - map.off({ - 'viewreset': this.projectLatlngs, - 'moveend': this._updatePath - }, this); - }, - - projectLatlngs: function () { - // do all projection stuff here - }, - - setStyle: function (style) { - L.setOptions(this, style); - - if (this._container) { - this._updateStyle(); - } - - return this; - }, - - redraw: function () { - if (this._map) { - this.projectLatlngs(); - this._updatePath(); - } - return this; - } -}); - -L.Map.include({ - _updatePathViewport: function () { - var p = L.Path.CLIP_PADDING, - size = this.getSize(), - panePos = L.DomUtil.getPosition(this._mapPane), - min = panePos.multiplyBy(-1)._subtract(size.multiplyBy(p)._round()), - max = min.add(size.multiplyBy(1 + p * 2)._round()); - - this._pathViewport = new L.Bounds(min, max); - } -}); - - -/* - * Extends L.Path with SVG-specific rendering code. - */ - -L.Path.SVG_NS = 'http://www.w3.org/2000/svg'; - -L.Browser.svg = !!(document.createElementNS && document.createElementNS(L.Path.SVG_NS, 'svg').createSVGRect); - -L.Path = L.Path.extend({ - statics: { - SVG: L.Browser.svg - }, - - bringToFront: function () { - var root = this._map._pathRoot, - path = this._container; - - if (path && root.lastChild !== path) { - root.appendChild(path); - } - return this; - }, - - bringToBack: function () { - var root = this._map._pathRoot, - path = this._container, - first = root.firstChild; - - if (path && first !== path) { - root.insertBefore(path, first); - } - return this; - }, - - getPathString: function () { - // form path string here - }, - - _createElement: function (name) { - return document.createElementNS(L.Path.SVG_NS, name); - }, - - _initElements: function () { - this._map._initPathRoot(); - this._initPath(); - this._initStyle(); - }, - - _initPath: function () { - this._container = this._createElement('g'); - - this._path = this._createElement('path'); - - if (this.options.className) { - L.DomUtil.addClass(this._path, this.options.className); - } - - this._container.appendChild(this._path); - }, - - _initStyle: function () { - if (this.options.stroke) { - this._path.setAttribute('stroke-linejoin', 'round'); - this._path.setAttribute('stroke-linecap', 'round'); - } - if (this.options.fill) { - this._path.setAttribute('fill-rule', 'evenodd'); - } - if (this.options.pointerEvents) { - this._path.setAttribute('pointer-events', this.options.pointerEvents); - } - if (!this.options.clickable && !this.options.pointerEvents) { - this._path.setAttribute('pointer-events', 'none'); - } - this._updateStyle(); - }, - - _updateStyle: function () { - if (this.options.stroke) { - this._path.setAttribute('stroke', this.options.color); - this._path.setAttribute('stroke-opacity', this.options.opacity); - this._path.setAttribute('stroke-width', this.options.weight); - if (this.options.dashArray) { - this._path.setAttribute('stroke-dasharray', this.options.dashArray); - } else { - this._path.removeAttribute('stroke-dasharray'); - } - if (this.options.lineCap) { - this._path.setAttribute('stroke-linecap', this.options.lineCap); - } - if (this.options.lineJoin) { - this._path.setAttribute('stroke-linejoin', this.options.lineJoin); - } - } else { - this._path.setAttribute('stroke', 'none'); - } - if (this.options.fill) { - this._path.setAttribute('fill', this.options.fillColor || this.options.color); - this._path.setAttribute('fill-opacity', this.options.fillOpacity); - } else { - this._path.setAttribute('fill', 'none'); - } - }, - - _updatePath: function () { - var str = this.getPathString(); - if (!str) { - // fix webkit empty string parsing bug - str = 'M0 0'; - } - this._path.setAttribute('d', str); - }, - - // TODO remove duplication with L.Map - _initEvents: function () { - if (this.options.clickable) { - if (L.Browser.svg || !L.Browser.vml) { - L.DomUtil.addClass(this._path, 'leaflet-clickable'); - } - - L.DomEvent.on(this._container, 'click', this._onMouseClick, this); - - var events = ['dblclick', 'mousedown', 'mouseover', - 'mouseout', 'mousemove', 'contextmenu']; - for (var i = 0; i < events.length; i++) { - L.DomEvent.on(this._container, events[i], this._fireMouseEvent, this); - } - } - }, - - _onMouseClick: function (e) { - if (this._map.dragging && this._map.dragging.moved()) { return; } - - this._fireMouseEvent(e); - }, - - _fireMouseEvent: function (e) { - if (!this.hasEventListeners(e.type)) { return; } - - var map = this._map, - containerPoint = map.mouseEventToContainerPoint(e), - layerPoint = map.containerPointToLayerPoint(containerPoint), - latlng = map.layerPointToLatLng(layerPoint); - - this.fire(e.type, { - latlng: latlng, - layerPoint: layerPoint, - containerPoint: containerPoint, - originalEvent: e - }); - - if (e.type === 'contextmenu') { - L.DomEvent.preventDefault(e); - } - if (e.type !== 'mousemove') { - L.DomEvent.stopPropagation(e); - } - } -}); - -L.Map.include({ - _initPathRoot: function () { - if (!this._pathRoot) { - this._pathRoot = L.Path.prototype._createElement('svg'); - this._panes.overlayPane.appendChild(this._pathRoot); - - if (this.options.zoomAnimation && L.Browser.any3d) { - L.DomUtil.addClass(this._pathRoot, 'leaflet-zoom-animated'); - - this.on({ - 'zoomanim': this._animatePathZoom, - 'zoomend': this._endPathZoom - }); - } else { - L.DomUtil.addClass(this._pathRoot, 'leaflet-zoom-hide'); - } - - this.on('moveend', this._updateSvgViewport); - this._updateSvgViewport(); - } - }, - - _animatePathZoom: function (e) { - var scale = this.getZoomScale(e.zoom), - offset = this._getCenterOffset(e.center)._multiplyBy(-scale)._add(this._pathViewport.min); - - this._pathRoot.style[L.DomUtil.TRANSFORM] = - L.DomUtil.getTranslateString(offset) + ' scale(' + scale + ') '; - - this._pathZooming = true; - }, - - _endPathZoom: function () { - this._pathZooming = false; - }, - - _updateSvgViewport: function () { - - if (this._pathZooming) { - // Do not update SVGs while a zoom animation is going on otherwise the animation will break. - // When the zoom animation ends we will be updated again anyway - // This fixes the case where you do a momentum move and zoom while the move is still ongoing. - return; - } - - this._updatePathViewport(); - - var vp = this._pathViewport, - min = vp.min, - max = vp.max, - width = max.x - min.x, - height = max.y - min.y, - root = this._pathRoot, - pane = this._panes.overlayPane; - - // Hack to make flicker on drag end on mobile webkit less irritating - if (L.Browser.mobileWebkit) { - pane.removeChild(root); - } - - L.DomUtil.setPosition(root, min); - root.setAttribute('width', width); - root.setAttribute('height', height); - root.setAttribute('viewBox', [min.x, min.y, width, height].join(' ')); - - if (L.Browser.mobileWebkit) { - pane.appendChild(root); - } - } -}); - - -/* - * Popup extension to L.Path (polylines, polygons, circles), adding popup-related methods. - */ - -L.Path.include({ - - bindPopup: function (content, options) { - - if (content instanceof L.Popup) { - this._popup = content; - } else { - if (!this._popup || options) { - this._popup = new L.Popup(options, this); - } - this._popup.setContent(content); - } - - if (!this._popupHandlersAdded) { - this - .on('click', this._openPopup, this) - .on('remove', this.closePopup, this); - - this._popupHandlersAdded = true; - } - - return this; - }, - - unbindPopup: function () { - if (this._popup) { - this._popup = null; - this - .off('click', this._openPopup) - .off('remove', this.closePopup); - - this._popupHandlersAdded = false; - } - return this; - }, - - openPopup: function (latlng) { - - if (this._popup) { - // open the popup from one of the path's points if not specified - latlng = latlng || this._latlng || - this._latlngs[Math.floor(this._latlngs.length / 2)]; - - this._openPopup({latlng: latlng}); - } - - return this; - }, - - closePopup: function () { - if (this._popup) { - this._popup._close(); - } - return this; - }, - - _openPopup: function (e) { - this._popup.setLatLng(e.latlng); - this._map.openPopup(this._popup); - } -}); - - -/* - * Vector rendering for IE6-8 through VML. - * Thanks to Dmitry Baranovsky and his Raphael library for inspiration! - */ - -L.Browser.vml = !L.Browser.svg && (function () { - try { - var div = document.createElement('div'); - div.innerHTML = ''; - - var shape = div.firstChild; - shape.style.behavior = 'url(#default#VML)'; - - return shape && (typeof shape.adj === 'object'); - - } catch (e) { - return false; - } -}()); - -L.Path = L.Browser.svg || !L.Browser.vml ? L.Path : L.Path.extend({ - statics: { - VML: true, - CLIP_PADDING: 0.02 - }, - - _createElement: (function () { - try { - document.namespaces.add('lvml', 'urn:schemas-microsoft-com:vml'); - return function (name) { - return document.createElement(''); - }; - } catch (e) { - return function (name) { - return document.createElement( - '<' + name + ' xmlns="urn:schemas-microsoft.com:vml" class="lvml">'); - }; - } - }()), - - _initPath: function () { - var container = this._container = this._createElement('shape'); - - L.DomUtil.addClass(container, 'leaflet-vml-shape' + - (this.options.className ? ' ' + this.options.className : '')); - - if (this.options.clickable) { - L.DomUtil.addClass(container, 'leaflet-clickable'); - } - - container.coordsize = '1 1'; - - this._path = this._createElement('path'); - container.appendChild(this._path); - - this._map._pathRoot.appendChild(container); - }, - - _initStyle: function () { - this._updateStyle(); - }, - - _updateStyle: function () { - var stroke = this._stroke, - fill = this._fill, - options = this.options, - container = this._container; - - container.stroked = options.stroke; - container.filled = options.fill; - - if (options.stroke) { - if (!stroke) { - stroke = this._stroke = this._createElement('stroke'); - stroke.endcap = 'round'; - container.appendChild(stroke); - } - stroke.weight = options.weight + 'px'; - stroke.color = options.color; - stroke.opacity = options.opacity; - - if (options.dashArray) { - stroke.dashStyle = L.Util.isArray(options.dashArray) ? - options.dashArray.join(' ') : - options.dashArray.replace(/( *, *)/g, ' '); - } else { - stroke.dashStyle = ''; - } - if (options.lineCap) { - stroke.endcap = options.lineCap.replace('butt', 'flat'); - } - if (options.lineJoin) { - stroke.joinstyle = options.lineJoin; - } - - } else if (stroke) { - container.removeChild(stroke); - this._stroke = null; - } - - if (options.fill) { - if (!fill) { - fill = this._fill = this._createElement('fill'); - container.appendChild(fill); - } - fill.color = options.fillColor || options.color; - fill.opacity = options.fillOpacity; - - } else if (fill) { - container.removeChild(fill); - this._fill = null; - } - }, - - _updatePath: function () { - var style = this._container.style; - - style.display = 'none'; - this._path.v = this.getPathString() + ' '; // the space fixes IE empty path string bug - style.display = ''; - } -}); - -L.Map.include(L.Browser.svg || !L.Browser.vml ? {} : { - _initPathRoot: function () { - if (this._pathRoot) { return; } - - var root = this._pathRoot = document.createElement('div'); - root.className = 'leaflet-vml-container'; - this._panes.overlayPane.appendChild(root); - - this.on('moveend', this._updatePathViewport); - this._updatePathViewport(); - } -}); - - -/* - * Vector rendering for all browsers that support canvas. - */ - -L.Browser.canvas = (function () { - return !!document.createElement('canvas').getContext; -}()); - -L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path : L.Path.extend({ - statics: { - //CLIP_PADDING: 0.02, // not sure if there's a need to set it to a small value - CANVAS: true, - SVG: false - }, - - redraw: function () { - if (this._map) { - this.projectLatlngs(); - this._requestUpdate(); - } - return this; - }, - - setStyle: function (style) { - L.setOptions(this, style); - - if (this._map) { - this._updateStyle(); - this._requestUpdate(); - } - return this; - }, - - onRemove: function (map) { - map - .off('viewreset', this.projectLatlngs, this) - .off('moveend', this._updatePath, this); - - if (this.options.clickable) { - this._map.off('click', this._onClick, this); - this._map.off('mousemove', this._onMouseMove, this); - } - - this._requestUpdate(); - - this.fire('remove'); - this._map = null; - }, - - _requestUpdate: function () { - if (this._map && !L.Path._updateRequest) { - L.Path._updateRequest = L.Util.requestAnimFrame(this._fireMapMoveEnd, this._map); - } - }, - - _fireMapMoveEnd: function () { - L.Path._updateRequest = null; - this.fire('moveend'); - }, - - _initElements: function () { - this._map._initPathRoot(); - this._ctx = this._map._canvasCtx; - }, - - _updateStyle: function () { - var options = this.options; - - if (options.stroke) { - this._ctx.lineWidth = options.weight; - this._ctx.strokeStyle = options.color; - } - if (options.fill) { - this._ctx.fillStyle = options.fillColor || options.color; - } - }, - - _drawPath: function () { - var i, j, len, len2, point, drawMethod; - - this._ctx.beginPath(); - - for (i = 0, len = this._parts.length; i < len; i++) { - for (j = 0, len2 = this._parts[i].length; j < len2; j++) { - point = this._parts[i][j]; - drawMethod = (j === 0 ? 'move' : 'line') + 'To'; - - this._ctx[drawMethod](point.x, point.y); - } - // TODO refactor ugly hack - if (this instanceof L.Polygon) { - this._ctx.closePath(); - } - } - }, - - _checkIfEmpty: function () { - return !this._parts.length; - }, - - _updatePath: function () { - if (this._checkIfEmpty()) { return; } - - var ctx = this._ctx, - options = this.options; - - this._drawPath(); - ctx.save(); - this._updateStyle(); - - if (options.fill) { - ctx.globalAlpha = options.fillOpacity; - ctx.fill(); - } - - if (options.stroke) { - ctx.globalAlpha = options.opacity; - ctx.stroke(); - } - - ctx.restore(); - - // TODO optimization: 1 fill/stroke for all features with equal style instead of 1 for each feature - }, - - _initEvents: function () { - if (this.options.clickable) { - // TODO dblclick - this._map.on('mousemove', this._onMouseMove, this); - this._map.on('click', this._onClick, this); - } - }, - - _onClick: function (e) { - if (this._containsPoint(e.layerPoint)) { - this.fire('click', e); - } - }, - - _onMouseMove: function (e) { - if (!this._map || this._map._animatingZoom) { return; } - - // TODO don't do on each move - if (this._containsPoint(e.layerPoint)) { - this._ctx.canvas.style.cursor = 'pointer'; - this._mouseInside = true; - this.fire('mouseover', e); - - } else if (this._mouseInside) { - this._ctx.canvas.style.cursor = ''; - this._mouseInside = false; - this.fire('mouseout', e); - } - } -}); - -L.Map.include((L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? {} : { - _initPathRoot: function () { - var root = this._pathRoot, - ctx; - - if (!root) { - root = this._pathRoot = document.createElement('canvas'); - root.style.position = 'absolute'; - ctx = this._canvasCtx = root.getContext('2d'); - - ctx.lineCap = 'round'; - ctx.lineJoin = 'round'; - - this._panes.overlayPane.appendChild(root); - - if (this.options.zoomAnimation) { - this._pathRoot.className = 'leaflet-zoom-animated'; - this.on('zoomanim', this._animatePathZoom); - this.on('zoomend', this._endPathZoom); - } - this.on('moveend', this._updateCanvasViewport); - this._updateCanvasViewport(); - } - }, - - _updateCanvasViewport: function () { - // don't redraw while zooming. See _updateSvgViewport for more details - if (this._pathZooming) { return; } - this._updatePathViewport(); - - var vp = this._pathViewport, - min = vp.min, - size = vp.max.subtract(min), - root = this._pathRoot; - - //TODO check if this works properly on mobile webkit - L.DomUtil.setPosition(root, min); - root.width = size.x; - root.height = size.y; - root.getContext('2d').translate(-min.x, -min.y); - } -}); - - -/* - * L.LineUtil contains different utility functions for line segments - * and polylines (clipping, simplification, distances, etc.) - */ - -/*jshint bitwise:false */ // allow bitwise operations for this file - -L.LineUtil = { - - // Simplify polyline with vertex reduction and Douglas-Peucker simplification. - // Improves rendering performance dramatically by lessening the number of points to draw. - - simplify: function (/*Point[]*/ points, /*Number*/ tolerance) { - if (!tolerance || !points.length) { - return points.slice(); - } - - var sqTolerance = tolerance * tolerance; - - // stage 1: vertex reduction - points = this._reducePoints(points, sqTolerance); - - // stage 2: Douglas-Peucker simplification - points = this._simplifyDP(points, sqTolerance); - - return points; - }, - - // distance from a point to a segment between two points - pointToSegmentDistance: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) { - return Math.sqrt(this._sqClosestPointOnSegment(p, p1, p2, true)); - }, - - closestPointOnSegment: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) { - return this._sqClosestPointOnSegment(p, p1, p2); - }, - - // Douglas-Peucker simplification, see http://en.wikipedia.org/wiki/Douglas-Peucker_algorithm - _simplifyDP: function (points, sqTolerance) { - - var len = points.length, - ArrayConstructor = typeof Uint8Array !== undefined + '' ? Uint8Array : Array, - markers = new ArrayConstructor(len); - - markers[0] = markers[len - 1] = 1; - - this._simplifyDPStep(points, markers, sqTolerance, 0, len - 1); - - var i, - newPoints = []; - - for (i = 0; i < len; i++) { - if (markers[i]) { - newPoints.push(points[i]); - } - } - - return newPoints; - }, - - _simplifyDPStep: function (points, markers, sqTolerance, first, last) { - - var maxSqDist = 0, - index, i, sqDist; - - for (i = first + 1; i <= last - 1; i++) { - sqDist = this._sqClosestPointOnSegment(points[i], points[first], points[last], true); - - if (sqDist > maxSqDist) { - index = i; - maxSqDist = sqDist; - } - } - - if (maxSqDist > sqTolerance) { - markers[index] = 1; - - this._simplifyDPStep(points, markers, sqTolerance, first, index); - this._simplifyDPStep(points, markers, sqTolerance, index, last); - } - }, - - // reduce points that are too close to each other to a single point - _reducePoints: function (points, sqTolerance) { - var reducedPoints = [points[0]]; - - for (var i = 1, prev = 0, len = points.length; i < len; i++) { - if (this._sqDist(points[i], points[prev]) > sqTolerance) { - reducedPoints.push(points[i]); - prev = i; - } - } - if (prev < len - 1) { - reducedPoints.push(points[len - 1]); - } - return reducedPoints; - }, - - // Cohen-Sutherland line clipping algorithm. - // Used to avoid rendering parts of a polyline that are not currently visible. - - clipSegment: function (a, b, bounds, useLastCode) { - var codeA = useLastCode ? this._lastCode : this._getBitCode(a, bounds), - codeB = this._getBitCode(b, bounds), - - codeOut, p, newCode; - - // save 2nd code to avoid calculating it on the next segment - this._lastCode = codeB; - - while (true) { - // if a,b is inside the clip window (trivial accept) - if (!(codeA | codeB)) { - return [a, b]; - // if a,b is outside the clip window (trivial reject) - } else if (codeA & codeB) { - return false; - // other cases - } else { - codeOut = codeA || codeB; - p = this._getEdgeIntersection(a, b, codeOut, bounds); - newCode = this._getBitCode(p, bounds); - - if (codeOut === codeA) { - a = p; - codeA = newCode; - } else { - b = p; - codeB = newCode; - } - } - } - }, - - _getEdgeIntersection: function (a, b, code, bounds) { - var dx = b.x - a.x, - dy = b.y - a.y, - min = bounds.min, - max = bounds.max; - - if (code & 8) { // top - return new L.Point(a.x + dx * (max.y - a.y) / dy, max.y); - } else if (code & 4) { // bottom - return new L.Point(a.x + dx * (min.y - a.y) / dy, min.y); - } else if (code & 2) { // right - return new L.Point(max.x, a.y + dy * (max.x - a.x) / dx); - } else if (code & 1) { // left - return new L.Point(min.x, a.y + dy * (min.x - a.x) / dx); - } - }, - - _getBitCode: function (/*Point*/ p, bounds) { - var code = 0; - - if (p.x < bounds.min.x) { // left - code |= 1; - } else if (p.x > bounds.max.x) { // right - code |= 2; - } - if (p.y < bounds.min.y) { // bottom - code |= 4; - } else if (p.y > bounds.max.y) { // top - code |= 8; - } - - return code; - }, - - // square distance (to avoid unnecessary Math.sqrt calls) - _sqDist: function (p1, p2) { - var dx = p2.x - p1.x, - dy = p2.y - p1.y; - return dx * dx + dy * dy; - }, - - // return closest point on segment or distance to that point - _sqClosestPointOnSegment: function (p, p1, p2, sqDist) { - var x = p1.x, - y = p1.y, - dx = p2.x - x, - dy = p2.y - y, - dot = dx * dx + dy * dy, - t; - - if (dot > 0) { - t = ((p.x - x) * dx + (p.y - y) * dy) / dot; - - if (t > 1) { - x = p2.x; - y = p2.y; - } else if (t > 0) { - x += dx * t; - y += dy * t; - } - } - - dx = p.x - x; - dy = p.y - y; - - return sqDist ? dx * dx + dy * dy : new L.Point(x, y); - } -}; - - -/* - * L.Polyline is used to display polylines on a map. - */ - -L.Polyline = L.Path.extend({ - initialize: function (latlngs, options) { - L.Path.prototype.initialize.call(this, options); - - this._latlngs = this._convertLatLngs(latlngs); - }, - - options: { - // how much to simplify the polyline on each zoom level - // more = better performance and smoother look, less = more accurate - smoothFactor: 1.0, - noClip: false - }, - - projectLatlngs: function () { - this._originalPoints = []; - - for (var i = 0, len = this._latlngs.length; i < len; i++) { - this._originalPoints[i] = this._map.latLngToLayerPoint(this._latlngs[i]); - } - }, - - getPathString: function () { - for (var i = 0, len = this._parts.length, str = ''; i < len; i++) { - str += this._getPathPartStr(this._parts[i]); - } - return str; - }, - - getLatLngs: function () { - return this._latlngs; - }, - - setLatLngs: function (latlngs) { - this._latlngs = this._convertLatLngs(latlngs); - return this.redraw(); - }, - - addLatLng: function (latlng) { - this._latlngs.push(L.latLng(latlng)); - return this.redraw(); - }, - - spliceLatLngs: function () { // (Number index, Number howMany) - var removed = [].splice.apply(this._latlngs, arguments); - this._convertLatLngs(this._latlngs, true); - this.redraw(); - return removed; - }, - - closestLayerPoint: function (p) { - var minDistance = Infinity, parts = this._parts, p1, p2, minPoint = null; - - for (var j = 0, jLen = parts.length; j < jLen; j++) { - var points = parts[j]; - for (var i = 1, len = points.length; i < len; i++) { - p1 = points[i - 1]; - p2 = points[i]; - var sqDist = L.LineUtil._sqClosestPointOnSegment(p, p1, p2, true); - if (sqDist < minDistance) { - minDistance = sqDist; - minPoint = L.LineUtil._sqClosestPointOnSegment(p, p1, p2); - } - } - } - if (minPoint) { - minPoint.distance = Math.sqrt(minDistance); - } - return minPoint; - }, - - getBounds: function () { - return new L.LatLngBounds(this.getLatLngs()); - }, - - _convertLatLngs: function (latlngs, overwrite) { - var i, len, target = overwrite ? latlngs : []; - - for (i = 0, len = latlngs.length; i < len; i++) { - if (L.Util.isArray(latlngs[i]) && typeof latlngs[i][0] !== 'number') { - return; - } - target[i] = L.latLng(latlngs[i]); - } - return target; - }, - - _initEvents: function () { - L.Path.prototype._initEvents.call(this); - }, - - _getPathPartStr: function (points) { - var round = L.Path.VML; - - for (var j = 0, len2 = points.length, str = '', p; j < len2; j++) { - p = points[j]; - if (round) { - p._round(); - } - str += (j ? 'L' : 'M') + p.x + ' ' + p.y; - } - return str; - }, - - _clipPoints: function () { - var points = this._originalPoints, - len = points.length, - i, k, segment; - - if (this.options.noClip) { - this._parts = [points]; - return; - } - - this._parts = []; - - var parts = this._parts, - vp = this._map._pathViewport, - lu = L.LineUtil; - - for (i = 0, k = 0; i < len - 1; i++) { - segment = lu.clipSegment(points[i], points[i + 1], vp, i); - if (!segment) { - continue; - } - - parts[k] = parts[k] || []; - parts[k].push(segment[0]); - - // if segment goes out of screen, or it's the last one, it's the end of the line part - if ((segment[1] !== points[i + 1]) || (i === len - 2)) { - parts[k].push(segment[1]); - k++; - } - } - }, - - // simplify each clipped part of the polyline - _simplifyPoints: function () { - var parts = this._parts, - lu = L.LineUtil; - - for (var i = 0, len = parts.length; i < len; i++) { - parts[i] = lu.simplify(parts[i], this.options.smoothFactor); - } - }, - - _updatePath: function () { - if (!this._map) { return; } - - this._clipPoints(); - this._simplifyPoints(); - - L.Path.prototype._updatePath.call(this); - } -}); - -L.polyline = function (latlngs, options) { - return new L.Polyline(latlngs, options); -}; - - -/* - * L.PolyUtil contains utility functions for polygons (clipping, etc.). - */ - -/*jshint bitwise:false */ // allow bitwise operations here - -L.PolyUtil = {}; - -/* - * Sutherland-Hodgeman polygon clipping algorithm. - * Used to avoid rendering parts of a polygon that are not currently visible. - */ -L.PolyUtil.clipPolygon = function (points, bounds) { - var clippedPoints, - edges = [1, 4, 2, 8], - i, j, k, - a, b, - len, edge, p, - lu = L.LineUtil; - - for (i = 0, len = points.length; i < len; i++) { - points[i]._code = lu._getBitCode(points[i], bounds); - } - - // for each edge (left, bottom, right, top) - for (k = 0; k < 4; k++) { - edge = edges[k]; - clippedPoints = []; - - for (i = 0, len = points.length, j = len - 1; i < len; j = i++) { - a = points[i]; - b = points[j]; - - // if a is inside the clip window - if (!(a._code & edge)) { - // if b is outside the clip window (a->b goes out of screen) - if (b._code & edge) { - p = lu._getEdgeIntersection(b, a, edge, bounds); - p._code = lu._getBitCode(p, bounds); - clippedPoints.push(p); - } - clippedPoints.push(a); - - // else if b is inside the clip window (a->b enters the screen) - } else if (!(b._code & edge)) { - p = lu._getEdgeIntersection(b, a, edge, bounds); - p._code = lu._getBitCode(p, bounds); - clippedPoints.push(p); - } - } - points = clippedPoints; - } - - return points; -}; - - -/* - * L.Polygon is used to display polygons on a map. - */ - -L.Polygon = L.Polyline.extend({ - options: { - fill: true - }, - - initialize: function (latlngs, options) { - L.Polyline.prototype.initialize.call(this, latlngs, options); - this._initWithHoles(latlngs); - }, - - _initWithHoles: function (latlngs) { - var i, len, hole; - if (latlngs && L.Util.isArray(latlngs[0]) && (typeof latlngs[0][0] !== 'number')) { - this._latlngs = this._convertLatLngs(latlngs[0]); - this._holes = latlngs.slice(1); - - for (i = 0, len = this._holes.length; i < len; i++) { - hole = this._holes[i] = this._convertLatLngs(this._holes[i]); - if (hole[0].equals(hole[hole.length - 1])) { - hole.pop(); - } - } - } - - // filter out last point if its equal to the first one - latlngs = this._latlngs; - - if (latlngs.length >= 2 && latlngs[0].equals(latlngs[latlngs.length - 1])) { - latlngs.pop(); - } - }, - - projectLatlngs: function () { - L.Polyline.prototype.projectLatlngs.call(this); - - // project polygon holes points - // TODO move this logic to Polyline to get rid of duplication - this._holePoints = []; - - if (!this._holes) { return; } - - var i, j, len, len2; - - for (i = 0, len = this._holes.length; i < len; i++) { - this._holePoints[i] = []; - - for (j = 0, len2 = this._holes[i].length; j < len2; j++) { - this._holePoints[i][j] = this._map.latLngToLayerPoint(this._holes[i][j]); - } - } - }, - - setLatLngs: function (latlngs) { - if (latlngs && L.Util.isArray(latlngs[0]) && (typeof latlngs[0][0] !== 'number')) { - this._initWithHoles(latlngs); - return this.redraw(); - } else { - return L.Polyline.prototype.setLatLngs.call(this, latlngs); - } - }, - - _clipPoints: function () { - var points = this._originalPoints, - newParts = []; - - this._parts = [points].concat(this._holePoints); - - if (this.options.noClip) { return; } - - for (var i = 0, len = this._parts.length; i < len; i++) { - var clipped = L.PolyUtil.clipPolygon(this._parts[i], this._map._pathViewport); - if (clipped.length) { - newParts.push(clipped); - } - } - - this._parts = newParts; - }, - - _getPathPartStr: function (points) { - var str = L.Polyline.prototype._getPathPartStr.call(this, points); - return str + (L.Browser.svg ? 'z' : 'x'); - } -}); - -L.polygon = function (latlngs, options) { - return new L.Polygon(latlngs, options); -}; - - -/* - * Contains L.MultiPolyline and L.MultiPolygon layers. - */ - -(function () { - function createMulti(Klass) { - - return L.FeatureGroup.extend({ - - initialize: function (latlngs, options) { - this._layers = {}; - this._options = options; - this.setLatLngs(latlngs); - }, - - setLatLngs: function (latlngs) { - var i = 0, - len = latlngs.length; - - this.eachLayer(function (layer) { - if (i < len) { - layer.setLatLngs(latlngs[i++]); - } else { - this.removeLayer(layer); - } - }, this); - - while (i < len) { - this.addLayer(new Klass(latlngs[i++], this._options)); - } - - return this; - }, - - getLatLngs: function () { - var latlngs = []; - - this.eachLayer(function (layer) { - latlngs.push(layer.getLatLngs()); - }); - - return latlngs; - } - }); - } - - L.MultiPolyline = createMulti(L.Polyline); - L.MultiPolygon = createMulti(L.Polygon); - - L.multiPolyline = function (latlngs, options) { - return new L.MultiPolyline(latlngs, options); - }; - - L.multiPolygon = function (latlngs, options) { - return new L.MultiPolygon(latlngs, options); - }; -}()); - - -/* - * L.Rectangle extends Polygon and creates a rectangle when passed a LatLngBounds object. - */ - -L.Rectangle = L.Polygon.extend({ - initialize: function (latLngBounds, options) { - L.Polygon.prototype.initialize.call(this, this._boundsToLatLngs(latLngBounds), options); - }, - - setBounds: function (latLngBounds) { - this.setLatLngs(this._boundsToLatLngs(latLngBounds)); - }, - - _boundsToLatLngs: function (latLngBounds) { - latLngBounds = L.latLngBounds(latLngBounds); - return [ - latLngBounds.getSouthWest(), - latLngBounds.getNorthWest(), - latLngBounds.getNorthEast(), - latLngBounds.getSouthEast() - ]; - } -}); - -L.rectangle = function (latLngBounds, options) { - return new L.Rectangle(latLngBounds, options); -}; - - -/* - * L.Circle is a circle overlay (with a certain radius in meters). - */ - -L.Circle = L.Path.extend({ - initialize: function (latlng, radius, options) { - L.Path.prototype.initialize.call(this, options); - - this._latlng = L.latLng(latlng); - this._mRadius = radius; - }, - - options: { - fill: true - }, - - setLatLng: function (latlng) { - this._latlng = L.latLng(latlng); - return this.redraw(); - }, - - setRadius: function (radius) { - this._mRadius = radius; - return this.redraw(); - }, - - projectLatlngs: function () { - var lngRadius = this._getLngRadius(), - latlng = this._latlng, - pointLeft = this._map.latLngToLayerPoint([latlng.lat, latlng.lng - lngRadius]); - - this._point = this._map.latLngToLayerPoint(latlng); - this._radius = Math.max(this._point.x - pointLeft.x, 1); - }, - - getBounds: function () { - var lngRadius = this._getLngRadius(), - latRadius = (this._mRadius / 40075017) * 360, - latlng = this._latlng; - - return new L.LatLngBounds( - [latlng.lat - latRadius, latlng.lng - lngRadius], - [latlng.lat + latRadius, latlng.lng + lngRadius]); - }, - - getLatLng: function () { - return this._latlng; - }, - - getPathString: function () { - var p = this._point, - r = this._radius; - - if (this._checkIfEmpty()) { - return ''; - } - - if (L.Browser.svg) { - return 'M' + p.x + ',' + (p.y - r) + - 'A' + r + ',' + r + ',0,1,1,' + - (p.x - 0.1) + ',' + (p.y - r) + ' z'; - } else { - p._round(); - r = Math.round(r); - return 'AL ' + p.x + ',' + p.y + ' ' + r + ',' + r + ' 0,' + (65535 * 360); - } - }, - - getRadius: function () { - return this._mRadius; - }, - - // TODO Earth hardcoded, move into projection code! - - _getLatRadius: function () { - return (this._mRadius / 40075017) * 360; - }, - - _getLngRadius: function () { - return this._getLatRadius() / Math.cos(L.LatLng.DEG_TO_RAD * this._latlng.lat); - }, - - _checkIfEmpty: function () { - if (!this._map) { - return false; - } - var vp = this._map._pathViewport, - r = this._radius, - p = this._point; - - return p.x - r > vp.max.x || p.y - r > vp.max.y || - p.x + r < vp.min.x || p.y + r < vp.min.y; - } -}); - -L.circle = function (latlng, radius, options) { - return new L.Circle(latlng, radius, options); -}; - - -/* - * L.CircleMarker is a circle overlay with a permanent pixel radius. - */ - -L.CircleMarker = L.Circle.extend({ - options: { - radius: 10, - weight: 2 - }, - - initialize: function (latlng, options) { - L.Circle.prototype.initialize.call(this, latlng, null, options); - this._radius = this.options.radius; - }, - - projectLatlngs: function () { - this._point = this._map.latLngToLayerPoint(this._latlng); - }, - - _updateStyle : function () { - L.Circle.prototype._updateStyle.call(this); - this.setRadius(this.options.radius); - }, - - setLatLng: function (latlng) { - L.Circle.prototype.setLatLng.call(this, latlng); - if (this._popup && this._popup._isOpen) { - this._popup.setLatLng(latlng); - } - return this; - }, - - setRadius: function (radius) { - this.options.radius = this._radius = radius; - return this.redraw(); - }, - - getRadius: function () { - return this._radius; - } -}); - -L.circleMarker = function (latlng, options) { - return new L.CircleMarker(latlng, options); -}; - - -/* - * Extends L.Polyline to be able to manually detect clicks on Canvas-rendered polylines. - */ - -L.Polyline.include(!L.Path.CANVAS ? {} : { - _containsPoint: function (p, closed) { - var i, j, k, len, len2, dist, part, - w = this.options.weight / 2; - - if (L.Browser.touch) { - w += 10; // polyline click tolerance on touch devices - } - - for (i = 0, len = this._parts.length; i < len; i++) { - part = this._parts[i]; - for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) { - if (!closed && (j === 0)) { - continue; - } - - dist = L.LineUtil.pointToSegmentDistance(p, part[k], part[j]); - - if (dist <= w) { - return true; - } - } - } - return false; - } -}); - - -/* - * Extends L.Polygon to be able to manually detect clicks on Canvas-rendered polygons. - */ - -L.Polygon.include(!L.Path.CANVAS ? {} : { - _containsPoint: function (p) { - var inside = false, - part, p1, p2, - i, j, k, - len, len2; - - // TODO optimization: check if within bounds first - - if (L.Polyline.prototype._containsPoint.call(this, p, true)) { - // click on polygon border - return true; - } - - // ray casting algorithm for detecting if point is in polygon - - for (i = 0, len = this._parts.length; i < len; i++) { - part = this._parts[i]; - - for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) { - p1 = part[j]; - p2 = part[k]; - - if (((p1.y > p.y) !== (p2.y > p.y)) && - (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) { - inside = !inside; - } - } - } - - return inside; - } -}); - - -/* - * Extends L.Circle with Canvas-specific code. - */ - -L.Circle.include(!L.Path.CANVAS ? {} : { - _drawPath: function () { - var p = this._point; - this._ctx.beginPath(); - this._ctx.arc(p.x, p.y, this._radius, 0, Math.PI * 2, false); - }, - - _containsPoint: function (p) { - var center = this._point, - w2 = this.options.stroke ? this.options.weight / 2 : 0; - - return (p.distanceTo(center) <= this._radius + w2); - } -}); - - -/* - * CircleMarker canvas specific drawing parts. - */ - -L.CircleMarker.include(!L.Path.CANVAS ? {} : { - _updateStyle: function () { - L.Path.prototype._updateStyle.call(this); - } -}); - - -/* - * L.GeoJSON turns any GeoJSON data into a Leaflet layer. - */ - -L.GeoJSON = L.FeatureGroup.extend({ - - initialize: function (geojson, options) { - L.setOptions(this, options); - - this._layers = {}; - - if (geojson) { - this.addData(geojson); - } - }, - - addData: function (geojson) { - var features = L.Util.isArray(geojson) ? geojson : geojson.features, - i, len, feature; - - if (features) { - for (i = 0, len = features.length; i < len; i++) { - // Only add this if geometry or geometries are set and not null - feature = features[i]; - if (feature.geometries || feature.geometry || feature.features || feature.coordinates) { - this.addData(features[i]); - } - } - return this; - } - - var options = this.options; - - if (options.filter && !options.filter(geojson)) { return; } - - var layer = L.GeoJSON.geometryToLayer(geojson, options.pointToLayer, options.coordsToLatLng, options); - layer.feature = L.GeoJSON.asFeature(geojson); - - layer.defaultOptions = layer.options; - this.resetStyle(layer); - - if (options.onEachFeature) { - options.onEachFeature(geojson, layer); - } - - return this.addLayer(layer); - }, - - resetStyle: function (layer) { - var style = this.options.style; - if (style) { - // reset any custom styles - L.Util.extend(layer.options, layer.defaultOptions); - - this._setLayerStyle(layer, style); - } - }, - - setStyle: function (style) { - this.eachLayer(function (layer) { - this._setLayerStyle(layer, style); - }, this); - }, - - _setLayerStyle: function (layer, style) { - if (typeof style === 'function') { - style = style(layer.feature); - } - if (layer.setStyle) { - layer.setStyle(style); - } - } -}); - -L.extend(L.GeoJSON, { - geometryToLayer: function (geojson, pointToLayer, coordsToLatLng, vectorOptions) { - var geometry = geojson.type === 'Feature' ? geojson.geometry : geojson, - coords = geometry.coordinates, - layers = [], - latlng, latlngs, i, len; - - coordsToLatLng = coordsToLatLng || this.coordsToLatLng; - - switch (geometry.type) { - case 'Point': - latlng = coordsToLatLng(coords); - return pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng); - - case 'MultiPoint': - for (i = 0, len = coords.length; i < len; i++) { - latlng = coordsToLatLng(coords[i]); - layers.push(pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng)); - } - return new L.FeatureGroup(layers); - - case 'LineString': - latlngs = this.coordsToLatLngs(coords, 0, coordsToLatLng); - return new L.Polyline(latlngs, vectorOptions); - - case 'Polygon': - if (coords.length === 2 && !coords[1].length) { - throw new Error('Invalid GeoJSON object.'); - } - latlngs = this.coordsToLatLngs(coords, 1, coordsToLatLng); - return new L.Polygon(latlngs, vectorOptions); - - case 'MultiLineString': - latlngs = this.coordsToLatLngs(coords, 1, coordsToLatLng); - return new L.MultiPolyline(latlngs, vectorOptions); - - case 'MultiPolygon': - latlngs = this.coordsToLatLngs(coords, 2, coordsToLatLng); - return new L.MultiPolygon(latlngs, vectorOptions); - - case 'GeometryCollection': - for (i = 0, len = geometry.geometries.length; i < len; i++) { - - layers.push(this.geometryToLayer({ - geometry: geometry.geometries[i], - type: 'Feature', - properties: geojson.properties - }, pointToLayer, coordsToLatLng, vectorOptions)); - } - return new L.FeatureGroup(layers); - - default: - throw new Error('Invalid GeoJSON object.'); - } - }, - - coordsToLatLng: function (coords) { // (Array[, Boolean]) -> LatLng - return new L.LatLng(coords[1], coords[0], coords[2]); - }, - - coordsToLatLngs: function (coords, levelsDeep, coordsToLatLng) { // (Array[, Number, Function]) -> Array - var latlng, i, len, - latlngs = []; - - for (i = 0, len = coords.length; i < len; i++) { - latlng = levelsDeep ? - this.coordsToLatLngs(coords[i], levelsDeep - 1, coordsToLatLng) : - (coordsToLatLng || this.coordsToLatLng)(coords[i]); - - latlngs.push(latlng); - } - - return latlngs; - }, - - latLngToCoords: function (latlng) { - var coords = [latlng.lng, latlng.lat]; - - if (latlng.alt !== undefined) { - coords.push(latlng.alt); - } - return coords; - }, - - latLngsToCoords: function (latLngs) { - var coords = []; - - for (var i = 0, len = latLngs.length; i < len; i++) { - coords.push(L.GeoJSON.latLngToCoords(latLngs[i])); - } - - return coords; - }, - - getFeature: function (layer, newGeometry) { - return layer.feature ? L.extend({}, layer.feature, {geometry: newGeometry}) : L.GeoJSON.asFeature(newGeometry); - }, - - asFeature: function (geoJSON) { - if (geoJSON.type === 'Feature') { - return geoJSON; - } - - return { - type: 'Feature', - properties: {}, - geometry: geoJSON - }; - } -}); - -var PointToGeoJSON = { - toGeoJSON: function () { - return L.GeoJSON.getFeature(this, { - type: 'Point', - coordinates: L.GeoJSON.latLngToCoords(this.getLatLng()) - }); - } -}; - -L.Marker.include(PointToGeoJSON); -L.Circle.include(PointToGeoJSON); -L.CircleMarker.include(PointToGeoJSON); - -L.Polyline.include({ - toGeoJSON: function () { - return L.GeoJSON.getFeature(this, { - type: 'LineString', - coordinates: L.GeoJSON.latLngsToCoords(this.getLatLngs()) - }); - } -}); - -L.Polygon.include({ - toGeoJSON: function () { - var coords = [L.GeoJSON.latLngsToCoords(this.getLatLngs())], - i, len, hole; - - coords[0].push(coords[0][0]); - - if (this._holes) { - for (i = 0, len = this._holes.length; i < len; i++) { - hole = L.GeoJSON.latLngsToCoords(this._holes[i]); - hole.push(hole[0]); - coords.push(hole); - } - } - - return L.GeoJSON.getFeature(this, { - type: 'Polygon', - coordinates: coords - }); - } -}); - -(function () { - function multiToGeoJSON(type) { - return function () { - var coords = []; - - this.eachLayer(function (layer) { - coords.push(layer.toGeoJSON().geometry.coordinates); - }); - - return L.GeoJSON.getFeature(this, { - type: type, - coordinates: coords - }); - }; - } - - L.MultiPolyline.include({toGeoJSON: multiToGeoJSON('MultiLineString')}); - L.MultiPolygon.include({toGeoJSON: multiToGeoJSON('MultiPolygon')}); - - L.LayerGroup.include({ - toGeoJSON: function () { - - var geometry = this.feature && this.feature.geometry, - jsons = [], - json; - - if (geometry && geometry.type === 'MultiPoint') { - return multiToGeoJSON('MultiPoint').call(this); - } - - var isGeometryCollection = geometry && geometry.type === 'GeometryCollection'; - - this.eachLayer(function (layer) { - if (layer.toGeoJSON) { - json = layer.toGeoJSON(); - jsons.push(isGeometryCollection ? json.geometry : L.GeoJSON.asFeature(json)); - } - }); - - if (isGeometryCollection) { - return L.GeoJSON.getFeature(this, { - geometries: jsons, - type: 'GeometryCollection' - }); - } - - return { - type: 'FeatureCollection', - features: jsons - }; - } - }); -}()); - -L.geoJson = function (geojson, options) { - return new L.GeoJSON(geojson, options); -}; - - -/* - * L.DomEvent contains functions for working with DOM events. - */ - -L.DomEvent = { - /* inspired by John Resig, Dean Edwards and YUI addEvent implementations */ - addListener: function (obj, type, fn, context) { // (HTMLElement, String, Function[, Object]) - - var id = L.stamp(fn), - key = '_leaflet_' + type + id, - handler, originalHandler, newType; - - if (obj[key]) { return this; } - - handler = function (e) { - return fn.call(context || obj, e || L.DomEvent._getEvent()); - }; - - if (L.Browser.pointer && type.indexOf('touch') === 0) { - return this.addPointerListener(obj, type, handler, id); - } - if (L.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener) { - this.addDoubleTapListener(obj, handler, id); - } - - if ('addEventListener' in obj) { - - if (type === 'mousewheel') { - obj.addEventListener('DOMMouseScroll', handler, false); - obj.addEventListener(type, handler, false); - - } else if ((type === 'mouseenter') || (type === 'mouseleave')) { - - originalHandler = handler; - newType = (type === 'mouseenter' ? 'mouseover' : 'mouseout'); - - handler = function (e) { - if (!L.DomEvent._checkMouse(obj, e)) { return; } - return originalHandler(e); - }; - - obj.addEventListener(newType, handler, false); - - } else if (type === 'click' && L.Browser.android) { - originalHandler = handler; - handler = function (e) { - return L.DomEvent._filterClick(e, originalHandler); - }; - - obj.addEventListener(type, handler, false); - } else { - obj.addEventListener(type, handler, false); - } - - } else if ('attachEvent' in obj) { - obj.attachEvent('on' + type, handler); - } - - obj[key] = handler; - - return this; - }, - - removeListener: function (obj, type, fn) { // (HTMLElement, String, Function) - - var id = L.stamp(fn), - key = '_leaflet_' + type + id, - handler = obj[key]; - - if (!handler) { return this; } - - if (L.Browser.pointer && type.indexOf('touch') === 0) { - this.removePointerListener(obj, type, id); - } else if (L.Browser.touch && (type === 'dblclick') && this.removeDoubleTapListener) { - this.removeDoubleTapListener(obj, id); - - } else if ('removeEventListener' in obj) { - - if (type === 'mousewheel') { - obj.removeEventListener('DOMMouseScroll', handler, false); - obj.removeEventListener(type, handler, false); - - } else if ((type === 'mouseenter') || (type === 'mouseleave')) { - obj.removeEventListener((type === 'mouseenter' ? 'mouseover' : 'mouseout'), handler, false); - } else { - obj.removeEventListener(type, handler, false); - } - } else if ('detachEvent' in obj) { - obj.detachEvent('on' + type, handler); - } - - obj[key] = null; - - return this; - }, - - stopPropagation: function (e) { - - if (e.stopPropagation) { - e.stopPropagation(); - } else { - e.cancelBubble = true; - } - L.DomEvent._skipped(e); - - return this; - }, - - disableScrollPropagation: function (el) { - var stop = L.DomEvent.stopPropagation; - - return L.DomEvent - .on(el, 'mousewheel', stop) - .on(el, 'MozMousePixelScroll', stop); - }, - - disableClickPropagation: function (el) { - var stop = L.DomEvent.stopPropagation; - - for (var i = L.Draggable.START.length - 1; i >= 0; i--) { - L.DomEvent.on(el, L.Draggable.START[i], stop); - } - - return L.DomEvent - .on(el, 'click', L.DomEvent._fakeStop) - .on(el, 'dblclick', stop); - }, - - preventDefault: function (e) { - - if (e.preventDefault) { - e.preventDefault(); - } else { - e.returnValue = false; - } - return this; - }, - - stop: function (e) { - return L.DomEvent - .preventDefault(e) - .stopPropagation(e); - }, - - getMousePosition: function (e, container) { - if (!container) { - return new L.Point(e.clientX, e.clientY); - } - - var rect = container.getBoundingClientRect(); - - return new L.Point( - e.clientX - rect.left - container.clientLeft, - e.clientY - rect.top - container.clientTop); - }, - - getWheelDelta: function (e) { - - var delta = 0; - - if (e.wheelDelta) { - delta = e.wheelDelta / 120; - } - if (e.detail) { - delta = -e.detail / 3; - } - return delta; - }, - - _skipEvents: {}, - - _fakeStop: function (e) { - // fakes stopPropagation by setting a special event flag, checked/reset with L.DomEvent._skipped(e) - L.DomEvent._skipEvents[e.type] = true; - }, - - _skipped: function (e) { - var skipped = this._skipEvents[e.type]; - // reset when checking, as it's only used in map container and propagates outside of the map - this._skipEvents[e.type] = false; - return skipped; - }, - - // check if element really left/entered the event target (for mouseenter/mouseleave) - _checkMouse: function (el, e) { - - var related = e.relatedTarget; - - if (!related) { return true; } - - try { - while (related && (related !== el)) { - related = related.parentNode; - } - } catch (err) { - return false; - } - return (related !== el); - }, - - _getEvent: function () { // evil magic for IE - /*jshint noarg:false */ - var e = window.event; - if (!e) { - var caller = arguments.callee.caller; - while (caller) { - e = caller['arguments'][0]; - if (e && window.Event === e.constructor) { - break; - } - caller = caller.caller; - } - } - return e; - }, - - // this is a horrible workaround for a bug in Android where a single touch triggers two click events - _filterClick: function (e, handler) { - var timeStamp = (e.timeStamp || e.originalEvent.timeStamp), - elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick); - - // are they closer together than 500ms yet more than 100ms? - // Android typically triggers them ~300ms apart while multiple listeners - // on the same event should be triggered far faster; - // or check if click is simulated on the element, and if it is, reject any non-simulated events - - if ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) { - L.DomEvent.stop(e); - return; - } - L.DomEvent._lastClick = timeStamp; - - return handler(e); - } -}; - -L.DomEvent.on = L.DomEvent.addListener; -L.DomEvent.off = L.DomEvent.removeListener; - - -/* - * L.Draggable allows you to add dragging capabilities to any element. Supports mobile devices too. - */ - -L.Draggable = L.Class.extend({ - includes: L.Mixin.Events, - - statics: { - START: L.Browser.touch ? ['touchstart', 'mousedown'] : ['mousedown'], - END: { - mousedown: 'mouseup', - touchstart: 'touchend', - pointerdown: 'touchend', - MSPointerDown: 'touchend' - }, - MOVE: { - mousedown: 'mousemove', - touchstart: 'touchmove', - pointerdown: 'touchmove', - MSPointerDown: 'touchmove' - } - }, - - initialize: function (element, dragStartTarget) { - this._element = element; - this._dragStartTarget = dragStartTarget || element; - }, - - enable: function () { - if (this._enabled) { return; } - - for (var i = L.Draggable.START.length - 1; i >= 0; i--) { - L.DomEvent.on(this._dragStartTarget, L.Draggable.START[i], this._onDown, this); - } - - this._enabled = true; - }, - - disable: function () { - if (!this._enabled) { return; } - - for (var i = L.Draggable.START.length - 1; i >= 0; i--) { - L.DomEvent.off(this._dragStartTarget, L.Draggable.START[i], this._onDown, this); - } - - this._enabled = false; - this._moved = false; - }, - - _onDown: function (e) { - this._moved = false; - - if (e.shiftKey || ((e.which !== 1) && (e.button !== 1) && !e.touches)) { return; } - - L.DomEvent.stopPropagation(e); - - if (L.Draggable._disabled) { return; } - - L.DomUtil.disableImageDrag(); - L.DomUtil.disableTextSelection(); - - if (this._moving) { return; } - - var first = e.touches ? e.touches[0] : e; - - this._startPoint = new L.Point(first.clientX, first.clientY); - this._startPos = this._newPos = L.DomUtil.getPosition(this._element); - - L.DomEvent - .on(document, L.Draggable.MOVE[e.type], this._onMove, this) - .on(document, L.Draggable.END[e.type], this._onUp, this); - }, - - _onMove: function (e) { - if (e.touches && e.touches.length > 1) { - this._moved = true; - return; - } - - var first = (e.touches && e.touches.length === 1 ? e.touches[0] : e), - newPoint = new L.Point(first.clientX, first.clientY), - offset = newPoint.subtract(this._startPoint); - - if (!offset.x && !offset.y) { return; } - if (L.Browser.touch && Math.abs(offset.x) + Math.abs(offset.y) < 3) { return; } - - L.DomEvent.preventDefault(e); - - if (!this._moved) { - this.fire('dragstart'); - - this._moved = true; - this._startPos = L.DomUtil.getPosition(this._element).subtract(offset); - - L.DomUtil.addClass(document.body, 'leaflet-dragging'); - this._lastTarget = e.target || e.srcElement; - L.DomUtil.addClass(this._lastTarget, 'leaflet-drag-target'); - } - - this._newPos = this._startPos.add(offset); - this._moving = true; - - L.Util.cancelAnimFrame(this._animRequest); - this._animRequest = L.Util.requestAnimFrame(this._updatePosition, this, true, this._dragStartTarget); - }, - - _updatePosition: function () { - this.fire('predrag'); - L.DomUtil.setPosition(this._element, this._newPos); - this.fire('drag'); - }, - - _onUp: function () { - L.DomUtil.removeClass(document.body, 'leaflet-dragging'); - - if (this._lastTarget) { - L.DomUtil.removeClass(this._lastTarget, 'leaflet-drag-target'); - this._lastTarget = null; - } - - for (var i in L.Draggable.MOVE) { - L.DomEvent - .off(document, L.Draggable.MOVE[i], this._onMove) - .off(document, L.Draggable.END[i], this._onUp); - } - - L.DomUtil.enableImageDrag(); - L.DomUtil.enableTextSelection(); - - if (this._moved && this._moving) { - // ensure drag is not fired after dragend - L.Util.cancelAnimFrame(this._animRequest); - - this.fire('dragend', { - distance: this._newPos.distanceTo(this._startPos) - }); - } - - this._moving = false; - } -}); - - -/* - L.Handler is a base class for handler classes that are used internally to inject - interaction features like dragging to classes like Map and Marker. -*/ - -L.Handler = L.Class.extend({ - initialize: function (map) { - this._map = map; - }, - - enable: function () { - if (this._enabled) { return; } - - this._enabled = true; - this.addHooks(); - }, - - disable: function () { - if (!this._enabled) { return; } - - this._enabled = false; - this.removeHooks(); - }, - - enabled: function () { - return !!this._enabled; - } -}); - - -/* - * L.Handler.MapDrag is used to make the map draggable (with panning inertia), enabled by default. - */ - -L.Map.mergeOptions({ - dragging: true, - - inertia: !L.Browser.android23, - inertiaDeceleration: 3400, // px/s^2 - inertiaMaxSpeed: Infinity, // px/s - inertiaThreshold: L.Browser.touch ? 32 : 18, // ms - easeLinearity: 0.25, - - // TODO refactor, move to CRS - worldCopyJump: false -}); - -L.Map.Drag = L.Handler.extend({ - addHooks: function () { - if (!this._draggable) { - var map = this._map; - - this._draggable = new L.Draggable(map._mapPane, map._container); - - this._draggable.on({ - 'dragstart': this._onDragStart, - 'drag': this._onDrag, - 'dragend': this._onDragEnd - }, this); - - if (map.options.worldCopyJump) { - this._draggable.on('predrag', this._onPreDrag, this); - map.on('viewreset', this._onViewReset, this); - - map.whenReady(this._onViewReset, this); - } - } - this._draggable.enable(); - }, - - removeHooks: function () { - this._draggable.disable(); - }, - - moved: function () { - return this._draggable && this._draggable._moved; - }, - - _onDragStart: function () { - var map = this._map; - - if (map._panAnim) { - map._panAnim.stop(); - } - - map - .fire('movestart') - .fire('dragstart'); - - if (map.options.inertia) { - this._positions = []; - this._times = []; - } - }, - - _onDrag: function () { - if (this._map.options.inertia) { - var time = this._lastTime = +new Date(), - pos = this._lastPos = this._draggable._newPos; - - this._positions.push(pos); - this._times.push(time); - - if (time - this._times[0] > 200) { - this._positions.shift(); - this._times.shift(); - } - } - - this._map - .fire('move') - .fire('drag'); - }, - - _onViewReset: function () { - // TODO fix hardcoded Earth values - var pxCenter = this._map.getSize()._divideBy(2), - pxWorldCenter = this._map.latLngToLayerPoint([0, 0]); - - this._initialWorldOffset = pxWorldCenter.subtract(pxCenter).x; - this._worldWidth = this._map.project([0, 180]).x; - }, - - _onPreDrag: function () { - // TODO refactor to be able to adjust map pane position after zoom - var worldWidth = this._worldWidth, - halfWidth = Math.round(worldWidth / 2), - dx = this._initialWorldOffset, - x = this._draggable._newPos.x, - newX1 = (x - halfWidth + dx) % worldWidth + halfWidth - dx, - newX2 = (x + halfWidth + dx) % worldWidth - halfWidth - dx, - newX = Math.abs(newX1 + dx) < Math.abs(newX2 + dx) ? newX1 : newX2; - - this._draggable._newPos.x = newX; - }, - - _onDragEnd: function (e) { - var map = this._map, - options = map.options, - delay = +new Date() - this._lastTime, - - noInertia = !options.inertia || delay > options.inertiaThreshold || !this._positions[0]; - - map.fire('dragend', e); - - if (noInertia) { - map.fire('moveend'); - - } else { - - var direction = this._lastPos.subtract(this._positions[0]), - duration = (this._lastTime + delay - this._times[0]) / 1000, - ease = options.easeLinearity, - - speedVector = direction.multiplyBy(ease / duration), - speed = speedVector.distanceTo([0, 0]), - - limitedSpeed = Math.min(options.inertiaMaxSpeed, speed), - limitedSpeedVector = speedVector.multiplyBy(limitedSpeed / speed), - - decelerationDuration = limitedSpeed / (options.inertiaDeceleration * ease), - offset = limitedSpeedVector.multiplyBy(-decelerationDuration / 2).round(); - - if (!offset.x || !offset.y) { - map.fire('moveend'); - - } else { - offset = map._limitOffset(offset, map.options.maxBounds); - - L.Util.requestAnimFrame(function () { - map.panBy(offset, { - duration: decelerationDuration, - easeLinearity: ease, - noMoveStart: true - }); - }); - } - } - } -}); - -L.Map.addInitHook('addHandler', 'dragging', L.Map.Drag); - - -/* - * L.Handler.DoubleClickZoom is used to handle double-click zoom on the map, enabled by default. - */ - -L.Map.mergeOptions({ - doubleClickZoom: true -}); - -L.Map.DoubleClickZoom = L.Handler.extend({ - addHooks: function () { - this._map.on('dblclick', this._onDoubleClick, this); - }, - - removeHooks: function () { - this._map.off('dblclick', this._onDoubleClick, this); - }, - - _onDoubleClick: function (e) { - var map = this._map, - zoom = map.getZoom() + (e.originalEvent.shiftKey ? -1 : 1); - - if (map.options.doubleClickZoom === 'center') { - map.setZoom(zoom); - } else { - map.setZoomAround(e.containerPoint, zoom); - } - } -}); - -L.Map.addInitHook('addHandler', 'doubleClickZoom', L.Map.DoubleClickZoom); - - -/* - * L.Handler.ScrollWheelZoom is used by L.Map to enable mouse scroll wheel zoom on the map. - */ - -L.Map.mergeOptions({ - scrollWheelZoom: true -}); - -L.Map.ScrollWheelZoom = L.Handler.extend({ - addHooks: function () { - L.DomEvent.on(this._map._container, 'mousewheel', this._onWheelScroll, this); - L.DomEvent.on(this._map._container, 'MozMousePixelScroll', L.DomEvent.preventDefault); - this._delta = 0; - }, - - removeHooks: function () { - L.DomEvent.off(this._map._container, 'mousewheel', this._onWheelScroll); - L.DomEvent.off(this._map._container, 'MozMousePixelScroll', L.DomEvent.preventDefault); - }, - - _onWheelScroll: function (e) { - var delta = L.DomEvent.getWheelDelta(e); - - this._delta += delta; - this._lastMousePos = this._map.mouseEventToContainerPoint(e); - - if (!this._startTime) { - this._startTime = +new Date(); - } - - var left = Math.max(40 - (+new Date() - this._startTime), 0); - - clearTimeout(this._timer); - this._timer = setTimeout(L.bind(this._performZoom, this), left); - - L.DomEvent.preventDefault(e); - L.DomEvent.stopPropagation(e); - }, - - _performZoom: function () { - var map = this._map, - delta = this._delta, - zoom = map.getZoom(); - - delta = delta > 0 ? Math.ceil(delta) : Math.floor(delta); - delta = Math.max(Math.min(delta, 4), -4); - delta = map._limitZoom(zoom + delta) - zoom; - - this._delta = 0; - this._startTime = null; - - if (!delta) { return; } - - if (map.options.scrollWheelZoom === 'center') { - map.setZoom(zoom + delta); - } else { - map.setZoomAround(this._lastMousePos, zoom + delta); - } - } -}); - -L.Map.addInitHook('addHandler', 'scrollWheelZoom', L.Map.ScrollWheelZoom); - - -/* - * Extends the event handling code with double tap support for mobile browsers. - */ - -L.extend(L.DomEvent, { - - _touchstart: L.Browser.msPointer ? 'MSPointerDown' : L.Browser.pointer ? 'pointerdown' : 'touchstart', - _touchend: L.Browser.msPointer ? 'MSPointerUp' : L.Browser.pointer ? 'pointerup' : 'touchend', - - // inspired by Zepto touch code by Thomas Fuchs - addDoubleTapListener: function (obj, handler, id) { - var last, - doubleTap = false, - delay = 250, - touch, - pre = '_leaflet_', - touchstart = this._touchstart, - touchend = this._touchend, - trackedTouches = []; - - function onTouchStart(e) { - var count; - - if (L.Browser.pointer) { - trackedTouches.push(e.pointerId); - count = trackedTouches.length; - } else { - count = e.touches.length; - } - if (count > 1) { - return; - } - - var now = Date.now(), - delta = now - (last || now); - - touch = e.touches ? e.touches[0] : e; - doubleTap = (delta > 0 && delta <= delay); - last = now; - } - - function onTouchEnd(e) { - if (L.Browser.pointer) { - var idx = trackedTouches.indexOf(e.pointerId); - if (idx === -1) { - return; - } - trackedTouches.splice(idx, 1); - } - - if (doubleTap) { - if (L.Browser.pointer) { - // work around .type being readonly with MSPointer* events - var newTouch = { }, - prop; - - // jshint forin:false - for (var i in touch) { - prop = touch[i]; - if (typeof prop === 'function') { - newTouch[i] = prop.bind(touch); - } else { - newTouch[i] = prop; - } - } - touch = newTouch; - } - touch.type = 'dblclick'; - handler(touch); - last = null; - } - } - obj[pre + touchstart + id] = onTouchStart; - obj[pre + touchend + id] = onTouchEnd; - - // on pointer we need to listen on the document, otherwise a drag starting on the map and moving off screen - // will not come through to us, so we will lose track of how many touches are ongoing - var endElement = L.Browser.pointer ? document.documentElement : obj; - - obj.addEventListener(touchstart, onTouchStart, false); - endElement.addEventListener(touchend, onTouchEnd, false); - - if (L.Browser.pointer) { - endElement.addEventListener(L.DomEvent.POINTER_CANCEL, onTouchEnd, false); - } - - return this; - }, - - removeDoubleTapListener: function (obj, id) { - var pre = '_leaflet_'; - - obj.removeEventListener(this._touchstart, obj[pre + this._touchstart + id], false); - (L.Browser.pointer ? document.documentElement : obj).removeEventListener( - this._touchend, obj[pre + this._touchend + id], false); - - if (L.Browser.pointer) { - document.documentElement.removeEventListener(L.DomEvent.POINTER_CANCEL, obj[pre + this._touchend + id], - false); - } - - return this; - } -}); - - -/* - * Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices. - */ - -L.extend(L.DomEvent, { - - //static - POINTER_DOWN: L.Browser.msPointer ? 'MSPointerDown' : 'pointerdown', - POINTER_MOVE: L.Browser.msPointer ? 'MSPointerMove' : 'pointermove', - POINTER_UP: L.Browser.msPointer ? 'MSPointerUp' : 'pointerup', - POINTER_CANCEL: L.Browser.msPointer ? 'MSPointerCancel' : 'pointercancel', - - _pointers: [], - _pointerDocumentListener: false, - - // Provides a touch events wrapper for (ms)pointer events. - // Based on changes by veproza https://github.com/CloudMade/Leaflet/pull/1019 - //ref http://www.w3.org/TR/pointerevents/ https://www.w3.org/Bugs/Public/show_bug.cgi?id=22890 - - addPointerListener: function (obj, type, handler, id) { - - switch (type) { - case 'touchstart': - return this.addPointerListenerStart(obj, type, handler, id); - case 'touchend': - return this.addPointerListenerEnd(obj, type, handler, id); - case 'touchmove': - return this.addPointerListenerMove(obj, type, handler, id); - default: - throw 'Unknown touch event type'; - } - }, - - addPointerListenerStart: function (obj, type, handler, id) { - var pre = '_leaflet_', - pointers = this._pointers; - - var cb = function (e) { - - L.DomEvent.preventDefault(e); - - var alreadyInArray = false; - for (var i = 0; i < pointers.length; i++) { - if (pointers[i].pointerId === e.pointerId) { - alreadyInArray = true; - break; - } - } - if (!alreadyInArray) { - pointers.push(e); - } - - e.touches = pointers.slice(); - e.changedTouches = [e]; - - handler(e); - }; - - obj[pre + 'touchstart' + id] = cb; - obj.addEventListener(this.POINTER_DOWN, cb, false); - - // need to also listen for end events to keep the _pointers list accurate - // this needs to be on the body and never go away - if (!this._pointerDocumentListener) { - var internalCb = function (e) { - for (var i = 0; i < pointers.length; i++) { - if (pointers[i].pointerId === e.pointerId) { - pointers.splice(i, 1); - break; - } - } - }; - //We listen on the documentElement as any drags that end by moving the touch off the screen get fired there - document.documentElement.addEventListener(this.POINTER_UP, internalCb, false); - document.documentElement.addEventListener(this.POINTER_CANCEL, internalCb, false); - - this._pointerDocumentListener = true; - } - - return this; - }, - - addPointerListenerMove: function (obj, type, handler, id) { - var pre = '_leaflet_', - touches = this._pointers; - - function cb(e) { - - // don't fire touch moves when mouse isn't down - if ((e.pointerType === e.MSPOINTER_TYPE_MOUSE || e.pointerType === 'mouse') && e.buttons === 0) { return; } - - for (var i = 0; i < touches.length; i++) { - if (touches[i].pointerId === e.pointerId) { - touches[i] = e; - break; - } - } - - e.touches = touches.slice(); - e.changedTouches = [e]; - - handler(e); - } - - obj[pre + 'touchmove' + id] = cb; - obj.addEventListener(this.POINTER_MOVE, cb, false); - - return this; - }, - - addPointerListenerEnd: function (obj, type, handler, id) { - var pre = '_leaflet_', - touches = this._pointers; - - var cb = function (e) { - for (var i = 0; i < touches.length; i++) { - if (touches[i].pointerId === e.pointerId) { - touches.splice(i, 1); - break; - } - } - - e.touches = touches.slice(); - e.changedTouches = [e]; - - handler(e); - }; - - obj[pre + 'touchend' + id] = cb; - obj.addEventListener(this.POINTER_UP, cb, false); - obj.addEventListener(this.POINTER_CANCEL, cb, false); - - return this; - }, - - removePointerListener: function (obj, type, id) { - var pre = '_leaflet_', - cb = obj[pre + type + id]; - - switch (type) { - case 'touchstart': - obj.removeEventListener(this.POINTER_DOWN, cb, false); - break; - case 'touchmove': - obj.removeEventListener(this.POINTER_MOVE, cb, false); - break; - case 'touchend': - obj.removeEventListener(this.POINTER_UP, cb, false); - obj.removeEventListener(this.POINTER_CANCEL, cb, false); - break; - } - - return this; - } -}); - - -/* - * L.Handler.TouchZoom is used by L.Map to add pinch zoom on supported mobile browsers. - */ - -L.Map.mergeOptions({ - touchZoom: L.Browser.touch && !L.Browser.android23, - bounceAtZoomLimits: true -}); - -L.Map.TouchZoom = L.Handler.extend({ - addHooks: function () { - L.DomEvent.on(this._map._container, 'touchstart', this._onTouchStart, this); - }, - - removeHooks: function () { - L.DomEvent.off(this._map._container, 'touchstart', this._onTouchStart, this); - }, - - _onTouchStart: function (e) { - var map = this._map; - - if (!e.touches || e.touches.length !== 2 || map._animatingZoom || this._zooming) { return; } - - var p1 = map.mouseEventToLayerPoint(e.touches[0]), - p2 = map.mouseEventToLayerPoint(e.touches[1]), - viewCenter = map._getCenterLayerPoint(); - - this._startCenter = p1.add(p2)._divideBy(2); - this._startDist = p1.distanceTo(p2); - - this._moved = false; - this._zooming = true; - - this._centerOffset = viewCenter.subtract(this._startCenter); - - if (map._panAnim) { - map._panAnim.stop(); - } - - L.DomEvent - .on(document, 'touchmove', this._onTouchMove, this) - .on(document, 'touchend', this._onTouchEnd, this); - - L.DomEvent.preventDefault(e); - }, - - _onTouchMove: function (e) { - var map = this._map; - - if (!e.touches || e.touches.length !== 2 || !this._zooming) { return; } - - var p1 = map.mouseEventToLayerPoint(e.touches[0]), - p2 = map.mouseEventToLayerPoint(e.touches[1]); - - this._scale = p1.distanceTo(p2) / this._startDist; - this._delta = p1._add(p2)._divideBy(2)._subtract(this._startCenter); - - if (this._scale === 1) { return; } - - if (!map.options.bounceAtZoomLimits) { - if ((map.getZoom() === map.getMinZoom() && this._scale < 1) || - (map.getZoom() === map.getMaxZoom() && this._scale > 1)) { return; } - } - - if (!this._moved) { - L.DomUtil.addClass(map._mapPane, 'leaflet-touching'); - - map - .fire('movestart') - .fire('zoomstart'); - - this._moved = true; - } - - L.Util.cancelAnimFrame(this._animRequest); - this._animRequest = L.Util.requestAnimFrame( - this._updateOnMove, this, true, this._map._container); - - L.DomEvent.preventDefault(e); - }, - - _updateOnMove: function () { - var map = this._map, - origin = this._getScaleOrigin(), - center = map.layerPointToLatLng(origin), - zoom = map.getScaleZoom(this._scale); - - map._animateZoom(center, zoom, this._startCenter, this._scale, this._delta, false, true); - }, - - _onTouchEnd: function () { - if (!this._moved || !this._zooming) { - this._zooming = false; - return; - } - - var map = this._map; - - this._zooming = false; - L.DomUtil.removeClass(map._mapPane, 'leaflet-touching'); - L.Util.cancelAnimFrame(this._animRequest); - - L.DomEvent - .off(document, 'touchmove', this._onTouchMove) - .off(document, 'touchend', this._onTouchEnd); - - var origin = this._getScaleOrigin(), - center = map.layerPointToLatLng(origin), - - oldZoom = map.getZoom(), - floatZoomDelta = map.getScaleZoom(this._scale) - oldZoom, - roundZoomDelta = (floatZoomDelta > 0 ? - Math.ceil(floatZoomDelta) : Math.floor(floatZoomDelta)), - - zoom = map._limitZoom(oldZoom + roundZoomDelta), - scale = map.getZoomScale(zoom) / this._scale; - - map._animateZoom(center, zoom, origin, scale); - }, - - _getScaleOrigin: function () { - var centerOffset = this._centerOffset.subtract(this._delta).divideBy(this._scale); - return this._startCenter.add(centerOffset); - } -}); - -L.Map.addInitHook('addHandler', 'touchZoom', L.Map.TouchZoom); - - -/* - * L.Map.Tap is used to enable mobile hacks like quick taps and long hold. - */ - -L.Map.mergeOptions({ - tap: true, - tapTolerance: 15 -}); - -L.Map.Tap = L.Handler.extend({ - addHooks: function () { - L.DomEvent.on(this._map._container, 'touchstart', this._onDown, this); - }, - - removeHooks: function () { - L.DomEvent.off(this._map._container, 'touchstart', this._onDown, this); - }, - - _onDown: function (e) { - if (!e.touches) { return; } - - L.DomEvent.preventDefault(e); - - this._fireClick = true; - - // don't simulate click or track longpress if more than 1 touch - if (e.touches.length > 1) { - this._fireClick = false; - clearTimeout(this._holdTimeout); - return; - } - - var first = e.touches[0], - el = first.target; - - this._startPos = this._newPos = new L.Point(first.clientX, first.clientY); - - // if touching a link, highlight it - if (el.tagName && el.tagName.toLowerCase() === 'a') { - L.DomUtil.addClass(el, 'leaflet-active'); - } - - // simulate long hold but setting a timeout - this._holdTimeout = setTimeout(L.bind(function () { - if (this._isTapValid()) { - this._fireClick = false; - this._onUp(); - this._simulateEvent('contextmenu', first); - } - }, this), 1000); - - L.DomEvent - .on(document, 'touchmove', this._onMove, this) - .on(document, 'touchend', this._onUp, this); - }, - - _onUp: function (e) { - clearTimeout(this._holdTimeout); - - L.DomEvent - .off(document, 'touchmove', this._onMove, this) - .off(document, 'touchend', this._onUp, this); - - if (this._fireClick && e && e.changedTouches) { - - var first = e.changedTouches[0], - el = first.target; - - if (el && el.tagName && el.tagName.toLowerCase() === 'a') { - L.DomUtil.removeClass(el, 'leaflet-active'); - } - - // simulate click if the touch didn't move too much - if (this._isTapValid()) { - this._simulateEvent('click', first); - } - } - }, - - _isTapValid: function () { - return this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance; - }, - - _onMove: function (e) { - var first = e.touches[0]; - this._newPos = new L.Point(first.clientX, first.clientY); - }, - - _simulateEvent: function (type, e) { - var simulatedEvent = document.createEvent('MouseEvents'); - - simulatedEvent._simulated = true; - e.target._simulatedClick = true; - - simulatedEvent.initMouseEvent( - type, true, true, window, 1, - e.screenX, e.screenY, - e.clientX, e.clientY, - false, false, false, false, 0, null); - - e.target.dispatchEvent(simulatedEvent); - } -}); - -if (L.Browser.touch && !L.Browser.pointer) { - L.Map.addInitHook('addHandler', 'tap', L.Map.Tap); -} - - -/* - * L.Handler.ShiftDragZoom is used to add shift-drag zoom interaction to the map - * (zoom to a selected bounding box), enabled by default. - */ - -L.Map.mergeOptions({ - boxZoom: true -}); - -L.Map.BoxZoom = L.Handler.extend({ - initialize: function (map) { - this._map = map; - this._container = map._container; - this._pane = map._panes.overlayPane; - this._moved = false; - }, - - addHooks: function () { - L.DomEvent.on(this._container, 'mousedown', this._onMouseDown, this); - }, - - removeHooks: function () { - L.DomEvent.off(this._container, 'mousedown', this._onMouseDown); - this._moved = false; - }, - - moved: function () { - return this._moved; - }, - - _onMouseDown: function (e) { - this._moved = false; - - if (!e.shiftKey || ((e.which !== 1) && (e.button !== 1))) { return false; } - - L.DomUtil.disableTextSelection(); - L.DomUtil.disableImageDrag(); - - this._startLayerPoint = this._map.mouseEventToLayerPoint(e); - - L.DomEvent - .on(document, 'mousemove', this._onMouseMove, this) - .on(document, 'mouseup', this._onMouseUp, this) - .on(document, 'keydown', this._onKeyDown, this); - }, - - _onMouseMove: function (e) { - if (!this._moved) { - this._box = L.DomUtil.create('div', 'leaflet-zoom-box', this._pane); - L.DomUtil.setPosition(this._box, this._startLayerPoint); - - //TODO refactor: move cursor to styles - this._container.style.cursor = 'crosshair'; - this._map.fire('boxzoomstart'); - } - - var startPoint = this._startLayerPoint, - box = this._box, - - layerPoint = this._map.mouseEventToLayerPoint(e), - offset = layerPoint.subtract(startPoint), - - newPos = new L.Point( - Math.min(layerPoint.x, startPoint.x), - Math.min(layerPoint.y, startPoint.y)); - - L.DomUtil.setPosition(box, newPos); - - this._moved = true; - - // TODO refactor: remove hardcoded 4 pixels - box.style.width = (Math.max(0, Math.abs(offset.x) - 4)) + 'px'; - box.style.height = (Math.max(0, Math.abs(offset.y) - 4)) + 'px'; - }, - - _finish: function () { - if (this._moved) { - this._pane.removeChild(this._box); - this._container.style.cursor = ''; - } - - L.DomUtil.enableTextSelection(); - L.DomUtil.enableImageDrag(); - - L.DomEvent - .off(document, 'mousemove', this._onMouseMove) - .off(document, 'mouseup', this._onMouseUp) - .off(document, 'keydown', this._onKeyDown); - }, - - _onMouseUp: function (e) { - - this._finish(); - - var map = this._map, - layerPoint = map.mouseEventToLayerPoint(e); - - if (this._startLayerPoint.equals(layerPoint)) { return; } - - var bounds = new L.LatLngBounds( - map.layerPointToLatLng(this._startLayerPoint), - map.layerPointToLatLng(layerPoint)); - - map.fitBounds(bounds); - - map.fire('boxzoomend', { - boxZoomBounds: bounds - }); - }, - - _onKeyDown: function (e) { - if (e.keyCode === 27) { - this._finish(); - } - } -}); - -L.Map.addInitHook('addHandler', 'boxZoom', L.Map.BoxZoom); - - -/* - * L.Map.Keyboard is handling keyboard interaction with the map, enabled by default. - */ - -L.Map.mergeOptions({ - keyboard: true, - keyboardPanOffset: 80, - keyboardZoomOffset: 1 -}); - -L.Map.Keyboard = L.Handler.extend({ - - keyCodes: { - left: [37], - right: [39], - down: [40], - up: [38], - zoomIn: [187, 107, 61, 171], - zoomOut: [189, 109, 173] - }, - - initialize: function (map) { - this._map = map; - - this._setPanOffset(map.options.keyboardPanOffset); - this._setZoomOffset(map.options.keyboardZoomOffset); - }, - - addHooks: function () { - var container = this._map._container; - - // make the container focusable by tabbing - if (container.tabIndex === -1) { - container.tabIndex = '0'; - } - - L.DomEvent - .on(container, 'focus', this._onFocus, this) - .on(container, 'blur', this._onBlur, this) - .on(container, 'mousedown', this._onMouseDown, this); - - this._map - .on('focus', this._addHooks, this) - .on('blur', this._removeHooks, this); - }, - - removeHooks: function () { - this._removeHooks(); - - var container = this._map._container; - - L.DomEvent - .off(container, 'focus', this._onFocus, this) - .off(container, 'blur', this._onBlur, this) - .off(container, 'mousedown', this._onMouseDown, this); - - this._map - .off('focus', this._addHooks, this) - .off('blur', this._removeHooks, this); - }, - - _onMouseDown: function () { - if (this._focused) { return; } - - var body = document.body, - docEl = document.documentElement, - top = body.scrollTop || docEl.scrollTop, - left = body.scrollLeft || docEl.scrollLeft; - - this._map._container.focus(); - - window.scrollTo(left, top); - }, - - _onFocus: function () { - this._focused = true; - this._map.fire('focus'); - }, - - _onBlur: function () { - this._focused = false; - this._map.fire('blur'); - }, - - _setPanOffset: function (pan) { - var keys = this._panKeys = {}, - codes = this.keyCodes, - i, len; - - for (i = 0, len = codes.left.length; i < len; i++) { - keys[codes.left[i]] = [-1 * pan, 0]; - } - for (i = 0, len = codes.right.length; i < len; i++) { - keys[codes.right[i]] = [pan, 0]; - } - for (i = 0, len = codes.down.length; i < len; i++) { - keys[codes.down[i]] = [0, pan]; - } - for (i = 0, len = codes.up.length; i < len; i++) { - keys[codes.up[i]] = [0, -1 * pan]; - } - }, - - _setZoomOffset: function (zoom) { - var keys = this._zoomKeys = {}, - codes = this.keyCodes, - i, len; - - for (i = 0, len = codes.zoomIn.length; i < len; i++) { - keys[codes.zoomIn[i]] = zoom; - } - for (i = 0, len = codes.zoomOut.length; i < len; i++) { - keys[codes.zoomOut[i]] = -zoom; - } - }, - - _addHooks: function () { - L.DomEvent.on(document, 'keydown', this._onKeyDown, this); - }, - - _removeHooks: function () { - L.DomEvent.off(document, 'keydown', this._onKeyDown, this); - }, - - _onKeyDown: function (e) { - var key = e.keyCode, - map = this._map; - - if (key in this._panKeys) { - - if (map._panAnim && map._panAnim._inProgress) { return; } - - map.panBy(this._panKeys[key]); - - if (map.options.maxBounds) { - map.panInsideBounds(map.options.maxBounds); - } - - } else if (key in this._zoomKeys) { - map.setZoom(map.getZoom() + this._zoomKeys[key]); - - } else { - return; - } - - L.DomEvent.stop(e); - } -}); - -L.Map.addInitHook('addHandler', 'keyboard', L.Map.Keyboard); - - -/* - * L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable. - */ - -L.Handler.MarkerDrag = L.Handler.extend({ - initialize: function (marker) { - this._marker = marker; - }, - - addHooks: function () { - var icon = this._marker._icon; - if (!this._draggable) { - this._draggable = new L.Draggable(icon, icon); - } - - this._draggable - .on('dragstart', this._onDragStart, this) - .on('drag', this._onDrag, this) - .on('dragend', this._onDragEnd, this); - this._draggable.enable(); - L.DomUtil.addClass(this._marker._icon, 'leaflet-marker-draggable'); - }, - - removeHooks: function () { - this._draggable - .off('dragstart', this._onDragStart, this) - .off('drag', this._onDrag, this) - .off('dragend', this._onDragEnd, this); - - this._draggable.disable(); - L.DomUtil.removeClass(this._marker._icon, 'leaflet-marker-draggable'); - }, - - moved: function () { - return this._draggable && this._draggable._moved; - }, - - _onDragStart: function () { - this._marker - .closePopup() - .fire('movestart') - .fire('dragstart'); - }, - - _onDrag: function () { - var marker = this._marker, - shadow = marker._shadow, - iconPos = L.DomUtil.getPosition(marker._icon), - latlng = marker._map.layerPointToLatLng(iconPos); - - // update shadow position - if (shadow) { - L.DomUtil.setPosition(shadow, iconPos); - } - - marker._latlng = latlng; - - marker - .fire('move', {latlng: latlng}) - .fire('drag'); - }, - - _onDragEnd: function (e) { - this._marker - .fire('moveend') - .fire('dragend', e); - } -}); - - -/* - * L.Control is a base class for implementing map controls. Handles positioning. - * All other controls extend from this class. - */ - -L.Control = L.Class.extend({ - options: { - position: 'topright' - }, - - initialize: function (options) { - L.setOptions(this, options); - }, - - getPosition: function () { - return this.options.position; - }, - - setPosition: function (position) { - var map = this._map; - - if (map) { - map.removeControl(this); - } - - this.options.position = position; - - if (map) { - map.addControl(this); - } - - return this; - }, - - getContainer: function () { - return this._container; - }, - - addTo: function (map) { - this._map = map; - - var container = this._container = this.onAdd(map), - pos = this.getPosition(), - corner = map._controlCorners[pos]; - - L.DomUtil.addClass(container, 'leaflet-control'); - - if (pos.indexOf('bottom') !== -1) { - corner.insertBefore(container, corner.firstChild); - } else { - corner.appendChild(container); - } - - return this; - }, - - removeFrom: function (map) { - var pos = this.getPosition(), - corner = map._controlCorners[pos]; - - corner.removeChild(this._container); - this._map = null; - - if (this.onRemove) { - this.onRemove(map); - } - - return this; - }, - - _refocusOnMap: function () { - if (this._map) { - this._map.getContainer().focus(); - } - } -}); - -L.control = function (options) { - return new L.Control(options); -}; - - -// adds control-related methods to L.Map - -L.Map.include({ - addControl: function (control) { - control.addTo(this); - return this; - }, - - removeControl: function (control) { - control.removeFrom(this); - return this; - }, - - _initControlPos: function () { - var corners = this._controlCorners = {}, - l = 'leaflet-', - container = this._controlContainer = - L.DomUtil.create('div', l + 'control-container', this._container); - - function createCorner(vSide, hSide) { - var className = l + vSide + ' ' + l + hSide; - - corners[vSide + hSide] = L.DomUtil.create('div', className, container); - } - - createCorner('top', 'left'); - createCorner('top', 'right'); - createCorner('bottom', 'left'); - createCorner('bottom', 'right'); - }, - - _clearControlPos: function () { - this._container.removeChild(this._controlContainer); - } -}); - - -/* - * L.Control.Zoom is used for the default zoom buttons on the map. - */ - -L.Control.Zoom = L.Control.extend({ - options: { - position: 'topleft', - zoomInText: '+', - zoomInTitle: 'Zoom in', - zoomOutText: '-', - zoomOutTitle: 'Zoom out' - }, - - onAdd: function (map) { - var zoomName = 'leaflet-control-zoom', - container = L.DomUtil.create('div', zoomName + ' leaflet-bar'); - - this._map = map; - - this._zoomInButton = this._createButton( - this.options.zoomInText, this.options.zoomInTitle, - zoomName + '-in', container, this._zoomIn, this); - this._zoomOutButton = this._createButton( - this.options.zoomOutText, this.options.zoomOutTitle, - zoomName + '-out', container, this._zoomOut, this); - - this._updateDisabled(); - map.on('zoomend zoomlevelschange', this._updateDisabled, this); - - return container; - }, - - onRemove: function (map) { - map.off('zoomend zoomlevelschange', this._updateDisabled, this); - }, - - _zoomIn: function (e) { - this._map.zoomIn(e.shiftKey ? 3 : 1); - }, - - _zoomOut: function (e) { - this._map.zoomOut(e.shiftKey ? 3 : 1); - }, - - _createButton: function (html, title, className, container, fn, context) { - var link = L.DomUtil.create('a', className, container); - link.innerHTML = html; - link.href = '#'; - link.title = title; - - var stop = L.DomEvent.stopPropagation; - - L.DomEvent - .on(link, 'click', stop) - .on(link, 'mousedown', stop) - .on(link, 'dblclick', stop) - .on(link, 'click', L.DomEvent.preventDefault) - .on(link, 'click', fn, context) - .on(link, 'click', this._refocusOnMap, context); - - return link; - }, - - _updateDisabled: function () { - var map = this._map, - className = 'leaflet-disabled'; - - L.DomUtil.removeClass(this._zoomInButton, className); - L.DomUtil.removeClass(this._zoomOutButton, className); - - if (map._zoom === map.getMinZoom()) { - L.DomUtil.addClass(this._zoomOutButton, className); - } - if (map._zoom === map.getMaxZoom()) { - L.DomUtil.addClass(this._zoomInButton, className); - } - } -}); - -L.Map.mergeOptions({ - zoomControl: true -}); - -L.Map.addInitHook(function () { - if (this.options.zoomControl) { - this.zoomControl = new L.Control.Zoom(); - this.addControl(this.zoomControl); - } -}); - -L.control.zoom = function (options) { - return new L.Control.Zoom(options); -}; - - - -/* - * L.Control.Attribution is used for displaying attribution on the map (added by default). - */ - -L.Control.Attribution = L.Control.extend({ - options: { - position: 'bottomright', - prefix: 'Leaflet' - }, - - initialize: function (options) { - L.setOptions(this, options); - - this._attributions = {}; - }, - - onAdd: function (map) { - this._container = L.DomUtil.create('div', 'leaflet-control-attribution'); - L.DomEvent.disableClickPropagation(this._container); - - for (var i in map._layers) { - if (map._layers[i].getAttribution) { - this.addAttribution(map._layers[i].getAttribution()); - } - } - - map - .on('layeradd', this._onLayerAdd, this) - .on('layerremove', this._onLayerRemove, this); - - this._update(); - - return this._container; - }, - - onRemove: function (map) { - map - .off('layeradd', this._onLayerAdd) - .off('layerremove', this._onLayerRemove); - - }, - - setPrefix: function (prefix) { - this.options.prefix = prefix; - this._update(); - return this; - }, - - addAttribution: function (text) { - if (!text) { return; } - - if (!this._attributions[text]) { - this._attributions[text] = 0; - } - this._attributions[text]++; - - this._update(); - - return this; - }, - - removeAttribution: function (text) { - if (!text) { return; } - - if (this._attributions[text]) { - this._attributions[text]--; - this._update(); - } - - return this; - }, - - _update: function () { - if (!this._map) { return; } - - var attribs = []; - - for (var i in this._attributions) { - if (this._attributions[i]) { - attribs.push(i); - } - } - - var prefixAndAttribs = []; - - if (this.options.prefix) { - prefixAndAttribs.push(this.options.prefix); - } - if (attribs.length) { - prefixAndAttribs.push(attribs.join(', ')); - } - - this._container.innerHTML = prefixAndAttribs.join(' | '); - }, - - _onLayerAdd: function (e) { - if (e.layer.getAttribution) { - this.addAttribution(e.layer.getAttribution()); - } - }, - - _onLayerRemove: function (e) { - if (e.layer.getAttribution) { - this.removeAttribution(e.layer.getAttribution()); - } - } -}); - -L.Map.mergeOptions({ - attributionControl: true -}); - -L.Map.addInitHook(function () { - if (this.options.attributionControl) { - this.attributionControl = (new L.Control.Attribution()).addTo(this); - } -}); - -L.control.attribution = function (options) { - return new L.Control.Attribution(options); -}; - - -/* - * L.Control.Scale is used for displaying metric/imperial scale on the map. - */ - -L.Control.Scale = L.Control.extend({ - options: { - position: 'bottomleft', - maxWidth: 100, - metric: true, - imperial: true, - updateWhenIdle: false - }, - - onAdd: function (map) { - this._map = map; - - var className = 'leaflet-control-scale', - container = L.DomUtil.create('div', className), - options = this.options; - - this._addScales(options, className, container); - - map.on(options.updateWhenIdle ? 'moveend' : 'move', this._update, this); - map.whenReady(this._update, this); - - return container; - }, - - onRemove: function (map) { - map.off(this.options.updateWhenIdle ? 'moveend' : 'move', this._update, this); - }, - - _addScales: function (options, className, container) { - if (options.metric) { - this._mScale = L.DomUtil.create('div', className + '-line', container); - } - if (options.imperial) { - this._iScale = L.DomUtil.create('div', className + '-line', container); - } - }, - - _update: function () { - var bounds = this._map.getBounds(), - centerLat = bounds.getCenter().lat, - halfWorldMeters = 6378137 * Math.PI * Math.cos(centerLat * Math.PI / 180), - dist = halfWorldMeters * (bounds.getNorthEast().lng - bounds.getSouthWest().lng) / 180, - - size = this._map.getSize(), - options = this.options, - maxMeters = 0; - - if (size.x > 0) { - maxMeters = dist * (options.maxWidth / size.x); - } - - this._updateScales(options, maxMeters); - }, - - _updateScales: function (options, maxMeters) { - if (options.metric && maxMeters) { - this._updateMetric(maxMeters); - } - - if (options.imperial && maxMeters) { - this._updateImperial(maxMeters); - } - }, - - _updateMetric: function (maxMeters) { - var meters = this._getRoundNum(maxMeters); - - this._mScale.style.width = this._getScaleWidth(meters / maxMeters) + 'px'; - this._mScale.innerHTML = meters < 1000 ? meters + ' m' : (meters / 1000) + ' km'; - }, - - _updateImperial: function (maxMeters) { - var maxFeet = maxMeters * 3.2808399, - scale = this._iScale, - maxMiles, miles, feet; - - if (maxFeet > 5280) { - maxMiles = maxFeet / 5280; - miles = this._getRoundNum(maxMiles); - - scale.style.width = this._getScaleWidth(miles / maxMiles) + 'px'; - scale.innerHTML = miles + ' mi'; - - } else { - feet = this._getRoundNum(maxFeet); - - scale.style.width = this._getScaleWidth(feet / maxFeet) + 'px'; - scale.innerHTML = feet + ' ft'; - } - }, - - _getScaleWidth: function (ratio) { - return Math.round(this.options.maxWidth * ratio) - 10; - }, - - _getRoundNum: function (num) { - var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1), - d = num / pow10; - - d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1; - - return pow10 * d; - } -}); - -L.control.scale = function (options) { - return new L.Control.Scale(options); -}; - - -/* - * L.Control.Layers is a control to allow users to switch between different layers on the map. - */ - -L.Control.Layers = L.Control.extend({ - options: { - collapsed: true, - position: 'topright', - autoZIndex: true - }, - - initialize: function (baseLayers, overlays, options) { - L.setOptions(this, options); - - this._layers = {}; - this._lastZIndex = 0; - this._handlingClick = false; - - for (var i in baseLayers) { - this._addLayer(baseLayers[i], i); - } - - for (i in overlays) { - this._addLayer(overlays[i], i, true); - } - }, - - onAdd: function (map) { - this._initLayout(); - this._update(); - - map - .on('layeradd', this._onLayerChange, this) - .on('layerremove', this._onLayerChange, this); - - return this._container; - }, - - onRemove: function (map) { - map - .off('layeradd', this._onLayerChange, this) - .off('layerremove', this._onLayerChange, this); - }, - - addBaseLayer: function (layer, name) { - this._addLayer(layer, name); - this._update(); - return this; - }, - - addOverlay: function (layer, name) { - this._addLayer(layer, name, true); - this._update(); - return this; - }, - - removeLayer: function (layer) { - var id = L.stamp(layer); - delete this._layers[id]; - this._update(); - return this; - }, - - _initLayout: function () { - var className = 'leaflet-control-layers', - container = this._container = L.DomUtil.create('div', className); - - //Makes this work on IE10 Touch devices by stopping it from firing a mouseout event when the touch is released - container.setAttribute('aria-haspopup', true); - - if (!L.Browser.touch) { - L.DomEvent - .disableClickPropagation(container) - .disableScrollPropagation(container); - } else { - L.DomEvent.on(container, 'click', L.DomEvent.stopPropagation); - } - - var form = this._form = L.DomUtil.create('form', className + '-list'); - - if (this.options.collapsed) { - if (!L.Browser.android) { - L.DomEvent - .on(container, 'mouseover', this._expand, this) - .on(container, 'mouseout', this._collapse, this); - } - var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container); - link.href = '#'; - link.title = 'Layers'; - - if (L.Browser.touch) { - L.DomEvent - .on(link, 'click', L.DomEvent.stop) - .on(link, 'click', this._expand, this); - } - else { - L.DomEvent.on(link, 'focus', this._expand, this); - } - //Work around for Firefox android issue https://github.com/Leaflet/Leaflet/issues/2033 - L.DomEvent.on(form, 'click', function () { - setTimeout(L.bind(this._onInputClick, this), 0); - }, this); - - this._map.on('click', this._collapse, this); - // TODO keyboard accessibility - } else { - this._expand(); - } - - this._baseLayersList = L.DomUtil.create('div', className + '-base', form); - this._separator = L.DomUtil.create('div', className + '-separator', form); - this._overlaysList = L.DomUtil.create('div', className + '-overlays', form); - - container.appendChild(form); - }, - - _addLayer: function (layer, name, overlay) { - var id = L.stamp(layer); - - this._layers[id] = { - layer: layer, - name: name, - overlay: overlay - }; - - if (this.options.autoZIndex && layer.setZIndex) { - this._lastZIndex++; - layer.setZIndex(this._lastZIndex); - } - }, - - _update: function () { - if (!this._container) { - return; - } - - this._baseLayersList.innerHTML = ''; - this._overlaysList.innerHTML = ''; - - var baseLayersPresent = false, - overlaysPresent = false, - i, obj; - - for (i in this._layers) { - obj = this._layers[i]; - this._addItem(obj); - overlaysPresent = overlaysPresent || obj.overlay; - baseLayersPresent = baseLayersPresent || !obj.overlay; - } - - this._separator.style.display = overlaysPresent && baseLayersPresent ? '' : 'none'; - }, - - _onLayerChange: function (e) { - var obj = this._layers[L.stamp(e.layer)]; - - if (!obj) { return; } - - if (!this._handlingClick) { - this._update(); - } - - var type = obj.overlay ? - (e.type === 'layeradd' ? 'overlayadd' : 'overlayremove') : - (e.type === 'layeradd' ? 'baselayerchange' : null); - - if (type) { - this._map.fire(type, obj); - } - }, - - // IE7 bugs out if you create a radio dynamically, so you have to do it this hacky way (see http://bit.ly/PqYLBe) - _createRadioElement: function (name, checked) { - - var radioHtml = '= 0) { - this._onZoomTransitionEnd(); - } - }, - - _nothingToAnimate: function () { - return !this._container.getElementsByClassName('leaflet-zoom-animated').length; - }, - - _tryAnimatedZoom: function (center, zoom, options) { - - if (this._animatingZoom) { return true; } - - options = options || {}; - - // don't animate if disabled, not supported or zoom difference is too large - if (!this._zoomAnimated || options.animate === false || this._nothingToAnimate() || - Math.abs(zoom - this._zoom) > this.options.zoomAnimationThreshold) { return false; } - - // offset is the pixel coords of the zoom origin relative to the current center - var scale = this.getZoomScale(zoom), - offset = this._getCenterOffset(center)._divideBy(1 - 1 / scale), - origin = this._getCenterLayerPoint()._add(offset); - - // don't animate if the zoom origin isn't within one screen from the current center, unless forced - if (options.animate !== true && !this.getSize().contains(offset)) { return false; } - - this - .fire('movestart') - .fire('zoomstart'); - - this._animateZoom(center, zoom, origin, scale, null, true); - - return true; - }, - - _animateZoom: function (center, zoom, origin, scale, delta, backwards, forTouchZoom) { - - if (!forTouchZoom) { - this._animatingZoom = true; - } - - // put transform transition on all layers with leaflet-zoom-animated class - L.DomUtil.addClass(this._mapPane, 'leaflet-zoom-anim'); - - // remember what center/zoom to set after animation - this._animateToCenter = center; - this._animateToZoom = zoom; - - // disable any dragging during animation - if (L.Draggable) { - L.Draggable._disabled = true; - } - - L.Util.requestAnimFrame(function () { - this.fire('zoomanim', { - center: center, - zoom: zoom, - origin: origin, - scale: scale, - delta: delta, - backwards: backwards - }); - }, this); - }, - - _onZoomTransitionEnd: function () { - - this._animatingZoom = false; - - L.DomUtil.removeClass(this._mapPane, 'leaflet-zoom-anim'); - - this._resetView(this._animateToCenter, this._animateToZoom, true, true); - - if (L.Draggable) { - L.Draggable._disabled = false; - } - } -}); - - -/* - Zoom animation logic for L.TileLayer. -*/ - -L.TileLayer.include({ - _animateZoom: function (e) { - if (!this._animating) { - this._animating = true; - this._prepareBgBuffer(); - } - - var bg = this._bgBuffer, - transform = L.DomUtil.TRANSFORM, - initialTransform = e.delta ? L.DomUtil.getTranslateString(e.delta) : bg.style[transform], - scaleStr = L.DomUtil.getScaleString(e.scale, e.origin); - - bg.style[transform] = e.backwards ? - scaleStr + ' ' + initialTransform : - initialTransform + ' ' + scaleStr; - }, - - _endZoomAnim: function () { - var front = this._tileContainer, - bg = this._bgBuffer; - - front.style.visibility = ''; - front.parentNode.appendChild(front); // Bring to fore - - // force reflow - L.Util.falseFn(bg.offsetWidth); - - this._animating = false; - }, - - _clearBgBuffer: function () { - var map = this._map; - - if (map && !map._animatingZoom && !map.touchZoom._zooming) { - this._bgBuffer.innerHTML = ''; - this._bgBuffer.style[L.DomUtil.TRANSFORM] = ''; - } - }, - - _prepareBgBuffer: function () { - - var front = this._tileContainer, - bg = this._bgBuffer; - - // if foreground layer doesn't have many tiles but bg layer does, - // keep the existing bg layer and just zoom it some more - - var bgLoaded = this._getLoadedTilesPercentage(bg), - frontLoaded = this._getLoadedTilesPercentage(front); - - if (bg && bgLoaded > 0.5 && frontLoaded < 0.5) { - - front.style.visibility = 'hidden'; - this._stopLoadingImages(front); - return; - } - - // prepare the buffer to become the front tile pane - bg.style.visibility = 'hidden'; - bg.style[L.DomUtil.TRANSFORM] = ''; - - // switch out the current layer to be the new bg layer (and vice-versa) - this._tileContainer = bg; - bg = this._bgBuffer = front; - - this._stopLoadingImages(bg); - - //prevent bg buffer from clearing right after zoom - clearTimeout(this._clearBgBufferTimer); - }, - - _getLoadedTilesPercentage: function (container) { - var tiles = container.getElementsByTagName('img'), - i, len, count = 0; - - for (i = 0, len = tiles.length; i < len; i++) { - if (tiles[i].complete) { - count++; - } - } - return count / len; - }, - - // stops loading all tiles in the background layer - _stopLoadingImages: function (container) { - var tiles = Array.prototype.slice.call(container.getElementsByTagName('img')), - i, len, tile; - - for (i = 0, len = tiles.length; i < len; i++) { - tile = tiles[i]; - - if (!tile.complete) { - tile.onload = L.Util.falseFn; - tile.onerror = L.Util.falseFn; - tile.src = L.Util.emptyImageUrl; - - tile.parentNode.removeChild(tile); - } - } - } -}); - - -/* - * Provides L.Map with convenient shortcuts for using browser geolocation features. - */ - -L.Map.include({ - _defaultLocateOptions: { - watch: false, - setView: false, - maxZoom: Infinity, - timeout: 10000, - maximumAge: 0, - enableHighAccuracy: false - }, - - locate: function (/*Object*/ options) { - - options = this._locateOptions = L.extend(this._defaultLocateOptions, options); - - if (!navigator.geolocation) { - this._handleGeolocationError({ - code: 0, - message: 'Geolocation not supported.' - }); - return this; - } - - var onResponse = L.bind(this._handleGeolocationResponse, this), - onError = L.bind(this._handleGeolocationError, this); - - if (options.watch) { - this._locationWatchId = - navigator.geolocation.watchPosition(onResponse, onError, options); - } else { - navigator.geolocation.getCurrentPosition(onResponse, onError, options); - } - return this; - }, - - stopLocate: function () { - if (navigator.geolocation) { - navigator.geolocation.clearWatch(this._locationWatchId); - } - if (this._locateOptions) { - this._locateOptions.setView = false; - } - return this; - }, - - _handleGeolocationError: function (error) { - var c = error.code, - message = error.message || - (c === 1 ? 'permission denied' : - (c === 2 ? 'position unavailable' : 'timeout')); - - if (this._locateOptions.setView && !this._loaded) { - this.fitWorld(); - } - - this.fire('locationerror', { - code: c, - message: 'Geolocation error: ' + message + '.' - }); - }, - - _handleGeolocationResponse: function (pos) { - var lat = pos.coords.latitude, - lng = pos.coords.longitude, - latlng = new L.LatLng(lat, lng), - - latAccuracy = 180 * pos.coords.accuracy / 40075017, - lngAccuracy = latAccuracy / Math.cos(L.LatLng.DEG_TO_RAD * lat), - - bounds = L.latLngBounds( - [lat - latAccuracy, lng - lngAccuracy], - [lat + latAccuracy, lng + lngAccuracy]), - - options = this._locateOptions; - - if (options.setView) { - var zoom = Math.min(this.getBoundsZoom(bounds), options.maxZoom); - this.setView(latlng, zoom); - } - - var data = { - latlng: latlng, - bounds: bounds, - timestamp: pos.timestamp - }; - - for (var i in pos.coords) { - if (typeof pos.coords[i] === 'number') { - data[i] = pos.coords[i]; - } - } - - this.fire('locationfound', data); - } -}); - - -}(window, document)); \ No newline at end of file diff --git a/www7/sites/all/libraries/leaflet/leaflet.js b/www7/sites/all/libraries/leaflet/leaflet.js deleted file mode 100644 index 03434b77d..000000000 --- a/www7/sites/all/libraries/leaflet/leaflet.js +++ /dev/null @@ -1,9 +0,0 @@ -/* - Leaflet, a JavaScript library for mobile-friendly interactive maps. http://leafletjs.com - (c) 2010-2013, Vladimir Agafonkin - (c) 2010-2011, CloudMade -*/ -!function(t,e,i){var n=t.L,o={};o.version="0.7.3","object"==typeof module&&"object"==typeof module.exports?module.exports=o:"function"==typeof define&&define.amd&&define(o),o.noConflict=function(){return t.L=n,this},t.L=o,o.Util={extend:function(t){var e,i,n,o,s=Array.prototype.slice.call(arguments,1);for(i=0,n=s.length;n>i;i++){o=s[i]||{};for(e in o)o.hasOwnProperty(e)&&(t[e]=o[e])}return t},bind:function(t,e){var i=arguments.length>2?Array.prototype.slice.call(arguments,2):null;return function(){return t.apply(e,i||arguments)}},stamp:function(){var t=0,e="_leaflet_id";return function(i){return i[e]=i[e]||++t,i[e]}}(),invokeEach:function(t,e,i){var n,o;if("object"==typeof t){o=Array.prototype.slice.call(arguments,3);for(n in t)e.apply(i,[n,t[n]].concat(o));return!0}return!1},limitExecByInterval:function(t,e,i){var n,o;return function s(){var a=arguments;return n?void(o=!0):(n=!0,setTimeout(function(){n=!1,o&&(s.apply(i,a),o=!1)},e),void t.apply(i,a))}},falseFn:function(){return!1},formatNum:function(t,e){var i=Math.pow(10,e||5);return Math.round(t*i)/i},trim:function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},splitWords:function(t){return o.Util.trim(t).split(/\s+/)},setOptions:function(t,e){return t.options=o.extend({},t.options,e),t.options},getParamString:function(t,e,i){var n=[];for(var o in t)n.push(encodeURIComponent(i?o.toUpperCase():o)+"="+encodeURIComponent(t[o]));return(e&&-1!==e.indexOf("?")?"&":"?")+n.join("&")},template:function(t,e){return t.replace(/\{ *([\w_]+) *\}/g,function(t,n){var o=e[n];if(o===i)throw new Error("No value provided for variable "+t);return"function"==typeof o&&(o=o(e)),o})},isArray:Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},emptyImageUrl:"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="},function(){function e(e){var i,n,o=["webkit","moz","o","ms"];for(i=0;it;t++)n._initHooks[t].call(this)}},e},o.Class.include=function(t){o.extend(this.prototype,t)},o.Class.mergeOptions=function(t){o.extend(this.prototype.options,t)},o.Class.addInitHook=function(t){var e=Array.prototype.slice.call(arguments,1),i="function"==typeof t?t:function(){this[t].apply(this,e)};this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(i)};var s="_leaflet_events";o.Mixin={},o.Mixin.Events={addEventListener:function(t,e,i){if(o.Util.invokeEach(t,this.addEventListener,this,e,i))return this;var n,a,r,h,l,u,c,d=this[s]=this[s]||{},p=i&&i!==this&&o.stamp(i);for(t=o.Util.splitWords(t),n=0,a=t.length;a>n;n++)r={action:e,context:i||this},h=t[n],p?(l=h+"_idx",u=l+"_len",c=d[l]=d[l]||{},c[p]||(c[p]=[],d[u]=(d[u]||0)+1),c[p].push(r)):(d[h]=d[h]||[],d[h].push(r));return this},hasEventListeners:function(t){var e=this[s];return!!e&&(t in e&&e[t].length>0||t+"_idx"in e&&e[t+"_idx_len"]>0)},removeEventListener:function(t,e,i){if(!this[s])return this;if(!t)return this.clearAllEventListeners();if(o.Util.invokeEach(t,this.removeEventListener,this,e,i))return this;var n,a,r,h,l,u,c,d,p,_=this[s],m=i&&i!==this&&o.stamp(i);for(t=o.Util.splitWords(t),n=0,a=t.length;a>n;n++)if(r=t[n],u=r+"_idx",c=u+"_len",d=_[u],e){if(h=m&&d?d[m]:_[r]){for(l=h.length-1;l>=0;l--)h[l].action!==e||i&&h[l].context!==i||(p=h.splice(l,1),p[0].action=o.Util.falseFn);i&&d&&0===h.length&&(delete d[m],_[c]--)}}else delete _[r],delete _[u],delete _[c];return this},clearAllEventListeners:function(){return delete this[s],this},fireEvent:function(t,e){if(!this.hasEventListeners(t))return this;var i,n,a,r,h,l=o.Util.extend({},e,{type:t,target:this}),u=this[s];if(u[t])for(i=u[t].slice(),n=0,a=i.length;a>n;n++)i[n].action.call(i[n].context,l);r=u[t+"_idx"];for(h in r)if(i=r[h].slice())for(n=0,a=i.length;a>n;n++)i[n].action.call(i[n].context,l);return this},addOneTimeEventListener:function(t,e,i){if(o.Util.invokeEach(t,this.addOneTimeEventListener,this,e,i))return this;var n=o.bind(function(){this.removeEventListener(t,e,i).removeEventListener(t,n,i)},this);return this.addEventListener(t,e,i).addEventListener(t,n,i)}},o.Mixin.Events.on=o.Mixin.Events.addEventListener,o.Mixin.Events.off=o.Mixin.Events.removeEventListener,o.Mixin.Events.once=o.Mixin.Events.addOneTimeEventListener,o.Mixin.Events.fire=o.Mixin.Events.fireEvent,function(){var n="ActiveXObject"in t,s=n&&!e.addEventListener,a=navigator.userAgent.toLowerCase(),r=-1!==a.indexOf("webkit"),h=-1!==a.indexOf("chrome"),l=-1!==a.indexOf("phantom"),u=-1!==a.indexOf("android"),c=-1!==a.search("android [23]"),d=-1!==a.indexOf("gecko"),p=typeof orientation!=i+"",_=t.navigator&&t.navigator.msPointerEnabled&&t.navigator.msMaxTouchPoints&&!t.PointerEvent,m=t.PointerEvent&&t.navigator.pointerEnabled&&t.navigator.maxTouchPoints||_,f="devicePixelRatio"in t&&t.devicePixelRatio>1||"matchMedia"in t&&t.matchMedia("(min-resolution:144dpi)")&&t.matchMedia("(min-resolution:144dpi)").matches,g=e.documentElement,v=n&&"transition"in g.style,y="WebKitCSSMatrix"in t&&"m11"in new t.WebKitCSSMatrix&&!c,P="MozPerspective"in g.style,L="OTransition"in g.style,x=!t.L_DISABLE_3D&&(v||y||P||L)&&!l,w=!t.L_NO_TOUCH&&!l&&function(){var t="ontouchstart";if(m||t in g)return!0;var i=e.createElement("div"),n=!1;return i.setAttribute?(i.setAttribute(t,"return;"),"function"==typeof i[t]&&(n=!0),i.removeAttribute(t),i=null,n):!1}();o.Browser={ie:n,ielt9:s,webkit:r,gecko:d&&!r&&!t.opera&&!n,android:u,android23:c,chrome:h,ie3d:v,webkit3d:y,gecko3d:P,opera3d:L,any3d:x,mobile:p,mobileWebkit:p&&r,mobileWebkit3d:p&&y,mobileOpera:p&&t.opera,touch:w,msPointer:_,pointer:m,retina:f}}(),o.Point=function(t,e,i){this.x=i?Math.round(t):t,this.y=i?Math.round(e):e},o.Point.prototype={clone:function(){return new o.Point(this.x,this.y)},add:function(t){return this.clone()._add(o.point(t))},_add:function(t){return this.x+=t.x,this.y+=t.y,this},subtract:function(t){return this.clone()._subtract(o.point(t))},_subtract:function(t){return this.x-=t.x,this.y-=t.y,this},divideBy:function(t){return this.clone()._divideBy(t)},_divideBy:function(t){return this.x/=t,this.y/=t,this},multiplyBy:function(t){return this.clone()._multiplyBy(t)},_multiplyBy:function(t){return this.x*=t,this.y*=t,this},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},distanceTo:function(t){t=o.point(t);var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},equals:function(t){return t=o.point(t),t.x===this.x&&t.y===this.y},contains:function(t){return t=o.point(t),Math.abs(t.x)<=Math.abs(this.x)&&Math.abs(t.y)<=Math.abs(this.y)},toString:function(){return"Point("+o.Util.formatNum(this.x)+", "+o.Util.formatNum(this.y)+")"}},o.point=function(t,e,n){return t instanceof o.Point?t:o.Util.isArray(t)?new o.Point(t[0],t[1]):t===i||null===t?t:new o.Point(t,e,n)},o.Bounds=function(t,e){if(t)for(var i=e?[t,e]:t,n=0,o=i.length;o>n;n++)this.extend(i[n])},o.Bounds.prototype={extend:function(t){return t=o.point(t),this.min||this.max?(this.min.x=Math.min(t.x,this.min.x),this.max.x=Math.max(t.x,this.max.x),this.min.y=Math.min(t.y,this.min.y),this.max.y=Math.max(t.y,this.max.y)):(this.min=t.clone(),this.max=t.clone()),this},getCenter:function(t){return new o.Point((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,t)},getBottomLeft:function(){return new o.Point(this.min.x,this.max.y)},getTopRight:function(){return new o.Point(this.max.x,this.min.y)},getSize:function(){return this.max.subtract(this.min)},contains:function(t){var e,i;return t="number"==typeof t[0]||t instanceof o.Point?o.point(t):o.bounds(t),t instanceof o.Bounds?(e=t.min,i=t.max):e=i=t,e.x>=this.min.x&&i.x<=this.max.x&&e.y>=this.min.y&&i.y<=this.max.y},intersects:function(t){t=o.bounds(t);var e=this.min,i=this.max,n=t.min,s=t.max,a=s.x>=e.x&&n.x<=i.x,r=s.y>=e.y&&n.y<=i.y;return a&&r},isValid:function(){return!(!this.min||!this.max)}},o.bounds=function(t,e){return!t||t instanceof o.Bounds?t:new o.Bounds(t,e)},o.Transformation=function(t,e,i,n){this._a=t,this._b=e,this._c=i,this._d=n},o.Transformation.prototype={transform:function(t,e){return this._transform(t.clone(),e)},_transform:function(t,e){return e=e||1,t.x=e*(this._a*t.x+this._b),t.y=e*(this._c*t.y+this._d),t},untransform:function(t,e){return e=e||1,new o.Point((t.x/e-this._b)/this._a,(t.y/e-this._d)/this._c)}},o.DomUtil={get:function(t){return"string"==typeof t?e.getElementById(t):t},getStyle:function(t,i){var n=t.style[i];if(!n&&t.currentStyle&&(n=t.currentStyle[i]),(!n||"auto"===n)&&e.defaultView){var o=e.defaultView.getComputedStyle(t,null);n=o?o[i]:null}return"auto"===n?null:n},getViewportOffset:function(t){var i,n=0,s=0,a=t,r=e.body,h=e.documentElement;do{if(n+=a.offsetTop||0,s+=a.offsetLeft||0,n+=parseInt(o.DomUtil.getStyle(a,"borderTopWidth"),10)||0,s+=parseInt(o.DomUtil.getStyle(a,"borderLeftWidth"),10)||0,i=o.DomUtil.getStyle(a,"position"),a.offsetParent===r&&"absolute"===i)break;if("fixed"===i){n+=r.scrollTop||h.scrollTop||0,s+=r.scrollLeft||h.scrollLeft||0;break}if("relative"===i&&!a.offsetLeft){var l=o.DomUtil.getStyle(a,"width"),u=o.DomUtil.getStyle(a,"max-width"),c=a.getBoundingClientRect();("none"!==l||"none"!==u)&&(s+=c.left+a.clientLeft),n+=c.top+(r.scrollTop||h.scrollTop||0);break}a=a.offsetParent}while(a);a=t;do{if(a===r)break;n-=a.scrollTop||0,s-=a.scrollLeft||0,a=a.parentNode}while(a);return new o.Point(s,n)},documentIsLtr:function(){return o.DomUtil._docIsLtrCached||(o.DomUtil._docIsLtrCached=!0,o.DomUtil._docIsLtr="ltr"===o.DomUtil.getStyle(e.body,"direction")),o.DomUtil._docIsLtr},create:function(t,i,n){var o=e.createElement(t);return o.className=i,n&&n.appendChild(o),o},hasClass:function(t,e){if(t.classList!==i)return t.classList.contains(e);var n=o.DomUtil._getClass(t);return n.length>0&&new RegExp("(^|\\s)"+e+"(\\s|$)").test(n)},addClass:function(t,e){if(t.classList!==i)for(var n=o.Util.splitWords(e),s=0,a=n.length;a>s;s++)t.classList.add(n[s]);else if(!o.DomUtil.hasClass(t,e)){var r=o.DomUtil._getClass(t);o.DomUtil._setClass(t,(r?r+" ":"")+e)}},removeClass:function(t,e){t.classList!==i?t.classList.remove(e):o.DomUtil._setClass(t,o.Util.trim((" "+o.DomUtil._getClass(t)+" ").replace(" "+e+" "," ")))},_setClass:function(t,e){t.className.baseVal===i?t.className=e:t.className.baseVal=e},_getClass:function(t){return t.className.baseVal===i?t.className:t.className.baseVal},setOpacity:function(t,e){if("opacity"in t.style)t.style.opacity=e;else if("filter"in t.style){var i=!1,n="DXImageTransform.Microsoft.Alpha";try{i=t.filters.item(n)}catch(o){if(1===e)return}e=Math.round(100*e),i?(i.Enabled=100!==e,i.Opacity=e):t.style.filter+=" progid:"+n+"(opacity="+e+")"}},testProp:function(t){for(var i=e.documentElement.style,n=0;ni||i===e?e:t),new o.LatLng(this.lat,i)}},o.latLng=function(t,e){return t instanceof o.LatLng?t:o.Util.isArray(t)?"number"==typeof t[0]||"string"==typeof t[0]?new o.LatLng(t[0],t[1],t[2]):null:t===i||null===t?t:"object"==typeof t&&"lat"in t?new o.LatLng(t.lat,"lng"in t?t.lng:t.lon):e===i?null:new o.LatLng(t,e)},o.LatLngBounds=function(t,e){if(t)for(var i=e?[t,e]:t,n=0,o=i.length;o>n;n++)this.extend(i[n])},o.LatLngBounds.prototype={extend:function(t){if(!t)return this;var e=o.latLng(t);return t=null!==e?e:o.latLngBounds(t),t instanceof o.LatLng?this._southWest||this._northEast?(this._southWest.lat=Math.min(t.lat,this._southWest.lat),this._southWest.lng=Math.min(t.lng,this._southWest.lng),this._northEast.lat=Math.max(t.lat,this._northEast.lat),this._northEast.lng=Math.max(t.lng,this._northEast.lng)):(this._southWest=new o.LatLng(t.lat,t.lng),this._northEast=new o.LatLng(t.lat,t.lng)):t instanceof o.LatLngBounds&&(this.extend(t._southWest),this.extend(t._northEast)),this},pad:function(t){var e=this._southWest,i=this._northEast,n=Math.abs(e.lat-i.lat)*t,s=Math.abs(e.lng-i.lng)*t;return new o.LatLngBounds(new o.LatLng(e.lat-n,e.lng-s),new o.LatLng(i.lat+n,i.lng+s))},getCenter:function(){return new o.LatLng((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new o.LatLng(this.getNorth(),this.getWest())},getSouthEast:function(){return new o.LatLng(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(t){t="number"==typeof t[0]||t instanceof o.LatLng?o.latLng(t):o.latLngBounds(t);var e,i,n=this._southWest,s=this._northEast;return t instanceof o.LatLngBounds?(e=t.getSouthWest(),i=t.getNorthEast()):e=i=t,e.lat>=n.lat&&i.lat<=s.lat&&e.lng>=n.lng&&i.lng<=s.lng},intersects:function(t){t=o.latLngBounds(t);var e=this._southWest,i=this._northEast,n=t.getSouthWest(),s=t.getNorthEast(),a=s.lat>=e.lat&&n.lat<=i.lat,r=s.lng>=e.lng&&n.lng<=i.lng;return a&&r},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(t){return t?(t=o.latLngBounds(t),this._southWest.equals(t.getSouthWest())&&this._northEast.equals(t.getNorthEast())):!1},isValid:function(){return!(!this._southWest||!this._northEast)}},o.latLngBounds=function(t,e){return!t||t instanceof o.LatLngBounds?t:new o.LatLngBounds(t,e)},o.Projection={},o.Projection.SphericalMercator={MAX_LATITUDE:85.0511287798,project:function(t){var e=o.LatLng.DEG_TO_RAD,i=this.MAX_LATITUDE,n=Math.max(Math.min(i,t.lat),-i),s=t.lng*e,a=n*e;return a=Math.log(Math.tan(Math.PI/4+a/2)),new o.Point(s,a)},unproject:function(t){var e=o.LatLng.RAD_TO_DEG,i=t.x*e,n=(2*Math.atan(Math.exp(t.y))-Math.PI/2)*e;return new o.LatLng(n,i)}},o.Projection.LonLat={project:function(t){return new o.Point(t.lng,t.lat)},unproject:function(t){return new o.LatLng(t.y,t.x)}},o.CRS={latLngToPoint:function(t,e){var i=this.projection.project(t),n=this.scale(e);return this.transformation._transform(i,n)},pointToLatLng:function(t,e){var i=this.scale(e),n=this.transformation.untransform(t,i);return this.projection.unproject(n)},project:function(t){return this.projection.project(t)},scale:function(t){return 256*Math.pow(2,t)},getSize:function(t){var e=this.scale(t);return o.point(e,e)}},o.CRS.Simple=o.extend({},o.CRS,{projection:o.Projection.LonLat,transformation:new o.Transformation(1,0,-1,0),scale:function(t){return Math.pow(2,t)}}),o.CRS.EPSG3857=o.extend({},o.CRS,{code:"EPSG:3857",projection:o.Projection.SphericalMercator,transformation:new o.Transformation(.5/Math.PI,.5,-.5/Math.PI,.5),project:function(t){var e=this.projection.project(t),i=6378137;return e.multiplyBy(i)}}),o.CRS.EPSG900913=o.extend({},o.CRS.EPSG3857,{code:"EPSG:900913"}),o.CRS.EPSG4326=o.extend({},o.CRS,{code:"EPSG:4326",projection:o.Projection.LonLat,transformation:new o.Transformation(1/360,.5,-1/360,.5)}),o.Map=o.Class.extend({includes:o.Mixin.Events,options:{crs:o.CRS.EPSG3857,fadeAnimation:o.DomUtil.TRANSITION&&!o.Browser.android23,trackResize:!0,markerZoomAnimation:o.DomUtil.TRANSITION&&o.Browser.any3d},initialize:function(t,e){e=o.setOptions(this,e),this._initContainer(t),this._initLayout(),this._onResize=o.bind(this._onResize,this),this._initEvents(),e.maxBounds&&this.setMaxBounds(e.maxBounds),e.center&&e.zoom!==i&&this.setView(o.latLng(e.center),e.zoom,{reset:!0}),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._tileLayersNum=0,this.callInitHooks(),this._addLayers(e.layers)},setView:function(t,e){return e=e===i?this.getZoom():e,this._resetView(o.latLng(t),this._limitZoom(e)),this},setZoom:function(t,e){return this._loaded?this.setView(this.getCenter(),t,{zoom:e}):(this._zoom=this._limitZoom(t),this)},zoomIn:function(t,e){return this.setZoom(this._zoom+(t||1),e)},zoomOut:function(t,e){return this.setZoom(this._zoom-(t||1),e)},setZoomAround:function(t,e,i){var n=this.getZoomScale(e),s=this.getSize().divideBy(2),a=t instanceof o.Point?t:this.latLngToContainerPoint(t),r=a.subtract(s).multiplyBy(1-1/n),h=this.containerPointToLatLng(s.add(r));return this.setView(h,e,{zoom:i})},fitBounds:function(t,e){e=e||{},t=t.getBounds?t.getBounds():o.latLngBounds(t);var i=o.point(e.paddingTopLeft||e.padding||[0,0]),n=o.point(e.paddingBottomRight||e.padding||[0,0]),s=this.getBoundsZoom(t,!1,i.add(n)),a=n.subtract(i).divideBy(2),r=this.project(t.getSouthWest(),s),h=this.project(t.getNorthEast(),s),l=this.unproject(r.add(h).divideBy(2).add(a),s);return s=e&&e.maxZoom?Math.min(e.maxZoom,s):s,this.setView(l,s,e)},fitWorld:function(t){return this.fitBounds([[-90,-180],[90,180]],t)},panTo:function(t,e){return this.setView(t,this._zoom,{pan:e})},panBy:function(t){return this.fire("movestart"),this._rawPanBy(o.point(t)),this.fire("move"),this.fire("moveend")},setMaxBounds:function(t){return t=o.latLngBounds(t),this.options.maxBounds=t,t?(this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds,this)):this.off("moveend",this._panInsideMaxBounds,this)},panInsideBounds:function(t,e){var i=this.getCenter(),n=this._limitCenter(i,this._zoom,t);return i.equals(n)?this:this.panTo(n,e)},addLayer:function(t){var e=o.stamp(t);return this._layers[e]?this:(this._layers[e]=t,!t.options||isNaN(t.options.maxZoom)&&isNaN(t.options.minZoom)||(this._zoomBoundLayers[e]=t,this._updateZoomLevels()),this.options.zoomAnimation&&o.TileLayer&&t instanceof o.TileLayer&&(this._tileLayersNum++,this._tileLayersToLoad++,t.on("load",this._onTileLayerLoad,this)),this._loaded&&this._layerAdd(t),this)},removeLayer:function(t){var e=o.stamp(t);return this._layers[e]?(this._loaded&&t.onRemove(this),delete this._layers[e],this._loaded&&this.fire("layerremove",{layer:t}),this._zoomBoundLayers[e]&&(delete this._zoomBoundLayers[e],this._updateZoomLevels()),this.options.zoomAnimation&&o.TileLayer&&t instanceof o.TileLayer&&(this._tileLayersNum--,this._tileLayersToLoad--,t.off("load",this._onTileLayerLoad,this)),this):this},hasLayer:function(t){return t?o.stamp(t)in this._layers:!1},eachLayer:function(t,e){for(var i in this._layers)t.call(e,this._layers[i]);return this},invalidateSize:function(t){if(!this._loaded)return this;t=o.extend({animate:!1,pan:!0},t===!0?{animate:!0}:t);var e=this.getSize();this._sizeChanged=!0,this._initialCenter=null;var i=this.getSize(),n=e.divideBy(2).round(),s=i.divideBy(2).round(),a=n.subtract(s);return a.x||a.y?(t.animate&&t.pan?this.panBy(a):(t.pan&&this._rawPanBy(a),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(o.bind(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:e,newSize:i})):this},addHandler:function(t,e){if(!e)return this;var i=this[t]=new e(this);return this._handlers.push(i),this.options[t]&&i.enable(),this},remove:function(){this._loaded&&this.fire("unload"),this._initEvents("off");try{delete this._container._leaflet}catch(t){this._container._leaflet=i}return this._clearPanes(),this._clearControlPos&&this._clearControlPos(),this._clearHandlers(),this},getCenter:function(){return this._checkIfLoaded(),this._initialCenter&&!this._moved()?this._initialCenter:this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds(),e=this.unproject(t.getBottomLeft()),i=this.unproject(t.getTopRight());return new o.LatLngBounds(e,i)},getMinZoom:function(){return this.options.minZoom===i?this._layersMinZoom===i?0:this._layersMinZoom:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===i?this._layersMaxZoom===i?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(t,e,i){t=o.latLngBounds(t);var n,s=this.getMinZoom()-(e?1:0),a=this.getMaxZoom(),r=this.getSize(),h=t.getNorthWest(),l=t.getSouthEast(),u=!0;i=o.point(i||[0,0]);do s++,n=this.project(l,s).subtract(this.project(h,s)).add(i),u=e?n.x=s);return u&&e?null:e?s:s-1},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new o.Point(this._container.clientWidth,this._container.clientHeight),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(){var t=this._getTopLeftPoint();return new o.Bounds(t,t.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._initialTopLeftPoint},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(t){var e=this.options.crs;return e.scale(t)/e.scale(this._zoom)},getScaleZoom:function(t){return this._zoom+Math.log(t)/Math.LN2},project:function(t,e){return e=e===i?this._zoom:e,this.options.crs.latLngToPoint(o.latLng(t),e)},unproject:function(t,e){return e=e===i?this._zoom:e,this.options.crs.pointToLatLng(o.point(t),e)},layerPointToLatLng:function(t){var e=o.point(t).add(this.getPixelOrigin());return this.unproject(e)},latLngToLayerPoint:function(t){var e=this.project(o.latLng(t))._round();return e._subtract(this.getPixelOrigin())},containerPointToLayerPoint:function(t){return o.point(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return o.point(t).add(this._getMapPanePos())},containerPointToLatLng:function(t){var e=this.containerPointToLayerPoint(o.point(t));return this.layerPointToLatLng(e)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(o.latLng(t)))},mouseEventToContainerPoint:function(t){return o.DomEvent.getMousePosition(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(t){var e=this._container=o.DomUtil.get(t);if(!e)throw new Error("Map container not found.");if(e._leaflet)throw new Error("Map container is already initialized.");e._leaflet=!0},_initLayout:function(){var t=this._container;o.DomUtil.addClass(t,"leaflet-container"+(o.Browser.touch?" leaflet-touch":"")+(o.Browser.retina?" leaflet-retina":"")+(o.Browser.ielt9?" leaflet-oldie":"")+(this.options.fadeAnimation?" leaflet-fade-anim":""));var e=o.DomUtil.getStyle(t,"position");"absolute"!==e&&"relative"!==e&&"fixed"!==e&&(t.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._mapPane=t.mapPane=this._createPane("leaflet-map-pane",this._container),this._tilePane=t.tilePane=this._createPane("leaflet-tile-pane",this._mapPane),t.objectsPane=this._createPane("leaflet-objects-pane",this._mapPane),t.shadowPane=this._createPane("leaflet-shadow-pane"),t.overlayPane=this._createPane("leaflet-overlay-pane"),t.markerPane=this._createPane("leaflet-marker-pane"),t.popupPane=this._createPane("leaflet-popup-pane");var e=" leaflet-zoom-hide";this.options.markerZoomAnimation||(o.DomUtil.addClass(t.markerPane,e),o.DomUtil.addClass(t.shadowPane,e),o.DomUtil.addClass(t.popupPane,e))},_createPane:function(t,e){return o.DomUtil.create("div",t,e||this._panes.objectsPane)},_clearPanes:function(){this._container.removeChild(this._mapPane)},_addLayers:function(t){t=t?o.Util.isArray(t)?t:[t]:[];for(var e=0,i=t.length;i>e;e++)this.addLayer(t[e])},_resetView:function(t,e,i,n){var s=this._zoom!==e;n||(this.fire("movestart"),s&&this.fire("zoomstart")),this._zoom=e,this._initialCenter=t,this._initialTopLeftPoint=this._getNewTopLeftPoint(t),i?this._initialTopLeftPoint._add(this._getMapPanePos()):o.DomUtil.setPosition(this._mapPane,new o.Point(0,0)),this._tileLayersToLoad=this._tileLayersNum;var a=!this._loaded;this._loaded=!0,this.fire("viewreset",{hard:!i}),a&&(this.fire("load"),this.eachLayer(this._layerAdd,this)),this.fire("move"),(s||n)&&this.fire("zoomend"),this.fire("moveend",{hard:!i})},_rawPanBy:function(t){o.DomUtil.setPosition(this._mapPane,this._getMapPanePos().subtract(t))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_updateZoomLevels:function(){var t,e=1/0,n=-1/0,o=this._getZoomSpan();for(t in this._zoomBoundLayers){var s=this._zoomBoundLayers[t];isNaN(s.options.minZoom)||(e=Math.min(e,s.options.minZoom)),isNaN(s.options.maxZoom)||(n=Math.max(n,s.options.maxZoom))}t===i?this._layersMaxZoom=this._layersMinZoom=i:(this._layersMaxZoom=n,this._layersMinZoom=e),o!==this._getZoomSpan()&&this.fire("zoomlevelschange")},_panInsideMaxBounds:function(){this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(e){if(o.DomEvent){e=e||"on",o.DomEvent[e](this._container,"click",this._onMouseClick,this);var i,n,s=["dblclick","mousedown","mouseup","mouseenter","mouseleave","mousemove","contextmenu"];for(i=0,n=s.length;n>i;i++)o.DomEvent[e](this._container,s[i],this._fireMouseEvent,this);this.options.trackResize&&o.DomEvent[e](t,"resize",this._onResize,this)}},_onResize:function(){o.Util.cancelAnimFrame(this._resizeRequest),this._resizeRequest=o.Util.requestAnimFrame(function(){this.invalidateSize({debounceMoveend:!0})},this,!1,this._container)},_onMouseClick:function(t){!this._loaded||!t._simulated&&(this.dragging&&this.dragging.moved()||this.boxZoom&&this.boxZoom.moved())||o.DomEvent._skipped(t)||(this.fire("preclick"),this._fireMouseEvent(t))},_fireMouseEvent:function(t){if(this._loaded&&!o.DomEvent._skipped(t)){var e=t.type;if(e="mouseenter"===e?"mouseover":"mouseleave"===e?"mouseout":e,this.hasEventListeners(e)){"contextmenu"===e&&o.DomEvent.preventDefault(t);var i=this.mouseEventToContainerPoint(t),n=this.containerPointToLayerPoint(i),s=this.layerPointToLatLng(n);this.fire(e,{latlng:s,layerPoint:n,containerPoint:i,originalEvent:t})}}},_onTileLayerLoad:function(){this._tileLayersToLoad--,this._tileLayersNum&&!this._tileLayersToLoad&&this.fire("tilelayersload")},_clearHandlers:function(){for(var t=0,e=this._handlers.length;e>t;t++)this._handlers[t].disable()},whenReady:function(t,e){return this._loaded?t.call(e||this,this):this.on("load",t,e),this},_layerAdd:function(t){t.onAdd(this),this.fire("layeradd",{layer:t})},_getMapPanePos:function(){return o.DomUtil.getPosition(this._mapPane)},_moved:function(){var t=this._getMapPanePos();return t&&!t.equals([0,0])},_getTopLeftPoint:function(){return this.getPixelOrigin().subtract(this._getMapPanePos())},_getNewTopLeftPoint:function(t,e){var i=this.getSize()._divideBy(2);return this.project(t,e)._subtract(i)._round()},_latLngToNewLayerPoint:function(t,e,i){var n=this._getNewTopLeftPoint(i,e).add(this._getMapPanePos());return this.project(t,e)._subtract(n)},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(t){return this.latLngToLayerPoint(t).subtract(this._getCenterLayerPoint())},_limitCenter:function(t,e,i){if(!i)return t;var n=this.project(t,e),s=this.getSize().divideBy(2),a=new o.Bounds(n.subtract(s),n.add(s)),r=this._getBoundsOffset(a,i,e);return this.unproject(n.add(r),e)},_limitOffset:function(t,e){if(!e)return t;var i=this.getPixelBounds(),n=new o.Bounds(i.min.add(t),i.max.add(t));return t.add(this._getBoundsOffset(n,e))},_getBoundsOffset:function(t,e,i){var n=this.project(e.getNorthWest(),i).subtract(t.min),s=this.project(e.getSouthEast(),i).subtract(t.max),a=this._rebound(n.x,-s.x),r=this._rebound(n.y,-s.y);return new o.Point(a,r)},_rebound:function(t,e){return t+e>0?Math.round(t-e)/2:Math.max(0,Math.ceil(t))-Math.max(0,Math.floor(e))},_limitZoom:function(t){var e=this.getMinZoom(),i=this.getMaxZoom();return Math.max(e,Math.min(i,t))}}),o.map=function(t,e){return new o.Map(t,e)},o.Projection.Mercator={MAX_LATITUDE:85.0840591556,R_MINOR:6356752.314245179,R_MAJOR:6378137,project:function(t){var e=o.LatLng.DEG_TO_RAD,i=this.MAX_LATITUDE,n=Math.max(Math.min(i,t.lat),-i),s=this.R_MAJOR,a=this.R_MINOR,r=t.lng*e*s,h=n*e,l=a/s,u=Math.sqrt(1-l*l),c=u*Math.sin(h);c=Math.pow((1-c)/(1+c),.5*u);var d=Math.tan(.5*(.5*Math.PI-h))/c;return h=-s*Math.log(d),new o.Point(r,h)},unproject:function(t){for(var e,i=o.LatLng.RAD_TO_DEG,n=this.R_MAJOR,s=this.R_MINOR,a=t.x*i/n,r=s/n,h=Math.sqrt(1-r*r),l=Math.exp(-t.y/n),u=Math.PI/2-2*Math.atan(l),c=15,d=1e-7,p=c,_=.1;Math.abs(_)>d&&--p>0;)e=h*Math.sin(u),_=Math.PI/2-2*Math.atan(l*Math.pow((1-e)/(1+e),.5*h))-u,u+=_; -return new o.LatLng(u*i,a)}},o.CRS.EPSG3395=o.extend({},o.CRS,{code:"EPSG:3395",projection:o.Projection.Mercator,transformation:function(){var t=o.Projection.Mercator,e=t.R_MAJOR,i=.5/(Math.PI*e);return new o.Transformation(i,.5,-i,.5)}()}),o.TileLayer=o.Class.extend({includes:o.Mixin.Events,options:{minZoom:0,maxZoom:18,tileSize:256,subdomains:"abc",errorTileUrl:"",attribution:"",zoomOffset:0,opacity:1,unloadInvisibleTiles:o.Browser.mobile,updateWhenIdle:o.Browser.mobile},initialize:function(t,e){e=o.setOptions(this,e),e.detectRetina&&o.Browser.retina&&e.maxZoom>0&&(e.tileSize=Math.floor(e.tileSize/2),e.zoomOffset++,e.minZoom>0&&e.minZoom--,this.options.maxZoom--),e.bounds&&(e.bounds=o.latLngBounds(e.bounds)),this._url=t;var i=this.options.subdomains;"string"==typeof i&&(this.options.subdomains=i.split(""))},onAdd:function(t){this._map=t,this._animated=t._zoomAnimated,this._initContainer(),t.on({viewreset:this._reset,moveend:this._update},this),this._animated&&t.on({zoomanim:this._animateZoom,zoomend:this._endZoomAnim},this),this.options.updateWhenIdle||(this._limitedUpdate=o.Util.limitExecByInterval(this._update,150,this),t.on("move",this._limitedUpdate,this)),this._reset(),this._update()},addTo:function(t){return t.addLayer(this),this},onRemove:function(t){this._container.parentNode.removeChild(this._container),t.off({viewreset:this._reset,moveend:this._update},this),this._animated&&t.off({zoomanim:this._animateZoom,zoomend:this._endZoomAnim},this),this.options.updateWhenIdle||t.off("move",this._limitedUpdate,this),this._container=null,this._map=null},bringToFront:function(){var t=this._map._panes.tilePane;return this._container&&(t.appendChild(this._container),this._setAutoZIndex(t,Math.max)),this},bringToBack:function(){var t=this._map._panes.tilePane;return this._container&&(t.insertBefore(this._container,t.firstChild),this._setAutoZIndex(t,Math.min)),this},getAttribution:function(){return this.options.attribution},getContainer:function(){return this._container},setOpacity:function(t){return this.options.opacity=t,this._map&&this._updateOpacity(),this},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},setUrl:function(t,e){return this._url=t,e||this.redraw(),this},redraw:function(){return this._map&&(this._reset({hard:!0}),this._update()),this},_updateZIndex:function(){this._container&&this.options.zIndex!==i&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(t,e){var i,n,o,s=t.children,a=-e(1/0,-1/0);for(n=0,o=s.length;o>n;n++)s[n]!==this._container&&(i=parseInt(s[n].style.zIndex,10),isNaN(i)||(a=e(a,i)));this.options.zIndex=this._container.style.zIndex=(isFinite(a)?a:0)+e(1,-1)},_updateOpacity:function(){var t,e=this._tiles;if(o.Browser.ielt9)for(t in e)o.DomUtil.setOpacity(e[t],this.options.opacity);else o.DomUtil.setOpacity(this._container,this.options.opacity)},_initContainer:function(){var t=this._map._panes.tilePane;if(!this._container){if(this._container=o.DomUtil.create("div","leaflet-layer"),this._updateZIndex(),this._animated){var e="leaflet-tile-container";this._bgBuffer=o.DomUtil.create("div",e,this._container),this._tileContainer=o.DomUtil.create("div",e,this._container)}else this._tileContainer=this._container;t.appendChild(this._container),this.options.opacity<1&&this._updateOpacity()}},_reset:function(t){for(var e in this._tiles)this.fire("tileunload",{tile:this._tiles[e]});this._tiles={},this._tilesToLoad=0,this.options.reuseTiles&&(this._unusedTiles=[]),this._tileContainer.innerHTML="",this._animated&&t&&t.hard&&this._clearBgBuffer(),this._initContainer()},_getTileSize:function(){var t=this._map,e=t.getZoom()+this.options.zoomOffset,i=this.options.maxNativeZoom,n=this.options.tileSize;return i&&e>i&&(n=Math.round(t.getZoomScale(e)/t.getZoomScale(i)*n)),n},_update:function(){if(this._map){var t=this._map,e=t.getPixelBounds(),i=t.getZoom(),n=this._getTileSize();if(!(i>this.options.maxZoom||in;n++)this._addTile(a[n],l);this._tileContainer.appendChild(l)}},_tileShouldBeLoaded:function(t){if(t.x+":"+t.y in this._tiles)return!1;var e=this.options;if(!e.continuousWorld){var i=this._getWrapTileNum();if(e.noWrap&&(t.x<0||t.x>=i.x)||t.y<0||t.y>=i.y)return!1}if(e.bounds){var n=e.tileSize,o=t.multiplyBy(n),s=o.add([n,n]),a=this._map.unproject(o),r=this._map.unproject(s);if(e.continuousWorld||e.noWrap||(a=a.wrap(),r=r.wrap()),!e.bounds.intersects([a,r]))return!1}return!0},_removeOtherTiles:function(t){var e,i,n,o;for(o in this._tiles)e=o.split(":"),i=parseInt(e[0],10),n=parseInt(e[1],10),(it.max.x||nt.max.y)&&this._removeTile(o)},_removeTile:function(t){var e=this._tiles[t];this.fire("tileunload",{tile:e,url:e.src}),this.options.reuseTiles?(o.DomUtil.removeClass(e,"leaflet-tile-loaded"),this._unusedTiles.push(e)):e.parentNode===this._tileContainer&&this._tileContainer.removeChild(e),o.Browser.android||(e.onload=null,e.src=o.Util.emptyImageUrl),delete this._tiles[t]},_addTile:function(t,e){var i=this._getTilePos(t),n=this._getTile();o.DomUtil.setPosition(n,i,o.Browser.chrome),this._tiles[t.x+":"+t.y]=n,this._loadTile(n,t),n.parentNode!==this._tileContainer&&e.appendChild(n)},_getZoomForUrl:function(){var t=this.options,e=this._map.getZoom();return t.zoomReverse&&(e=t.maxZoom-e),e+=t.zoomOffset,t.maxNativeZoom?Math.min(e,t.maxNativeZoom):e},_getTilePos:function(t){var e=this._map.getPixelOrigin(),i=this._getTileSize();return t.multiplyBy(i).subtract(e)},getTileUrl:function(t){return o.Util.template(this._url,o.extend({s:this._getSubdomain(t),z:t.z,x:t.x,y:t.y},this.options))},_getWrapTileNum:function(){var t=this._map.options.crs,e=t.getSize(this._map.getZoom());return e.divideBy(this._getTileSize())._floor()},_adjustTilePoint:function(t){var e=this._getWrapTileNum();this.options.continuousWorld||this.options.noWrap||(t.x=(t.x%e.x+e.x)%e.x),this.options.tms&&(t.y=e.y-t.y-1),t.z=this._getZoomForUrl()},_getSubdomain:function(t){var e=Math.abs(t.x+t.y)%this.options.subdomains.length;return this.options.subdomains[e]},_getTile:function(){if(this.options.reuseTiles&&this._unusedTiles.length>0){var t=this._unusedTiles.pop();return this._resetTile(t),t}return this._createTile()},_resetTile:function(){},_createTile:function(){var t=o.DomUtil.create("img","leaflet-tile");return t.style.width=t.style.height=this._getTileSize()+"px",t.galleryimg="no",t.onselectstart=t.onmousemove=o.Util.falseFn,o.Browser.ielt9&&this.options.opacity!==i&&o.DomUtil.setOpacity(t,this.options.opacity),o.Browser.mobileWebkit3d&&(t.style.WebkitBackfaceVisibility="hidden"),t},_loadTile:function(t,e){t._layer=this,t.onload=this._tileOnLoad,t.onerror=this._tileOnError,this._adjustTilePoint(e),t.src=this.getTileUrl(e),this.fire("tileloadstart",{tile:t,url:t.src})},_tileLoaded:function(){this._tilesToLoad--,this._animated&&o.DomUtil.addClass(this._tileContainer,"leaflet-zoom-animated"),this._tilesToLoad||(this.fire("load"),this._animated&&(clearTimeout(this._clearBgBufferTimer),this._clearBgBufferTimer=setTimeout(o.bind(this._clearBgBuffer,this),500)))},_tileOnLoad:function(){var t=this._layer;this.src!==o.Util.emptyImageUrl&&(o.DomUtil.addClass(this,"leaflet-tile-loaded"),t.fire("tileload",{tile:this,url:this.src})),t._tileLoaded()},_tileOnError:function(){var t=this._layer;t.fire("tileerror",{tile:this,url:this.src});var e=t.options.errorTileUrl;e&&(this.src=e),t._tileLoaded()}}),o.tileLayer=function(t,e){return new o.TileLayer(t,e)},o.TileLayer.WMS=o.TileLayer.extend({defaultWmsParams:{service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1},initialize:function(t,e){this._url=t;var i=o.extend({},this.defaultWmsParams),n=e.tileSize||this.options.tileSize;i.width=i.height=e.detectRetina&&o.Browser.retina?2*n:n;for(var s in e)this.options.hasOwnProperty(s)||"crs"===s||(i[s]=e[s]);this.wmsParams=i,o.setOptions(this,e)},onAdd:function(t){this._crs=this.options.crs||t.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var e=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[e]=this._crs.code,o.TileLayer.prototype.onAdd.call(this,t)},getTileUrl:function(t){var e=this._map,i=this.options.tileSize,n=t.multiplyBy(i),s=n.add([i,i]),a=this._crs.project(e.unproject(n,t.z)),r=this._crs.project(e.unproject(s,t.z)),h=this._wmsVersion>=1.3&&this._crs===o.CRS.EPSG4326?[r.y,a.x,a.y,r.x].join(","):[a.x,r.y,r.x,a.y].join(","),l=o.Util.template(this._url,{s:this._getSubdomain(t)});return l+o.Util.getParamString(this.wmsParams,l,!0)+"&BBOX="+h},setParams:function(t,e){return o.extend(this.wmsParams,t),e||this.redraw(),this}}),o.tileLayer.wms=function(t,e){return new o.TileLayer.WMS(t,e)},o.TileLayer.Canvas=o.TileLayer.extend({options:{async:!1},initialize:function(t){o.setOptions(this,t)},redraw:function(){this._map&&(this._reset({hard:!0}),this._update());for(var t in this._tiles)this._redrawTile(this._tiles[t]);return this},_redrawTile:function(t){this.drawTile(t,t._tilePoint,this._map._zoom)},_createTile:function(){var t=o.DomUtil.create("canvas","leaflet-tile");return t.width=t.height=this.options.tileSize,t.onselectstart=t.onmousemove=o.Util.falseFn,t},_loadTile:function(t,e){t._layer=this,t._tilePoint=e,this._redrawTile(t),this.options.async||this.tileDrawn(t)},drawTile:function(){},tileDrawn:function(t){this._tileOnLoad.call(t)}}),o.tileLayer.canvas=function(t){return new o.TileLayer.Canvas(t)},o.ImageOverlay=o.Class.extend({includes:o.Mixin.Events,options:{opacity:1},initialize:function(t,e,i){this._url=t,this._bounds=o.latLngBounds(e),o.setOptions(this,i)},onAdd:function(t){this._map=t,this._image||this._initImage(),t._panes.overlayPane.appendChild(this._image),t.on("viewreset",this._reset,this),t.options.zoomAnimation&&o.Browser.any3d&&t.on("zoomanim",this._animateZoom,this),this._reset()},onRemove:function(t){t.getPanes().overlayPane.removeChild(this._image),t.off("viewreset",this._reset,this),t.options.zoomAnimation&&t.off("zoomanim",this._animateZoom,this)},addTo:function(t){return t.addLayer(this),this},setOpacity:function(t){return this.options.opacity=t,this._updateOpacity(),this},bringToFront:function(){return this._image&&this._map._panes.overlayPane.appendChild(this._image),this},bringToBack:function(){var t=this._map._panes.overlayPane;return this._image&&t.insertBefore(this._image,t.firstChild),this},setUrl:function(t){this._url=t,this._image.src=this._url},getAttribution:function(){return this.options.attribution},_initImage:function(){this._image=o.DomUtil.create("img","leaflet-image-layer"),this._map.options.zoomAnimation&&o.Browser.any3d?o.DomUtil.addClass(this._image,"leaflet-zoom-animated"):o.DomUtil.addClass(this._image,"leaflet-zoom-hide"),this._updateOpacity(),o.extend(this._image,{galleryimg:"no",onselectstart:o.Util.falseFn,onmousemove:o.Util.falseFn,onload:o.bind(this._onImageLoad,this),src:this._url})},_animateZoom:function(t){var e=this._map,i=this._image,n=e.getZoomScale(t.zoom),s=this._bounds.getNorthWest(),a=this._bounds.getSouthEast(),r=e._latLngToNewLayerPoint(s,t.zoom,t.center),h=e._latLngToNewLayerPoint(a,t.zoom,t.center)._subtract(r),l=r._add(h._multiplyBy(.5*(1-1/n)));i.style[o.DomUtil.TRANSFORM]=o.DomUtil.getTranslateString(l)+" scale("+n+") "},_reset:function(){var t=this._image,e=this._map.latLngToLayerPoint(this._bounds.getNorthWest()),i=this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(e);o.DomUtil.setPosition(t,e),t.style.width=i.x+"px",t.style.height=i.y+"px"},_onImageLoad:function(){this.fire("load")},_updateOpacity:function(){o.DomUtil.setOpacity(this._image,this.options.opacity)}}),o.imageOverlay=function(t,e,i){return new o.ImageOverlay(t,e,i)},o.Icon=o.Class.extend({options:{className:""},initialize:function(t){o.setOptions(this,t)},createIcon:function(t){return this._createIcon("icon",t)},createShadow:function(t){return this._createIcon("shadow",t)},_createIcon:function(t,e){var i=this._getIconUrl(t);if(!i){if("icon"===t)throw new Error("iconUrl not set in Icon options (see the docs).");return null}var n;return n=e&&"IMG"===e.tagName?this._createImg(i,e):this._createImg(i),this._setIconStyles(n,t),n},_setIconStyles:function(t,e){var i,n=this.options,s=o.point(n[e+"Size"]);i=o.point("shadow"===e?n.shadowAnchor||n.iconAnchor:n.iconAnchor),!i&&s&&(i=s.divideBy(2,!0)),t.className="leaflet-marker-"+e+" "+n.className,i&&(t.style.marginLeft=-i.x+"px",t.style.marginTop=-i.y+"px"),s&&(t.style.width=s.x+"px",t.style.height=s.y+"px")},_createImg:function(t,i){return i=i||e.createElement("img"),i.src=t,i},_getIconUrl:function(t){return o.Browser.retina&&this.options[t+"RetinaUrl"]?this.options[t+"RetinaUrl"]:this.options[t+"Url"]}}),o.icon=function(t){return new o.Icon(t)},o.Icon.Default=o.Icon.extend({options:{iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],shadowSize:[41,41]},_getIconUrl:function(t){var e=t+"Url";if(this.options[e])return this.options[e];o.Browser.retina&&"icon"===t&&(t+="-2x");var i=o.Icon.Default.imagePath;if(!i)throw new Error("Couldn't autodetect L.Icon.Default.imagePath, set it manually.");return i+"/marker-"+t+".png"}}),o.Icon.Default.imagePath=function(){var t,i,n,o,s,a=e.getElementsByTagName("script"),r=/[\/^]leaflet[\-\._]?([\w\-\._]*)\.js\??/;for(t=0,i=a.length;i>t;t++)if(n=a[t].src,o=n.match(r))return s=n.split(r)[0],(s?s+"/":"")+"images"}(),o.Marker=o.Class.extend({includes:o.Mixin.Events,options:{icon:new o.Icon.Default,title:"",alt:"",clickable:!0,draggable:!1,keyboard:!0,zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250},initialize:function(t,e){o.setOptions(this,e),this._latlng=o.latLng(t)},onAdd:function(t){this._map=t,t.on("viewreset",this.update,this),this._initIcon(),this.update(),this.fire("add"),t.options.zoomAnimation&&t.options.markerZoomAnimation&&t.on("zoomanim",this._animateZoom,this)},addTo:function(t){return t.addLayer(this),this},onRemove:function(t){this.dragging&&this.dragging.disable(),this._removeIcon(),this._removeShadow(),this.fire("remove"),t.off({viewreset:this.update,zoomanim:this._animateZoom},this),this._map=null},getLatLng:function(){return this._latlng},setLatLng:function(t){return this._latlng=o.latLng(t),this.update(),this.fire("move",{latlng:this._latlng})},setZIndexOffset:function(t){return this.options.zIndexOffset=t,this.update(),this},setIcon:function(t){return this.options.icon=t,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup),this},update:function(){if(this._icon){var t=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(t)}return this},_initIcon:function(){var t=this.options,e=this._map,i=e.options.zoomAnimation&&e.options.markerZoomAnimation,n=i?"leaflet-zoom-animated":"leaflet-zoom-hide",s=t.icon.createIcon(this._icon),a=!1;s!==this._icon&&(this._icon&&this._removeIcon(),a=!0,t.title&&(s.title=t.title),t.alt&&(s.alt=t.alt)),o.DomUtil.addClass(s,n),t.keyboard&&(s.tabIndex="0"),this._icon=s,this._initInteraction(),t.riseOnHover&&o.DomEvent.on(s,"mouseover",this._bringToFront,this).on(s,"mouseout",this._resetZIndex,this);var r=t.icon.createShadow(this._shadow),h=!1;r!==this._shadow&&(this._removeShadow(),h=!0),r&&o.DomUtil.addClass(r,n),this._shadow=r,t.opacity<1&&this._updateOpacity();var l=this._map._panes;a&&l.markerPane.appendChild(this._icon),r&&h&&l.shadowPane.appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&o.DomEvent.off(this._icon,"mouseover",this._bringToFront).off(this._icon,"mouseout",this._resetZIndex),this._map._panes.markerPane.removeChild(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&this._map._panes.shadowPane.removeChild(this._shadow),this._shadow=null},_setPos:function(t){o.DomUtil.setPosition(this._icon,t),this._shadow&&o.DomUtil.setPosition(this._shadow,t),this._zIndex=t.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(t){this._icon.style.zIndex=this._zIndex+t},_animateZoom:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center).round();this._setPos(e)},_initInteraction:function(){if(this.options.clickable){var t=this._icon,e=["dblclick","mousedown","mouseover","mouseout","contextmenu"];o.DomUtil.addClass(t,"leaflet-clickable"),o.DomEvent.on(t,"click",this._onMouseClick,this),o.DomEvent.on(t,"keypress",this._onKeyPress,this);for(var i=0;is?(e.height=s+"px",o.DomUtil.addClass(t,a)):o.DomUtil.removeClass(t,a),this._containerWidth=this._container.offsetWidth},_updatePosition:function(){if(this._map){var t=this._map.latLngToLayerPoint(this._latlng),e=this._animated,i=o.point(this.options.offset);e&&o.DomUtil.setPosition(this._container,t),this._containerBottom=-i.y-(e?0:t.y),this._containerLeft=-Math.round(this._containerWidth/2)+i.x+(e?0:t.x),this._container.style.bottom=this._containerBottom+"px",this._container.style.left=this._containerLeft+"px"}},_zoomAnimation:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center);o.DomUtil.setPosition(this._container,e)},_adjustPan:function(){if(this.options.autoPan){var t=this._map,e=this._container.offsetHeight,i=this._containerWidth,n=new o.Point(this._containerLeft,-e-this._containerBottom);this._animated&&n._add(o.DomUtil.getPosition(this._container));var s=t.layerPointToContainerPoint(n),a=o.point(this.options.autoPanPadding),r=o.point(this.options.autoPanPaddingTopLeft||a),h=o.point(this.options.autoPanPaddingBottomRight||a),l=t.getSize(),u=0,c=0;s.x+i+h.x>l.x&&(u=s.x+i-l.x+h.x),s.x-u-r.x<0&&(u=s.x-r.x),s.y+e+h.y>l.y&&(c=s.y+e-l.y+h.y),s.y-c-r.y<0&&(c=s.y-r.y),(u||c)&&t.fire("autopanstart").panBy([u,c])}},_onCloseButtonClick:function(t){this._close(),o.DomEvent.stop(t)}}),o.popup=function(t,e){return new o.Popup(t,e)},o.Map.include({openPopup:function(t,e,i){if(this.closePopup(),!(t instanceof o.Popup)){var n=t;t=new o.Popup(i).setLatLng(e).setContent(n)}return t._isOpen=!0,this._popup=t,this.addLayer(t)},closePopup:function(t){return t&&t!==this._popup||(t=this._popup,this._popup=null),t&&(this.removeLayer(t),t._isOpen=!1),this}}),o.Marker.include({openPopup:function(){return this._popup&&this._map&&!this._map.hasLayer(this._popup)&&(this._popup.setLatLng(this._latlng),this._map.openPopup(this._popup)),this},closePopup:function(){return this._popup&&this._popup._close(),this},togglePopup:function(){return this._popup&&(this._popup._isOpen?this.closePopup():this.openPopup()),this},bindPopup:function(t,e){var i=o.point(this.options.icon.options.popupAnchor||[0,0]);return i=i.add(o.Popup.prototype.options.offset),e&&e.offset&&(i=i.add(e.offset)),e=o.extend({offset:i},e),this._popupHandlersAdded||(this.on("click",this.togglePopup,this).on("remove",this.closePopup,this).on("move",this._movePopup,this),this._popupHandlersAdded=!0),t instanceof o.Popup?(o.setOptions(t,e),this._popup=t):this._popup=new o.Popup(e,this).setContent(t),this},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},unbindPopup:function(){return this._popup&&(this._popup=null,this.off("click",this.togglePopup,this).off("remove",this.closePopup,this).off("move",this._movePopup,this),this._popupHandlersAdded=!1),this},getPopup:function(){return this._popup},_movePopup:function(t){this._popup.setLatLng(t.latlng)}}),o.LayerGroup=o.Class.extend({initialize:function(t){this._layers={};var e,i;if(t)for(e=0,i=t.length;i>e;e++)this.addLayer(t[e])},addLayer:function(t){var e=this.getLayerId(t);return this._layers[e]=t,this._map&&this._map.addLayer(t),this},removeLayer:function(t){var e=t in this._layers?t:this.getLayerId(t);return this._map&&this._layers[e]&&this._map.removeLayer(this._layers[e]),delete this._layers[e],this},hasLayer:function(t){return t?t in this._layers||this.getLayerId(t)in this._layers:!1},clearLayers:function(){return this.eachLayer(this.removeLayer,this),this},invoke:function(t){var e,i,n=Array.prototype.slice.call(arguments,1);for(e in this._layers)i=this._layers[e],i[t]&&i[t].apply(i,n);return this},onAdd:function(t){this._map=t,this.eachLayer(t.addLayer,t)},onRemove:function(t){this.eachLayer(t.removeLayer,t),this._map=null},addTo:function(t){return t.addLayer(this),this},eachLayer:function(t,e){for(var i in this._layers)t.call(e,this._layers[i]);return this},getLayer:function(t){return this._layers[t]},getLayers:function(){var t=[];for(var e in this._layers)t.push(this._layers[e]);return t},setZIndex:function(t){return this.invoke("setZIndex",t)},getLayerId:function(t){return o.stamp(t)}}),o.layerGroup=function(t){return new o.LayerGroup(t)},o.FeatureGroup=o.LayerGroup.extend({includes:o.Mixin.Events,statics:{EVENTS:"click dblclick mouseover mouseout mousemove contextmenu popupopen popupclose"},addLayer:function(t){return this.hasLayer(t)?this:("on"in t&&t.on(o.FeatureGroup.EVENTS,this._propagateEvent,this),o.LayerGroup.prototype.addLayer.call(this,t),this._popupContent&&t.bindPopup&&t.bindPopup(this._popupContent,this._popupOptions),this.fire("layeradd",{layer:t}))},removeLayer:function(t){return this.hasLayer(t)?(t in this._layers&&(t=this._layers[t]),t.off(o.FeatureGroup.EVENTS,this._propagateEvent,this),o.LayerGroup.prototype.removeLayer.call(this,t),this._popupContent&&this.invoke("unbindPopup"),this.fire("layerremove",{layer:t})):this},bindPopup:function(t,e){return this._popupContent=t,this._popupOptions=e,this.invoke("bindPopup",t,e)},openPopup:function(t){for(var e in this._layers){this._layers[e].openPopup(t);break}return this},setStyle:function(t){return this.invoke("setStyle",t)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var t=new o.LatLngBounds;return this.eachLayer(function(e){t.extend(e instanceof o.Marker?e.getLatLng():e.getBounds())}),t},_propagateEvent:function(t){t=o.extend({layer:t.target,target:this},t),this.fire(t.type,t)}}),o.featureGroup=function(t){return new o.FeatureGroup(t)},o.Path=o.Class.extend({includes:[o.Mixin.Events],statics:{CLIP_PADDING:function(){var e=o.Browser.mobile?1280:2e3,i=(e/Math.max(t.outerWidth,t.outerHeight)-1)/2;return Math.max(0,Math.min(.5,i))}()},options:{stroke:!0,color:"#0033ff",dashArray:null,lineCap:null,lineJoin:null,weight:5,opacity:.5,fill:!1,fillColor:null,fillOpacity:.2,clickable:!0},initialize:function(t){o.setOptions(this,t)},onAdd:function(t){this._map=t,this._container||(this._initElements(),this._initEvents()),this.projectLatlngs(),this._updatePath(),this._container&&this._map._pathRoot.appendChild(this._container),this.fire("add"),t.on({viewreset:this.projectLatlngs,moveend:this._updatePath},this)},addTo:function(t){return t.addLayer(this),this},onRemove:function(t){t._pathRoot.removeChild(this._container),this.fire("remove"),this._map=null,o.Browser.vml&&(this._container=null,this._stroke=null,this._fill=null),t.off({viewreset:this.projectLatlngs,moveend:this._updatePath},this)},projectLatlngs:function(){},setStyle:function(t){return o.setOptions(this,t),this._container&&this._updateStyle(),this},redraw:function(){return this._map&&(this.projectLatlngs(),this._updatePath()),this}}),o.Map.include({_updatePathViewport:function(){var t=o.Path.CLIP_PADDING,e=this.getSize(),i=o.DomUtil.getPosition(this._mapPane),n=i.multiplyBy(-1)._subtract(e.multiplyBy(t)._round()),s=n.add(e.multiplyBy(1+2*t)._round());this._pathViewport=new o.Bounds(n,s)}}),o.Path.SVG_NS="http://www.w3.org/2000/svg",o.Browser.svg=!(!e.createElementNS||!e.createElementNS(o.Path.SVG_NS,"svg").createSVGRect),o.Path=o.Path.extend({statics:{SVG:o.Browser.svg},bringToFront:function(){var t=this._map._pathRoot,e=this._container;return e&&t.lastChild!==e&&t.appendChild(e),this},bringToBack:function(){var t=this._map._pathRoot,e=this._container,i=t.firstChild;return e&&i!==e&&t.insertBefore(e,i),this},getPathString:function(){},_createElement:function(t){return e.createElementNS(o.Path.SVG_NS,t)},_initElements:function(){this._map._initPathRoot(),this._initPath(),this._initStyle()},_initPath:function(){this._container=this._createElement("g"),this._path=this._createElement("path"),this.options.className&&o.DomUtil.addClass(this._path,this.options.className),this._container.appendChild(this._path)},_initStyle:function(){this.options.stroke&&(this._path.setAttribute("stroke-linejoin","round"),this._path.setAttribute("stroke-linecap","round")),this.options.fill&&this._path.setAttribute("fill-rule","evenodd"),this.options.pointerEvents&&this._path.setAttribute("pointer-events",this.options.pointerEvents),this.options.clickable||this.options.pointerEvents||this._path.setAttribute("pointer-events","none"),this._updateStyle()},_updateStyle:function(){this.options.stroke?(this._path.setAttribute("stroke",this.options.color),this._path.setAttribute("stroke-opacity",this.options.opacity),this._path.setAttribute("stroke-width",this.options.weight),this.options.dashArray?this._path.setAttribute("stroke-dasharray",this.options.dashArray):this._path.removeAttribute("stroke-dasharray"),this.options.lineCap&&this._path.setAttribute("stroke-linecap",this.options.lineCap),this.options.lineJoin&&this._path.setAttribute("stroke-linejoin",this.options.lineJoin)):this._path.setAttribute("stroke","none"),this.options.fill?(this._path.setAttribute("fill",this.options.fillColor||this.options.color),this._path.setAttribute("fill-opacity",this.options.fillOpacity)):this._path.setAttribute("fill","none")},_updatePath:function(){var t=this.getPathString();t||(t="M0 0"),this._path.setAttribute("d",t)},_initEvents:function(){if(this.options.clickable){(o.Browser.svg||!o.Browser.vml)&&o.DomUtil.addClass(this._path,"leaflet-clickable"),o.DomEvent.on(this._container,"click",this._onMouseClick,this);for(var t=["dblclick","mousedown","mouseover","mouseout","mousemove","contextmenu"],e=0;e';var i=t.firstChild;return i.style.behavior="url(#default#VML)",i&&"object"==typeof i.adj}catch(n){return!1}}(),o.Path=o.Browser.svg||!o.Browser.vml?o.Path:o.Path.extend({statics:{VML:!0,CLIP_PADDING:.02},_createElement:function(){try{return e.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(t){return e.createElement("')}}catch(t){return function(t){return e.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),_initPath:function(){var t=this._container=this._createElement("shape");o.DomUtil.addClass(t,"leaflet-vml-shape"+(this.options.className?" "+this.options.className:"")),this.options.clickable&&o.DomUtil.addClass(t,"leaflet-clickable"),t.coordsize="1 1",this._path=this._createElement("path"),t.appendChild(this._path),this._map._pathRoot.appendChild(t)},_initStyle:function(){this._updateStyle()},_updateStyle:function(){var t=this._stroke,e=this._fill,i=this.options,n=this._container;n.stroked=i.stroke,n.filled=i.fill,i.stroke?(t||(t=this._stroke=this._createElement("stroke"),t.endcap="round",n.appendChild(t)),t.weight=i.weight+"px",t.color=i.color,t.opacity=i.opacity,t.dashStyle=i.dashArray?o.Util.isArray(i.dashArray)?i.dashArray.join(" "):i.dashArray.replace(/( *, *)/g," "):"",i.lineCap&&(t.endcap=i.lineCap.replace("butt","flat")),i.lineJoin&&(t.joinstyle=i.lineJoin)):t&&(n.removeChild(t),this._stroke=null),i.fill?(e||(e=this._fill=this._createElement("fill"),n.appendChild(e)),e.color=i.fillColor||i.color,e.opacity=i.fillOpacity):e&&(n.removeChild(e),this._fill=null)},_updatePath:function(){var t=this._container.style;t.display="none",this._path.v=this.getPathString()+" ",t.display=""}}),o.Map.include(o.Browser.svg||!o.Browser.vml?{}:{_initPathRoot:function(){if(!this._pathRoot){var t=this._pathRoot=e.createElement("div");t.className="leaflet-vml-container",this._panes.overlayPane.appendChild(t),this.on("moveend",this._updatePathViewport),this._updatePathViewport()}}}),o.Browser.canvas=function(){return!!e.createElement("canvas").getContext}(),o.Path=o.Path.SVG&&!t.L_PREFER_CANVAS||!o.Browser.canvas?o.Path:o.Path.extend({statics:{CANVAS:!0,SVG:!1},redraw:function(){return this._map&&(this.projectLatlngs(),this._requestUpdate()),this},setStyle:function(t){return o.setOptions(this,t),this._map&&(this._updateStyle(),this._requestUpdate()),this},onRemove:function(t){t.off("viewreset",this.projectLatlngs,this).off("moveend",this._updatePath,this),this.options.clickable&&(this._map.off("click",this._onClick,this),this._map.off("mousemove",this._onMouseMove,this)),this._requestUpdate(),this.fire("remove"),this._map=null},_requestUpdate:function(){this._map&&!o.Path._updateRequest&&(o.Path._updateRequest=o.Util.requestAnimFrame(this._fireMapMoveEnd,this._map))},_fireMapMoveEnd:function(){o.Path._updateRequest=null,this.fire("moveend")},_initElements:function(){this._map._initPathRoot(),this._ctx=this._map._canvasCtx},_updateStyle:function(){var t=this.options;t.stroke&&(this._ctx.lineWidth=t.weight,this._ctx.strokeStyle=t.color),t.fill&&(this._ctx.fillStyle=t.fillColor||t.color)},_drawPath:function(){var t,e,i,n,s,a;for(this._ctx.beginPath(),t=0,i=this._parts.length;i>t;t++){for(e=0,n=this._parts[t].length;n>e;e++)s=this._parts[t][e],a=(0===e?"move":"line")+"To",this._ctx[a](s.x,s.y);this instanceof o.Polygon&&this._ctx.closePath()}},_checkIfEmpty:function(){return!this._parts.length},_updatePath:function(){if(!this._checkIfEmpty()){var t=this._ctx,e=this.options;this._drawPath(),t.save(),this._updateStyle(),e.fill&&(t.globalAlpha=e.fillOpacity,t.fill()),e.stroke&&(t.globalAlpha=e.opacity,t.stroke()),t.restore()}},_initEvents:function(){this.options.clickable&&(this._map.on("mousemove",this._onMouseMove,this),this._map.on("click",this._onClick,this))},_onClick:function(t){this._containsPoint(t.layerPoint)&&this.fire("click",t)},_onMouseMove:function(t){this._map&&!this._map._animatingZoom&&(this._containsPoint(t.layerPoint)?(this._ctx.canvas.style.cursor="pointer",this._mouseInside=!0,this.fire("mouseover",t)):this._mouseInside&&(this._ctx.canvas.style.cursor="",this._mouseInside=!1,this.fire("mouseout",t)))}}),o.Map.include(o.Path.SVG&&!t.L_PREFER_CANVAS||!o.Browser.canvas?{}:{_initPathRoot:function(){var t,i=this._pathRoot;i||(i=this._pathRoot=e.createElement("canvas"),i.style.position="absolute",t=this._canvasCtx=i.getContext("2d"),t.lineCap="round",t.lineJoin="round",this._panes.overlayPane.appendChild(i),this.options.zoomAnimation&&(this._pathRoot.className="leaflet-zoom-animated",this.on("zoomanim",this._animatePathZoom),this.on("zoomend",this._endPathZoom)),this.on("moveend",this._updateCanvasViewport),this._updateCanvasViewport())},_updateCanvasViewport:function(){if(!this._pathZooming){this._updatePathViewport();var t=this._pathViewport,e=t.min,i=t.max.subtract(e),n=this._pathRoot;o.DomUtil.setPosition(n,e),n.width=i.x,n.height=i.y,n.getContext("2d").translate(-e.x,-e.y)}}}),o.LineUtil={simplify:function(t,e){if(!e||!t.length)return t.slice();var i=e*e;return t=this._reducePoints(t,i),t=this._simplifyDP(t,i)},pointToSegmentDistance:function(t,e,i){return Math.sqrt(this._sqClosestPointOnSegment(t,e,i,!0))},closestPointOnSegment:function(t,e,i){return this._sqClosestPointOnSegment(t,e,i)},_simplifyDP:function(t,e){var n=t.length,o=typeof Uint8Array!=i+""?Uint8Array:Array,s=new o(n);s[0]=s[n-1]=1,this._simplifyDPStep(t,s,e,0,n-1);var a,r=[];for(a=0;n>a;a++)s[a]&&r.push(t[a]);return r},_simplifyDPStep:function(t,e,i,n,o){var s,a,r,h=0;for(a=n+1;o-1>=a;a++)r=this._sqClosestPointOnSegment(t[a],t[n],t[o],!0),r>h&&(s=a,h=r);h>i&&(e[s]=1,this._simplifyDPStep(t,e,i,n,s),this._simplifyDPStep(t,e,i,s,o))},_reducePoints:function(t,e){for(var i=[t[0]],n=1,o=0,s=t.length;s>n;n++)this._sqDist(t[n],t[o])>e&&(i.push(t[n]),o=n);return s-1>o&&i.push(t[s-1]),i},clipSegment:function(t,e,i,n){var o,s,a,r=n?this._lastCode:this._getBitCode(t,i),h=this._getBitCode(e,i);for(this._lastCode=h;;){if(!(r|h))return[t,e];if(r&h)return!1;o=r||h,s=this._getEdgeIntersection(t,e,o,i),a=this._getBitCode(s,i),o===r?(t=s,r=a):(e=s,h=a)}},_getEdgeIntersection:function(t,e,i,n){var s=e.x-t.x,a=e.y-t.y,r=n.min,h=n.max;return 8&i?new o.Point(t.x+s*(h.y-t.y)/a,h.y):4&i?new o.Point(t.x+s*(r.y-t.y)/a,r.y):2&i?new o.Point(h.x,t.y+a*(h.x-t.x)/s):1&i?new o.Point(r.x,t.y+a*(r.x-t.x)/s):void 0},_getBitCode:function(t,e){var i=0;return t.xe.max.x&&(i|=2),t.ye.max.y&&(i|=8),i},_sqDist:function(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n},_sqClosestPointOnSegment:function(t,e,i,n){var s,a=e.x,r=e.y,h=i.x-a,l=i.y-r,u=h*h+l*l;return u>0&&(s=((t.x-a)*h+(t.y-r)*l)/u,s>1?(a=i.x,r=i.y):s>0&&(a+=h*s,r+=l*s)),h=t.x-a,l=t.y-r,n?h*h+l*l:new o.Point(a,r)}},o.Polyline=o.Path.extend({initialize:function(t,e){o.Path.prototype.initialize.call(this,e),this._latlngs=this._convertLatLngs(t)},options:{smoothFactor:1,noClip:!1},projectLatlngs:function(){this._originalPoints=[];for(var t=0,e=this._latlngs.length;e>t;t++)this._originalPoints[t]=this._map.latLngToLayerPoint(this._latlngs[t])},getPathString:function(){for(var t=0,e=this._parts.length,i="";e>t;t++)i+=this._getPathPartStr(this._parts[t]);return i},getLatLngs:function(){return this._latlngs},setLatLngs:function(t){return this._latlngs=this._convertLatLngs(t),this.redraw()},addLatLng:function(t){return this._latlngs.push(o.latLng(t)),this.redraw()},spliceLatLngs:function(){var t=[].splice.apply(this._latlngs,arguments);return this._convertLatLngs(this._latlngs,!0),this.redraw(),t},closestLayerPoint:function(t){for(var e,i,n=1/0,s=this._parts,a=null,r=0,h=s.length;h>r;r++)for(var l=s[r],u=1,c=l.length;c>u;u++){e=l[u-1],i=l[u];var d=o.LineUtil._sqClosestPointOnSegment(t,e,i,!0);n>d&&(n=d,a=o.LineUtil._sqClosestPointOnSegment(t,e,i))}return a&&(a.distance=Math.sqrt(n)),a},getBounds:function(){return new o.LatLngBounds(this.getLatLngs())},_convertLatLngs:function(t,e){var i,n,s=e?t:[];for(i=0,n=t.length;n>i;i++){if(o.Util.isArray(t[i])&&"number"!=typeof t[i][0])return;s[i]=o.latLng(t[i])}return s},_initEvents:function(){o.Path.prototype._initEvents.call(this)},_getPathPartStr:function(t){for(var e,i=o.Path.VML,n=0,s=t.length,a="";s>n;n++)e=t[n],i&&e._round(),a+=(n?"L":"M")+e.x+" "+e.y;return a},_clipPoints:function(){var t,e,i,n=this._originalPoints,s=n.length;if(this.options.noClip)return void(this._parts=[n]);this._parts=[];var a=this._parts,r=this._map._pathViewport,h=o.LineUtil;for(t=0,e=0;s-1>t;t++)i=h.clipSegment(n[t],n[t+1],r,t),i&&(a[e]=a[e]||[],a[e].push(i[0]),(i[1]!==n[t+1]||t===s-2)&&(a[e].push(i[1]),e++))},_simplifyPoints:function(){for(var t=this._parts,e=o.LineUtil,i=0,n=t.length;n>i;i++)t[i]=e.simplify(t[i],this.options.smoothFactor)},_updatePath:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),o.Path.prototype._updatePath.call(this))}}),o.polyline=function(t,e){return new o.Polyline(t,e)},o.PolyUtil={},o.PolyUtil.clipPolygon=function(t,e){var i,n,s,a,r,h,l,u,c,d=[1,4,2,8],p=o.LineUtil;for(n=0,l=t.length;l>n;n++)t[n]._code=p._getBitCode(t[n],e);for(a=0;4>a;a++){for(u=d[a],i=[],n=0,l=t.length,s=l-1;l>n;s=n++)r=t[n],h=t[s],r._code&u?h._code&u||(c=p._getEdgeIntersection(h,r,u,e),c._code=p._getBitCode(c,e),i.push(c)):(h._code&u&&(c=p._getEdgeIntersection(h,r,u,e),c._code=p._getBitCode(c,e),i.push(c)),i.push(r));t=i}return t},o.Polygon=o.Polyline.extend({options:{fill:!0},initialize:function(t,e){o.Polyline.prototype.initialize.call(this,t,e),this._initWithHoles(t)},_initWithHoles:function(t){var e,i,n;if(t&&o.Util.isArray(t[0])&&"number"!=typeof t[0][0])for(this._latlngs=this._convertLatLngs(t[0]),this._holes=t.slice(1),e=0,i=this._holes.length;i>e;e++)n=this._holes[e]=this._convertLatLngs(this._holes[e]),n[0].equals(n[n.length-1])&&n.pop();t=this._latlngs,t.length>=2&&t[0].equals(t[t.length-1])&&t.pop()},projectLatlngs:function(){if(o.Polyline.prototype.projectLatlngs.call(this),this._holePoints=[],this._holes){var t,e,i,n;for(t=0,i=this._holes.length;i>t;t++)for(this._holePoints[t]=[],e=0,n=this._holes[t].length;n>e;e++)this._holePoints[t][e]=this._map.latLngToLayerPoint(this._holes[t][e])}},setLatLngs:function(t){return t&&o.Util.isArray(t[0])&&"number"!=typeof t[0][0]?(this._initWithHoles(t),this.redraw()):o.Polyline.prototype.setLatLngs.call(this,t)},_clipPoints:function(){var t=this._originalPoints,e=[];if(this._parts=[t].concat(this._holePoints),!this.options.noClip){for(var i=0,n=this._parts.length;n>i;i++){var s=o.PolyUtil.clipPolygon(this._parts[i],this._map._pathViewport);s.length&&e.push(s)}this._parts=e}},_getPathPartStr:function(t){var e=o.Polyline.prototype._getPathPartStr.call(this,t);return e+(o.Browser.svg?"z":"x")}}),o.polygon=function(t,e){return new o.Polygon(t,e)},function(){function t(t){return o.FeatureGroup.extend({initialize:function(t,e){this._layers={},this._options=e,this.setLatLngs(t)},setLatLngs:function(e){var i=0,n=e.length;for(this.eachLayer(function(t){n>i?t.setLatLngs(e[i++]):this.removeLayer(t)},this);n>i;)this.addLayer(new t(e[i++],this._options));return this},getLatLngs:function(){var t=[];return this.eachLayer(function(e){t.push(e.getLatLngs())}),t}})}o.MultiPolyline=t(o.Polyline),o.MultiPolygon=t(o.Polygon),o.multiPolyline=function(t,e){return new o.MultiPolyline(t,e)},o.multiPolygon=function(t,e){return new o.MultiPolygon(t,e)}}(),o.Rectangle=o.Polygon.extend({initialize:function(t,e){o.Polygon.prototype.initialize.call(this,this._boundsToLatLngs(t),e)},setBounds:function(t){this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return t=o.latLngBounds(t),[t.getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}}),o.rectangle=function(t,e){return new o.Rectangle(t,e)},o.Circle=o.Path.extend({initialize:function(t,e,i){o.Path.prototype.initialize.call(this,i),this._latlng=o.latLng(t),this._mRadius=e},options:{fill:!0},setLatLng:function(t){return this._latlng=o.latLng(t),this.redraw()},setRadius:function(t){return this._mRadius=t,this.redraw()},projectLatlngs:function(){var t=this._getLngRadius(),e=this._latlng,i=this._map.latLngToLayerPoint([e.lat,e.lng-t]);this._point=this._map.latLngToLayerPoint(e),this._radius=Math.max(this._point.x-i.x,1)},getBounds:function(){var t=this._getLngRadius(),e=this._mRadius/40075017*360,i=this._latlng;return new o.LatLngBounds([i.lat-e,i.lng-t],[i.lat+e,i.lng+t])},getLatLng:function(){return this._latlng},getPathString:function(){var t=this._point,e=this._radius;return this._checkIfEmpty()?"":o.Browser.svg?"M"+t.x+","+(t.y-e)+"A"+e+","+e+",0,1,1,"+(t.x-.1)+","+(t.y-e)+" z":(t._round(),e=Math.round(e),"AL "+t.x+","+t.y+" "+e+","+e+" 0,23592600")},getRadius:function(){return this._mRadius},_getLatRadius:function(){return this._mRadius/40075017*360},_getLngRadius:function(){return this._getLatRadius()/Math.cos(o.LatLng.DEG_TO_RAD*this._latlng.lat)},_checkIfEmpty:function(){if(!this._map)return!1;var t=this._map._pathViewport,e=this._radius,i=this._point;return i.x-e>t.max.x||i.y-e>t.max.y||i.x+ei;i++)for(l=this._parts[i],n=0,r=l.length,s=r-1;r>n;s=n++)if((e||0!==n)&&(h=o.LineUtil.pointToSegmentDistance(t,l[s],l[n]),u>=h))return!0;return!1}}:{}),o.Polygon.include(o.Path.CANVAS?{_containsPoint:function(t){var e,i,n,s,a,r,h,l,u=!1;if(o.Polyline.prototype._containsPoint.call(this,t,!0))return!0;for(s=0,h=this._parts.length;h>s;s++)for(e=this._parts[s],a=0,l=e.length,r=l-1;l>a;r=a++)i=e[a],n=e[r],i.y>t.y!=n.y>t.y&&t.x<(n.x-i.x)*(t.y-i.y)/(n.y-i.y)+i.x&&(u=!u);return u}}:{}),o.Circle.include(o.Path.CANVAS?{_drawPath:function(){var t=this._point;this._ctx.beginPath(),this._ctx.arc(t.x,t.y,this._radius,0,2*Math.PI,!1)},_containsPoint:function(t){var e=this._point,i=this.options.stroke?this.options.weight/2:0;return t.distanceTo(e)<=this._radius+i}}:{}),o.CircleMarker.include(o.Path.CANVAS?{_updateStyle:function(){o.Path.prototype._updateStyle.call(this)}}:{}),o.GeoJSON=o.FeatureGroup.extend({initialize:function(t,e){o.setOptions(this,e),this._layers={},t&&this.addData(t)},addData:function(t){var e,i,n,s=o.Util.isArray(t)?t:t.features;if(s){for(e=0,i=s.length;i>e;e++)n=s[e],(n.geometries||n.geometry||n.features||n.coordinates)&&this.addData(s[e]);return this}var a=this.options;if(!a.filter||a.filter(t)){var r=o.GeoJSON.geometryToLayer(t,a.pointToLayer,a.coordsToLatLng,a);return r.feature=o.GeoJSON.asFeature(t),r.defaultOptions=r.options,this.resetStyle(r),a.onEachFeature&&a.onEachFeature(t,r),this.addLayer(r)}},resetStyle:function(t){var e=this.options.style;e&&(o.Util.extend(t.options,t.defaultOptions),this._setLayerStyle(t,e))},setStyle:function(t){this.eachLayer(function(e){this._setLayerStyle(e,t)},this)},_setLayerStyle:function(t,e){"function"==typeof e&&(e=e(t.feature)),t.setStyle&&t.setStyle(e)}}),o.extend(o.GeoJSON,{geometryToLayer:function(t,e,i,n){var s,a,r,h,l="Feature"===t.type?t.geometry:t,u=l.coordinates,c=[];switch(i=i||this.coordsToLatLng,l.type){case"Point":return s=i(u),e?e(t,s):new o.Marker(s);case"MultiPoint":for(r=0,h=u.length;h>r;r++)s=i(u[r]),c.push(e?e(t,s):new o.Marker(s));return new o.FeatureGroup(c);case"LineString":return a=this.coordsToLatLngs(u,0,i),new o.Polyline(a,n);case"Polygon":if(2===u.length&&!u[1].length)throw new Error("Invalid GeoJSON object.");return a=this.coordsToLatLngs(u,1,i),new o.Polygon(a,n);case"MultiLineString":return a=this.coordsToLatLngs(u,1,i),new o.MultiPolyline(a,n);case"MultiPolygon":return a=this.coordsToLatLngs(u,2,i),new o.MultiPolygon(a,n);case"GeometryCollection":for(r=0,h=l.geometries.length;h>r;r++)c.push(this.geometryToLayer({geometry:l.geometries[r],type:"Feature",properties:t.properties},e,i,n));return new o.FeatureGroup(c);default:throw new Error("Invalid GeoJSON object.")}},coordsToLatLng:function(t){return new o.LatLng(t[1],t[0],t[2])},coordsToLatLngs:function(t,e,i){var n,o,s,a=[];for(o=0,s=t.length;s>o;o++)n=e?this.coordsToLatLngs(t[o],e-1,i):(i||this.coordsToLatLng)(t[o]),a.push(n);return a},latLngToCoords:function(t){var e=[t.lng,t.lat];return t.alt!==i&&e.push(t.alt),e},latLngsToCoords:function(t){for(var e=[],i=0,n=t.length;n>i;i++)e.push(o.GeoJSON.latLngToCoords(t[i]));return e},getFeature:function(t,e){return t.feature?o.extend({},t.feature,{geometry:e}):o.GeoJSON.asFeature(e)},asFeature:function(t){return"Feature"===t.type?t:{type:"Feature",properties:{},geometry:t}}});var a={toGeoJSON:function(){return o.GeoJSON.getFeature(this,{type:"Point",coordinates:o.GeoJSON.latLngToCoords(this.getLatLng())})}};o.Marker.include(a),o.Circle.include(a),o.CircleMarker.include(a),o.Polyline.include({toGeoJSON:function(){return o.GeoJSON.getFeature(this,{type:"LineString",coordinates:o.GeoJSON.latLngsToCoords(this.getLatLngs())})}}),o.Polygon.include({toGeoJSON:function(){var t,e,i,n=[o.GeoJSON.latLngsToCoords(this.getLatLngs())];if(n[0].push(n[0][0]),this._holes)for(t=0,e=this._holes.length;e>t;t++)i=o.GeoJSON.latLngsToCoords(this._holes[t]),i.push(i[0]),n.push(i);return o.GeoJSON.getFeature(this,{type:"Polygon",coordinates:n})}}),function(){function t(t){return function(){var e=[];return this.eachLayer(function(t){e.push(t.toGeoJSON().geometry.coordinates)}),o.GeoJSON.getFeature(this,{type:t,coordinates:e})}}o.MultiPolyline.include({toGeoJSON:t("MultiLineString")}),o.MultiPolygon.include({toGeoJSON:t("MultiPolygon")}),o.LayerGroup.include({toGeoJSON:function(){var e,i=this.feature&&this.feature.geometry,n=[];if(i&&"MultiPoint"===i.type)return t("MultiPoint").call(this);var s=i&&"GeometryCollection"===i.type;return this.eachLayer(function(t){t.toGeoJSON&&(e=t.toGeoJSON(),n.push(s?e.geometry:o.GeoJSON.asFeature(e)))}),s?o.GeoJSON.getFeature(this,{geometries:n,type:"GeometryCollection"}):{type:"FeatureCollection",features:n}}})}(),o.geoJson=function(t,e){return new o.GeoJSON(t,e)},o.DomEvent={addListener:function(t,e,i,n){var s,a,r,h=o.stamp(i),l="_leaflet_"+e+h;return t[l]?this:(s=function(e){return i.call(n||t,e||o.DomEvent._getEvent())},o.Browser.pointer&&0===e.indexOf("touch")?this.addPointerListener(t,e,s,h):(o.Browser.touch&&"dblclick"===e&&this.addDoubleTapListener&&this.addDoubleTapListener(t,s,h),"addEventListener"in t?"mousewheel"===e?(t.addEventListener("DOMMouseScroll",s,!1),t.addEventListener(e,s,!1)):"mouseenter"===e||"mouseleave"===e?(a=s,r="mouseenter"===e?"mouseover":"mouseout",s=function(e){return o.DomEvent._checkMouse(t,e)?a(e):void 0},t.addEventListener(r,s,!1)):"click"===e&&o.Browser.android?(a=s,s=function(t){return o.DomEvent._filterClick(t,a)},t.addEventListener(e,s,!1)):t.addEventListener(e,s,!1):"attachEvent"in t&&t.attachEvent("on"+e,s),t[l]=s,this))},removeListener:function(t,e,i){var n=o.stamp(i),s="_leaflet_"+e+n,a=t[s];return a?(o.Browser.pointer&&0===e.indexOf("touch")?this.removePointerListener(t,e,n):o.Browser.touch&&"dblclick"===e&&this.removeDoubleTapListener?this.removeDoubleTapListener(t,n):"removeEventListener"in t?"mousewheel"===e?(t.removeEventListener("DOMMouseScroll",a,!1),t.removeEventListener(e,a,!1)):"mouseenter"===e||"mouseleave"===e?t.removeEventListener("mouseenter"===e?"mouseover":"mouseout",a,!1):t.removeEventListener(e,a,!1):"detachEvent"in t&&t.detachEvent("on"+e,a),t[s]=null,this):this},stopPropagation:function(t){return t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,o.DomEvent._skipped(t),this},disableScrollPropagation:function(t){var e=o.DomEvent.stopPropagation;return o.DomEvent.on(t,"mousewheel",e).on(t,"MozMousePixelScroll",e)},disableClickPropagation:function(t){for(var e=o.DomEvent.stopPropagation,i=o.Draggable.START.length-1;i>=0;i--)o.DomEvent.on(t,o.Draggable.START[i],e);return o.DomEvent.on(t,"click",o.DomEvent._fakeStop).on(t,"dblclick",e)},preventDefault:function(t){return t.preventDefault?t.preventDefault():t.returnValue=!1,this},stop:function(t){return o.DomEvent.preventDefault(t).stopPropagation(t)},getMousePosition:function(t,e){if(!e)return new o.Point(t.clientX,t.clientY);var i=e.getBoundingClientRect();return new o.Point(t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop)},getWheelDelta:function(t){var e=0;return t.wheelDelta&&(e=t.wheelDelta/120),t.detail&&(e=-t.detail/3),e},_skipEvents:{},_fakeStop:function(t){o.DomEvent._skipEvents[t.type]=!0},_skipped:function(t){var e=this._skipEvents[t.type];return this._skipEvents[t.type]=!1,e},_checkMouse:function(t,e){var i=e.relatedTarget;if(!i)return!0;try{for(;i&&i!==t;)i=i.parentNode}catch(n){return!1}return i!==t},_getEvent:function(){var e=t.event;if(!e)for(var i=arguments.callee.caller;i&&(e=i.arguments[0],!e||t.Event!==e.constructor);)i=i.caller;return e},_filterClick:function(t,e){var i=t.timeStamp||t.originalEvent.timeStamp,n=o.DomEvent._lastClick&&i-o.DomEvent._lastClick;return n&&n>100&&500>n||t.target._simulatedClick&&!t._simulated?void o.DomEvent.stop(t):(o.DomEvent._lastClick=i,e(t))}},o.DomEvent.on=o.DomEvent.addListener,o.DomEvent.off=o.DomEvent.removeListener,o.Draggable=o.Class.extend({includes:o.Mixin.Events,statics:{START:o.Browser.touch?["touchstart","mousedown"]:["mousedown"],END:{mousedown:"mouseup",touchstart:"touchend",pointerdown:"touchend",MSPointerDown:"touchend"},MOVE:{mousedown:"mousemove",touchstart:"touchmove",pointerdown:"touchmove",MSPointerDown:"touchmove"}},initialize:function(t,e){this._element=t,this._dragStartTarget=e||t},enable:function(){if(!this._enabled){for(var t=o.Draggable.START.length-1;t>=0;t--)o.DomEvent.on(this._dragStartTarget,o.Draggable.START[t],this._onDown,this);this._enabled=!0}},disable:function(){if(this._enabled){for(var t=o.Draggable.START.length-1;t>=0;t--)o.DomEvent.off(this._dragStartTarget,o.Draggable.START[t],this._onDown,this);this._enabled=!1,this._moved=!1}},_onDown:function(t){if(this._moved=!1,!(t.shiftKey||1!==t.which&&1!==t.button&&!t.touches||(o.DomEvent.stopPropagation(t),o.Draggable._disabled||(o.DomUtil.disableImageDrag(),o.DomUtil.disableTextSelection(),this._moving)))){var i=t.touches?t.touches[0]:t;this._startPoint=new o.Point(i.clientX,i.clientY),this._startPos=this._newPos=o.DomUtil.getPosition(this._element),o.DomEvent.on(e,o.Draggable.MOVE[t.type],this._onMove,this).on(e,o.Draggable.END[t.type],this._onUp,this)}},_onMove:function(t){if(t.touches&&t.touches.length>1)return void(this._moved=!0);var i=t.touches&&1===t.touches.length?t.touches[0]:t,n=new o.Point(i.clientX,i.clientY),s=n.subtract(this._startPoint);(s.x||s.y)&&(o.Browser.touch&&Math.abs(s.x)+Math.abs(s.y)<3||(o.DomEvent.preventDefault(t),this._moved||(this.fire("dragstart"),this._moved=!0,this._startPos=o.DomUtil.getPosition(this._element).subtract(s),o.DomUtil.addClass(e.body,"leaflet-dragging"),this._lastTarget=t.target||t.srcElement,o.DomUtil.addClass(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(s),this._moving=!0,o.Util.cancelAnimFrame(this._animRequest),this._animRequest=o.Util.requestAnimFrame(this._updatePosition,this,!0,this._dragStartTarget)))},_updatePosition:function(){this.fire("predrag"),o.DomUtil.setPosition(this._element,this._newPos),this.fire("drag")},_onUp:function(){o.DomUtil.removeClass(e.body,"leaflet-dragging"),this._lastTarget&&(o.DomUtil.removeClass(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null);for(var t in o.Draggable.MOVE)o.DomEvent.off(e,o.Draggable.MOVE[t],this._onMove).off(e,o.Draggable.END[t],this._onUp);o.DomUtil.enableImageDrag(),o.DomUtil.enableTextSelection(),this._moved&&this._moving&&(o.Util.cancelAnimFrame(this._animRequest),this.fire("dragend",{distance:this._newPos.distanceTo(this._startPos)})),this._moving=!1}}),o.Handler=o.Class.extend({initialize:function(t){this._map=t},enable:function(){this._enabled||(this._enabled=!0,this.addHooks())},disable:function(){this._enabled&&(this._enabled=!1,this.removeHooks())},enabled:function(){return!!this._enabled}}),o.Map.mergeOptions({dragging:!0,inertia:!o.Browser.android23,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,inertiaThreshold:o.Browser.touch?32:18,easeLinearity:.25,worldCopyJump:!1}),o.Map.Drag=o.Handler.extend({addHooks:function(){if(!this._draggable){var t=this._map;this._draggable=new o.Draggable(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDrag,this),t.on("viewreset",this._onViewReset,this),t.whenReady(this._onViewReset,this))}this._draggable.enable()},removeHooks:function(){this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},_onDragStart:function(){var t=this._map;t._panAnim&&t._panAnim.stop(),t.fire("movestart").fire("dragstart"),t.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(){if(this._map.options.inertia){var t=this._lastTime=+new Date,e=this._lastPos=this._draggable._newPos;this._positions.push(e),this._times.push(t),t-this._times[0]>200&&(this._positions.shift(),this._times.shift())}this._map.fire("move").fire("drag")},_onViewReset:function(){var t=this._map.getSize()._divideBy(2),e=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=e.subtract(t).x,this._worldWidth=this._map.project([0,180]).x},_onPreDrag:function(){var t=this._worldWidth,e=Math.round(t/2),i=this._initialWorldOffset,n=this._draggable._newPos.x,o=(n-e+i)%t+e-i,s=(n+e+i)%t-e-i,a=Math.abs(o+i)i.inertiaThreshold||!this._positions[0];if(e.fire("dragend",t),s)e.fire("moveend");else{var a=this._lastPos.subtract(this._positions[0]),r=(this._lastTime+n-this._times[0])/1e3,h=i.easeLinearity,l=a.multiplyBy(h/r),u=l.distanceTo([0,0]),c=Math.min(i.inertiaMaxSpeed,u),d=l.multiplyBy(c/u),p=c/(i.inertiaDeceleration*h),_=d.multiplyBy(-p/2).round();_.x&&_.y?(_=e._limitOffset(_,e.options.maxBounds),o.Util.requestAnimFrame(function(){e.panBy(_,{duration:p,easeLinearity:h,noMoveStart:!0})})):e.fire("moveend")}}}),o.Map.addInitHook("addHandler","dragging",o.Map.Drag),o.Map.mergeOptions({doubleClickZoom:!0}),o.Map.DoubleClickZoom=o.Handler.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var e=this._map,i=e.getZoom()+(t.originalEvent.shiftKey?-1:1);"center"===e.options.doubleClickZoom?e.setZoom(i):e.setZoomAround(t.containerPoint,i)}}),o.Map.addInitHook("addHandler","doubleClickZoom",o.Map.DoubleClickZoom),o.Map.mergeOptions({scrollWheelZoom:!0}),o.Map.ScrollWheelZoom=o.Handler.extend({addHooks:function(){o.DomEvent.on(this._map._container,"mousewheel",this._onWheelScroll,this),o.DomEvent.on(this._map._container,"MozMousePixelScroll",o.DomEvent.preventDefault),this._delta=0},removeHooks:function(){o.DomEvent.off(this._map._container,"mousewheel",this._onWheelScroll),o.DomEvent.off(this._map._container,"MozMousePixelScroll",o.DomEvent.preventDefault)},_onWheelScroll:function(t){var e=o.DomEvent.getWheelDelta(t);this._delta+=e,this._lastMousePos=this._map.mouseEventToContainerPoint(t),this._startTime||(this._startTime=+new Date);var i=Math.max(40-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(o.bind(this._performZoom,this),i),o.DomEvent.preventDefault(t),o.DomEvent.stopPropagation(t)},_performZoom:function(){var t=this._map,e=this._delta,i=t.getZoom();e=e>0?Math.ceil(e):Math.floor(e),e=Math.max(Math.min(e,4),-4),e=t._limitZoom(i+e)-i,this._delta=0,this._startTime=null,e&&("center"===t.options.scrollWheelZoom?t.setZoom(i+e):t.setZoomAround(this._lastMousePos,i+e))}}),o.Map.addInitHook("addHandler","scrollWheelZoom",o.Map.ScrollWheelZoom),o.extend(o.DomEvent,{_touchstart:o.Browser.msPointer?"MSPointerDown":o.Browser.pointer?"pointerdown":"touchstart",_touchend:o.Browser.msPointer?"MSPointerUp":o.Browser.pointer?"pointerup":"touchend",addDoubleTapListener:function(t,i,n){function s(t){var e;if(o.Browser.pointer?(_.push(t.pointerId),e=_.length):e=t.touches.length,!(e>1)){var i=Date.now(),n=i-(r||i);h=t.touches?t.touches[0]:t,l=n>0&&u>=n,r=i}}function a(t){if(o.Browser.pointer){var e=_.indexOf(t.pointerId);if(-1===e)return;_.splice(e,1)}if(l){if(o.Browser.pointer){var n,s={};for(var a in h)n=h[a],s[a]="function"==typeof n?n.bind(h):n;h=s}h.type="dblclick",i(h),r=null}}var r,h,l=!1,u=250,c="_leaflet_",d=this._touchstart,p=this._touchend,_=[];t[c+d+n]=s,t[c+p+n]=a;var m=o.Browser.pointer?e.documentElement:t;return t.addEventListener(d,s,!1),m.addEventListener(p,a,!1),o.Browser.pointer&&m.addEventListener(o.DomEvent.POINTER_CANCEL,a,!1),this},removeDoubleTapListener:function(t,i){var n="_leaflet_";return t.removeEventListener(this._touchstart,t[n+this._touchstart+i],!1),(o.Browser.pointer?e.documentElement:t).removeEventListener(this._touchend,t[n+this._touchend+i],!1),o.Browser.pointer&&e.documentElement.removeEventListener(o.DomEvent.POINTER_CANCEL,t[n+this._touchend+i],!1),this}}),o.extend(o.DomEvent,{POINTER_DOWN:o.Browser.msPointer?"MSPointerDown":"pointerdown",POINTER_MOVE:o.Browser.msPointer?"MSPointerMove":"pointermove",POINTER_UP:o.Browser.msPointer?"MSPointerUp":"pointerup",POINTER_CANCEL:o.Browser.msPointer?"MSPointerCancel":"pointercancel",_pointers:[],_pointerDocumentListener:!1,addPointerListener:function(t,e,i,n){switch(e){case"touchstart":return this.addPointerListenerStart(t,e,i,n);case"touchend":return this.addPointerListenerEnd(t,e,i,n);case"touchmove":return this.addPointerListenerMove(t,e,i,n);default:throw"Unknown touch event type"}},addPointerListenerStart:function(t,i,n,s){var a="_leaflet_",r=this._pointers,h=function(t){o.DomEvent.preventDefault(t);for(var e=!1,i=0;i1))&&(this._moved||(o.DomUtil.addClass(e._mapPane,"leaflet-touching"),e.fire("movestart").fire("zoomstart"),this._moved=!0),o.Util.cancelAnimFrame(this._animRequest),this._animRequest=o.Util.requestAnimFrame(this._updateOnMove,this,!0,this._map._container),o.DomEvent.preventDefault(t))}},_updateOnMove:function(){var t=this._map,e=this._getScaleOrigin(),i=t.layerPointToLatLng(e),n=t.getScaleZoom(this._scale);t._animateZoom(i,n,this._startCenter,this._scale,this._delta,!1,!0)},_onTouchEnd:function(){if(!this._moved||!this._zooming)return void(this._zooming=!1);var t=this._map;this._zooming=!1,o.DomUtil.removeClass(t._mapPane,"leaflet-touching"),o.Util.cancelAnimFrame(this._animRequest),o.DomEvent.off(e,"touchmove",this._onTouchMove).off(e,"touchend",this._onTouchEnd);var i=this._getScaleOrigin(),n=t.layerPointToLatLng(i),s=t.getZoom(),a=t.getScaleZoom(this._scale)-s,r=a>0?Math.ceil(a):Math.floor(a),h=t._limitZoom(s+r),l=t.getZoomScale(h)/this._scale;t._animateZoom(n,h,i,l)},_getScaleOrigin:function(){var t=this._centerOffset.subtract(this._delta).divideBy(this._scale);return this._startCenter.add(t)}}),o.Map.addInitHook("addHandler","touchZoom",o.Map.TouchZoom),o.Map.mergeOptions({tap:!0,tapTolerance:15}),o.Map.Tap=o.Handler.extend({addHooks:function(){o.DomEvent.on(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){o.DomEvent.off(this._map._container,"touchstart",this._onDown,this)},_onDown:function(t){if(t.touches){if(o.DomEvent.preventDefault(t),this._fireClick=!0,t.touches.length>1)return this._fireClick=!1,void clearTimeout(this._holdTimeout);var i=t.touches[0],n=i.target;this._startPos=this._newPos=new o.Point(i.clientX,i.clientY),n.tagName&&"a"===n.tagName.toLowerCase()&&o.DomUtil.addClass(n,"leaflet-active"),this._holdTimeout=setTimeout(o.bind(function(){this._isTapValid()&&(this._fireClick=!1,this._onUp(),this._simulateEvent("contextmenu",i))},this),1e3),o.DomEvent.on(e,"touchmove",this._onMove,this).on(e,"touchend",this._onUp,this)}},_onUp:function(t){if(clearTimeout(this._holdTimeout),o.DomEvent.off(e,"touchmove",this._onMove,this).off(e,"touchend",this._onUp,this),this._fireClick&&t&&t.changedTouches){var i=t.changedTouches[0],n=i.target;n&&n.tagName&&"a"===n.tagName.toLowerCase()&&o.DomUtil.removeClass(n,"leaflet-active"),this._isTapValid()&&this._simulateEvent("click",i)}},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_onMove:function(t){var e=t.touches[0];this._newPos=new o.Point(e.clientX,e.clientY)},_simulateEvent:function(i,n){var o=e.createEvent("MouseEvents");o._simulated=!0,n.target._simulatedClick=!0,o.initMouseEvent(i,!0,!0,t,1,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),n.target.dispatchEvent(o)}}),o.Browser.touch&&!o.Browser.pointer&&o.Map.addInitHook("addHandler","tap",o.Map.Tap),o.Map.mergeOptions({boxZoom:!0}),o.Map.BoxZoom=o.Handler.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._moved=!1},addHooks:function(){o.DomEvent.on(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){o.DomEvent.off(this._container,"mousedown",this._onMouseDown),this._moved=!1},moved:function(){return this._moved},_onMouseDown:function(t){return this._moved=!1,!t.shiftKey||1!==t.which&&1!==t.button?!1:(o.DomUtil.disableTextSelection(),o.DomUtil.disableImageDrag(),this._startLayerPoint=this._map.mouseEventToLayerPoint(t),void o.DomEvent.on(e,"mousemove",this._onMouseMove,this).on(e,"mouseup",this._onMouseUp,this).on(e,"keydown",this._onKeyDown,this))},_onMouseMove:function(t){this._moved||(this._box=o.DomUtil.create("div","leaflet-zoom-box",this._pane),o.DomUtil.setPosition(this._box,this._startLayerPoint),this._container.style.cursor="crosshair",this._map.fire("boxzoomstart"));var e=this._startLayerPoint,i=this._box,n=this._map.mouseEventToLayerPoint(t),s=n.subtract(e),a=new o.Point(Math.min(n.x,e.x),Math.min(n.y,e.y));o.DomUtil.setPosition(i,a),this._moved=!0,i.style.width=Math.max(0,Math.abs(s.x)-4)+"px",i.style.height=Math.max(0,Math.abs(s.y)-4)+"px"},_finish:function(){this._moved&&(this._pane.removeChild(this._box),this._container.style.cursor=""),o.DomUtil.enableTextSelection(),o.DomUtil.enableImageDrag(),o.DomEvent.off(e,"mousemove",this._onMouseMove).off(e,"mouseup",this._onMouseUp).off(e,"keydown",this._onKeyDown)},_onMouseUp:function(t){this._finish();var e=this._map,i=e.mouseEventToLayerPoint(t);if(!this._startLayerPoint.equals(i)){var n=new o.LatLngBounds(e.layerPointToLatLng(this._startLayerPoint),e.layerPointToLatLng(i));e.fitBounds(n),e.fire("boxzoomend",{boxZoomBounds:n})}},_onKeyDown:function(t){27===t.keyCode&&this._finish()}}),o.Map.addInitHook("addHandler","boxZoom",o.Map.BoxZoom),o.Map.mergeOptions({keyboard:!0,keyboardPanOffset:80,keyboardZoomOffset:1}),o.Map.Keyboard=o.Handler.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,173]},initialize:function(t){this._map=t,this._setPanOffset(t.options.keyboardPanOffset),this._setZoomOffset(t.options.keyboardZoomOffset)},addHooks:function(){var t=this._map._container;-1===t.tabIndex&&(t.tabIndex="0"),o.DomEvent.on(t,"focus",this._onFocus,this).on(t,"blur",this._onBlur,this).on(t,"mousedown",this._onMouseDown,this),this._map.on("focus",this._addHooks,this).on("blur",this._removeHooks,this)},removeHooks:function(){this._removeHooks();var t=this._map._container;o.DomEvent.off(t,"focus",this._onFocus,this).off(t,"blur",this._onBlur,this).off(t,"mousedown",this._onMouseDown,this),this._map.off("focus",this._addHooks,this).off("blur",this._removeHooks,this)},_onMouseDown:function(){if(!this._focused){var i=e.body,n=e.documentElement,o=i.scrollTop||n.scrollTop,s=i.scrollLeft||n.scrollLeft;this._map._container.focus(),t.scrollTo(s,o)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanOffset:function(t){var e,i,n=this._panKeys={},o=this.keyCodes;for(e=0,i=o.left.length;i>e;e++)n[o.left[e]]=[-1*t,0];for(e=0,i=o.right.length;i>e;e++)n[o.right[e]]=[t,0];for(e=0,i=o.down.length;i>e;e++)n[o.down[e]]=[0,t];for(e=0,i=o.up.length;i>e;e++)n[o.up[e]]=[0,-1*t]},_setZoomOffset:function(t){var e,i,n=this._zoomKeys={},o=this.keyCodes;for(e=0,i=o.zoomIn.length;i>e;e++)n[o.zoomIn[e]]=t;for(e=0,i=o.zoomOut.length;i>e;e++)n[o.zoomOut[e]]=-t},_addHooks:function(){o.DomEvent.on(e,"keydown",this._onKeyDown,this)},_removeHooks:function(){o.DomEvent.off(e,"keydown",this._onKeyDown,this)},_onKeyDown:function(t){var e=t.keyCode,i=this._map;if(e in this._panKeys){if(i._panAnim&&i._panAnim._inProgress)return;i.panBy(this._panKeys[e]),i.options.maxBounds&&i.panInsideBounds(i.options.maxBounds)}else{if(!(e in this._zoomKeys))return;i.setZoom(i.getZoom()+this._zoomKeys[e])}o.DomEvent.stop(t)}}),o.Map.addInitHook("addHandler","keyboard",o.Map.Keyboard),o.Handler.MarkerDrag=o.Handler.extend({initialize:function(t){this._marker=t},addHooks:function(){var t=this._marker._icon;this._draggable||(this._draggable=new o.Draggable(t,t)),this._draggable.on("dragstart",this._onDragStart,this).on("drag",this._onDrag,this).on("dragend",this._onDragEnd,this),this._draggable.enable(),o.DomUtil.addClass(this._marker._icon,"leaflet-marker-draggable")},removeHooks:function(){this._draggable.off("dragstart",this._onDragStart,this).off("drag",this._onDrag,this).off("dragend",this._onDragEnd,this),this._draggable.disable(),o.DomUtil.removeClass(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_onDragStart:function(){this._marker.closePopup().fire("movestart").fire("dragstart")},_onDrag:function(){var t=this._marker,e=t._shadow,i=o.DomUtil.getPosition(t._icon),n=t._map.layerPointToLatLng(i);e&&o.DomUtil.setPosition(e,i),t._latlng=n,t.fire("move",{latlng:n}).fire("drag")},_onDragEnd:function(t){this._marker.fire("moveend").fire("dragend",t)}}),o.Control=o.Class.extend({options:{position:"topright"},initialize:function(t){o.setOptions(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var e=this._map;return e&&e.removeControl(this),this.options.position=t,e&&e.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this._map=t;var e=this._container=this.onAdd(t),i=this.getPosition(),n=t._controlCorners[i];return o.DomUtil.addClass(e,"leaflet-control"),-1!==i.indexOf("bottom")?n.insertBefore(e,n.firstChild):n.appendChild(e),this},removeFrom:function(t){var e=this.getPosition(),i=t._controlCorners[e];return i.removeChild(this._container),this._map=null,this.onRemove&&this.onRemove(t),this},_refocusOnMap:function(){this._map&&this._map.getContainer().focus()}}),o.control=function(t){return new o.Control(t)},o.Map.include({addControl:function(t){return t.addTo(this),this},removeControl:function(t){return t.removeFrom(this),this},_initControlPos:function(){function t(t,s){var a=i+t+" "+i+s;e[t+s]=o.DomUtil.create("div",a,n)}var e=this._controlCorners={},i="leaflet-",n=this._controlContainer=o.DomUtil.create("div",i+"control-container",this._container);t("top","left"),t("top","right"),t("bottom","left"),t("bottom","right")},_clearControlPos:function(){this._container.removeChild(this._controlContainer)}}),o.Control.Zoom=o.Control.extend({options:{position:"topleft",zoomInText:"+",zoomInTitle:"Zoom in",zoomOutText:"-",zoomOutTitle:"Zoom out"},onAdd:function(t){var e="leaflet-control-zoom",i=o.DomUtil.create("div",e+" leaflet-bar");return this._map=t,this._zoomInButton=this._createButton(this.options.zoomInText,this.options.zoomInTitle,e+"-in",i,this._zoomIn,this),this._zoomOutButton=this._createButton(this.options.zoomOutText,this.options.zoomOutTitle,e+"-out",i,this._zoomOut,this),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),i},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},_zoomIn:function(t){this._map.zoomIn(t.shiftKey?3:1)},_zoomOut:function(t){this._map.zoomOut(t.shiftKey?3:1)},_createButton:function(t,e,i,n,s,a){var r=o.DomUtil.create("a",i,n);r.innerHTML=t,r.href="#",r.title=e;var h=o.DomEvent.stopPropagation;return o.DomEvent.on(r,"click",h).on(r,"mousedown",h).on(r,"dblclick",h).on(r,"click",o.DomEvent.preventDefault).on(r,"click",s,a).on(r,"click",this._refocusOnMap,a),r},_updateDisabled:function(){var t=this._map,e="leaflet-disabled";o.DomUtil.removeClass(this._zoomInButton,e),o.DomUtil.removeClass(this._zoomOutButton,e),t._zoom===t.getMinZoom()&&o.DomUtil.addClass(this._zoomOutButton,e),t._zoom===t.getMaxZoom()&&o.DomUtil.addClass(this._zoomInButton,e)}}),o.Map.mergeOptions({zoomControl:!0}),o.Map.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new o.Control.Zoom,this.addControl(this.zoomControl))}),o.control.zoom=function(t){return new o.Control.Zoom(t)},o.Control.Attribution=o.Control.extend({options:{position:"bottomright",prefix:'Leaflet'},initialize:function(t){o.setOptions(this,t),this._attributions={}},onAdd:function(t){this._container=o.DomUtil.create("div","leaflet-control-attribution"),o.DomEvent.disableClickPropagation(this._container);for(var e in t._layers)t._layers[e].getAttribution&&this.addAttribution(t._layers[e].getAttribution());return t.on("layeradd",this._onLayerAdd,this).on("layerremove",this._onLayerRemove,this),this._update(),this._container},onRemove:function(t){t.off("layeradd",this._onLayerAdd).off("layerremove",this._onLayerRemove)},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t?(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update(),this):void 0},removeAttribution:function(t){return t?(this._attributions[t]&&(this._attributions[t]--,this._update()),this):void 0},_update:function(){if(this._map){var t=[];for(var e in this._attributions)this._attributions[e]&&t.push(e);var i=[];this.options.prefix&&i.push(this.options.prefix),t.length&&i.push(t.join(", ")),this._container.innerHTML=i.join(" | ")}},_onLayerAdd:function(t){t.layer.getAttribution&&this.addAttribution(t.layer.getAttribution())},_onLayerRemove:function(t){t.layer.getAttribution&&this.removeAttribution(t.layer.getAttribution())}}),o.Map.mergeOptions({attributionControl:!0}),o.Map.addInitHook(function(){this.options.attributionControl&&(this.attributionControl=(new o.Control.Attribution).addTo(this))}),o.control.attribution=function(t){return new o.Control.Attribution(t)},o.Control.Scale=o.Control.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0,updateWhenIdle:!1},onAdd:function(t){this._map=t;var e="leaflet-control-scale",i=o.DomUtil.create("div",e),n=this.options;return this._addScales(n,e,i),t.on(n.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),i},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,e,i){t.metric&&(this._mScale=o.DomUtil.create("div",e+"-line",i)),t.imperial&&(this._iScale=o.DomUtil.create("div",e+"-line",i))},_update:function(){var t=this._map.getBounds(),e=t.getCenter().lat,i=6378137*Math.PI*Math.cos(e*Math.PI/180),n=i*(t.getNorthEast().lng-t.getSouthWest().lng)/180,o=this._map.getSize(),s=this.options,a=0;o.x>0&&(a=n*(s.maxWidth/o.x)),this._updateScales(s,a)},_updateScales:function(t,e){t.metric&&e&&this._updateMetric(e),t.imperial&&e&&this._updateImperial(e)},_updateMetric:function(t){var e=this._getRoundNum(t);this._mScale.style.width=this._getScaleWidth(e/t)+"px",this._mScale.innerHTML=1e3>e?e+" m":e/1e3+" km"},_updateImperial:function(t){var e,i,n,o=3.2808399*t,s=this._iScale;o>5280?(e=o/5280,i=this._getRoundNum(e),s.style.width=this._getScaleWidth(i/e)+"px",s.innerHTML=i+" mi"):(n=this._getRoundNum(o),s.style.width=this._getScaleWidth(n/o)+"px",s.innerHTML=n+" ft")},_getScaleWidth:function(t){return Math.round(this.options.maxWidth*t)-10},_getRoundNum:function(t){var e=Math.pow(10,(Math.floor(t)+"").length-1),i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:1,e*i}}),o.control.scale=function(t){return new o.Control.Scale(t)},o.Control.Layers=o.Control.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0},initialize:function(t,e,i){o.setOptions(this,i),this._layers={},this._lastZIndex=0,this._handlingClick=!1;for(var n in t)this._addLayer(t[n],n);for(n in e)this._addLayer(e[n],n,!0)},onAdd:function(t){return this._initLayout(),this._update(),t.on("layeradd",this._onLayerChange,this).on("layerremove",this._onLayerChange,this),this._container},onRemove:function(t){t.off("layeradd",this._onLayerChange,this).off("layerremove",this._onLayerChange,this)},addBaseLayer:function(t,e){return this._addLayer(t,e),this._update(),this},addOverlay:function(t,e){return this._addLayer(t,e,!0),this._update(),this},removeLayer:function(t){var e=o.stamp(t);return delete this._layers[e],this._update(),this},_initLayout:function(){var t="leaflet-control-layers",e=this._container=o.DomUtil.create("div",t);e.setAttribute("aria-haspopup",!0),o.Browser.touch?o.DomEvent.on(e,"click",o.DomEvent.stopPropagation):o.DomEvent.disableClickPropagation(e).disableScrollPropagation(e);var i=this._form=o.DomUtil.create("form",t+"-list");if(this.options.collapsed){o.Browser.android||o.DomEvent.on(e,"mouseover",this._expand,this).on(e,"mouseout",this._collapse,this);var n=this._layersLink=o.DomUtil.create("a",t+"-toggle",e);n.href="#",n.title="Layers",o.Browser.touch?o.DomEvent.on(n,"click",o.DomEvent.stop).on(n,"click",this._expand,this):o.DomEvent.on(n,"focus",this._expand,this),o.DomEvent.on(i,"click",function(){setTimeout(o.bind(this._onInputClick,this),0)},this),this._map.on("click",this._collapse,this)}else this._expand();this._baseLayersList=o.DomUtil.create("div",t+"-base",i),this._separator=o.DomUtil.create("div",t+"-separator",i),this._overlaysList=o.DomUtil.create("div",t+"-overlays",i),e.appendChild(i)},_addLayer:function(t,e,i){var n=o.stamp(t);this._layers[n]={layer:t,name:e,overlay:i},this.options.autoZIndex&&t.setZIndex&&(this._lastZIndex++,t.setZIndex(this._lastZIndex))},_update:function(){if(this._container){this._baseLayersList.innerHTML="",this._overlaysList.innerHTML="";var t,e,i=!1,n=!1;for(t in this._layers)e=this._layers[t],this._addItem(e),n=n||e.overlay,i=i||!e.overlay;this._separator.style.display=n&&i?"":"none"}},_onLayerChange:function(t){var e=this._layers[o.stamp(t.layer)];if(e){this._handlingClick||this._update();var i=e.overlay?"layeradd"===t.type?"overlayadd":"overlayremove":"layeradd"===t.type?"baselayerchange":null;i&&this._map.fire(i,e)}},_createRadioElement:function(t,i){var n='t;t++)e=n[t],i=this._layers[e.layerId],e.checked&&!this._map.hasLayer(i.layer)?this._map.addLayer(i.layer):!e.checked&&this._map.hasLayer(i.layer)&&this._map.removeLayer(i.layer);this._handlingClick=!1,this._refocusOnMap()},_expand:function(){o.DomUtil.addClass(this._container,"leaflet-control-layers-expanded")},_collapse:function(){this._container.className=this._container.className.replace(" leaflet-control-layers-expanded","")}}),o.control.layers=function(t,e,i){return new o.Control.Layers(t,e,i)},o.PosAnimation=o.Class.extend({includes:o.Mixin.Events,run:function(t,e,i,n){this.stop(),this._el=t,this._inProgress=!0,this._newPos=e,this.fire("start"),t.style[o.DomUtil.TRANSITION]="all "+(i||.25)+"s cubic-bezier(0,0,"+(n||.5)+",1)",o.DomEvent.on(t,o.DomUtil.TRANSITION_END,this._onTransitionEnd,this),o.DomUtil.setPosition(t,e),o.Util.falseFn(t.offsetWidth),this._stepTimer=setInterval(o.bind(this._onStep,this),50)},stop:function(){this._inProgress&&(o.DomUtil.setPosition(this._el,this._getPos()),this._onTransitionEnd(),o.Util.falseFn(this._el.offsetWidth))},_onStep:function(){var t=this._getPos();return t?(this._el._leaflet_pos=t,void this.fire("step")):void this._onTransitionEnd()},_transformRe:/([-+]?(?:\d*\.)?\d+)\D*, ([-+]?(?:\d*\.)?\d+)\D*\)/,_getPos:function(){var e,i,n,s=this._el,a=t.getComputedStyle(s);if(o.Browser.any3d){if(n=a[o.DomUtil.TRANSFORM].match(this._transformRe),!n)return;e=parseFloat(n[1]),i=parseFloat(n[2])}else e=parseFloat(a.left),i=parseFloat(a.top);return new o.Point(e,i,!0)},_onTransitionEnd:function(){o.DomEvent.off(this._el,o.DomUtil.TRANSITION_END,this._onTransitionEnd,this),this._inProgress&&(this._inProgress=!1,this._el.style[o.DomUtil.TRANSITION]="",this._el._leaflet_pos=this._newPos,clearInterval(this._stepTimer),this.fire("step").fire("end"))}}),o.Map.include({setView:function(t,e,n){if(e=e===i?this._zoom:this._limitZoom(e),t=this._limitCenter(o.latLng(t),e,this.options.maxBounds),n=n||{},this._panAnim&&this._panAnim.stop(),this._loaded&&!n.reset&&n!==!0){n.animate!==i&&(n.zoom=o.extend({animate:n.animate},n.zoom),n.pan=o.extend({animate:n.animate},n.pan));var s=this._zoom!==e?this._tryAnimatedZoom&&this._tryAnimatedZoom(t,e,n.zoom):this._tryAnimatedPan(t,n.pan);if(s)return clearTimeout(this._sizeTimer),this}return this._resetView(t,e),this},panBy:function(t,e){if(t=o.point(t).round(),e=e||{},!t.x&&!t.y)return this;if(this._panAnim||(this._panAnim=new o.PosAnimation,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),e.noMoveStart||this.fire("movestart"),e.animate!==!1){o.DomUtil.addClass(this._mapPane,"leaflet-pan-anim");var i=this._getMapPanePos().subtract(t);this._panAnim.run(this._mapPane,i,e.duration||.25,e.easeLinearity)}else this._rawPanBy(t),this.fire("move").fire("moveend");return this},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){o.DomUtil.removeClass(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(t,e){var i=this._getCenterOffset(t)._floor();return(e&&e.animate)===!0||this.getSize().contains(i)?(this.panBy(i,e),!0):!1}}),o.PosAnimation=o.DomUtil.TRANSITION?o.PosAnimation:o.PosAnimation.extend({run:function(t,e,i,n){this.stop(),this._el=t,this._inProgress=!0,this._duration=i||.25,this._easeOutPower=1/Math.max(n||.5,.2),this._startPos=o.DomUtil.getPosition(t),this._offset=e.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(),this._complete())},_animate:function(){this._animId=o.Util.requestAnimFrame(this._animate,this),this._step()},_step:function(){var t=+new Date-this._startTime,e=1e3*this._duration;e>t?this._runFrame(this._easeOut(t/e)):(this._runFrame(1),this._complete())},_runFrame:function(t){var e=this._startPos.add(this._offset.multiplyBy(t));o.DomUtil.setPosition(this._el,e),this.fire("step")},_complete:function(){o.Util.cancelAnimFrame(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(t){return 1-Math.pow(1-t,this._easeOutPower)}}),o.Map.mergeOptions({zoomAnimation:!0,zoomAnimationThreshold:4}),o.DomUtil.TRANSITION&&o.Map.addInitHook(function(){this._zoomAnimated=this.options.zoomAnimation&&o.DomUtil.TRANSITION&&o.Browser.any3d&&!o.Browser.android23&&!o.Browser.mobileOpera,this._zoomAnimated&&o.DomEvent.on(this._mapPane,o.DomUtil.TRANSITION_END,this._catchTransitionEnd,this)}),o.Map.include(o.DomUtil.TRANSITION?{_catchTransitionEnd:function(t){this._animatingZoom&&t.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(t,e,i){if(this._animatingZoom)return!0;if(i=i||{},!this._zoomAnimated||i.animate===!1||this._nothingToAnimate()||Math.abs(e-this._zoom)>this.options.zoomAnimationThreshold)return!1;var n=this.getZoomScale(e),o=this._getCenterOffset(t)._divideBy(1-1/n),s=this._getCenterLayerPoint()._add(o);return i.animate===!0||this.getSize().contains(o)?(this.fire("movestart").fire("zoomstart"),this._animateZoom(t,e,s,n,null,!0),!0):!1},_animateZoom:function(t,e,i,n,s,a,r){r||(this._animatingZoom=!0),o.DomUtil.addClass(this._mapPane,"leaflet-zoom-anim"),this._animateToCenter=t,this._animateToZoom=e,o.Draggable&&(o.Draggable._disabled=!0),o.Util.requestAnimFrame(function(){this.fire("zoomanim",{center:t,zoom:e,origin:i,scale:n,delta:s,backwards:a})},this)},_onZoomTransitionEnd:function(){this._animatingZoom=!1,o.DomUtil.removeClass(this._mapPane,"leaflet-zoom-anim"),this._resetView(this._animateToCenter,this._animateToZoom,!0,!0),o.Draggable&&(o.Draggable._disabled=!1)}}:{}),o.TileLayer.include({_animateZoom:function(t){this._animating||(this._animating=!0,this._prepareBgBuffer());var e=this._bgBuffer,i=o.DomUtil.TRANSFORM,n=t.delta?o.DomUtil.getTranslateString(t.delta):e.style[i],s=o.DomUtil.getScaleString(t.scale,t.origin);e.style[i]=t.backwards?s+" "+n:n+" "+s},_endZoomAnim:function(){var t=this._tileContainer,e=this._bgBuffer;t.style.visibility="",t.parentNode.appendChild(t),o.Util.falseFn(e.offsetWidth),this._animating=!1},_clearBgBuffer:function(){var t=this._map;!t||t._animatingZoom||t.touchZoom._zooming||(this._bgBuffer.innerHTML="",this._bgBuffer.style[o.DomUtil.TRANSFORM]="")},_prepareBgBuffer:function(){var t=this._tileContainer,e=this._bgBuffer,i=this._getLoadedTilesPercentage(e),n=this._getLoadedTilesPercentage(t);return e&&i>.5&&.5>n?(t.style.visibility="hidden",void this._stopLoadingImages(t)):(e.style.visibility="hidden",e.style[o.DomUtil.TRANSFORM]="",this._tileContainer=e,e=this._bgBuffer=t,this._stopLoadingImages(e),void clearTimeout(this._clearBgBufferTimer))},_getLoadedTilesPercentage:function(t){var e,i,n=t.getElementsByTagName("img"),o=0;for(e=0,i=n.length;i>e;e++)n[e].complete&&o++;return o/i},_stopLoadingImages:function(t){var e,i,n,s=Array.prototype.slice.call(t.getElementsByTagName("img"));for(e=0,i=s.length;i>e;e++)n=s[e],n.complete||(n.onload=o.Util.falseFn,n.onerror=o.Util.falseFn,n.src=o.Util.emptyImageUrl,n.parentNode.removeChild(n))}}),o.Map.include({_defaultLocateOptions:{watch:!1,setView:!1,maxZoom:1/0,timeout:1e4,maximumAge:0,enableHighAccuracy:!1},locate:function(t){if(t=this._locateOptions=o.extend(this._defaultLocateOptions,t),!navigator.geolocation)return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var e=o.bind(this._handleGeolocationResponse,this),i=o.bind(this._handleGeolocationError,this);return t.watch?this._locationWatchId=navigator.geolocation.watchPosition(e,i,t):navigator.geolocation.getCurrentPosition(e,i,t),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(t){var e=t.code,i=t.message||(1===e?"permission denied":2===e?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:e,message:"Geolocation error: "+i+"."})},_handleGeolocationResponse:function(t){var e=t.coords.latitude,i=t.coords.longitude,n=new o.LatLng(e,i),s=180*t.coords.accuracy/40075017,a=s/Math.cos(o.LatLng.DEG_TO_RAD*e),r=o.latLngBounds([e-s,i-a],[e+s,i+a]),h=this._locateOptions;if(h.setView){var l=Math.min(this.getBoundsZoom(r),h.maxZoom);this.setView(n,l)}var u={latlng:n,bounds:r,timestamp:t.timestamp};for(var c in t.coords)"number"==typeof t.coords[c]&&(u[c]=t.coords[c]);this.fire("locationfound",u)}})}(window,document); \ No newline at end of file diff --git a/www7/sites/all/modules/contrib/views_pdf/modules/views_append/views_append.info b/www7/sites/all/modules/contrib/views_pdf/modules/views_append/views_append.info index 0e7ee6c95..5070a0776 100644 --- a/www7/sites/all/modules/contrib/views_pdf/modules/views_append/views_append.info +++ b/www7/sites/all/modules/contrib/views_pdf/modules/views_append/views_append.info @@ -7,9 +7,9 @@ core = 7.x files[] = views_append_handler_append_view.inc -; Information added by Drupal.org packaging script on 2016-02-02 -version = "7.x-1.5" +; Information added by Drupal.org packaging script on 2017-01-20 +version = "7.x-1.7" core = "7.x" project = "views_pdf" -datestamp = "1454421840" +datestamp = "1484920085" diff --git a/www7/sites/all/modules/contrib/views_pdf/modules/views_view_field/views_view_field.info b/www7/sites/all/modules/contrib/views_pdf/modules/views_view_field/views_view_field.info index 63e49a12d..394c7aaf7 100644 --- a/www7/sites/all/modules/contrib/views_pdf/modules/views_view_field/views_view_field.info +++ b/www7/sites/all/modules/contrib/views_pdf/modules/views_view_field/views_view_field.info @@ -7,9 +7,9 @@ core = 7.x files[] = views_view_field_handler_include_view.inc -; Information added by Drupal.org packaging script on 2016-02-02 -version = "7.x-1.5" +; Information added by Drupal.org packaging script on 2017-01-20 +version = "7.x-1.7" core = "7.x" project = "views_pdf" -datestamp = "1454421840" +datestamp = "1484920085" diff --git a/www7/sites/all/modules/contrib/views_pdf/views_pdf.info b/www7/sites/all/modules/contrib/views_pdf/views_pdf.info index ff891b438..88a0abb87 100644 --- a/www7/sites/all/modules/contrib/views_pdf/views_pdf.info +++ b/www7/sites/all/modules/contrib/views_pdf/views_pdf.info @@ -15,9 +15,9 @@ files[] = views_pdf_plugin_row_fields.inc files[] = field_plugins/views_pdf_handler_page_number.inc files[] = field_plugins/views_pdf_handler_page_break.inc -; Information added by Drupal.org packaging script on 2016-02-02 -version = "7.x-1.5" +; Information added by Drupal.org packaging script on 2017-01-20 +version = "7.x-1.7" core = "7.x" project = "views_pdf" -datestamp = "1454421840" +datestamp = "1484920085" diff --git a/www7/sites/all/modules/contrib/views_pdf/views_pdf.install b/www7/sites/all/modules/contrib/views_pdf/views_pdf.install index 505ff2339..1b9eb3ef5 100644 --- a/www7/sites/all/modules/contrib/views_pdf/views_pdf.install +++ b/www7/sites/all/modules/contrib/views_pdf/views_pdf.install @@ -59,3 +59,30 @@ function views_pdf_requirements($phase) { return $requirements; } +/** + * The previous update to version 7.x-1.6 contained a faulty views_pdf_update_7000() function that + * created a faulty views display object for some pdf displays (i.e. pdf display with the default "Display a specified number of items | 10" pager ) + * This resulted in a display_option['pager'] NULL array element, which broke the pdf display. + * + * This new update replaces the views_pdf_update_7000() function and fixes the faulty array element + * It is recommended that users avoid 7.x-1.6 and update to 7.x-1.7 version + */ +function views_pdf_update_7101() { + $views = views_get_all_views(); + + foreach ($views as $key => $view) { + foreach ($view->display as $key => $display) { + if($display->display_plugin == 'pdf') { + if(isset($display->display_options['pager'])) { + if (!isset($display->display_options['defaults']['pager'])) { + $display->display_options['defaults']['pager'] = FALSE; + } + if (!isset($display->display_options['defaults']['pager_options'])) { + $display->display_options['defaults']['pager_options'] = FALSE; + } + } + } + } + views_save_view($view); + } +} diff --git a/www7/sites/all/modules/contrib/views_pdf/views_pdf.make b/www7/sites/all/modules/contrib/views_pdf/views_pdf.make.example similarity index 100% rename from www7/sites/all/modules/contrib/views_pdf/views_pdf.make rename to www7/sites/all/modules/contrib/views_pdf/views_pdf.make.example diff --git a/www7/sites/all/modules/contrib/views_pdf/views_pdf.rules.inc b/www7/sites/all/modules/contrib/views_pdf/views_pdf.rules.inc index fe1cc49a9..dea9d9748 100644 --- a/www7/sites/all/modules/contrib/views_pdf/views_pdf.rules.inc +++ b/www7/sites/all/modules/contrib/views_pdf/views_pdf.rules.inc @@ -79,7 +79,7 @@ function views_pdf_rules_action_save($views_pdf, $arguments, $path) { $view->pre_execute(); foreach ($view->display as $id => $display) { - if ($display->display_plugin == 'pdf' && isset($display->handler)) { + if ($display->display_plugin == 'pdf' && isset($display->handler) && $id == $display_id) { $display->handler->execute($path, 'F'); } } diff --git a/www7/sites/all/modules/contrib/views_pdf/views_pdf.views.inc b/www7/sites/all/modules/contrib/views_pdf/views_pdf.views.inc index 31dc7743a..51e2be29c 100644 --- a/www7/sites/all/modules/contrib/views_pdf/views_pdf.views.inc +++ b/www7/sites/all/modules/contrib/views_pdf/views_pdf.views.inc @@ -53,7 +53,7 @@ function views_pdf_views_plugins() { 'handler' => 'views_pdf_plugin_display', 'uses hook menu' => TRUE, 'use ajax' => FALSE, - 'use pager' => FALSE, + 'use pager' => TRUE, 'use more' => FALSE, 'accept attachments' => FALSE, 'admin' => t('PDF Page'), diff --git a/www7/sites/all/modules/contrib/views_pdf/views_pdf_plugin_row_fields.inc b/www7/sites/all/modules/contrib/views_pdf/views_pdf_plugin_row_fields.inc index c26ad4f99..c5312f761 100644 --- a/www7/sites/all/modules/contrib/views_pdf/views_pdf_plugin_row_fields.inc +++ b/www7/sites/all/modules/contrib/views_pdf/views_pdf_plugin_row_fields.inc @@ -258,6 +258,12 @@ class views_pdf_plugin_row_fields extends views_plugin_row { '#default_value' => isset($this->options['formats'][$field]['render']['is_html']) ? $this->options['formats'][$field]['render']['is_html'] : 1, ); + $form['formats'][$field]['render']['custom_layout'] = array( + '#type' => 'checkbox', + '#title' => t('Enable custom layout hook.'), + '#description' => t("Allow a custom module to alter the layout of this field."), + '#default_value' => !empty($this->options['formats'][$field]['render']['custom_layout']) ? $this->options['formats'][$field]['render']['custom_layout'] : FALSE, + ); $form['formats'][$field]['render']['minimal_space'] = array( '#type' => 'textfield', '#title' => t('Minimal Space'), @@ -276,6 +282,12 @@ class views_pdf_plugin_row_fields extends views_plugin_row { '#description' => t("WARNING: If you don't know the risk of using eval leave as it."), '#default_value' => !empty($this->options['formats'][$field]['render']['bypass_eval_before']) ? $this->options['formats'][$field]['render']['bypass_eval_before'] : FALSE, ); + $form['formats'][$field]['render']['custom_post'] = array( + '#type' => 'checkbox', + '#title' => t('Enable custom post render hook.'), + '#description' => t("Allow a custom module hook to be executed after the rendering of this field."), + '#default_value' => !empty($this->options['formats'][$field]['render']['custom_post']) ? $this->options['formats'][$field]['render']['custom_post'] : FALSE, + ); $form['formats'][$field]['render']['eval_after'] = array( '#type' => 'textarea', diff --git a/www7/sites/all/modules/contrib/views_pdf/views_pdf_template.php b/www7/sites/all/modules/contrib/views_pdf/views_pdf_template.php index 93b885d38..61874d033 100644 --- a/www7/sites/all/modules/contrib/views_pdf/views_pdf_template.php +++ b/www7/sites/all/modules/contrib/views_pdf/views_pdf_template.php @@ -257,6 +257,8 @@ public function drawContent($row, $options, &$view = NULL, $key = NULL, $printLa 'eval_after' => '', 'bypass_eval_before' => FALSE, 'bypass_eval_after' => FALSE, + 'custom_layout' => FALSE, + 'custom_post' => FALSE, ); $x = $y = 0; @@ -513,6 +515,26 @@ protected function renderRow($x, $y, $row, $options, &$view = NULL, $key = NULL, $content = php_eval($options['render']['eval_before']); } } + if ($options['render']['custom_layout']) { + // Custom layout hook. + $layout_data = array ( + 'x' => &$x, + 'y' => &$y, + 'h' => &$h, + 'w' => &$w, + 'content' => &$content, + 'key' => &$key, + 'view' => &$view, + 'this' => &$this, + 'border' => &$border, + 'color' => &$textColor, + 'font' => &$font_family, + 'font_style' => &$font_style, + 'font_size' => &$font_size, + + ); + drupal_alter('views_pdf_custom_layout', $layout_data); + } // Add css if there is a css file set and stripHTML is not active. if (!empty($css_file) && is_string($css_file) && !$stripHTML && $ishtml && !empty($content)) { @@ -545,6 +567,10 @@ protected function renderRow($x, $y, $row, $options, &$view = NULL, $key = NULL, // Reset font to default. $this->SetFont($this->defaultFontFamily, implode('', $this->defaultFontStyle), $this->defaultFontSize); + // Post render. + if ($options['render']['custom_post']) { + drupal_alter('views_pdf_custom_post', $view); + } // Run eval after. if (VIEWS_PDF_PHP) { if (!empty($options['render']['bypass_eval_after']) && !empty($options['render']['eval_after'])) { From ecf1c14ebfb1609f7fe9abf2058715712510c8ab Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Sat, 21 Jan 2017 11:36:15 +0100 Subject: [PATCH 14/16] Update metatag to 7.x-1.20 --- .../all/modules/contrib/metatag/CHANGELOG.txt | 8 ++ .../all/modules/contrib/metatag/README.txt | 5 +- .../all/modules/contrib/metatag/metatag.info | 6 +- .../modules/contrib/metatag/metatag.install | 75 +++++++++++++++---- .../modules/contrib/metatag/metatag.module | 58 +++++++++++++- .../metatag_app_links/metatag_app_links.info | 6 +- .../metatag_context/metatag_context.info | 6 +- .../tests/metatag_context_tests.info | 6 +- .../metatag/metatag_dc/metatag_dc.info | 6 +- .../metatag_dc_advanced.info | 6 +- .../metatag/metatag_devel/metatag_devel.info | 6 +- .../metatag_facebook/metatag_facebook.info | 6 +- .../metatag_favicons/metatag_favicons.info | 6 +- .../metatag_google_cse.info | 6 +- .../metatag_google_plus.info | 6 +- .../metatag_hreflang/metatag_hreflang.info | 6 +- .../metatag_importer/metatag_importer.info | 6 +- .../metatag_mobile/metatag_mobile.info | 6 +- .../metatag_opengraph/metatag_opengraph.info | 6 +- .../metatag_opengraph_products.info | 6 +- .../metatag_panels/metatag_panels.info | 6 +- .../tests/metatag_panels_tests.info | 6 +- .../metatag_twitter_cards.info | 6 +- .../metatag_verification.info | 6 +- .../metatag/metatag_views/metatag_views.info | 6 +- .../tests/metatag_views_tests.info | 6 +- .../metatag.with_workbench_moderation.test | 4 +- .../metatag/tests/metatag_search_test.info | 6 +- .../contrib/metatag/tests/metatag_test.info | 6 +- 29 files changed, 200 insertions(+), 94 deletions(-) diff --git a/www7/sites/all/modules/contrib/metatag/CHANGELOG.txt b/www7/sites/all/modules/contrib/metatag/CHANGELOG.txt index d93024799..182cf8cfe 100644 --- a/www7/sites/all/modules/contrib/metatag/CHANGELOG.txt +++ b/www7/sites/all/modules/contrib/metatag/CHANGELOG.txt @@ -1,3 +1,11 @@ +Metatag 7.x-1.20, 2017-01-18 +---------------------------- +#2840500 by DamienMcKenna: Bring back compatibility with Workbench Moderation + v1. +#2841064 by klausi, DamienMcKenna: Fix sandbox-based update scripts so they + don't run into infinite loops. + + Metatag 7.x-1.19, 2017-01-01 ---------------------------- #2832427 by dmitry.kazberovich, e2thex, DamienMcKenna: Allow the metatag cache diff --git a/www7/sites/all/modules/contrib/metatag/README.txt b/www7/sites/all/modules/contrib/metatag/README.txt index 791f5286a..49aae5897 100644 --- a/www7/sites/all/modules/contrib/metatag/README.txt +++ b/www7/sites/all/modules/contrib/metatag/README.txt @@ -104,8 +104,9 @@ The primary features include: * Integrates with Devel_Generate, part of the Devel module, to automatically generate meta tags for generated nodes, via the Metatag:Devel submodule. -* Integrates with Workbench Moderation (both v1 and v2) allowing meta tags on - nodes to be managed through the workflow process. +* Integrates with Workbench Moderation (v1) allowing meta tags on nodes to be + managed through the workflow process; this custom support is not needed in + Workbench Moderation v3 so the extra logic is automatically ignored. * The Transliteration module (see below) is highly recommended when using image meta tags, e.g. og:image, to ensure that filenames are HTML-safe. diff --git a/www7/sites/all/modules/contrib/metatag/metatag.info b/www7/sites/all/modules/contrib/metatag/metatag.info index 5dc5d54ca..6cfda5b02 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag.info +++ b/www7/sites/all/modules/contrib/metatag/metatag.info @@ -102,9 +102,9 @@ files[] = tests/metatag.with_views.test ; Other test dependencies. test_dependencies[] = context -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag.install b/www7/sites/all/modules/contrib/metatag/metatag.install index 989634929..313e97669 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag.install +++ b/www7/sites/all/modules/contrib/metatag/metatag.install @@ -182,13 +182,12 @@ function metatag_requirements($phase) { } } - // If Workbench Moderation is installed, this only works with v3. + // If Workbench Moderation is installed, show a message if it is out of + // date. if (module_exists('workbench_moderation')) { $wm_module = $module_data['workbench_moderation']; // If the version string is not present then it means the module is // running from git, which means it can't be compared against. - // Alternatively, look for the test file, which was the last commit of - // the 1.6 release. if (!empty($wm_module->info['version'])) { // Versions are in the format 7.x-1.y, so split the string up to find // the 'y' portion. @@ -202,13 +201,13 @@ function metatag_requirements($phase) { $major = 0; } } - // If v3.x is not installed, give an error message. + // If v3.x is not installed, give a message. if ($major < 3) { $requirements['metatag_wm_version'] = array( - 'severity' => REQUIREMENT_ERROR, + 'severity' => REQUIREMENT_INFO, 'title' => 'Metatag', 'value' => $t('Workbench Moderation module is out of date.'), - 'description' => $t('Metatag only works with Workbench Moderation module v7.x-3.0 or newer, otherwise there will be problems when content is changed.'), + 'description' => $t('It is recommended to use Workbench Moderation module v7.x-3.0 or newer.'), ); } } @@ -544,10 +543,17 @@ function metatag_update_replace_entity_tag(&$sandbox, $old_tag, $new_tag) { if (!empty($count)) { $sandbox['progress'] += $count; - $sandbox['#finished'] = min(0.99, $sandbox['progress'] / $sandbox['max']); + // In some cases the query yields results that cannot be fixed and we would + // run into an infinite loop. Stop immediately if we processed all records. + if ($sandbox['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } } else { - $sandbox['#finished'] = 1; + $sandbox['#finished'] = TRUE; return t('Converted the "@old_tag" meta tag for @count entity records to "@new_tag" meta tag.', array('@old_tag' => $old_tag, '@new_tag' => $new_tag, '@count' => $sandbox['progress'])); } } @@ -621,10 +627,17 @@ function metatag_update_replace_entity_value(&$sandbox, $meta_tag, $old_value, $ } if (!empty($count)) { - $sandbox['#finished'] = min(0.99, $sandbox['progress'] / $sandbox['max']); + // In some cases the query yields results that cannot be fixed and we would + // run into an infinite loop. Stop immediately if we processed all records. + if ($sandbox['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } } else { - $sandbox['#finished'] = 1; + $sandbox['#finished'] = TRUE; return t('Replaced the value of @count entity records for the "@meta_tag" meta tag.', array('@meta_tag' => $meta_tag, '@count' => $sandbox['count'])); } } @@ -1142,7 +1155,12 @@ function metatag_update_7011(&$sandbox) { // Set the "finished" status, to tell batch engine whether this function // needs to run again. If you set a float, this will indicate the progress of // the batch so the progress bar will update. - $sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']); + if ($sandbox['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } if ($sandbox['#finished']) { // Clear all caches so the fixed data will be reloaded. @@ -1300,7 +1318,12 @@ function metatag_update_7013(&$sandbox) { // Set the "finished" status, to tell batch engine whether this function // needs to run again. If you set a float, this will indicate the progress of // the batch so the progress bar will update. - $sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']); + if ($sandbox['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } if ($sandbox['#finished']) { // Clear all caches so the fixed data will be reloaded. @@ -1785,7 +1808,12 @@ function metatag_update_7018(&$sandbox) { // Set the "finished" status, to tell batch engine whether this function // needs to run again. If you set a float, this will indicate the progress of // the batch so the progress bar will update. - $sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']); + if ($sandbox['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } if ($sandbox['#finished']) { // Clear all caches so the fixed data will be reloaded. @@ -2153,7 +2181,12 @@ function metatag_update_7040(&$sandbox) { // Set the "finished" status, to tell batch engine whether this function // needs to run again. If you set a float, this will indicate the progress of // the batch so the progress bar will update. - $sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']); + if ($sandbox['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } // Only display a status message if process finished. if ($sandbox['#finished'] === TRUE) { @@ -2336,7 +2369,12 @@ function metatag_update_7104(&$sandbox) { // Set the "finished" status, to tell batch engine whether this function // needs to run again. If you set a float, this will indicate the progress of // the batch so the progress bar will update. - $sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']); + if ($sandbox['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } if ($sandbox['#finished']) { // Clear all caches so the fixed data will be reloaded. @@ -2469,7 +2507,12 @@ function metatag_update_7108(&$sandbox) { // Set the "finished" status, to tell batch engine whether this function // needs to run again. If you set a float, this will indicate the progress of // the batch so the progress bar will update. - $sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']); + if ($sandbox['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } if ($sandbox['#finished']) { // Clear all caches so the fixed data will be reloaded. diff --git a/www7/sites/all/modules/contrib/metatag/metatag.module b/www7/sites/all/modules/contrib/metatag/metatag.module index 42125891d..5fbe3ea66 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag.module +++ b/www7/sites/all/modules/contrib/metatag/metatag.module @@ -893,6 +893,11 @@ function metatag_entity_insert($entity, $entity_type) { unset($entity->metatags[LANGUAGE_NONE]); } + // Support for Workbench Moderation. + if ($entity_type == 'node' && _metatag_isdefaultrevision($entity)) { + return; + } + metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags, $bundle); } } @@ -948,6 +953,11 @@ function metatag_entity_update($entity, $entity_type) { } } + // Support for Workbench Moderation. + if ($entity_type == 'node' && _metatag_isdefaultrevision($entity)) { + return; + } + // Save the record. metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags, $bundle); } @@ -1867,8 +1877,8 @@ function _metatag_entity_is_page($entity_type, $entity) { $uri = entity_uri($entity_type, $entity); $current_path = current_path(); - // Support for Workbench Moderation v1 - if this is a node, check if the - // content type supports moderation. + // Support for Workbench Moderation - if this is a node, check if the content + // type supports moderation. if ($entity_type == 'node' && function_exists('workbench_moderation_node_type_moderated') && workbench_moderation_node_type_moderated($entity->type) === TRUE) { return !empty($uri['path']) && ($current_path == $uri['path'] || $current_path == $uri['path'] . '/draft'); } @@ -2553,6 +2563,50 @@ function metatag_ctools_render_alter(&$info, $page, $context) { } } +/** + * Checks if this entity is the default revision (published). + * + * Only needed when running Workbench Moderation v1; v3 is skipped. + * + * @param object $entity + * The entity object, e.g., $node. + * + * @return bool + * TRUE if the entity is the default revision, FALSE otherwise. + */ +function _metatag_isdefaultrevision($entity) { + // D7 "Forward revisioning" is complex and causes a node_save() with the + // future node in node table. This fires hook_node_update() twice and cause + // abnormal behaviour in metatag. + // + // The steps taken by Workbench Moderation is to save the forward revision + // first and overwrite this with the live version in a shutdown function in + // a second step. This will confuse metatag. D7 has no generic property + // in the node object, if the node that is updated is the 'published' version + // or only a draft of a future version. + // + // This behaviour will change in D8 where $node->isDefaultRevision has been + // introduced. See below links for more details. + // - https://www.drupal.org/node/1879482 + // - https://www.drupal.org/node/218755 + // - https://www.drupal.org/node/1522154 + // + // Every moderation module saving a forward revision needs to return FALSE. + // @todo: Refactor this workaround under D8. + + // Workbench Moderation v1 uses the hook_node_presave() for some custom logic. + // This was replaced with hook_entity_presave() in v3, so only proceed if the + // old hook implementation is present. + if (function_exists('workbench_moderation_node_presave')) { + // If this is a node, check if the content type supports moderation. + if (function_exists('workbench_moderation_node_type_moderated') && workbench_moderation_node_type_moderated($entity->type) === TRUE) { + return !empty($entity->workbench_moderation['updating_live_revision']); + } + } + + return FALSE; +} + /** * Generate the cache ID to use with metatag_cache_get/metatag_cache_set calls. * diff --git a/www7/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info b/www7/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info index 917ce1242..c730a1cda 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info @@ -8,9 +8,9 @@ dependencies[] = metatag files[] = tests/metatag_app_links.test files[] = tests/metatag_app_links.tags.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_context/metatag_context.info b/www7/sites/all/modules/contrib/metatag/metatag_context/metatag_context.info index 4cabc3623..0a895a065 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_context/metatag_context.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_context/metatag_context.info @@ -12,9 +12,9 @@ dependencies[] = context files[] = tests/metatag_context.test files[] = tests/metatag_context.i18n.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.info b/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.info index 082c585ff..264d26c99 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.info @@ -9,9 +9,9 @@ dependencies[] = context dependencies[] = metatag dependencies[] = metatag_context -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.info b/www7/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.info index a61f10493..0ed13ad94 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.info @@ -8,9 +8,9 @@ dependencies[] = metatag files[] = tests/metatag_dc.test files[] = tests/metatag_dc.tags.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.info b/www7/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.info index 699ec7a5e..f41edcf6a 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.info @@ -9,9 +9,9 @@ dependencies[] = metatag_dc files[] = tests/metatag_dc_advanced.test files[] = tests/metatag_dc_advanced.tags.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.info b/www7/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.info index 5b2f352a8..7dd942b9b 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.info @@ -8,9 +8,9 @@ dependencies[] = metatag ; Tests. files[] = tests/metatag_devel.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.info b/www7/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.info index ce3b4edc5..c48f16e76 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.info @@ -8,9 +8,9 @@ dependencies[] = metatag files[] = tests/metatag_facebook.test files[] = tests/metatag_facebook.tags.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.info b/www7/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.info index 5d7887817..93bf8748a 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.info @@ -11,9 +11,9 @@ files[] = metatag_favicons.mask-icon.class.inc files[] = tests/metatag_favicons.test files[] = tests/metatag_favicons.tags.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.info b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.info index 381ea16c5..7fab9af53 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.info @@ -8,9 +8,9 @@ dependencies[] = metatag files[] = tests/metatag_google_cse.test files[] = tests/metatag_google_cse.tags.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info index 2babfa155..94c221f15 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info @@ -11,9 +11,9 @@ files[] = metatag_google_plus.inc files[] = tests/metatag_google_plus.test files[] = tests/metatag_google_plus.tags.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.info b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.info index 6e225dba7..d89117b8e 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.info @@ -17,9 +17,9 @@ test_dependencies[] = devel test_dependencies[] = entity_translation files[] = tests/metatag_hreflang.with_entity_translation.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.info b/www7/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.info index 389e42bb6..f4b940174 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.info @@ -9,9 +9,9 @@ dependencies[] = metatag ; Tests. files[] = tests/metatag_importer.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info b/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info index 815af8f6b..4913f99a5 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info @@ -8,9 +8,9 @@ dependencies[] = metatag files[] = tests/metatag_mobile.test files[] = tests/metatag_mobile.tags.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.info b/www7/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.info index 82ace5751..5663f0cc0 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.info @@ -8,9 +8,9 @@ dependencies[] = metatag files[] = tests/metatag_opengraph.test files[] = tests/metatag_opengraph.tags.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.info b/www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.info index 45fcdf90d..f426485c7 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.info @@ -9,9 +9,9 @@ dependencies[] = metatag_opengraph files[] = tests/metatag_opengraph_products.test files[] = tests/metatag_opengraph_products.tags.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.info b/www7/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.info index ccb2e67d1..8da62ae50 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.info @@ -10,9 +10,9 @@ dependencies[] = panels files[] = tests/metatag_panels.test files[] = tests/metatag_panels.i18n.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.info b/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.info index 0d1cab3ef..e4826f1a1 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.info @@ -10,9 +10,9 @@ dependencies[] = page_manager dependencies[] = metatag dependencies[] = metatag_panels -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.info b/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.info index 5b4848941..23952c579 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.info @@ -8,9 +8,9 @@ dependencies[] = metatag files[] = tests/metatag_twitter_cards.test files[] = tests/metatag_twitter_cards.tags.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.info b/www7/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.info index ce4e81f1c..26652a4a7 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.info @@ -8,9 +8,9 @@ dependencies[] = metatag files[] = tests/metatag_verification.test files[] = tests/metatag_verification.tags.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_views/metatag_views.info b/www7/sites/all/modules/contrib/metatag/metatag_views/metatag_views.info index f8b104a2d..2958293c6 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_views/metatag_views.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_views/metatag_views.info @@ -13,9 +13,9 @@ files[] = metatag_views_plugin_display_extender_metatags.inc files[] = tests/metatag_views.test files[] = tests/metatag_views.i18n.test -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.info b/www7/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.info index f65ec98df..d0e26731a 100644 --- a/www7/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.info +++ b/www7/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.info @@ -9,9 +9,9 @@ dependencies[] = metatag dependencies[] = metatag_views dependencies[] = views -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_workbench_moderation.test b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_workbench_moderation.test index 77f8355e4..98007d550 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag.with_workbench_moderation.test +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag.with_workbench_moderation.test @@ -11,8 +11,8 @@ class MetatagCoreWithWorkbenchModerationTest extends MetatagTestHelper { */ public static function getInfo() { return array( - 'name' => 'Metatag core tests with Workbench Moderation', - 'description' => 'Test Metatag integration with the Workbench Moderation module.', + 'name' => 'Metatag core tests with Workbench Moderation v3', + 'description' => 'Test Metatag integration with the Workbench Moderation module (v3).', 'group' => 'Metatag', 'dependencies' => array('ctools', 'token', 'workbench_moderation'), ); diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag_search_test.info b/www7/sites/all/modules/contrib/metatag/tests/metatag_search_test.info index 325315e9e..6a8e1b2b2 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag_search_test.info +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag_search_test.info @@ -8,9 +8,9 @@ dependencies[] = search_api hidden = TRUE -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" diff --git a/www7/sites/all/modules/contrib/metatag/tests/metatag_test.info b/www7/sites/all/modules/contrib/metatag/tests/metatag_test.info index 19185d752..b525ce4f9 100644 --- a/www7/sites/all/modules/contrib/metatag/tests/metatag_test.info +++ b/www7/sites/all/modules/contrib/metatag/tests/metatag_test.info @@ -7,9 +7,9 @@ hidden = TRUE dependencies[] = metatag -; Information added by Drupal.org packaging script on 2017-01-01 -version = "7.x-1.19" +; Information added by Drupal.org packaging script on 2017-01-18 +version = "7.x-1.20" core = "7.x" project = "metatag" -datestamp = "1483294745" +datestamp = "1484735128" From 5b463b1c5fc920377bf6698dfbad6f9b38c8953e Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Sat, 21 Jan 2017 11:37:04 +0100 Subject: [PATCH 15/16] Update leaflet to 7.x-1.4 --- .../all/modules/contrib/leaflet/README.txt | 4 +- .../modules/contrib/leaflet/leaflet.api.php | 6 ++- .../modules/contrib/leaflet/leaflet.drupal.js | 29 +++++++------- .../all/modules/contrib/leaflet/leaflet.info | 6 +-- .../modules/contrib/leaflet/leaflet.module | 35 +++++++++++++++-- .../leaflet/leaflet_views/leaflet_views.info | 6 +-- .../leaflet_views/leaflet_views.views.inc | 2 +- .../leaflet_views_plugin_style.inc | 38 +++++++++++++++++-- 8 files changed, 93 insertions(+), 33 deletions(-) diff --git a/www7/sites/all/modules/contrib/leaflet/README.txt b/www7/sites/all/modules/contrib/leaflet/README.txt index 611f16e37..f717b778c 100644 --- a/www7/sites/all/modules/contrib/leaflet/README.txt +++ b/www7/sites/all/modules/contrib/leaflet/README.txt @@ -14,7 +14,7 @@ Installation 1. Install the Drupal Leaflet module as per normal. -2. Download the Leaflet library from http://leafletjs.com. Leaflet 0.7.5 or later +2. Download the Leaflet library from http://leafletjs.com. Leaflet 1.0.2 or later is recommended. Extract it to your drupal root /sites/all/libraries/leaflet. The file 'leaflet.js' must reside at /sites/all/libraries/leaflet/leaflet.js. All other files and folder(s) that come with the library are also needed. @@ -93,7 +93,7 @@ In the Description field, select "" and then select a View mode. For a tutorial, please read http://marzeelabs.org/blog/2012/09/24/building-maps-in-drupal-using-leaflet-views/ Roadmap -------- +-------- * UI for managing maps * Better documentation diff --git a/www7/sites/all/modules/contrib/leaflet/leaflet.api.php b/www7/sites/all/modules/contrib/leaflet/leaflet.api.php index a047270d0..f21197b52 100644 --- a/www7/sites/all/modules/contrib/leaflet/leaflet.api.php +++ b/www7/sites/all/modules/contrib/leaflet/leaflet.api.php @@ -13,10 +13,12 @@ * collection of features. * * The settings array maps to the settings available to leaflet map object, - * http://leaflet.cloudmade.com/reference.html#map-properties + * http://leafletjs.com/reference-1.0.2.html#map * * Layers are the available base layers for the map and, if you enable the - * layer control, can be toggled on the map. + * layer control, can be toggled on the map. On top of layers, you can add + * overlays. Overlays are defined just a layers, but have their 'layer_type' + * set to 'overlay'. See drupal.org/project/leaflet_more_maps for examples. * * @return array * Associative array containing a complete leaflet map definition. diff --git a/www7/sites/all/modules/contrib/leaflet/leaflet.drupal.js b/www7/sites/all/modules/contrib/leaflet/leaflet.drupal.js index 2a050d34a..383a6c94b 100644 --- a/www7/sites/all/modules/contrib/leaflet/leaflet.drupal.js +++ b/www7/sites/all/modules/contrib/leaflet/leaflet.drupal.js @@ -6,7 +6,7 @@ $(settings.leaflet).each(function () { // skip to the next iteration if the map already exists var container = L.DomUtil.get(this.mapId); - if (!container || container._leaflet) { + if (!container || container._leaflet_id) { return; } @@ -26,25 +26,24 @@ for (var key in this.map.layers) { var layer = this.map.layers[key]; var map_layer = Drupal.leaflet.create_layer(layer, key); + //layers[key] = map_layer; - layers[key] = map_layer; - - // keep the reference of first layer - // Distinguish between "base layers" and "overlays", fallback to "base" - // in case "layer_type" has not been defined in hook_leaflet_map_info() + // Distinguish between "base layers" and "overlays". + // Fall back to "base" in case "layer_type" has not been defined in + // hook_leaflet_map_info() layer.layer_type = (typeof layer.layer_type === 'undefined') ? 'base' : layer.layer_type; - // as written in the doc (http://leafletjs.com/examples/layers-control.html) - // Always add overlays layers when instantiate, and keep track of - // them for Control.Layers. - // Only add the very first "base layer" when instantiating the map - // if we have map controls enabled + // As stated in http://leafletjs.com/examples/layers-control, + // when using multiple base layers, only one of them should be added + // to the map at instantiation, but all of them should be present in + // the base layers object when creating the layers control. + // See statement L.control.layers(layers, overlays) much further below. switch (layer.layer_type) { case 'overlay': - lMap.addLayer(map_layer); + //lMap.addLayer(map_layer); overlays[key] = map_layer; break; default: - if (i === 0 || !this.map.settings.layerControl) { + if (i === 0 /*|| !this.map.settings.layerControl*/) { lMap.addLayer(map_layer); i++; } @@ -53,7 +52,7 @@ } i++; } - // We loop through the layers once they have all been created to connect them to their switchlayer if necessary. + var switchEnable = false; for (var key in layers) { if (layers[key].options.switchLayer) { @@ -112,7 +111,7 @@ // add layer switcher if (this.map.settings.layerControl) { - lMap.addControl(new L.Control.Layers(layers, overlays)); + L.control.layers(layers, overlays).addTo(lMap); } // center the map diff --git a/www7/sites/all/modules/contrib/leaflet/leaflet.info b/www7/sites/all/modules/contrib/leaflet/leaflet.info index 9cfe92607..e4d2c9b16 100644 --- a/www7/sites/all/modules/contrib/leaflet/leaflet.info +++ b/www7/sites/all/modules/contrib/leaflet/leaflet.info @@ -7,9 +7,9 @@ dependencies[] = libraries files[] = leaflet.formatters.inc -; Information added by Drupal.org packaging script on 2015-10-09 -version = "7.x-1.3" +; Information added by Drupal.org packaging script on 2017-01-20 +version = "7.x-1.4" core = "7.x" project = "leaflet" -datestamp = "1444353929" +datestamp = "1484885587" diff --git a/www7/sites/all/modules/contrib/leaflet/leaflet.module b/www7/sites/all/modules/contrib/leaflet/leaflet.module index 6da7358a9..74ada78fb 100644 --- a/www7/sites/all/modules/contrib/leaflet/leaflet.module +++ b/www7/sites/all/modules/contrib/leaflet/leaflet.module @@ -7,6 +7,30 @@ module_load_include('inc', 'leaflet', 'leaflet.formatters'); +/** + * Implements hook_help(). + */ +function leaflet_help($path, $arg) { + switch ($path) { + case 'admin/help#leaflet': + $output = ''; + $output .= '

      ' . t('About') . '

      '; + $output .= '

      ' . t('The Leaflet module provides integration with Leaflet, the modern open-source JavaScript library for mobile-friendly interactive maps.') . '

      '; + + $output .= '

      ' . t('The module provides a field formatter that can show a map for fields that contain geospatial data. It includes Views integration that plots data on a map (using the sub module Leaflet Views) and an API for displaying data on a map. For more information, see the online documentation for the Leaflet module.', array('@leaflet' => 'http://drupal.org/node/1645460')) . '

      '; + + $output .= '

      ' . t('Uses') . '

      '; + $output .= '
      '; + $output .= '
      ' . t('Field Formatter') . '
      '; + $output .= '
      ' . t('Leaflet includes a field formatter that makes it possible to show geospatial data (for example longitude and latitude) on a map. You can use tokens instead of static text for Popups that use the Leaflet field formatter.') . '
      '; + $output .= '
      ' . t('Views Integration') . '
      '; + $output .= '
      ' . t('You can have maps on node displays and maps on views displays, thanks to Views integration. The process is very similar to adding and setting up a plugin on Views. To render a map using Views, enable the included module Leaflet_views.') . '
      '; + $output .= '
      ' . t('Leaflet API') . '
      '; + $output .= '
      ' . t('Rendering a map is as simple as calling a single method, leaflet_render_map(), which takes 3 parameters $map, $features, and $height.') . '
      '; + return $output; + } +} + /** * Implements hook_theme(). */ @@ -27,10 +51,10 @@ function leaflet_libraries_info() { // Only used in administrative UI of Libraries API. 'name' => 'Leaflet JavaScript Library', 'vendor url' => 'http://leafletjs.com/', - 'download url' => 'http://cdn.leafletjs.com/downloads/leaflet-0.7.5.zip', + 'download url' => 'http://cdn.leafletjs.com/leaflet/v1.0.2/leaflet.zip', 'version arguments' => array( 'file' => 'leaflet.js', - // Handle things like version:"1.0.0-beta.2" + // Handle patterns like version: "1.0.2+4bbb16c" 'pattern' => '/version[=: ]*[\'"]([\d+\.]+[\-a-z\.\d]*)[\'"]/', ), 'files' => array( @@ -48,7 +72,8 @@ function leaflet_libraries_info() { // For AdvAgg module. See [#2294639] This runs after leaflet.js. 'leaflet_imagepath' => array( 'type' => 'inline', - 'data' => 'L.Icon.Default.imagePath = "' . base_path() . libraries_get_path('leaflet') . '/images";', + // Note: ends with "/" + 'data' => 'L.Icon.Default.imagePath = "' . base_path() . libraries_get_path('leaflet') . '/images/";', ), ), 'css' => array( @@ -88,7 +113,9 @@ function leaflet_libraries_info() { * A renderable array. */ function leaflet_build_map($map, $features = array(), $height = '400px') { - $map_id = drupal_html_id('leaflet_map'); + // [#2777321] With two maps on 1 page, drupal_html_id() sometimes fails to + // return a unique id. Make it so. + $map_id = drupal_html_id('leaflet_map') . '-' . rand(); $build = array( '#theme' => 'html_tag', '#tag' => 'div', diff --git a/www7/sites/all/modules/contrib/leaflet/leaflet_views/leaflet_views.info b/www7/sites/all/modules/contrib/leaflet/leaflet_views/leaflet_views.info index d22543c9d..b01218669 100644 --- a/www7/sites/all/modules/contrib/leaflet/leaflet_views/leaflet_views.info +++ b/www7/sites/all/modules/contrib/leaflet/leaflet_views/leaflet_views.info @@ -8,9 +8,9 @@ dependencies[] = entity files[] = leaflet_views.views.inc files[] = leaflet_views_plugin_style.inc -; Information added by Drupal.org packaging script on 2015-10-09 -version = "7.x-1.3" +; Information added by Drupal.org packaging script on 2017-01-20 +version = "7.x-1.4" core = "7.x" project = "leaflet" -datestamp = "1444353929" +datestamp = "1484885587" diff --git a/www7/sites/all/modules/contrib/leaflet/leaflet_views/leaflet_views.views.inc b/www7/sites/all/modules/contrib/leaflet/leaflet_views/leaflet_views.views.inc index 073f463be..3364aa7a1 100644 --- a/www7/sites/all/modules/contrib/leaflet/leaflet_views/leaflet_views.views.inc +++ b/www7/sites/all/modules/contrib/leaflet/leaflet_views/leaflet_views.views.inc @@ -19,7 +19,7 @@ function leaflet_views_views_plugins() { 'help' => t('Displays a View as a Leaflet map.'), 'path' => drupal_get_path('module', 'leaflet_views'), 'handler' => 'leaflet_views_plugin_style', - 'theme' => 'leaflet-map', + 'theme' => 'leaflet_map', 'uses fields' => TRUE, 'uses row plugin' => FALSE, 'uses options' => TRUE, diff --git a/www7/sites/all/modules/contrib/leaflet/leaflet_views/leaflet_views_plugin_style.inc b/www7/sites/all/modules/contrib/leaflet/leaflet_views/leaflet_views_plugin_style.inc index 4b9598901..10fdd39e0 100644 --- a/www7/sites/all/modules/contrib/leaflet/leaflet_views/leaflet_views_plugin_style.inc +++ b/www7/sites/all/modules/contrib/leaflet/leaflet_views/leaflet_views_plugin_style.inc @@ -18,14 +18,34 @@ class leaflet_views_plugin_style extends views_plugin_style { // Fallback for views that do not have entity_type set, for example // because the view was created before this option got introduced. if (empty($this->entity_type)) { - $info = entity_get_info($view->base_table); + $info = $this->getEntityInfoByTable($view->base_table); if (!empty($info)) { - $this->entity_type = $view->base_table; + $this->entity_type = $info['entity type']; $this->entity_info = $info; } } } + /** + * Gets entity information based on the entity table passed in. + * + * @param string $table + * Table name. + * + * @return array + * Returns the entity_info array. + */ + function getEntityInfoByTable($table) { + $info = entity_get_info(); + foreach($info as $entity_type => &$entity_info) { + if($entity_info['base table'] == $table) { + $entity_info['entity type'] = $entity_type; + return $entity_info; + } + } + return array(); + } + /** * Set default options. */ @@ -278,9 +298,14 @@ class leaflet_views_plugin_style extends views_plugin_style { if (!empty($result->{$this->entity_info['entity keys']['id']})) { $entity_id = $result->{$this->entity_info['entity keys']['id']}; } - elseif ($result->entity) { + elseif (isset($result->entity)) { $entity_id = $result->entity; } + elseif (isset($result->_field_data)) { + $tmp = $result->_field_data; + $tmp = array_pop($tmp); + $entity_id = $tmp['entity']->{$this->entity_info['entity keys']['id']}; + } $entity = entity_load_single($this->entity_type, $entity_id); if ($this->options['description_field'] === '#rendered_entity') { $build = entity_view($this->entity_type, array($entity), $this->options['view_mode']); @@ -336,4 +361,11 @@ class leaflet_views_plugin_style extends views_plugin_style { } return; } + + /** + * {@inheritdoc} + */ + function even_empty() { + return !$this->options['hide_empty']; + } } From ea0b93902cc73576593c5186b056a4a66d71767d Mon Sep 17 00:00:00 2001 From: Florent Torregrosa Date: Sat, 21 Jan 2017 11:37:45 +0100 Subject: [PATCH 16/16] Update leaflet library to 1.0.2 --- .../libraries/leaflet/images/layers-2x.png | Bin 0 -> 1259 bytes .../all/libraries/leaflet/images/layers.png | Bin 0 -> 696 bytes .../leaflet/images/marker-icon-2x.png | Bin 0 -> 2586 bytes .../libraries/leaflet/images/marker-icon.png | Bin 0 -> 1466 bytes .../leaflet/images/marker-shadow.png | Bin 0 -> 618 bytes .../all/libraries/leaflet/leaflet-src.js | 13170 ++++++++++++++++ .../all/libraries/leaflet/leaflet-src.map | 1 + www7/sites/all/libraries/leaflet/leaflet.css | 216 +- www7/sites/all/libraries/leaflet/leaflet.js | 9 + 9 files changed, 13361 insertions(+), 35 deletions(-) create mode 100644 www7/sites/all/libraries/leaflet/images/layers-2x.png create mode 100644 www7/sites/all/libraries/leaflet/images/layers.png create mode 100644 www7/sites/all/libraries/leaflet/images/marker-icon-2x.png create mode 100644 www7/sites/all/libraries/leaflet/images/marker-icon.png create mode 100644 www7/sites/all/libraries/leaflet/images/marker-shadow.png create mode 100644 www7/sites/all/libraries/leaflet/leaflet-src.js create mode 100644 www7/sites/all/libraries/leaflet/leaflet-src.map create mode 100644 www7/sites/all/libraries/leaflet/leaflet.js diff --git a/www7/sites/all/libraries/leaflet/images/layers-2x.png b/www7/sites/all/libraries/leaflet/images/layers-2x.png new file mode 100644 index 0000000000000000000000000000000000000000..200c333dca9652ac4cba004d609e5af4eee168c1 GIT binary patch literal 1259 zcmVFhCYNy;#0irRPomHqW|G1C*;4?@4#E?jH>?v@U%cy?3dQAc-DchXVErpOh~ z-jbon+tNbnl6hoEb;)TVk+%hTDDi_G%i3*RZ&15!$Fjr^f;Ke&A@|?=`2&+{zr+3a z{D*=t(`AXyS%X7N z%a#RZw6vD^t_rnM`L4E>m=U&R!A-&}nZIi$BOPvkhrCuUe@BN~-lRD)f44;J%TwgE zcze8u!PQ_NR7?o(NylLXVTfDO zxs5=@|GsYEsNo4M#nT%N!UE(?dnS)t2+{ELYAFp*3=iF=|EQnTp`#vlSXuGVraYo? z+RCzXo6h3qA8{KG?S4nE(lM+;Eb4nT3XV;7gcAxUi5m)`k5tv}cPy()8ZR3TLW3I- zAS^}cq-IJvL7a4RgR!yk@~RT%$lA7{L5ES*hyx)M4(yxI$Ub(4f)K|^v1>zvwQY!_ zIrWw8q9GS^!Dp~}+?mbnB6jDF8mVlbQ!jFKDY;w=7;XO{9bq7>LXGK24WA`;rL)_Z z)&j}pbV(;6gY;VMhbxgvn`X;6x}VUEE-7 z%)7j-%t8S=ZL3yc)HbXDAqJZvBTPoiW_A-+a8m3_Z?v{DN7Tnr#O_VUMT0UBt$;p` zDh6JbGHN8JJ*JN%y2%msb97@_S>9!%Egwk;?PEkU9ntz&3uR}%Fj5d$JHQbQb3}a{ zSzFT^#n=VInPpcAS}CNxj?_ zVscANk5Cfz(51EI1pz};AWWb|kgbYNb4wCEGUn3+eMUMV?1-{=I4TlmLJMot@rd07 zZuo2hk1ccu{YmGkcYdWAVdk{Z4Nm?^cTD&}jGm+Q1SYIXMwmG*oO*83&#>l%nbR`G zhh=lZ%xIb7kU3#;TBbfECrnC9P=-XpL|TG2BoZdj61*XiFbW8?1Z_wp%#;>${SUIy V$8qr;L*)Pf002ovPDHLkV1hYLS~36t literal 0 HcmV?d00001 diff --git a/www7/sites/all/libraries/leaflet/images/layers.png b/www7/sites/all/libraries/leaflet/images/layers.png new file mode 100644 index 0000000000000000000000000000000000000000..1a72e5784b2b456eac5d7670738db80697af3377 GIT binary patch literal 696 zcmV;p0!RIcP)*@&l2<6p=!C&s@#ZL+%BQvF&b?w6S%wp=I>1QHj7AP5C)IWy#b znXXB;g;j=$a-tW89K%FbDceHVq&unY*Wx3L#=EGWH=rjqnp|4c_Ulec!ql3#G-5ZF zVlbBA@XP=)C8U&+Lrc)S4O5%1$&{(;7R^K(CSnvSr$v;+B$8q&7Bf|h$#PARo1^%M zf1H^nG-EiXVXr07OH(*8R)xa|FD;lXUlg_-%)~ZGsL2cX0NXaAzN2q%jqLRR6ruVk8`Jb7n#{`T;o@`F= z#3YcynIR^s83UNF3D!f5m#Mg)NJ24&Qfrqb&_z=yF;=B)#9Iq7u-@^O!(mW{D;qvr zPc)gVb%aowtS8m@ElL4A9G>w#ffQ~q{i&_i)*6f^)Sz|C?C>zb4Uo?H<-&Hz@a?J; z$ml@zGygWofb9$ZBj6aLjpLhsT2AzjOu=-*u_gSCULuqp7Vds@BKcX=lOk~^Pb;%&wG9p3o}FL;Zuhp5D3)R z2yY2yCGfH2=LJmOkQw^9n>daF6?Fz>oOD64$CM+_T`j0x%{zb|G zWolt{H|diO#S`|$6RM$ zYQuE4RW{2yZ`>fAt>jzyYyOB?)~HrQBlbbLT5yF%Xq8FEuzo80dd{%Q!{_)^mTE`^ z2$xe>TH$qiDJ+}(ajTp$Y*4vgGRrt^_?JwUO3+hm&{Mb<8aRtf7%F@*!JJv* zmcB*cag=-t4U&g79u1krRAKHHm?ZXHP8z-#KdAM9?vU7sxldD%A5;r0Rk~kblro}5 z9YhoJP18m~=v^kMBWPltYTV$TD;r4n^eZVWmDs^6;ZN_RG+a#^(N18a+%xd;JvScL zu54_hiMdFR4767cmcp!KOryQBQG{$|3e)h(z_sY-NRM>A$84n-CdxAt6V242bQmV| z86*uGCJtVTXCvLyz=eM@jE-Vz#IeA4DY~VhqL`R_>D;YIh9amQX~+l$Sfbohb*X)d zKiDG!?8t|64T_+_Jzbv6K)P|KG-6qDVGPYUwpPqb#c;-juz~ZW0bFF4JlB>cOB#?3 z9XJ~@0J1u{T_(66oVpmpLOkqOk6}qY=vN7820OS|_L-o5(4!i~Ivv=j{IKzS2m>C_ zhm9Npo09&0s*wy#K%InNpSW)yCZOhAFheUQtcXnn!x)WSjonNUm7@fguKPg0C3ESs~`Bd3Pyd$@XU8m z0JZWv0l=fZ{{jH?{!9Nt!mEGL|9_Oug?i>9H?4E!|Krk+(hy9WRiM;!>w8@J9&fq& z${#rK1z4j2$*KVGO=b{ivL6FFEPprv0No7|9RPB_H>dzW{;{(>P`XWmKn^Y#<8`e9 zc*;k@X>z(^khkvlh3UB1ICnF@RRHbZaQhkI;sl{txVGnBEzaFKZpw96Fm8qu^5@!a z+db!omc48o>}VvJr!j9Mpo^ZMPs2FKikZu-3edWhZ~5&Mp15G60gsVYic)|~eH4Q6 zF8d5^efqo~DD}CwRpRO|j91O-zygw(bv;<>V5MDzeC#nk zosJI@GCU;ylx)tp87H~!5Gl8^4UxdZ-ZLrRy7g=zwjIe|v>O(6W-QBuv-7h4HTLcz&ce9H!^9o^4XLD_t08@f%uD+tdxMAHzHi z6>y1>XBw|wNRu9u6j`13s*X9iz%Z1zep^?+<}$-U*uzd9$?LD0QWc+GSyhyvx<?!6YcvM{vC6CN2-dD>XyCsuOMe zdjA0H)tFMHvR%5Uqd_swkzDP0t5)bhy5xwusp(WsD}~`13N0NuN78MHcc03G_@3v- zZOvStb!W8+G+$o+mNh5)?USue0<9~5nql|l&C!mcb^cmUZGk2gF&p9IOMcs@2-WZX z+M_WESiwx34!IyuOY(`!=Sit;If5uuYqSJm`D>ogL1P7x5=v2W{zicaAxUs>WGzTn zQv?x3HR!VK$IB{-D-)cU&hLE;M2}umynSZBHRVLCW#WkaY>!>~#*V;;^Ck!H4Swwp zDHCGo7gMu}4-?)ga$s&da$6}|l&eSgpl~CnG5lbg z7&|&nHy^@(l0;d(4qw!>Pc+03BPqwvhV@DjJr)KAb74dUY>mzPErgW+cGhAfAE(Hx zg7S551PZuugrt1qVHk*xE*1`NeDO|ZnOO1ye(Ps{N=r+Q=S*|(%4dYb+TIr5*H@Ka z&IFce5q4snQ7O4sQm?Pxu??B#U>#Bu+HC!Ti{Sl150Y#4pk06Ac+lU@`2YRqk-uHH zZoIWi#kr-H+gi|P?w*2JMQ7U)c>*fCAPTksemc#0N4+Zgz+o*bN1@=(#&Q(RLz+r2 zQx|up>q>^w^^^t*`_3bp*JBDwCvP3iT>oMu+dLrW{Yd*GhC1Kx;_L$zF%*j;?iDxZ zrao$m-Bw;}qtlD8Ts>}{*(A|it9iEx_ZRY$yVv3y#q}J<;l}p;3_y0NqKJBW%sac- z#s<-=rSr4%CNFQcuf<8$A3ba|hx+!=-B0jwr*}bFG1p0OLTqz#DYd z16dVY=E5n{UkaA*7{FAF7c$=SE0gV@(AxW_6rfOFvBFyfQpO=ChwyqQo?nZOT`6__ zP3(sCcoy|xktOO{hUoSFKDM)^*yWXvlS$9yTyC~k^q#t~$$O;oU_E7XGiY~S^b+mS zVh=RZHn+0(T-ooM5xx%AW=ZUqv zgKQURIr-z7x5ejdVPYlT>F)dyou|#!MM#5qXK_BVQyz*bJ!*A&^rr((=SaeGlUNwV z01+e{DcnsPPIth+gTfMc34NrqGRM-T5f0=)<0vZ6?K`I0Z1Y3GdqxI|$iyh%qoeNX UQO-*oc+)|Q_08}VdXD6O0C*xx%>V!Z literal 0 HcmV?d00001 diff --git a/www7/sites/all/libraries/leaflet/images/marker-icon.png b/www7/sites/all/libraries/leaflet/images/marker-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..950edf24677ded147df13b26f91baa2b0fa70513 GIT binary patch literal 1466 zcmV;r1x5OaP)P001cn1^@s6z>|W`000GnNklGNuHDcIX17Zdjl&3`L?0sTjIws<{((Dh&g-s0<@jYQyl?D*X^?%13;ml^gy> ziMrY_^1WI=(g@LMizu=zCoA>C`6|QEq1eV92k*7m>G65*&@&6)aC&e}G zI)pf-Za|N`DT&Cn1J|o`19mumxW~hiKiKyc-P`S@q)rdTo84@QI@;0yXrG%9uhI>A zG5QHb6s4=<6xy{1 z@NMxEkryp{LS44%z$3lP^cX!9+2-;CTt3wM4(k*#C{aiIiLuB>jJj;KPhPzIC00bL zU3a#;aJld94lCW=`4&aAy8M7PY=HQ>O%$YEP4c4UY#CRxfgbE~(|uiI=YS8q;O9y6 zmIkXzR`}p7ti|PrM3a}WMnR=3NVnWdAAR>b9X@)DKL6=YsvmH%?I24wdq?Gh54_;# z$?_LvgjEdspdQlft#4CQ z`2Zyvy?*)N1Ftw|{_hakhG9WjS?Az@I@+IZ8JbWewR!XUK4&6346+d#~gsE0SY(LX8&JfY>Aj)RxGy96nwhs2rv zzW6pTnMpFkDSkT*a*6Dx|u@ds6ISVn0@^RmIsKZ5Y;bazbc;tTSq(kg(=481ODrPyNB6n z-$+U}(w$m6U6H$w17Bw+wDaFIe~GvNMYvnw31MpY0eQKT9l>SU``8k7w4)z!GZKMI z#_cEKq7k~i%nlK@6c-K?+R;B#5$?T#YpKD`t_4bAs^#E+@5QW$@OX3*`;(#{U^d-vY)&xEE>n5lYl&T?Amke9$Lam@{1K@O ze*LXqlKQHiv=gx+V^Cbb2?z@ISBQ*3amF;9UJ3SBg(N|710TLamQmYZ&Qjn2LuO<* zCZlB4n%@pc&7NNnY1}x+NWpHlq`OJEo|`aYN9<`RBUB+79g;>dgb6YlfN#kGL?lO_ z!6~M^7sOnbsUkKk<@Ysie&`G>ruxH&Mgy&8;i=A zB9OO!xR{AyODw>DS-q5YM{0ExFEAzt zm>RdS+ssW(-8|?xr0(?$vBVB*%(xDLtq3Hf0I5yFm<_g=W2`QWAax{1rWVH=I!VrP zs(rTFX@W#t$hXNvbgX`gK&^w_YD;CQ!B@e0QbLIWaKAXQe2-kkloo;{iF#6}z!4=W zi$giRj1{ zt;2w`VSCF#WE&*ev7jpsC=6175@(~nTE2;7M-L((0bH@yG}-TB$R~WXd?tA$s3|%y zA`9$sA(>F%J3ioz<-LJl*^o1|w84l>HBR`>3l9c8$5Xr@xCiIQ7{x$fMCzOk_-M=% z+{a_Q#;42`#KfUte@$NT77uaTz?b-fBe)1s5XE$yA79fm?KqM^VgLXD07*qoM6N<$ Ef<_J(9smFU literal 0 HcmV?d00001 diff --git a/www7/sites/all/libraries/leaflet/leaflet-src.js b/www7/sites/all/libraries/leaflet/leaflet-src.js new file mode 100644 index 000000000..fc71cfe03 --- /dev/null +++ b/www7/sites/all/libraries/leaflet/leaflet-src.js @@ -0,0 +1,13170 @@ +/* + Leaflet 1.0.2+4bbb16c, a JS library for interactive maps. http://leafletjs.com + (c) 2010-2016 Vladimir Agafonkin, (c) 2010-2011 CloudMade +*/ +(function (window, document, undefined) { +var L = { + version: "1.0.2+4bbb16c" +}; + +function expose() { + var oldL = window.L; + + L.noConflict = function () { + window.L = oldL; + return this; + }; + + window.L = L; +} + +// define Leaflet for Node module pattern loaders, including Browserify +if (typeof module === 'object' && typeof module.exports === 'object') { + module.exports = L; + +// define Leaflet as an AMD module +} else if (typeof define === 'function' && define.amd) { + define(L); +} + +// define Leaflet as a global L variable, saving the original L to restore later if needed +if (typeof window !== 'undefined') { + expose(); +} + + + +/* + * @namespace Util + * + * Various utility functions, used by Leaflet internally. + */ + +L.Util = { + + // @function extend(dest: Object, src?: Object): Object + // Merges the properties of the `src` object (or multiple objects) into `dest` object and returns the latter. Has an `L.extend` shortcut. + extend: function (dest) { + var i, j, len, src; + + for (j = 1, len = arguments.length; j < len; j++) { + src = arguments[j]; + for (i in src) { + dest[i] = src[i]; + } + } + return dest; + }, + + // @function create(proto: Object, properties?: Object): Object + // Compatibility polyfill for [Object.create](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/create) + create: Object.create || (function () { + function F() {} + return function (proto) { + F.prototype = proto; + return new F(); + }; + })(), + + // @function bind(fn: Function, …): Function + // Returns a new function bound to the arguments passed, like [Function.prototype.bind](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). + // Has a `L.bind()` shortcut. + bind: function (fn, obj) { + var slice = Array.prototype.slice; + + if (fn.bind) { + return fn.bind.apply(fn, slice.call(arguments, 1)); + } + + var args = slice.call(arguments, 2); + + return function () { + return fn.apply(obj, args.length ? args.concat(slice.call(arguments)) : arguments); + }; + }, + + // @function stamp(obj: Object): Number + // Returns the unique ID of an object, assiging it one if it doesn't have it. + stamp: function (obj) { + /*eslint-disable */ + obj._leaflet_id = obj._leaflet_id || ++L.Util.lastId; + return obj._leaflet_id; + /*eslint-enable */ + }, + + // @property lastId: Number + // Last unique ID used by [`stamp()`](#util-stamp) + lastId: 0, + + // @function throttle(fn: Function, time: Number, context: Object): Function + // Returns a function which executes function `fn` with the given scope `context` + // (so that the `this` keyword refers to `context` inside `fn`'s code). The function + // `fn` will be called no more than one time per given amount of `time`. The arguments + // received by the bound function will be any arguments passed when binding the + // function, followed by any arguments passed when invoking the bound function. + // Has an `L.bind` shortcut. + throttle: function (fn, time, context) { + var lock, args, wrapperFn, later; + + later = function () { + // reset lock and call if queued + lock = false; + if (args) { + wrapperFn.apply(context, args); + args = false; + } + }; + + wrapperFn = function () { + if (lock) { + // called too soon, queue to call later + args = arguments; + + } else { + // call and lock until later + fn.apply(context, arguments); + setTimeout(later, time); + lock = true; + } + }; + + return wrapperFn; + }, + + // @function wrapNum(num: Number, range: Number[], includeMax?: Boolean): Number + // Returns the number `num` modulo `range` in such a way so it lies within + // `range[0]` and `range[1]`. The returned value will be always smaller than + // `range[1]` unless `includeMax` is set to `true`. + wrapNum: function (x, range, includeMax) { + var max = range[1], + min = range[0], + d = max - min; + return x === max && includeMax ? x : ((x - min) % d + d) % d + min; + }, + + // @function falseFn(): Function + // Returns a function which always returns `false`. + falseFn: function () { return false; }, + + // @function formatNum(num: Number, digits?: Number): Number + // Returns the number `num` rounded to `digits` decimals, or to 5 decimals by default. + formatNum: function (num, digits) { + var pow = Math.pow(10, digits || 5); + return Math.round(num * pow) / pow; + }, + + // @function trim(str: String): String + // Compatibility polyfill for [String.prototype.trim](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim) + trim: function (str) { + return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ''); + }, + + // @function splitWords(str: String): String[] + // Trims and splits the string on whitespace and returns the array of parts. + splitWords: function (str) { + return L.Util.trim(str).split(/\s+/); + }, + + // @function setOptions(obj: Object, options: Object): Object + // Merges the given properties to the `options` of the `obj` object, returning the resulting options. See `Class options`. Has an `L.setOptions` shortcut. + setOptions: function (obj, options) { + if (!obj.hasOwnProperty('options')) { + obj.options = obj.options ? L.Util.create(obj.options) : {}; + } + for (var i in options) { + obj.options[i] = options[i]; + } + return obj.options; + }, + + // @function getParamString(obj: Object, existingUrl?: String, uppercase?: Boolean): String + // Converts an object into a parameter URL string, e.g. `{a: "foo", b: "bar"}` + // translates to `'?a=foo&b=bar'`. If `existingUrl` is set, the parameters will + // be appended at the end. If `uppercase` is `true`, the parameter names will + // be uppercased (e.g. `'?A=foo&B=bar'`) + getParamString: function (obj, existingUrl, uppercase) { + var params = []; + for (var i in obj) { + params.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i])); + } + return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&'); + }, + + // @function template(str: String, data: Object): String + // Simple templating facility, accepts a template string of the form `'Hello {a}, {b}'` + // and a data object like `{a: 'foo', b: 'bar'}`, returns evaluated string + // `('Hello foo, bar')`. You can also specify functions instead of strings for + // data values — they will be evaluated passing `data` as an argument. + template: function (str, data) { + return str.replace(L.Util.templateRe, function (str, key) { + var value = data[key]; + + if (value === undefined) { + throw new Error('No value provided for variable ' + str); + + } else if (typeof value === 'function') { + value = value(data); + } + return value; + }); + }, + + templateRe: /\{ *([\w_\-]+) *\}/g, + + // @function isArray(obj): Boolean + // Compatibility polyfill for [Array.isArray](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray) + isArray: Array.isArray || function (obj) { + return (Object.prototype.toString.call(obj) === '[object Array]'); + }, + + // @function indexOf(array: Array, el: Object): Number + // Compatibility polyfill for [Array.prototype.indexOf](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) + indexOf: function (array, el) { + for (var i = 0; i < array.length; i++) { + if (array[i] === el) { return i; } + } + return -1; + }, + + // @property emptyImageUrl: String + // Data URI string containing a base64-encoded empty GIF image. + // Used as a hack to free memory from unused images on WebKit-powered + // mobile devices (by setting image `src` to this string). + emptyImageUrl: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=' +}; + +(function () { + // inspired by http://paulirish.com/2011/requestanimationframe-for-smart-animating/ + + function getPrefixed(name) { + return window['webkit' + name] || window['moz' + name] || window['ms' + name]; + } + + var lastTime = 0; + + // fallback for IE 7-8 + function timeoutDefer(fn) { + var time = +new Date(), + timeToCall = Math.max(0, 16 - (time - lastTime)); + + lastTime = time + timeToCall; + return window.setTimeout(fn, timeToCall); + } + + var requestFn = window.requestAnimationFrame || getPrefixed('RequestAnimationFrame') || timeoutDefer, + cancelFn = window.cancelAnimationFrame || getPrefixed('CancelAnimationFrame') || + getPrefixed('CancelRequestAnimationFrame') || function (id) { window.clearTimeout(id); }; + + + // @function requestAnimFrame(fn: Function, context?: Object, immediate?: Boolean): Number + // Schedules `fn` to be executed when the browser repaints. `fn` is bound to + // `context` if given. When `immediate` is set, `fn` is called immediately if + // the browser doesn't have native support for + // [`window.requestAnimationFrame`](https://developer.mozilla.org/docs/Web/API/window/requestAnimationFrame), + // otherwise it's delayed. Returns a request ID that can be used to cancel the request. + L.Util.requestAnimFrame = function (fn, context, immediate) { + if (immediate && requestFn === timeoutDefer) { + fn.call(context); + } else { + return requestFn.call(window, L.bind(fn, context)); + } + }; + + // @function cancelAnimFrame(id: Number): undefined + // Cancels a previous `requestAnimFrame`. See also [window.cancelAnimationFrame](https://developer.mozilla.org/docs/Web/API/window/cancelAnimationFrame). + L.Util.cancelAnimFrame = function (id) { + if (id) { + cancelFn.call(window, id); + } + }; +})(); + +// shortcuts for most used utility functions +L.extend = L.Util.extend; +L.bind = L.Util.bind; +L.stamp = L.Util.stamp; +L.setOptions = L.Util.setOptions; + + + + +// @class Class +// @aka L.Class + +// @section +// @uninheritable + +// Thanks to John Resig and Dean Edwards for inspiration! + +L.Class = function () {}; + +L.Class.extend = function (props) { + + // @function extend(props: Object): Function + // [Extends the current class](#class-inheritance) given the properties to be included. + // Returns a Javascript function that is a class constructor (to be called with `new`). + var NewClass = function () { + + // call the constructor + if (this.initialize) { + this.initialize.apply(this, arguments); + } + + // call all constructor hooks + this.callInitHooks(); + }; + + var parentProto = NewClass.__super__ = this.prototype; + + var proto = L.Util.create(parentProto); + proto.constructor = NewClass; + + NewClass.prototype = proto; + + // inherit parent's statics + for (var i in this) { + if (this.hasOwnProperty(i) && i !== 'prototype') { + NewClass[i] = this[i]; + } + } + + // mix static properties into the class + if (props.statics) { + L.extend(NewClass, props.statics); + delete props.statics; + } + + // mix includes into the prototype + if (props.includes) { + L.Util.extend.apply(null, [proto].concat(props.includes)); + delete props.includes; + } + + // merge options + if (proto.options) { + props.options = L.Util.extend(L.Util.create(proto.options), props.options); + } + + // mix given properties into the prototype + L.extend(proto, props); + + proto._initHooks = []; + + // add method for calling all hooks + proto.callInitHooks = function () { + + if (this._initHooksCalled) { return; } + + if (parentProto.callInitHooks) { + parentProto.callInitHooks.call(this); + } + + this._initHooksCalled = true; + + for (var i = 0, len = proto._initHooks.length; i < len; i++) { + proto._initHooks[i].call(this); + } + }; + + return NewClass; +}; + + +// @function include(properties: Object): this +// [Includes a mixin](#class-includes) into the current class. +L.Class.include = function (props) { + L.extend(this.prototype, props); + return this; +}; + +// @function mergeOptions(options: Object): this +// [Merges `options`](#class-options) into the defaults of the class. +L.Class.mergeOptions = function (options) { + L.extend(this.prototype.options, options); + return this; +}; + +// @function addInitHook(fn: Function): this +// Adds a [constructor hook](#class-constructor-hooks) to the class. +L.Class.addInitHook = function (fn) { // (Function) || (String, args...) + var args = Array.prototype.slice.call(arguments, 1); + + var init = typeof fn === 'function' ? fn : function () { + this[fn].apply(this, args); + }; + + this.prototype._initHooks = this.prototype._initHooks || []; + this.prototype._initHooks.push(init); + return this; +}; + + + +/* + * @class Evented + * @aka L.Evented + * @inherits Class + * + * A set of methods shared between event-powered classes (like `Map` and `Marker`). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire `'click'` event). + * + * @example + * + * ```js + * map.on('click', function(e) { + * alert(e.latlng); + * } ); + * ``` + * + * Leaflet deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a function: + * + * ```js + * function onClick(e) { ... } + * + * map.on('click', onClick); + * map.off('click', onClick); + * ``` + */ + + +L.Evented = L.Class.extend({ + + /* @method on(type: String, fn: Function, context?: Object): this + * Adds a listener function (`fn`) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. `'click dblclick'`). + * + * @alternative + * @method on(eventMap: Object): this + * Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}` + */ + on: function (types, fn, context) { + + // types can be a map of types/handlers + if (typeof types === 'object') { + for (var type in types) { + // we don't process space-separated events here for performance; + // it's a hot path since Layer uses the on(obj) syntax + this._on(type, types[type], fn); + } + + } else { + // types can be a string of space-separated words + types = L.Util.splitWords(types); + + for (var i = 0, len = types.length; i < len; i++) { + this._on(types[i], fn, context); + } + } + + return this; + }, + + /* @method off(type: String, fn?: Function, context?: Object): this + * Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to `on`, you must pass the same context to `off` in order to remove the listener. + * + * @alternative + * @method off(eventMap: Object): this + * Removes a set of type/listener pairs. + * + * @alternative + * @method off: this + * Removes all listeners to all events on the object. + */ + off: function (types, fn, context) { + + if (!types) { + // clear all listeners if called without arguments + delete this._events; + + } else if (typeof types === 'object') { + for (var type in types) { + this._off(type, types[type], fn); + } + + } else { + types = L.Util.splitWords(types); + + for (var i = 0, len = types.length; i < len; i++) { + this._off(types[i], fn, context); + } + } + + return this; + }, + + // attach listener (without syntactic sugar now) + _on: function (type, fn, context) { + this._events = this._events || {}; + + /* get/init listeners for type */ + var typeListeners = this._events[type]; + if (!typeListeners) { + typeListeners = []; + this._events[type] = typeListeners; + } + + if (context === this) { + // Less memory footprint. + context = undefined; + } + var newListener = {fn: fn, ctx: context}, + listeners = typeListeners; + + // check if fn already there + for (var i = 0, len = listeners.length; i < len; i++) { + if (listeners[i].fn === fn && listeners[i].ctx === context) { + return; + } + } + + listeners.push(newListener); + typeListeners.count++; + }, + + _off: function (type, fn, context) { + var listeners, + i, + len; + + if (!this._events) { return; } + + listeners = this._events[type]; + + if (!listeners) { + return; + } + + if (!fn) { + // Set all removed listeners to noop so they are not called if remove happens in fire + for (i = 0, len = listeners.length; i < len; i++) { + listeners[i].fn = L.Util.falseFn; + } + // clear all listeners for a type if function isn't specified + delete this._events[type]; + return; + } + + if (context === this) { + context = undefined; + } + + if (listeners) { + + // find fn and remove it + for (i = 0, len = listeners.length; i < len; i++) { + var l = listeners[i]; + if (l.ctx !== context) { continue; } + if (l.fn === fn) { + + // set the removed listener to noop so that's not called if remove happens in fire + l.fn = L.Util.falseFn; + + if (this._firingCount) { + /* copy array in case events are being fired */ + this._events[type] = listeners = listeners.slice(); + } + listeners.splice(i, 1); + + return; + } + } + } + }, + + // @method fire(type: String, data?: Object, propagate?: Boolean): this + // Fires an event of the specified type. You can optionally provide an data + // object — the first argument of the listener function will contain its + // properties. The event can optionally be propagated to event parents. + fire: function (type, data, propagate) { + if (!this.listens(type, propagate)) { return this; } + + var event = L.Util.extend({}, data, {type: type, target: this}); + + if (this._events) { + var listeners = this._events[type]; + + if (listeners) { + this._firingCount = (this._firingCount + 1) || 1; + for (var i = 0, len = listeners.length; i < len; i++) { + var l = listeners[i]; + l.fn.call(l.ctx || this, event); + } + + this._firingCount--; + } + } + + if (propagate) { + // propagate the event to parents (set with addEventParent) + this._propagateEvent(event); + } + + return this; + }, + + // @method listens(type: String): Boolean + // Returns `true` if a particular event type has any listeners attached to it. + listens: function (type, propagate) { + var listeners = this._events && this._events[type]; + if (listeners && listeners.length) { return true; } + + if (propagate) { + // also check parents for listeners if event propagates + for (var id in this._eventParents) { + if (this._eventParents[id].listens(type, propagate)) { return true; } + } + } + return false; + }, + + // @method once(…): this + // Behaves as [`on(…)`](#evented-on), except the listener will only get fired once and then removed. + once: function (types, fn, context) { + + if (typeof types === 'object') { + for (var type in types) { + this.once(type, types[type], fn); + } + return this; + } + + var handler = L.bind(function () { + this + .off(types, fn, context) + .off(types, handler, context); + }, this); + + // add a listener that's executed once and removed after that + return this + .on(types, fn, context) + .on(types, handler, context); + }, + + // @method addEventParent(obj: Evented): this + // Adds an event parent - an `Evented` that will receive propagated events + addEventParent: function (obj) { + this._eventParents = this._eventParents || {}; + this._eventParents[L.stamp(obj)] = obj; + return this; + }, + + // @method removeEventParent(obj: Evented): this + // Removes an event parent, so it will stop receiving propagated events + removeEventParent: function (obj) { + if (this._eventParents) { + delete this._eventParents[L.stamp(obj)]; + } + return this; + }, + + _propagateEvent: function (e) { + for (var id in this._eventParents) { + this._eventParents[id].fire(e.type, L.extend({layer: e.target}, e), true); + } + } +}); + +var proto = L.Evented.prototype; + +// aliases; we should ditch those eventually + +// @method addEventListener(…): this +// Alias to [`on(…)`](#evented-on) +proto.addEventListener = proto.on; + +// @method removeEventListener(…): this +// Alias to [`off(…)`](#evented-off) + +// @method clearAllEventListeners(…): this +// Alias to [`off()`](#evented-off) +proto.removeEventListener = proto.clearAllEventListeners = proto.off; + +// @method addOneTimeEventListener(…): this +// Alias to [`once(…)`](#evented-once) +proto.addOneTimeEventListener = proto.once; + +// @method fireEvent(…): this +// Alias to [`fire(…)`](#evented-fire) +proto.fireEvent = proto.fire; + +// @method hasEventListeners(…): Boolean +// Alias to [`listens(…)`](#evented-listens) +proto.hasEventListeners = proto.listens; + +L.Mixin = {Events: proto}; + + + +/* + * @namespace Browser + * @aka L.Browser + * + * A namespace with static properties for browser/feature detection used by Leaflet internally. + * + * @example + * + * ```js + * if (L.Browser.ielt9) { + * alert('Upgrade your browser, dude!'); + * } + * ``` + */ + +(function () { + + var ua = navigator.userAgent.toLowerCase(), + doc = document.documentElement, + + ie = 'ActiveXObject' in window, + + webkit = ua.indexOf('webkit') !== -1, + phantomjs = ua.indexOf('phantom') !== -1, + android23 = ua.search('android [23]') !== -1, + chrome = ua.indexOf('chrome') !== -1, + gecko = ua.indexOf('gecko') !== -1 && !webkit && !window.opera && !ie, + + win = navigator.platform.indexOf('Win') === 0, + + mobile = typeof orientation !== 'undefined' || ua.indexOf('mobile') !== -1, + msPointer = !window.PointerEvent && window.MSPointerEvent, + pointer = window.PointerEvent || msPointer, + + ie3d = ie && ('transition' in doc.style), + webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23, + gecko3d = 'MozPerspective' in doc.style, + opera12 = 'OTransition' in doc.style; + + + var touch = !window.L_NO_TOUCH && (pointer || 'ontouchstart' in window || + (window.DocumentTouch && document instanceof window.DocumentTouch)); + + L.Browser = { + + // @property ie: Boolean + // `true` for all Internet Explorer versions (not Edge). + ie: ie, + + // @property ielt9: Boolean + // `true` for Internet Explorer versions less than 9. + ielt9: ie && !document.addEventListener, + + // @property edge: Boolean + // `true` for the Edge web browser. + edge: 'msLaunchUri' in navigator && !('documentMode' in document), + + // @property webkit: Boolean + // `true` for webkit-based browsers like Chrome and Safari (including mobile versions). + webkit: webkit, + + // @property gecko: Boolean + // `true` for gecko-based browsers like Firefox. + gecko: gecko, + + // @property android: Boolean + // `true` for any browser running on an Android platform. + android: ua.indexOf('android') !== -1, + + // @property android23: Boolean + // `true` for browsers running on Android 2 or Android 3. + android23: android23, + + // @property chrome: Boolean + // `true` for the Chrome browser. + chrome: chrome, + + // @property safari: Boolean + // `true` for the Safari browser. + safari: !chrome && ua.indexOf('safari') !== -1, + + + // @property win: Boolean + // `true` when the browser is running in a Windows platform + win: win, + + + // @property ie3d: Boolean + // `true` for all Internet Explorer versions supporting CSS transforms. + ie3d: ie3d, + + // @property webkit3d: Boolean + // `true` for webkit-based browsers supporting CSS transforms. + webkit3d: webkit3d, + + // @property gecko3d: Boolean + // `true` for gecko-based browsers supporting CSS transforms. + gecko3d: gecko3d, + + // @property opera12: Boolean + // `true` for the Opera browser supporting CSS transforms (version 12 or later). + opera12: opera12, + + // @property any3d: Boolean + // `true` for all browsers supporting CSS transforms. + any3d: !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d) && !opera12 && !phantomjs, + + + // @property mobile: Boolean + // `true` for all browsers running in a mobile device. + mobile: mobile, + + // @property mobileWebkit: Boolean + // `true` for all webkit-based browsers in a mobile device. + mobileWebkit: mobile && webkit, + + // @property mobileWebkit3d: Boolean + // `true` for all webkit-based browsers in a mobile device supporting CSS transforms. + mobileWebkit3d: mobile && webkit3d, + + // @property mobileOpera: Boolean + // `true` for the Opera browser in a mobile device. + mobileOpera: mobile && window.opera, + + // @property mobileGecko: Boolean + // `true` for gecko-based browsers running in a mobile device. + mobileGecko: mobile && gecko, + + + // @property touch: Boolean + // `true` for all browsers supporting [touch events](https://developer.mozilla.org/docs/Web/API/Touch_events). + touch: !!touch, + + // @property msPointer: Boolean + // `true` for browsers implementing the Microsoft touch events model (notably IE10). + msPointer: !!msPointer, + + // @property pointer: Boolean + // `true` for all browsers supporting [pointer events](https://msdn.microsoft.com/en-us/library/dn433244%28v=vs.85%29.aspx). + pointer: !!pointer, + + + // @property retina: Boolean + // `true` for browsers on a high-resolution "retina" screen. + retina: (window.devicePixelRatio || (window.screen.deviceXDPI / window.screen.logicalXDPI)) > 1 + }; + +}()); + + + +/* + * @class Point + * @aka L.Point + * + * Represents a point with `x` and `y` coordinates in pixels. + * + * @example + * + * ```js + * var point = L.point(200, 300); + * ``` + * + * All Leaflet methods and options that accept `Point` objects also accept them in a simple Array form (unless noted otherwise), so these lines are equivalent: + * + * ```js + * map.panBy([200, 300]); + * map.panBy(L.point(200, 300)); + * ``` + */ + +L.Point = function (x, y, round) { + // @property x: Number; The `x` coordinate of the point + this.x = (round ? Math.round(x) : x); + // @property y: Number; The `y` coordinate of the point + this.y = (round ? Math.round(y) : y); +}; + +L.Point.prototype = { + + // @method clone(): Point + // Returns a copy of the current point. + clone: function () { + return new L.Point(this.x, this.y); + }, + + // @method add(otherPoint: Point): Point + // Returns the result of addition of the current and the given points. + add: function (point) { + // non-destructive, returns a new point + return this.clone()._add(L.point(point)); + }, + + _add: function (point) { + // destructive, used directly for performance in situations where it's safe to modify existing point + this.x += point.x; + this.y += point.y; + return this; + }, + + // @method subtract(otherPoint: Point): Point + // Returns the result of subtraction of the given point from the current. + subtract: function (point) { + return this.clone()._subtract(L.point(point)); + }, + + _subtract: function (point) { + this.x -= point.x; + this.y -= point.y; + return this; + }, + + // @method divideBy(num: Number): Point + // Returns the result of division of the current point by the given number. + divideBy: function (num) { + return this.clone()._divideBy(num); + }, + + _divideBy: function (num) { + this.x /= num; + this.y /= num; + return this; + }, + + // @method multiplyBy(num: Number): Point + // Returns the result of multiplication of the current point by the given number. + multiplyBy: function (num) { + return this.clone()._multiplyBy(num); + }, + + _multiplyBy: function (num) { + this.x *= num; + this.y *= num; + return this; + }, + + // @method scaleBy(scale: Point): Point + // Multiply each coordinate of the current point by each coordinate of + // `scale`. In linear algebra terms, multiply the point by the + // [scaling matrix](https://en.wikipedia.org/wiki/Scaling_%28geometry%29#Matrix_representation) + // defined by `scale`. + scaleBy: function (point) { + return new L.Point(this.x * point.x, this.y * point.y); + }, + + // @method unscaleBy(scale: Point): Point + // Inverse of `scaleBy`. Divide each coordinate of the current point by + // each coordinate of `scale`. + unscaleBy: function (point) { + return new L.Point(this.x / point.x, this.y / point.y); + }, + + // @method round(): Point + // Returns a copy of the current point with rounded coordinates. + round: function () { + return this.clone()._round(); + }, + + _round: function () { + this.x = Math.round(this.x); + this.y = Math.round(this.y); + return this; + }, + + // @method floor(): Point + // Returns a copy of the current point with floored coordinates (rounded down). + floor: function () { + return this.clone()._floor(); + }, + + _floor: function () { + this.x = Math.floor(this.x); + this.y = Math.floor(this.y); + return this; + }, + + // @method ceil(): Point + // Returns a copy of the current point with ceiled coordinates (rounded up). + ceil: function () { + return this.clone()._ceil(); + }, + + _ceil: function () { + this.x = Math.ceil(this.x); + this.y = Math.ceil(this.y); + return this; + }, + + // @method distanceTo(otherPoint: Point): Number + // Returns the cartesian distance between the current and the given points. + distanceTo: function (point) { + point = L.point(point); + + var x = point.x - this.x, + y = point.y - this.y; + + return Math.sqrt(x * x + y * y); + }, + + // @method equals(otherPoint: Point): Boolean + // Returns `true` if the given point has the same coordinates. + equals: function (point) { + point = L.point(point); + + return point.x === this.x && + point.y === this.y; + }, + + // @method contains(otherPoint: Point): Boolean + // Returns `true` if both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). + contains: function (point) { + point = L.point(point); + + return Math.abs(point.x) <= Math.abs(this.x) && + Math.abs(point.y) <= Math.abs(this.y); + }, + + // @method toString(): String + // Returns a string representation of the point for debugging purposes. + toString: function () { + return 'Point(' + + L.Util.formatNum(this.x) + ', ' + + L.Util.formatNum(this.y) + ')'; + } +}; + +// @factory L.point(x: Number, y: Number, round?: Boolean) +// Creates a Point object with the given `x` and `y` coordinates. If optional `round` is set to true, rounds the `x` and `y` values. + +// @alternative +// @factory L.point(coords: Number[]) +// Expects an array of the form `[x, y]` instead. + +// @alternative +// @factory L.point(coords: Object) +// Expects a plain object of the form `{x: Number, y: Number}` instead. +L.point = function (x, y, round) { + if (x instanceof L.Point) { + return x; + } + if (L.Util.isArray(x)) { + return new L.Point(x[0], x[1]); + } + if (x === undefined || x === null) { + return x; + } + if (typeof x === 'object' && 'x' in x && 'y' in x) { + return new L.Point(x.x, x.y); + } + return new L.Point(x, y, round); +}; + + + +/* + * @class Bounds + * @aka L.Bounds + * + * Represents a rectangular area in pixel coordinates. + * + * @example + * + * ```js + * var p1 = L.point(10, 10), + * p2 = L.point(40, 60), + * bounds = L.bounds(p1, p2); + * ``` + * + * All Leaflet methods that accept `Bounds` objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this: + * + * ```js + * otherBounds.intersects([[10, 10], [40, 60]]); + * ``` + */ + +L.Bounds = function (a, b) { + if (!a) { return; } + + var points = b ? [a, b] : a; + + for (var i = 0, len = points.length; i < len; i++) { + this.extend(points[i]); + } +}; + +L.Bounds.prototype = { + // @method extend(point: Point): this + // Extends the bounds to contain the given point. + extend: function (point) { // (Point) + point = L.point(point); + + // @property min: Point + // The top left corner of the rectangle. + // @property max: Point + // The bottom right corner of the rectangle. + if (!this.min && !this.max) { + this.min = point.clone(); + this.max = point.clone(); + } else { + this.min.x = Math.min(point.x, this.min.x); + this.max.x = Math.max(point.x, this.max.x); + this.min.y = Math.min(point.y, this.min.y); + this.max.y = Math.max(point.y, this.max.y); + } + return this; + }, + + // @method getCenter(round?: Boolean): Point + // Returns the center point of the bounds. + getCenter: function (round) { + return new L.Point( + (this.min.x + this.max.x) / 2, + (this.min.y + this.max.y) / 2, round); + }, + + // @method getBottomLeft(): Point + // Returns the bottom-left point of the bounds. + getBottomLeft: function () { + return new L.Point(this.min.x, this.max.y); + }, + + // @method getTopRight(): Point + // Returns the top-right point of the bounds. + getTopRight: function () { // -> Point + return new L.Point(this.max.x, this.min.y); + }, + + // @method getSize(): Point + // Returns the size of the given bounds + getSize: function () { + return this.max.subtract(this.min); + }, + + // @method contains(otherBounds: Bounds): Boolean + // Returns `true` if the rectangle contains the given one. + // @alternative + // @method contains(point: Point): Boolean + // Returns `true` if the rectangle contains the given point. + contains: function (obj) { + var min, max; + + if (typeof obj[0] === 'number' || obj instanceof L.Point) { + obj = L.point(obj); + } else { + obj = L.bounds(obj); + } + + if (obj instanceof L.Bounds) { + min = obj.min; + max = obj.max; + } else { + min = max = obj; + } + + return (min.x >= this.min.x) && + (max.x <= this.max.x) && + (min.y >= this.min.y) && + (max.y <= this.max.y); + }, + + // @method intersects(otherBounds: Bounds): Boolean + // Returns `true` if the rectangle intersects the given bounds. Two bounds + // intersect if they have at least one point in common. + intersects: function (bounds) { // (Bounds) -> Boolean + bounds = L.bounds(bounds); + + var min = this.min, + max = this.max, + min2 = bounds.min, + max2 = bounds.max, + xIntersects = (max2.x >= min.x) && (min2.x <= max.x), + yIntersects = (max2.y >= min.y) && (min2.y <= max.y); + + return xIntersects && yIntersects; + }, + + // @method overlaps(otherBounds: Bounds): Boolean + // Returns `true` if the rectangle overlaps the given bounds. Two bounds + // overlap if their intersection is an area. + overlaps: function (bounds) { // (Bounds) -> Boolean + bounds = L.bounds(bounds); + + var min = this.min, + max = this.max, + min2 = bounds.min, + max2 = bounds.max, + xOverlaps = (max2.x > min.x) && (min2.x < max.x), + yOverlaps = (max2.y > min.y) && (min2.y < max.y); + + return xOverlaps && yOverlaps; + }, + + isValid: function () { + return !!(this.min && this.max); + } +}; + + +// @factory L.bounds(topLeft: Point, bottomRight: Point) +// Creates a Bounds object from two coordinates (usually top-left and bottom-right corners). +// @alternative +// @factory L.bounds(points: Point[]) +// Creates a Bounds object from the points it contains +L.bounds = function (a, b) { + if (!a || a instanceof L.Bounds) { + return a; + } + return new L.Bounds(a, b); +}; + + + +/* + * @class Transformation + * @aka L.Transformation + * + * Represents an affine transformation: a set of coefficients `a`, `b`, `c`, `d` + * for transforming a point of a form `(x, y)` into `(a*x + b, c*y + d)` and doing + * the reverse. Used by Leaflet in its projections code. + * + * @example + * + * ```js + * var transformation = new L.Transformation(2, 5, -1, 10), + * p = L.point(1, 2), + * p2 = transformation.transform(p), // L.point(7, 8) + * p3 = transformation.untransform(p2); // L.point(1, 2) + * ``` + */ + + +// factory new L.Transformation(a: Number, b: Number, c: Number, d: Number) +// Creates a `Transformation` object with the given coefficients. +L.Transformation = function (a, b, c, d) { + this._a = a; + this._b = b; + this._c = c; + this._d = d; +}; + +L.Transformation.prototype = { + // @method transform(point: Point, scale?: Number): Point + // Returns a transformed point, optionally multiplied by the given scale. + // Only accepts actual `L.Point` instances, not arrays. + transform: function (point, scale) { // (Point, Number) -> Point + return this._transform(point.clone(), scale); + }, + + // destructive transform (faster) + _transform: function (point, scale) { + scale = scale || 1; + point.x = scale * (this._a * point.x + this._b); + point.y = scale * (this._c * point.y + this._d); + return point; + }, + + // @method untransform(point: Point, scale?: Number): Point + // Returns the reverse transformation of the given point, optionally divided + // by the given scale. Only accepts actual `L.Point` instances, not arrays. + untransform: function (point, scale) { + scale = scale || 1; + return new L.Point( + (point.x / scale - this._b) / this._a, + (point.y / scale - this._d) / this._c); + } +}; + + + +/* + * @namespace DomUtil + * + * Utility functions to work with the [DOM](https://developer.mozilla.org/docs/Web/API/Document_Object_Model) + * tree, used by Leaflet internally. + * + * Most functions expecting or returning a `HTMLElement` also work for + * SVG elements. The only difference is that classes refer to CSS classes + * in HTML and SVG classes in SVG. + */ + +L.DomUtil = { + + // @function get(id: String|HTMLElement): HTMLElement + // Returns an element given its DOM id, or returns the element itself + // if it was passed directly. + get: function (id) { + return typeof id === 'string' ? document.getElementById(id) : id; + }, + + // @function getStyle(el: HTMLElement, styleAttrib: String): String + // Returns the value for a certain style attribute on an element, + // including computed values or values set through CSS. + getStyle: function (el, style) { + + var value = el.style[style] || (el.currentStyle && el.currentStyle[style]); + + if ((!value || value === 'auto') && document.defaultView) { + var css = document.defaultView.getComputedStyle(el, null); + value = css ? css[style] : null; + } + + return value === 'auto' ? null : value; + }, + + // @function create(tagName: String, className?: String, container?: HTMLElement): HTMLElement + // Creates an HTML element with `tagName`, sets its class to `className`, and optionally appends it to `container` element. + create: function (tagName, className, container) { + + var el = document.createElement(tagName); + el.className = className || ''; + + if (container) { + container.appendChild(el); + } + + return el; + }, + + // @function remove(el: HTMLElement) + // Removes `el` from its parent element + remove: function (el) { + var parent = el.parentNode; + if (parent) { + parent.removeChild(el); + } + }, + + // @function empty(el: HTMLElement) + // Removes all of `el`'s children elements from `el` + empty: function (el) { + while (el.firstChild) { + el.removeChild(el.firstChild); + } + }, + + // @function toFront(el: HTMLElement) + // Makes `el` the last children of its parent, so it renders in front of the other children. + toFront: function (el) { + el.parentNode.appendChild(el); + }, + + // @function toBack(el: HTMLElement) + // Makes `el` the first children of its parent, so it renders back from the other children. + toBack: function (el) { + var parent = el.parentNode; + parent.insertBefore(el, parent.firstChild); + }, + + // @function hasClass(el: HTMLElement, name: String): Boolean + // Returns `true` if the element's class attribute contains `name`. + hasClass: function (el, name) { + if (el.classList !== undefined) { + return el.classList.contains(name); + } + var className = L.DomUtil.getClass(el); + return className.length > 0 && new RegExp('(^|\\s)' + name + '(\\s|$)').test(className); + }, + + // @function addClass(el: HTMLElement, name: String) + // Adds `name` to the element's class attribute. + addClass: function (el, name) { + if (el.classList !== undefined) { + var classes = L.Util.splitWords(name); + for (var i = 0, len = classes.length; i < len; i++) { + el.classList.add(classes[i]); + } + } else if (!L.DomUtil.hasClass(el, name)) { + var className = L.DomUtil.getClass(el); + L.DomUtil.setClass(el, (className ? className + ' ' : '') + name); + } + }, + + // @function removeClass(el: HTMLElement, name: String) + // Removes `name` from the element's class attribute. + removeClass: function (el, name) { + if (el.classList !== undefined) { + el.classList.remove(name); + } else { + L.DomUtil.setClass(el, L.Util.trim((' ' + L.DomUtil.getClass(el) + ' ').replace(' ' + name + ' ', ' '))); + } + }, + + // @function setClass(el: HTMLElement, name: String) + // Sets the element's class. + setClass: function (el, name) { + if (el.className.baseVal === undefined) { + el.className = name; + } else { + // in case of SVG element + el.className.baseVal = name; + } + }, + + // @function getClass(el: HTMLElement): String + // Returns the element's class. + getClass: function (el) { + return el.className.baseVal === undefined ? el.className : el.className.baseVal; + }, + + // @function setOpacity(el: HTMLElement, opacity: Number) + // Set the opacity of an element (including old IE support). + // `opacity` must be a number from `0` to `1`. + setOpacity: function (el, value) { + + if ('opacity' in el.style) { + el.style.opacity = value; + + } else if ('filter' in el.style) { + L.DomUtil._setOpacityIE(el, value); + } + }, + + _setOpacityIE: function (el, value) { + var filter = false, + filterName = 'DXImageTransform.Microsoft.Alpha'; + + // filters collection throws an error if we try to retrieve a filter that doesn't exist + try { + filter = el.filters.item(filterName); + } catch (e) { + // don't set opacity to 1 if we haven't already set an opacity, + // it isn't needed and breaks transparent pngs. + if (value === 1) { return; } + } + + value = Math.round(value * 100); + + if (filter) { + filter.Enabled = (value !== 100); + filter.Opacity = value; + } else { + el.style.filter += ' progid:' + filterName + '(opacity=' + value + ')'; + } + }, + + // @function testProp(props: String[]): String|false + // Goes through the array of style names and returns the first name + // that is a valid style name for an element. If no such name is found, + // it returns false. Useful for vendor-prefixed styles like `transform`. + testProp: function (props) { + + var style = document.documentElement.style; + + for (var i = 0; i < props.length; i++) { + if (props[i] in style) { + return props[i]; + } + } + return false; + }, + + // @function setTransform(el: HTMLElement, offset: Point, scale?: Number) + // Resets the 3D CSS transform of `el` so it is translated by `offset` pixels + // and optionally scaled by `scale`. Does not have an effect if the + // browser doesn't support 3D CSS transforms. + setTransform: function (el, offset, scale) { + var pos = offset || new L.Point(0, 0); + + el.style[L.DomUtil.TRANSFORM] = + (L.Browser.ie3d ? + 'translate(' + pos.x + 'px,' + pos.y + 'px)' : + 'translate3d(' + pos.x + 'px,' + pos.y + 'px,0)') + + (scale ? ' scale(' + scale + ')' : ''); + }, + + // @function setPosition(el: HTMLElement, position: Point) + // Sets the position of `el` to coordinates specified by `position`, + // using CSS translate or top/left positioning depending on the browser + // (used by Leaflet internally to position its layers). + setPosition: function (el, point) { // (HTMLElement, Point[, Boolean]) + + /*eslint-disable */ + el._leaflet_pos = point; + /*eslint-enable */ + + if (L.Browser.any3d) { + L.DomUtil.setTransform(el, point); + } else { + el.style.left = point.x + 'px'; + el.style.top = point.y + 'px'; + } + }, + + // @function getPosition(el: HTMLElement): Point + // Returns the coordinates of an element previously positioned with setPosition. + getPosition: function (el) { + // this method is only used for elements previously positioned using setPosition, + // so it's safe to cache the position for performance + + return el._leaflet_pos || new L.Point(0, 0); + } +}; + + +(function () { + // prefix style property names + + // @property TRANSFORM: String + // Vendor-prefixed fransform style name (e.g. `'webkitTransform'` for WebKit). + L.DomUtil.TRANSFORM = L.DomUtil.testProp( + ['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform']); + + + // webkitTransition comes first because some browser versions that drop vendor prefix don't do + // the same for the transitionend event, in particular the Android 4.1 stock browser + + // @property TRANSITION: String + // Vendor-prefixed transform style name. + var transition = L.DomUtil.TRANSITION = L.DomUtil.testProp( + ['webkitTransition', 'transition', 'OTransition', 'MozTransition', 'msTransition']); + + L.DomUtil.TRANSITION_END = + transition === 'webkitTransition' || transition === 'OTransition' ? transition + 'End' : 'transitionend'; + + // @function disableTextSelection() + // Prevents the user from generating `selectstart` DOM events, usually generated + // when the user drags the mouse through a page with text. Used internally + // by Leaflet to override the behaviour of any click-and-drag interaction on + // the map. Affects drag interactions on the whole document. + + // @function enableTextSelection() + // Cancels the effects of a previous [`L.DomUtil.disableTextSelection`](#domutil-disabletextselection). + if ('onselectstart' in document) { + L.DomUtil.disableTextSelection = function () { + L.DomEvent.on(window, 'selectstart', L.DomEvent.preventDefault); + }; + L.DomUtil.enableTextSelection = function () { + L.DomEvent.off(window, 'selectstart', L.DomEvent.preventDefault); + }; + + } else { + var userSelectProperty = L.DomUtil.testProp( + ['userSelect', 'WebkitUserSelect', 'OUserSelect', 'MozUserSelect', 'msUserSelect']); + + L.DomUtil.disableTextSelection = function () { + if (userSelectProperty) { + var style = document.documentElement.style; + this._userSelect = style[userSelectProperty]; + style[userSelectProperty] = 'none'; + } + }; + L.DomUtil.enableTextSelection = function () { + if (userSelectProperty) { + document.documentElement.style[userSelectProperty] = this._userSelect; + delete this._userSelect; + } + }; + } + + // @function disableImageDrag() + // As [`L.DomUtil.disableTextSelection`](#domutil-disabletextselection), but + // for `dragstart` DOM events, usually generated when the user drags an image. + L.DomUtil.disableImageDrag = function () { + L.DomEvent.on(window, 'dragstart', L.DomEvent.preventDefault); + }; + + // @function enableImageDrag() + // Cancels the effects of a previous [`L.DomUtil.disableImageDrag`](#domutil-disabletextselection). + L.DomUtil.enableImageDrag = function () { + L.DomEvent.off(window, 'dragstart', L.DomEvent.preventDefault); + }; + + // @function preventOutline(el: HTMLElement) + // Makes the [outline](https://developer.mozilla.org/docs/Web/CSS/outline) + // of the element `el` invisible. Used internally by Leaflet to prevent + // focusable elements from displaying an outline when the user performs a + // drag interaction on them. + L.DomUtil.preventOutline = function (element) { + while (element.tabIndex === -1) { + element = element.parentNode; + } + if (!element || !element.style) { return; } + L.DomUtil.restoreOutline(); + this._outlineElement = element; + this._outlineStyle = element.style.outline; + element.style.outline = 'none'; + L.DomEvent.on(window, 'keydown', L.DomUtil.restoreOutline, this); + }; + + // @function restoreOutline() + // Cancels the effects of a previous [`L.DomUtil.preventOutline`](). + L.DomUtil.restoreOutline = function () { + if (!this._outlineElement) { return; } + this._outlineElement.style.outline = this._outlineStyle; + delete this._outlineElement; + delete this._outlineStyle; + L.DomEvent.off(window, 'keydown', L.DomUtil.restoreOutline, this); + }; +})(); + + + +/* @class LatLng + * @aka L.LatLng + * + * Represents a geographical point with a certain latitude and longitude. + * + * @example + * + * ``` + * var latlng = L.latLng(50.5, 30.5); + * ``` + * + * All Leaflet methods that accept LatLng objects also accept them in a simple Array form and simple object form (unless noted otherwise), so these lines are equivalent: + * + * ``` + * map.panTo([50, 30]); + * map.panTo({lon: 30, lat: 50}); + * map.panTo({lat: 50, lng: 30}); + * map.panTo(L.latLng(50, 30)); + * ``` + */ + +L.LatLng = function (lat, lng, alt) { + if (isNaN(lat) || isNaN(lng)) { + throw new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')'); + } + + // @property lat: Number + // Latitude in degrees + this.lat = +lat; + + // @property lng: Number + // Longitude in degrees + this.lng = +lng; + + // @property alt: Number + // Altitude in meters (optional) + if (alt !== undefined) { + this.alt = +alt; + } +}; + +L.LatLng.prototype = { + // @method equals(otherLatLng: LatLng, maxMargin?: Number): Boolean + // Returns `true` if the given `LatLng` point is at the same position (within a small margin of error). The margin of error can be overriden by setting `maxMargin` to a small number. + equals: function (obj, maxMargin) { + if (!obj) { return false; } + + obj = L.latLng(obj); + + var margin = Math.max( + Math.abs(this.lat - obj.lat), + Math.abs(this.lng - obj.lng)); + + return margin <= (maxMargin === undefined ? 1.0E-9 : maxMargin); + }, + + // @method toString(): String + // Returns a string representation of the point (for debugging purposes). + toString: function (precision) { + return 'LatLng(' + + L.Util.formatNum(this.lat, precision) + ', ' + + L.Util.formatNum(this.lng, precision) + ')'; + }, + + // @method distanceTo(otherLatLng: LatLng): Number + // Returns the distance (in meters) to the given `LatLng` calculated using the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula). + distanceTo: function (other) { + return L.CRS.Earth.distance(this, L.latLng(other)); + }, + + // @method wrap(): LatLng + // Returns a new `LatLng` object with the longitude wrapped so it's always between -180 and +180 degrees. + wrap: function () { + return L.CRS.Earth.wrapLatLng(this); + }, + + // @method toBounds(sizeInMeters: Number): LatLngBounds + // Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters` meters apart from the `LatLng`. + toBounds: function (sizeInMeters) { + var latAccuracy = 180 * sizeInMeters / 40075017, + lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat); + + return L.latLngBounds( + [this.lat - latAccuracy, this.lng - lngAccuracy], + [this.lat + latAccuracy, this.lng + lngAccuracy]); + }, + + clone: function () { + return new L.LatLng(this.lat, this.lng, this.alt); + } +}; + + + +// @factory L.latLng(latitude: Number, longitude: Number, altitude?: Number): LatLng +// Creates an object representing a geographical point with the given latitude and longitude (and optionally altitude). + +// @alternative +// @factory L.latLng(coords: Array): LatLng +// Expects an array of the form `[Number, Number]` or `[Number, Number, Number]` instead. + +// @alternative +// @factory L.latLng(coords: Object): LatLng +// Expects an plain object of the form `{lat: Number, lng: Number}` or `{lat: Number, lng: Number, alt: Number}` instead. + +L.latLng = function (a, b, c) { + if (a instanceof L.LatLng) { + return a; + } + if (L.Util.isArray(a) && typeof a[0] !== 'object') { + if (a.length === 3) { + return new L.LatLng(a[0], a[1], a[2]); + } + if (a.length === 2) { + return new L.LatLng(a[0], a[1]); + } + return null; + } + if (a === undefined || a === null) { + return a; + } + if (typeof a === 'object' && 'lat' in a) { + return new L.LatLng(a.lat, 'lng' in a ? a.lng : a.lon, a.alt); + } + if (b === undefined) { + return null; + } + return new L.LatLng(a, b, c); +}; + + + +/* + * @class LatLngBounds + * @aka L.LatLngBounds + * + * Represents a rectangular geographical area on a map. + * + * @example + * + * ```js + * var corner1 = L.latLng(40.712, -74.227), + * corner2 = L.latLng(40.774, -74.125), + * bounds = L.latLngBounds(corner1, corner2); + * ``` + * + * All Leaflet methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this: + * + * ```js + * map.fitBounds([ + * [40.712, -74.227], + * [40.774, -74.125] + * ]); + * ``` + * + * Caution: if the area crosses the antimeridian (often confused with the International Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range. + */ + +L.LatLngBounds = function (corner1, corner2) { // (LatLng, LatLng) or (LatLng[]) + if (!corner1) { return; } + + var latlngs = corner2 ? [corner1, corner2] : corner1; + + for (var i = 0, len = latlngs.length; i < len; i++) { + this.extend(latlngs[i]); + } +}; + +L.LatLngBounds.prototype = { + + // @method extend(latlng: LatLng): this + // Extend the bounds to contain the given point + + // @alternative + // @method extend(otherBounds: LatLngBounds): this + // Extend the bounds to contain the given bounds + extend: function (obj) { + var sw = this._southWest, + ne = this._northEast, + sw2, ne2; + + if (obj instanceof L.LatLng) { + sw2 = obj; + ne2 = obj; + + } else if (obj instanceof L.LatLngBounds) { + sw2 = obj._southWest; + ne2 = obj._northEast; + + if (!sw2 || !ne2) { return this; } + + } else { + return obj ? this.extend(L.latLng(obj) || L.latLngBounds(obj)) : this; + } + + if (!sw && !ne) { + this._southWest = new L.LatLng(sw2.lat, sw2.lng); + this._northEast = new L.LatLng(ne2.lat, ne2.lng); + } else { + sw.lat = Math.min(sw2.lat, sw.lat); + sw.lng = Math.min(sw2.lng, sw.lng); + ne.lat = Math.max(ne2.lat, ne.lat); + ne.lng = Math.max(ne2.lng, ne.lng); + } + + return this; + }, + + // @method pad(bufferRatio: Number): LatLngBounds + // Returns bigger bounds created by extending the current bounds by a given percentage in each direction. + pad: function (bufferRatio) { + var sw = this._southWest, + ne = this._northEast, + heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio, + widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio; + + return new L.LatLngBounds( + new L.LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer), + new L.LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer)); + }, + + // @method getCenter(): LatLng + // Returns the center point of the bounds. + getCenter: function () { + return new L.LatLng( + (this._southWest.lat + this._northEast.lat) / 2, + (this._southWest.lng + this._northEast.lng) / 2); + }, + + // @method getSouthWest(): LatLng + // Returns the south-west point of the bounds. + getSouthWest: function () { + return this._southWest; + }, + + // @method getNorthEast(): LatLng + // Returns the north-east point of the bounds. + getNorthEast: function () { + return this._northEast; + }, + + // @method getNorthWest(): LatLng + // Returns the north-west point of the bounds. + getNorthWest: function () { + return new L.LatLng(this.getNorth(), this.getWest()); + }, + + // @method getSouthEast(): LatLng + // Returns the south-east point of the bounds. + getSouthEast: function () { + return new L.LatLng(this.getSouth(), this.getEast()); + }, + + // @method getWest(): Number + // Returns the west longitude of the bounds + getWest: function () { + return this._southWest.lng; + }, + + // @method getSouth(): Number + // Returns the south latitude of the bounds + getSouth: function () { + return this._southWest.lat; + }, + + // @method getEast(): Number + // Returns the east longitude of the bounds + getEast: function () { + return this._northEast.lng; + }, + + // @method getNorth(): Number + // Returns the north latitude of the bounds + getNorth: function () { + return this._northEast.lat; + }, + + // @method contains(otherBounds: LatLngBounds): Boolean + // Returns `true` if the rectangle contains the given one. + + // @alternative + // @method contains (latlng: LatLng): Boolean + // Returns `true` if the rectangle contains the given point. + contains: function (obj) { // (LatLngBounds) or (LatLng) -> Boolean + if (typeof obj[0] === 'number' || obj instanceof L.LatLng) { + obj = L.latLng(obj); + } else { + obj = L.latLngBounds(obj); + } + + var sw = this._southWest, + ne = this._northEast, + sw2, ne2; + + if (obj instanceof L.LatLngBounds) { + sw2 = obj.getSouthWest(); + ne2 = obj.getNorthEast(); + } else { + sw2 = ne2 = obj; + } + + return (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) && + (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng); + }, + + // @method intersects(otherBounds: LatLngBounds): Boolean + // Returns `true` if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common. + intersects: function (bounds) { + bounds = L.latLngBounds(bounds); + + var sw = this._southWest, + ne = this._northEast, + sw2 = bounds.getSouthWest(), + ne2 = bounds.getNorthEast(), + + latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat), + lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng); + + return latIntersects && lngIntersects; + }, + + // @method overlaps(otherBounds: Bounds): Boolean + // Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area. + overlaps: function (bounds) { + bounds = L.latLngBounds(bounds); + + var sw = this._southWest, + ne = this._northEast, + sw2 = bounds.getSouthWest(), + ne2 = bounds.getNorthEast(), + + latOverlaps = (ne2.lat > sw.lat) && (sw2.lat < ne.lat), + lngOverlaps = (ne2.lng > sw.lng) && (sw2.lng < ne.lng); + + return latOverlaps && lngOverlaps; + }, + + // @method toBBoxString(): String + // Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data. + toBBoxString: function () { + return [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(','); + }, + + // @method equals(otherBounds: LatLngBounds): Boolean + // Returns `true` if the rectangle is equivalent (within a small margin of error) to the given bounds. + equals: function (bounds) { + if (!bounds) { return false; } + + bounds = L.latLngBounds(bounds); + + return this._southWest.equals(bounds.getSouthWest()) && + this._northEast.equals(bounds.getNorthEast()); + }, + + // @method isValid(): Boolean + // Returns `true` if the bounds are properly initialized. + isValid: function () { + return !!(this._southWest && this._northEast); + } +}; + +// TODO International date line? + +// @factory L.latLngBounds(corner1: LatLng, corner2: LatLng) +// Creates a `LatLngBounds` object by defining two diagonally opposite corners of the rectangle. + +// @alternative +// @factory L.latLngBounds(latlngs: LatLng[]) +// Creates a `LatLngBounds` object defined by the geographical points it contains. Very useful for zooming the map to fit a particular set of locations with [`fitBounds`](#map-fitbounds). +L.latLngBounds = function (a, b) { + if (a instanceof L.LatLngBounds) { + return a; + } + return new L.LatLngBounds(a, b); +}; + + + +/* + * @namespace Projection + * @section + * Leaflet comes with a set of already defined Projections out of the box: + * + * @projection L.Projection.LonLat + * + * Equirectangular, or Plate Carree projection — the most simple projection, + * mostly used by GIS enthusiasts. Directly maps `x` as longitude, and `y` as + * latitude. Also suitable for flat worlds, e.g. game maps. Used by the + * `EPSG:3395` and `Simple` CRS. + */ + +L.Projection = {}; + +L.Projection.LonLat = { + project: function (latlng) { + return new L.Point(latlng.lng, latlng.lat); + }, + + unproject: function (point) { + return new L.LatLng(point.y, point.x); + }, + + bounds: L.bounds([-180, -90], [180, 90]) +}; + + + +/* + * @namespace Projection + * @projection L.Projection.SphericalMercator + * + * Spherical Mercator projection — the most common projection for online maps, + * used by almost all free and commercial tile providers. Assumes that Earth is + * a sphere. Used by the `EPSG:3857` CRS. + */ + +L.Projection.SphericalMercator = { + + R: 6378137, + MAX_LATITUDE: 85.0511287798, + + project: function (latlng) { + var d = Math.PI / 180, + max = this.MAX_LATITUDE, + lat = Math.max(Math.min(max, latlng.lat), -max), + sin = Math.sin(lat * d); + + return new L.Point( + this.R * latlng.lng * d, + this.R * Math.log((1 + sin) / (1 - sin)) / 2); + }, + + unproject: function (point) { + var d = 180 / Math.PI; + + return new L.LatLng( + (2 * Math.atan(Math.exp(point.y / this.R)) - (Math.PI / 2)) * d, + point.x * d / this.R); + }, + + bounds: (function () { + var d = 6378137 * Math.PI; + return L.bounds([-d, -d], [d, d]); + })() +}; + + + +/* + * @class CRS + * @aka L.CRS + * Abstract class that defines coordinate reference systems for projecting + * geographical points into pixel (screen) coordinates and back (and to + * coordinates in other units for [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services). See + * [spatial reference system](http://en.wikipedia.org/wiki/Coordinate_reference_system). + * + * Leaflet defines the most usual CRSs by default. If you want to use a + * CRS not defined by default, take a look at the + * [Proj4Leaflet](https://github.com/kartena/Proj4Leaflet) plugin. + */ + +L.CRS = { + // @method latLngToPoint(latlng: LatLng, zoom: Number): Point + // Projects geographical coordinates into pixel coordinates for a given zoom. + latLngToPoint: function (latlng, zoom) { + var projectedPoint = this.projection.project(latlng), + scale = this.scale(zoom); + + return this.transformation._transform(projectedPoint, scale); + }, + + // @method pointToLatLng(point: Point, zoom: Number): LatLng + // The inverse of `latLngToPoint`. Projects pixel coordinates on a given + // zoom into geographical coordinates. + pointToLatLng: function (point, zoom) { + var scale = this.scale(zoom), + untransformedPoint = this.transformation.untransform(point, scale); + + return this.projection.unproject(untransformedPoint); + }, + + // @method project(latlng: LatLng): Point + // Projects geographical coordinates into coordinates in units accepted for + // this CRS (e.g. meters for EPSG:3857, for passing it to WMS services). + project: function (latlng) { + return this.projection.project(latlng); + }, + + // @method unproject(point: Point): LatLng + // Given a projected coordinate returns the corresponding LatLng. + // The inverse of `project`. + unproject: function (point) { + return this.projection.unproject(point); + }, + + // @method scale(zoom: Number): Number + // Returns the scale used when transforming projected coordinates into + // pixel coordinates for a particular zoom. For example, it returns + // `256 * 2^zoom` for Mercator-based CRS. + scale: function (zoom) { + return 256 * Math.pow(2, zoom); + }, + + // @method zoom(scale: Number): Number + // Inverse of `scale()`, returns the zoom level corresponding to a scale + // factor of `scale`. + zoom: function (scale) { + return Math.log(scale / 256) / Math.LN2; + }, + + // @method getProjectedBounds(zoom: Number): Bounds + // Returns the projection's bounds scaled and transformed for the provided `zoom`. + getProjectedBounds: function (zoom) { + if (this.infinite) { return null; } + + var b = this.projection.bounds, + s = this.scale(zoom), + min = this.transformation.transform(b.min, s), + max = this.transformation.transform(b.max, s); + + return L.bounds(min, max); + }, + + // @method distance(latlng1: LatLng, latlng2: LatLng): Number + // Returns the distance between two geographical coordinates. + + // @property code: String + // Standard code name of the CRS passed into WMS services (e.g. `'EPSG:3857'`) + // + // @property wrapLng: Number[] + // An array of two numbers defining whether the longitude (horizontal) coordinate + // axis wraps around a given range and how. Defaults to `[-180, 180]` in most + // geographical CRSs. If `undefined`, the longitude axis does not wrap around. + // + // @property wrapLat: Number[] + // Like `wrapLng`, but for the latitude (vertical) axis. + + // wrapLng: [min, max], + // wrapLat: [min, max], + + // @property infinite: Boolean + // If true, the coordinate space will be unbounded (infinite in both axes) + infinite: false, + + // @method wrapLatLng(latlng: LatLng): LatLng + // Returns a `LatLng` where lat and lng has been wrapped according to the + // CRS's `wrapLat` and `wrapLng` properties, if they are outside the CRS's bounds. + wrapLatLng: function (latlng) { + var lng = this.wrapLng ? L.Util.wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng, + lat = this.wrapLat ? L.Util.wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat, + alt = latlng.alt; + + return L.latLng(lat, lng, alt); + } +}; + + + +/* + * @namespace CRS + * @crs L.CRS.Simple + * + * A simple CRS that maps longitude and latitude into `x` and `y` directly. + * May be used for maps of flat surfaces (e.g. game maps). Note that the `y` + * axis should still be inverted (going from bottom to top). `distance()` returns + * simple euclidean distance. + */ + +L.CRS.Simple = L.extend({}, L.CRS, { + projection: L.Projection.LonLat, + transformation: new L.Transformation(1, 0, -1, 0), + + scale: function (zoom) { + return Math.pow(2, zoom); + }, + + zoom: function (scale) { + return Math.log(scale) / Math.LN2; + }, + + distance: function (latlng1, latlng2) { + var dx = latlng2.lng - latlng1.lng, + dy = latlng2.lat - latlng1.lat; + + return Math.sqrt(dx * dx + dy * dy); + }, + + infinite: true +}); + + + +/* + * @namespace CRS + * @crs L.CRS.Earth + * + * Serves as the base for CRS that are global such that they cover the earth. + * Can only be used as the base for other CRS and cannot be used directly, + * since it does not have a `code`, `projection` or `transformation`. `distance()` returns + * meters. + */ + +L.CRS.Earth = L.extend({}, L.CRS, { + wrapLng: [-180, 180], + + // Mean Earth Radius, as recommended for use by + // the International Union of Geodesy and Geophysics, + // see http://rosettacode.org/wiki/Haversine_formula + R: 6371000, + + // distance between two geographical points using spherical law of cosines approximation + distance: function (latlng1, latlng2) { + var rad = Math.PI / 180, + lat1 = latlng1.lat * rad, + lat2 = latlng2.lat * rad, + a = Math.sin(lat1) * Math.sin(lat2) + + Math.cos(lat1) * Math.cos(lat2) * Math.cos((latlng2.lng - latlng1.lng) * rad); + + return this.R * Math.acos(Math.min(a, 1)); + } +}); + + + +/* + * @namespace CRS + * @crs L.CRS.EPSG3857 + * + * The most common CRS for online maps, used by almost all free and commercial + * tile providers. Uses Spherical Mercator projection. Set in by default in + * Map's `crs` option. + */ + +L.CRS.EPSG3857 = L.extend({}, L.CRS.Earth, { + code: 'EPSG:3857', + projection: L.Projection.SphericalMercator, + + transformation: (function () { + var scale = 0.5 / (Math.PI * L.Projection.SphericalMercator.R); + return new L.Transformation(scale, 0.5, -scale, 0.5); + }()) +}); + +L.CRS.EPSG900913 = L.extend({}, L.CRS.EPSG3857, { + code: 'EPSG:900913' +}); + + + +/* + * @namespace CRS + * @crs L.CRS.EPSG4326 + * + * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection. + * + * Leaflet 1.0.x complies with the [TMS coordinate scheme for EPSG:4326](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic), + * which is a breaking change from 0.7.x behaviour. If you are using a `TileLayer` + * with this CRS, ensure that there are two 256x256 pixel tiles covering the + * whole earth at zoom level zero, and that the tile coordinate origin is (-180,+90), + * or (-180,-90) for `TileLayer`s with [the `tms` option](#tilelayer-tms) set. + */ + +L.CRS.EPSG4326 = L.extend({}, L.CRS.Earth, { + code: 'EPSG:4326', + projection: L.Projection.LonLat, + transformation: new L.Transformation(1 / 180, 1, -1 / 180, 0.5) +}); + + + +/* + * @class Map + * @aka L.Map + * @inherits Evented + * + * The central class of the API — it is used to create a map on a page and manipulate it. + * + * @example + * + * ```js + * // initialize the map on the "map" div with a given center and zoom + * var map = L.map('map', { + * center: [51.505, -0.09], + * zoom: 13 + * }); + * ``` + * + */ + +L.Map = L.Evented.extend({ + + options: { + // @section Map State Options + // @option crs: CRS = L.CRS.EPSG3857 + // The [Coordinate Reference System](#crs) to use. Don't change this if you're not + // sure what it means. + crs: L.CRS.EPSG3857, + + // @option center: LatLng = undefined + // Initial geographic center of the map + center: undefined, + + // @option zoom: Number = undefined + // Initial map zoom level + zoom: undefined, + + // @option minZoom: Number = undefined + // Minimum zoom level of the map. Overrides any `minZoom` option set on map layers. + minZoom: undefined, + + // @option maxZoom: Number = undefined + // Maximum zoom level of the map. Overrides any `maxZoom` option set on map layers. + maxZoom: undefined, + + // @option layers: Layer[] = [] + // Array of layers that will be added to the map initially + layers: [], + + // @option maxBounds: LatLngBounds = null + // When this option is set, the map restricts the view to the given + // geographical bounds, bouncing the user back when he tries to pan + // outside the view. To set the restriction dynamically, use + // [`setMaxBounds`](#map-setmaxbounds) method. + maxBounds: undefined, + + // @option renderer: Renderer = * + // The default method for drawing vector layers on the map. `L.SVG` + // or `L.Canvas` by default depending on browser support. + renderer: undefined, + + + // @section Animation Options + // @option zoomAnimation: Boolean = true + // Whether the map zoom animation is enabled. By default it's enabled + // in all browsers that support CSS3 Transitions except Android. + zoomAnimation: true, + + // @option zoomAnimationThreshold: Number = 4 + // Won't animate zoom if the zoom difference exceeds this value. + zoomAnimationThreshold: 4, + + // @option fadeAnimation: Boolean = true + // Whether the tile fade animation is enabled. By default it's enabled + // in all browsers that support CSS3 Transitions except Android. + fadeAnimation: true, + + // @option markerZoomAnimation: Boolean = true + // Whether markers animate their zoom with the zoom animation, if disabled + // they will disappear for the length of the animation. By default it's + // enabled in all browsers that support CSS3 Transitions except Android. + markerZoomAnimation: true, + + // @option transform3DLimit: Number = 2^23 + // Defines the maximum size of a CSS translation transform. The default + // value should not be changed unless a web browser positions layers in + // the wrong place after doing a large `panBy`. + transform3DLimit: 8388608, // Precision limit of a 32-bit float + + // @section Interaction Options + // @option zoomSnap: Number = 1 + // Forces the map's zoom level to always be a multiple of this, particularly + // right after a [`fitBounds()`](#map-fitbounds) or a pinch-zoom. + // By default, the zoom level snaps to the nearest integer; lower values + // (e.g. `0.5` or `0.1`) allow for greater granularity. A value of `0` + // means the zoom level will not be snapped after `fitBounds` or a pinch-zoom. + zoomSnap: 1, + + // @option zoomDelta: Number = 1 + // Controls how much the map's zoom level will change after a + // [`zoomIn()`](#map-zoomin), [`zoomOut()`](#map-zoomout), pressing `+` + // or `-` on the keyboard, or using the [zoom controls](#control-zoom). + // Values smaller than `1` (e.g. `0.5`) allow for greater granularity. + zoomDelta: 1, + + // @option trackResize: Boolean = true + // Whether the map automatically handles browser window resize to update itself. + trackResize: true + }, + + initialize: function (id, options) { // (HTMLElement or String, Object) + options = L.setOptions(this, options); + + this._initContainer(id); + this._initLayout(); + + // hack for https://github.com/Leaflet/Leaflet/issues/1980 + this._onResize = L.bind(this._onResize, this); + + this._initEvents(); + + if (options.maxBounds) { + this.setMaxBounds(options.maxBounds); + } + + if (options.zoom !== undefined) { + this._zoom = this._limitZoom(options.zoom); + } + + if (options.center && options.zoom !== undefined) { + this.setView(L.latLng(options.center), options.zoom, {reset: true}); + } + + this._handlers = []; + this._layers = {}; + this._zoomBoundLayers = {}; + this._sizeChanged = true; + + this.callInitHooks(); + + // don't animate on browsers without hardware-accelerated transitions or old Android/Opera + this._zoomAnimated = L.DomUtil.TRANSITION && L.Browser.any3d && !L.Browser.mobileOpera && + this.options.zoomAnimation; + + // zoom transitions run with the same duration for all layers, so if one of transitionend events + // happens after starting zoom animation (propagating to the map pane), we know that it ended globally + if (this._zoomAnimated) { + this._createAnimProxy(); + L.DomEvent.on(this._proxy, L.DomUtil.TRANSITION_END, this._catchTransitionEnd, this); + } + + this._addLayers(this.options.layers); + }, + + + // @section Methods for modifying map state + + // @method setView(center: LatLng, zoom: Number, options?: Zoom/pan options): this + // Sets the view of the map (geographical center and zoom) with the given + // animation options. + setView: function (center, zoom, options) { + + zoom = zoom === undefined ? this._zoom : this._limitZoom(zoom); + center = this._limitCenter(L.latLng(center), zoom, this.options.maxBounds); + options = options || {}; + + this._stop(); + + if (this._loaded && !options.reset && options !== true) { + + if (options.animate !== undefined) { + options.zoom = L.extend({animate: options.animate}, options.zoom); + options.pan = L.extend({animate: options.animate, duration: options.duration}, options.pan); + } + + // try animating pan or zoom + var moved = (this._zoom !== zoom) ? + this._tryAnimatedZoom && this._tryAnimatedZoom(center, zoom, options.zoom) : + this._tryAnimatedPan(center, options.pan); + + if (moved) { + // prevent resize handler call, the view will refresh after animation anyway + clearTimeout(this._sizeTimer); + return this; + } + } + + // animation didn't start, just reset the map view + this._resetView(center, zoom); + + return this; + }, + + // @method setZoom(zoom: Number, options: Zoom/pan options): this + // Sets the zoom of the map. + setZoom: function (zoom, options) { + if (!this._loaded) { + this._zoom = zoom; + return this; + } + return this.setView(this.getCenter(), zoom, {zoom: options}); + }, + + // @method zoomIn(delta?: Number, options?: Zoom options): this + // Increases the zoom of the map by `delta` ([`zoomDelta`](#map-zoomdelta) by default). + zoomIn: function (delta, options) { + delta = delta || (L.Browser.any3d ? this.options.zoomDelta : 1); + return this.setZoom(this._zoom + delta, options); + }, + + // @method zoomOut(delta?: Number, options?: Zoom options): this + // Decreases the zoom of the map by `delta` ([`zoomDelta`](#map-zoomdelta) by default). + zoomOut: function (delta, options) { + delta = delta || (L.Browser.any3d ? this.options.zoomDelta : 1); + return this.setZoom(this._zoom - delta, options); + }, + + // @method setZoomAround(latlng: LatLng, zoom: Number, options: Zoom options): this + // Zooms the map while keeping a specified geographical point on the map + // stationary (e.g. used internally for scroll zoom and double-click zoom). + // @alternative + // @method setZoomAround(offset: Point, zoom: Number, options: Zoom options): this + // Zooms the map while keeping a specified pixel on the map (relative to the top-left corner) stationary. + setZoomAround: function (latlng, zoom, options) { + var scale = this.getZoomScale(zoom), + viewHalf = this.getSize().divideBy(2), + containerPoint = latlng instanceof L.Point ? latlng : this.latLngToContainerPoint(latlng), + + centerOffset = containerPoint.subtract(viewHalf).multiplyBy(1 - 1 / scale), + newCenter = this.containerPointToLatLng(viewHalf.add(centerOffset)); + + return this.setView(newCenter, zoom, {zoom: options}); + }, + + _getBoundsCenterZoom: function (bounds, options) { + + options = options || {}; + bounds = bounds.getBounds ? bounds.getBounds() : L.latLngBounds(bounds); + + var paddingTL = L.point(options.paddingTopLeft || options.padding || [0, 0]), + paddingBR = L.point(options.paddingBottomRight || options.padding || [0, 0]), + + zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR)); + + zoom = (typeof options.maxZoom === 'number') ? Math.min(options.maxZoom, zoom) : zoom; + + var paddingOffset = paddingBR.subtract(paddingTL).divideBy(2), + + swPoint = this.project(bounds.getSouthWest(), zoom), + nePoint = this.project(bounds.getNorthEast(), zoom), + center = this.unproject(swPoint.add(nePoint).divideBy(2).add(paddingOffset), zoom); + + return { + center: center, + zoom: zoom + }; + }, + + // @method fitBounds(bounds: LatLngBounds, options: fitBounds options): this + // Sets a map view that contains the given geographical bounds with the + // maximum zoom level possible. + fitBounds: function (bounds, options) { + + bounds = L.latLngBounds(bounds); + + if (!bounds.isValid()) { + throw new Error('Bounds are not valid.'); + } + + var target = this._getBoundsCenterZoom(bounds, options); + return this.setView(target.center, target.zoom, options); + }, + + // @method fitWorld(options?: fitBounds options): this + // Sets a map view that mostly contains the whole world with the maximum + // zoom level possible. + fitWorld: function (options) { + return this.fitBounds([[-90, -180], [90, 180]], options); + }, + + // @method panTo(latlng: LatLng, options?: Pan options): this + // Pans the map to a given center. + panTo: function (center, options) { // (LatLng) + return this.setView(center, this._zoom, {pan: options}); + }, + + // @method panBy(offset: Point): this + // Pans the map by a given number of pixels (animated). + panBy: function (offset, options) { + offset = L.point(offset).round(); + options = options || {}; + + if (!offset.x && !offset.y) { + return this.fire('moveend'); + } + // If we pan too far, Chrome gets issues with tiles + // and makes them disappear or appear in the wrong place (slightly offset) #2602 + if (options.animate !== true && !this.getSize().contains(offset)) { + this._resetView(this.unproject(this.project(this.getCenter()).add(offset)), this.getZoom()); + return this; + } + + if (!this._panAnim) { + this._panAnim = new L.PosAnimation(); + + this._panAnim.on({ + 'step': this._onPanTransitionStep, + 'end': this._onPanTransitionEnd + }, this); + } + + // don't fire movestart if animating inertia + if (!options.noMoveStart) { + this.fire('movestart'); + } + + // animate pan unless animate: false specified + if (options.animate !== false) { + L.DomUtil.addClass(this._mapPane, 'leaflet-pan-anim'); + + var newPos = this._getMapPanePos().subtract(offset).round(); + this._panAnim.run(this._mapPane, newPos, options.duration || 0.25, options.easeLinearity); + } else { + this._rawPanBy(offset); + this.fire('move').fire('moveend'); + } + + return this; + }, + + // @method flyTo(latlng: LatLng, zoom?: Number, options?: Zoom/pan options): this + // Sets the view of the map (geographical center and zoom) performing a smooth + // pan-zoom animation. + flyTo: function (targetCenter, targetZoom, options) { + + options = options || {}; + if (options.animate === false || !L.Browser.any3d) { + return this.setView(targetCenter, targetZoom, options); + } + + this._stop(); + + var from = this.project(this.getCenter()), + to = this.project(targetCenter), + size = this.getSize(), + startZoom = this._zoom; + + targetCenter = L.latLng(targetCenter); + targetZoom = targetZoom === undefined ? startZoom : targetZoom; + + var w0 = Math.max(size.x, size.y), + w1 = w0 * this.getZoomScale(startZoom, targetZoom), + u1 = (to.distanceTo(from)) || 1, + rho = 1.42, + rho2 = rho * rho; + + function r(i) { + var s1 = i ? -1 : 1, + s2 = i ? w1 : w0, + t1 = w1 * w1 - w0 * w0 + s1 * rho2 * rho2 * u1 * u1, + b1 = 2 * s2 * rho2 * u1, + b = t1 / b1, + sq = Math.sqrt(b * b + 1) - b; + + // workaround for floating point precision bug when sq = 0, log = -Infinite, + // thus triggering an infinite loop in flyTo + var log = sq < 0.000000001 ? -18 : Math.log(sq); + + return log; + } + + function sinh(n) { return (Math.exp(n) - Math.exp(-n)) / 2; } + function cosh(n) { return (Math.exp(n) + Math.exp(-n)) / 2; } + function tanh(n) { return sinh(n) / cosh(n); } + + var r0 = r(0); + + function w(s) { return w0 * (cosh(r0) / cosh(r0 + rho * s)); } + function u(s) { return w0 * (cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2; } + + function easeOut(t) { return 1 - Math.pow(1 - t, 1.5); } + + var start = Date.now(), + S = (r(1) - r0) / rho, + duration = options.duration ? 1000 * options.duration : 1000 * S * 0.8; + + function frame() { + var t = (Date.now() - start) / duration, + s = easeOut(t) * S; + + if (t <= 1) { + this._flyToFrame = L.Util.requestAnimFrame(frame, this); + + this._move( + this.unproject(from.add(to.subtract(from).multiplyBy(u(s) / u1)), startZoom), + this.getScaleZoom(w0 / w(s), startZoom), + {flyTo: true}); + + } else { + this + ._move(targetCenter, targetZoom) + ._moveEnd(true); + } + } + + this._moveStart(true); + + frame.call(this); + return this; + }, + + // @method flyToBounds(bounds: LatLngBounds, options?: fitBounds options): this + // Sets the view of the map with a smooth animation like [`flyTo`](#map-flyto), + // but takes a bounds parameter like [`fitBounds`](#map-fitbounds). + flyToBounds: function (bounds, options) { + var target = this._getBoundsCenterZoom(bounds, options); + return this.flyTo(target.center, target.zoom, options); + }, + + // @method setMaxBounds(bounds: Bounds): this + // Restricts the map view to the given bounds (see the [maxBounds](#map-maxbounds) option). + setMaxBounds: function (bounds) { + bounds = L.latLngBounds(bounds); + + if (!bounds.isValid()) { + this.options.maxBounds = null; + return this.off('moveend', this._panInsideMaxBounds); + } else if (this.options.maxBounds) { + this.off('moveend', this._panInsideMaxBounds); + } + + this.options.maxBounds = bounds; + + if (this._loaded) { + this._panInsideMaxBounds(); + } + + return this.on('moveend', this._panInsideMaxBounds); + }, + + // @method setMinZoom(zoom: Number): this + // Sets the lower limit for the available zoom levels (see the [minZoom](#map-minzoom) option). + setMinZoom: function (zoom) { + this.options.minZoom = zoom; + + if (this._loaded && this.getZoom() < this.options.minZoom) { + return this.setZoom(zoom); + } + + return this; + }, + + // @method setMaxZoom(zoom: Number): this + // Sets the upper limit for the available zoom levels (see the [maxZoom](#map-maxzoom) option). + setMaxZoom: function (zoom) { + this.options.maxZoom = zoom; + + if (this._loaded && (this.getZoom() > this.options.maxZoom)) { + return this.setZoom(zoom); + } + + return this; + }, + + // @method panInsideBounds(bounds: LatLngBounds, options?: Pan options): this + // Pans the map to the closest view that would lie inside the given bounds (if it's not already), controlling the animation using the options specific, if any. + panInsideBounds: function (bounds, options) { + this._enforcingBounds = true; + var center = this.getCenter(), + newCenter = this._limitCenter(center, this._zoom, L.latLngBounds(bounds)); + + if (!center.equals(newCenter)) { + this.panTo(newCenter, options); + } + + this._enforcingBounds = false; + return this; + }, + + // @method invalidateSize(options: Zoom/Pan options): this + // Checks if the map container size changed and updates the map if so — + // call it after you've changed the map size dynamically, also animating + // pan by default. If `options.pan` is `false`, panning will not occur. + // If `options.debounceMoveend` is `true`, it will delay `moveend` event so + // that it doesn't happen often even if the method is called many + // times in a row. + + // @alternative + // @method invalidateSize(animate: Boolean): this + // Checks if the map container size changed and updates the map if so — + // call it after you've changed the map size dynamically, also animating + // pan by default. + invalidateSize: function (options) { + if (!this._loaded) { return this; } + + options = L.extend({ + animate: false, + pan: true + }, options === true ? {animate: true} : options); + + var oldSize = this.getSize(); + this._sizeChanged = true; + this._lastCenter = null; + + var newSize = this.getSize(), + oldCenter = oldSize.divideBy(2).round(), + newCenter = newSize.divideBy(2).round(), + offset = oldCenter.subtract(newCenter); + + if (!offset.x && !offset.y) { return this; } + + if (options.animate && options.pan) { + this.panBy(offset); + + } else { + if (options.pan) { + this._rawPanBy(offset); + } + + this.fire('move'); + + if (options.debounceMoveend) { + clearTimeout(this._sizeTimer); + this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200); + } else { + this.fire('moveend'); + } + } + + // @section Map state change events + // @event resize: ResizeEvent + // Fired when the map is resized. + return this.fire('resize', { + oldSize: oldSize, + newSize: newSize + }); + }, + + // @section Methods for modifying map state + // @method stop(): this + // Stops the currently running `panTo` or `flyTo` animation, if any. + stop: function () { + this.setZoom(this._limitZoom(this._zoom)); + if (!this.options.zoomSnap) { + this.fire('viewreset'); + } + return this._stop(); + }, + + // @section Geolocation methods + // @method locate(options?: Locate options): this + // Tries to locate the user using the Geolocation API, firing a [`locationfound`](#map-locationfound) + // event with location data on success or a [`locationerror`](#map-locationerror) event on failure, + // and optionally sets the map view to the user's location with respect to + // detection accuracy (or to the world view if geolocation failed). + // Note that, if your page doesn't use HTTPS, this method will fail in + // modern browsers ([Chrome 50 and newer](https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-powerful-features-on-insecure-origins)) + // See `Locate options` for more details. + locate: function (options) { + + options = this._locateOptions = L.extend({ + timeout: 10000, + watch: false + // setView: false + // maxZoom: + // maximumAge: 0 + // enableHighAccuracy: false + }, options); + + if (!('geolocation' in navigator)) { + this._handleGeolocationError({ + code: 0, + message: 'Geolocation not supported.' + }); + return this; + } + + var onResponse = L.bind(this._handleGeolocationResponse, this), + onError = L.bind(this._handleGeolocationError, this); + + if (options.watch) { + this._locationWatchId = + navigator.geolocation.watchPosition(onResponse, onError, options); + } else { + navigator.geolocation.getCurrentPosition(onResponse, onError, options); + } + return this; + }, + + // @method stopLocate(): this + // Stops watching location previously initiated by `map.locate({watch: true})` + // and aborts resetting the map view if map.locate was called with + // `{setView: true}`. + stopLocate: function () { + if (navigator.geolocation && navigator.geolocation.clearWatch) { + navigator.geolocation.clearWatch(this._locationWatchId); + } + if (this._locateOptions) { + this._locateOptions.setView = false; + } + return this; + }, + + _handleGeolocationError: function (error) { + var c = error.code, + message = error.message || + (c === 1 ? 'permission denied' : + (c === 2 ? 'position unavailable' : 'timeout')); + + if (this._locateOptions.setView && !this._loaded) { + this.fitWorld(); + } + + // @section Location events + // @event locationerror: ErrorEvent + // Fired when geolocation (using the [`locate`](#map-locate) method) failed. + this.fire('locationerror', { + code: c, + message: 'Geolocation error: ' + message + '.' + }); + }, + + _handleGeolocationResponse: function (pos) { + var lat = pos.coords.latitude, + lng = pos.coords.longitude, + latlng = new L.LatLng(lat, lng), + bounds = latlng.toBounds(pos.coords.accuracy), + options = this._locateOptions; + + if (options.setView) { + var zoom = this.getBoundsZoom(bounds); + this.setView(latlng, options.maxZoom ? Math.min(zoom, options.maxZoom) : zoom); + } + + var data = { + latlng: latlng, + bounds: bounds, + timestamp: pos.timestamp + }; + + for (var i in pos.coords) { + if (typeof pos.coords[i] === 'number') { + data[i] = pos.coords[i]; + } + } + + // @event locationfound: LocationEvent + // Fired when geolocation (using the [`locate`](#map-locate) method) + // went successfully. + this.fire('locationfound', data); + }, + + // TODO handler.addTo + // TODO Appropiate docs section? + // @section Other Methods + // @method addHandler(name: String, HandlerClass: Function): this + // Adds a new `Handler` to the map, given its name and constructor function. + addHandler: function (name, HandlerClass) { + if (!HandlerClass) { return this; } + + var handler = this[name] = new HandlerClass(this); + + this._handlers.push(handler); + + if (this.options[name]) { + handler.enable(); + } + + return this; + }, + + // @method remove(): this + // Destroys the map and clears all related event listeners. + remove: function () { + + this._initEvents(true); + + if (this._containerId !== this._container._leaflet_id) { + throw new Error('Map container is being reused by another instance'); + } + + try { + // throws error in IE6-8 + delete this._container._leaflet_id; + delete this._containerId; + } catch (e) { + /*eslint-disable */ + this._container._leaflet_id = undefined; + /*eslint-enable */ + this._containerId = undefined; + } + + L.DomUtil.remove(this._mapPane); + + if (this._clearControlPos) { + this._clearControlPos(); + } + + this._clearHandlers(); + + if (this._loaded) { + // @section Map state change events + // @event unload: Event + // Fired when the map is destroyed with [remove](#map-remove) method. + this.fire('unload'); + } + + for (var i in this._layers) { + this._layers[i].remove(); + } + + return this; + }, + + // @section Other Methods + // @method createPane(name: String, container?: HTMLElement): HTMLElement + // Creates a new [map pane](#map-pane) with the given name if it doesn't exist already, + // then returns it. The pane is created as a children of `container`, or + // as a children of the main map pane if not set. + createPane: function (name, container) { + var className = 'leaflet-pane' + (name ? ' leaflet-' + name.replace('Pane', '') + '-pane' : ''), + pane = L.DomUtil.create('div', className, container || this._mapPane); + + if (name) { + this._panes[name] = pane; + } + return pane; + }, + + // @section Methods for Getting Map State + + // @method getCenter(): LatLng + // Returns the geographical center of the map view + getCenter: function () { + this._checkIfLoaded(); + + if (this._lastCenter && !this._moved()) { + return this._lastCenter; + } + return this.layerPointToLatLng(this._getCenterLayerPoint()); + }, + + // @method getZoom(): Number + // Returns the current zoom level of the map view + getZoom: function () { + return this._zoom; + }, + + // @method getBounds(): LatLngBounds + // Returns the geographical bounds visible in the current map view + getBounds: function () { + var bounds = this.getPixelBounds(), + sw = this.unproject(bounds.getBottomLeft()), + ne = this.unproject(bounds.getTopRight()); + + return new L.LatLngBounds(sw, ne); + }, + + // @method getMinZoom(): Number + // Returns the minimum zoom level of the map (if set in the `minZoom` option of the map or of any layers), or `0` by default. + getMinZoom: function () { + return this.options.minZoom === undefined ? this._layersMinZoom || 0 : this.options.minZoom; + }, + + // @method getMaxZoom(): Number + // Returns the maximum zoom level of the map (if set in the `maxZoom` option of the map or of any layers). + getMaxZoom: function () { + return this.options.maxZoom === undefined ? + (this._layersMaxZoom === undefined ? Infinity : this._layersMaxZoom) : + this.options.maxZoom; + }, + + // @method getBoundsZoom(bounds: LatLngBounds, inside?: Boolean): Number + // Returns the maximum zoom level on which the given bounds fit to the map + // view in its entirety. If `inside` (optional) is set to `true`, the method + // instead returns the minimum zoom level on which the map view fits into + // the given bounds in its entirety. + getBoundsZoom: function (bounds, inside, padding) { // (LatLngBounds[, Boolean, Point]) -> Number + bounds = L.latLngBounds(bounds); + padding = L.point(padding || [0, 0]); + + var zoom = this.getZoom() || 0, + min = this.getMinZoom(), + max = this.getMaxZoom(), + nw = bounds.getNorthWest(), + se = bounds.getSouthEast(), + size = this.getSize().subtract(padding), + boundsSize = this.project(se, zoom).subtract(this.project(nw, zoom)), + snap = L.Browser.any3d ? this.options.zoomSnap : 1; + + var scale = Math.min(size.x / boundsSize.x, size.y / boundsSize.y); + zoom = this.getScaleZoom(scale, zoom); + + if (snap) { + zoom = Math.round(zoom / (snap / 100)) * (snap / 100); // don't jump if within 1% of a snap level + zoom = inside ? Math.ceil(zoom / snap) * snap : Math.floor(zoom / snap) * snap; + } + + return Math.max(min, Math.min(max, zoom)); + }, + + // @method getSize(): Point + // Returns the current size of the map container (in pixels). + getSize: function () { + if (!this._size || this._sizeChanged) { + this._size = new L.Point( + this._container.clientWidth, + this._container.clientHeight); + + this._sizeChanged = false; + } + return this._size.clone(); + }, + + // @method getPixelBounds(): Bounds + // Returns the bounds of the current map view in projected pixel + // coordinates (sometimes useful in layer and overlay implementations). + getPixelBounds: function (center, zoom) { + var topLeftPoint = this._getTopLeftPoint(center, zoom); + return new L.Bounds(topLeftPoint, topLeftPoint.add(this.getSize())); + }, + + // TODO: Check semantics - isn't the pixel origin the 0,0 coord relative to + // the map pane? "left point of the map layer" can be confusing, specially + // since there can be negative offsets. + // @method getPixelOrigin(): Point + // Returns the projected pixel coordinates of the top left point of + // the map layer (useful in custom layer and overlay implementations). + getPixelOrigin: function () { + this._checkIfLoaded(); + return this._pixelOrigin; + }, + + // @method getPixelWorldBounds(zoom?: Number): Bounds + // Returns the world's bounds in pixel coordinates for zoom level `zoom`. + // If `zoom` is omitted, the map's current zoom level is used. + getPixelWorldBounds: function (zoom) { + return this.options.crs.getProjectedBounds(zoom === undefined ? this.getZoom() : zoom); + }, + + // @section Other Methods + + // @method getPane(pane: String|HTMLElement): HTMLElement + // Returns a [map pane](#map-pane), given its name or its HTML element (its identity). + getPane: function (pane) { + return typeof pane === 'string' ? this._panes[pane] : pane; + }, + + // @method getPanes(): Object + // Returns a plain object containing the names of all [panes](#map-pane) as keys and + // the panes as values. + getPanes: function () { + return this._panes; + }, + + // @method getContainer: HTMLElement + // Returns the HTML element that contains the map. + getContainer: function () { + return this._container; + }, + + + // @section Conversion Methods + + // @method getZoomScale(toZoom: Number, fromZoom: Number): Number + // Returns the scale factor to be applied to a map transition from zoom level + // `fromZoom` to `toZoom`. Used internally to help with zoom animations. + getZoomScale: function (toZoom, fromZoom) { + // TODO replace with universal implementation after refactoring projections + var crs = this.options.crs; + fromZoom = fromZoom === undefined ? this._zoom : fromZoom; + return crs.scale(toZoom) / crs.scale(fromZoom); + }, + + // @method getScaleZoom(scale: Number, fromZoom: Number): Number + // Returns the zoom level that the map would end up at, if it is at `fromZoom` + // level and everything is scaled by a factor of `scale`. Inverse of + // [`getZoomScale`](#map-getZoomScale). + getScaleZoom: function (scale, fromZoom) { + var crs = this.options.crs; + fromZoom = fromZoom === undefined ? this._zoom : fromZoom; + var zoom = crs.zoom(scale * crs.scale(fromZoom)); + return isNaN(zoom) ? Infinity : zoom; + }, + + // @method project(latlng: LatLng, zoom: Number): Point + // Projects a geographical coordinate `LatLng` according to the projection + // of the map's CRS, then scales it according to `zoom` and the CRS's + // `Transformation`. The result is pixel coordinate relative to + // the CRS origin. + project: function (latlng, zoom) { + zoom = zoom === undefined ? this._zoom : zoom; + return this.options.crs.latLngToPoint(L.latLng(latlng), zoom); + }, + + // @method unproject(point: Point, zoom: Number): LatLng + // Inverse of [`project`](#map-project). + unproject: function (point, zoom) { + zoom = zoom === undefined ? this._zoom : zoom; + return this.options.crs.pointToLatLng(L.point(point), zoom); + }, + + // @method layerPointToLatLng(point: Point): LatLng + // Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin), + // returns the corresponding geographical coordinate (for the current zoom level). + layerPointToLatLng: function (point) { + var projectedPoint = L.point(point).add(this.getPixelOrigin()); + return this.unproject(projectedPoint); + }, + + // @method latLngToLayerPoint(latlng: LatLng): Point + // Given a geographical coordinate, returns the corresponding pixel coordinate + // relative to the [origin pixel](#map-getpixelorigin). + latLngToLayerPoint: function (latlng) { + var projectedPoint = this.project(L.latLng(latlng))._round(); + return projectedPoint._subtract(this.getPixelOrigin()); + }, + + // @method wrapLatLng(latlng: LatLng): LatLng + // Returns a `LatLng` where `lat` and `lng` has been wrapped according to the + // map's CRS's `wrapLat` and `wrapLng` properties, if they are outside the + // CRS's bounds. + // By default this means longitude is wrapped around the dateline so its + // value is between -180 and +180 degrees. + wrapLatLng: function (latlng) { + return this.options.crs.wrapLatLng(L.latLng(latlng)); + }, + + // @method distance(latlng1: LatLng, latlng2: LatLng): Number + // Returns the distance between two geographical coordinates according to + // the map's CRS. By default this measures distance in meters. + distance: function (latlng1, latlng2) { + return this.options.crs.distance(L.latLng(latlng1), L.latLng(latlng2)); + }, + + // @method containerPointToLayerPoint(point: Point): Point + // Given a pixel coordinate relative to the map container, returns the corresponding + // pixel coordinate relative to the [origin pixel](#map-getpixelorigin). + containerPointToLayerPoint: function (point) { // (Point) + return L.point(point).subtract(this._getMapPanePos()); + }, + + // @method layerPointToContainerPoint(point: Point): Point + // Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin), + // returns the corresponding pixel coordinate relative to the map container. + layerPointToContainerPoint: function (point) { // (Point) + return L.point(point).add(this._getMapPanePos()); + }, + + // @method containerPointToLatLng(point: Point): Point + // Given a pixel coordinate relative to the map container, returns + // the corresponding geographical coordinate (for the current zoom level). + containerPointToLatLng: function (point) { + var layerPoint = this.containerPointToLayerPoint(L.point(point)); + return this.layerPointToLatLng(layerPoint); + }, + + // @method latLngToContainerPoint(latlng: LatLng): Point + // Given a geographical coordinate, returns the corresponding pixel coordinate + // relative to the map container. + latLngToContainerPoint: function (latlng) { + return this.layerPointToContainerPoint(this.latLngToLayerPoint(L.latLng(latlng))); + }, + + // @method mouseEventToContainerPoint(ev: MouseEvent): Point + // Given a MouseEvent object, returns the pixel coordinate relative to the + // map container where the event took place. + mouseEventToContainerPoint: function (e) { + return L.DomEvent.getMousePosition(e, this._container); + }, + + // @method mouseEventToLayerPoint(ev: MouseEvent): Point + // Given a MouseEvent object, returns the pixel coordinate relative to + // the [origin pixel](#map-getpixelorigin) where the event took place. + mouseEventToLayerPoint: function (e) { + return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(e)); + }, + + // @method mouseEventToLatLng(ev: MouseEvent): LatLng + // Given a MouseEvent object, returns geographical coordinate where the + // event took place. + mouseEventToLatLng: function (e) { // (MouseEvent) + return this.layerPointToLatLng(this.mouseEventToLayerPoint(e)); + }, + + + // map initialization methods + + _initContainer: function (id) { + var container = this._container = L.DomUtil.get(id); + + if (!container) { + throw new Error('Map container not found.'); + } else if (container._leaflet_id) { + throw new Error('Map container is already initialized.'); + } + + L.DomEvent.addListener(container, 'scroll', this._onScroll, this); + this._containerId = L.Util.stamp(container); + }, + + _initLayout: function () { + var container = this._container; + + this._fadeAnimated = this.options.fadeAnimation && L.Browser.any3d; + + L.DomUtil.addClass(container, 'leaflet-container' + + (L.Browser.touch ? ' leaflet-touch' : '') + + (L.Browser.retina ? ' leaflet-retina' : '') + + (L.Browser.ielt9 ? ' leaflet-oldie' : '') + + (L.Browser.safari ? ' leaflet-safari' : '') + + (this._fadeAnimated ? ' leaflet-fade-anim' : '')); + + var position = L.DomUtil.getStyle(container, 'position'); + + if (position !== 'absolute' && position !== 'relative' && position !== 'fixed') { + container.style.position = 'relative'; + } + + this._initPanes(); + + if (this._initControlPos) { + this._initControlPos(); + } + }, + + _initPanes: function () { + var panes = this._panes = {}; + this._paneRenderers = {}; + + // @section + // + // Panes are DOM elements used to control the ordering of layers on the map. You + // can access panes with [`map.getPane`](#map-getpane) or + // [`map.getPanes`](#map-getpanes) methods. New panes can be created with the + // [`map.createPane`](#map-createpane) method. + // + // Every map has the following default panes that differ only in zIndex. + // + // @pane mapPane: HTMLElement = 'auto' + // Pane that contains all other map panes + + this._mapPane = this.createPane('mapPane', this._container); + L.DomUtil.setPosition(this._mapPane, new L.Point(0, 0)); + + // @pane tilePane: HTMLElement = 200 + // Pane for `GridLayer`s and `TileLayer`s + this.createPane('tilePane'); + // @pane overlayPane: HTMLElement = 400 + // Pane for vector overlays (`Path`s), like `Polyline`s and `Polygon`s + this.createPane('shadowPane'); + // @pane shadowPane: HTMLElement = 500 + // Pane for overlay shadows (e.g. `Marker` shadows) + this.createPane('overlayPane'); + // @pane markerPane: HTMLElement = 600 + // Pane for `Icon`s of `Marker`s + this.createPane('markerPane'); + // @pane tooltipPane: HTMLElement = 650 + // Pane for tooltip. + this.createPane('tooltipPane'); + // @pane popupPane: HTMLElement = 700 + // Pane for `Popup`s. + this.createPane('popupPane'); + + if (!this.options.markerZoomAnimation) { + L.DomUtil.addClass(panes.markerPane, 'leaflet-zoom-hide'); + L.DomUtil.addClass(panes.shadowPane, 'leaflet-zoom-hide'); + } + }, + + + // private methods that modify map state + + // @section Map state change events + _resetView: function (center, zoom) { + L.DomUtil.setPosition(this._mapPane, new L.Point(0, 0)); + + var loading = !this._loaded; + this._loaded = true; + zoom = this._limitZoom(zoom); + + this.fire('viewprereset'); + + var zoomChanged = this._zoom !== zoom; + this + ._moveStart(zoomChanged) + ._move(center, zoom) + ._moveEnd(zoomChanged); + + // @event viewreset: Event + // Fired when the map needs to redraw its content (this usually happens + // on map zoom or load). Very useful for creating custom overlays. + this.fire('viewreset'); + + // @event load: Event + // Fired when the map is initialized (when its center and zoom are set + // for the first time). + if (loading) { + this.fire('load'); + } + }, + + _moveStart: function (zoomChanged) { + // @event zoomstart: Event + // Fired when the map zoom is about to change (e.g. before zoom animation). + // @event movestart: Event + // Fired when the view of the map starts changing (e.g. user starts dragging the map). + if (zoomChanged) { + this.fire('zoomstart'); + } + return this.fire('movestart'); + }, + + _move: function (center, zoom, data) { + if (zoom === undefined) { + zoom = this._zoom; + } + var zoomChanged = this._zoom !== zoom; + + this._zoom = zoom; + this._lastCenter = center; + this._pixelOrigin = this._getNewPixelOrigin(center); + + // @event zoom: Event + // Fired repeatedly during any change in zoom level, including zoom + // and fly animations. + if (zoomChanged || (data && data.pinch)) { // Always fire 'zoom' if pinching because #3530 + this.fire('zoom', data); + } + + // @event move: Event + // Fired repeatedly during any movement of the map, including pan and + // fly animations. + return this.fire('move', data); + }, + + _moveEnd: function (zoomChanged) { + // @event zoomend: Event + // Fired when the map has changed, after any animations. + if (zoomChanged) { + this.fire('zoomend'); + } + + // @event moveend: Event + // Fired when the center of the map stops changing (e.g. user stopped + // dragging the map). + return this.fire('moveend'); + }, + + _stop: function () { + L.Util.cancelAnimFrame(this._flyToFrame); + if (this._panAnim) { + this._panAnim.stop(); + } + return this; + }, + + _rawPanBy: function (offset) { + L.DomUtil.setPosition(this._mapPane, this._getMapPanePos().subtract(offset)); + }, + + _getZoomSpan: function () { + return this.getMaxZoom() - this.getMinZoom(); + }, + + _panInsideMaxBounds: function () { + if (!this._enforcingBounds) { + this.panInsideBounds(this.options.maxBounds); + } + }, + + _checkIfLoaded: function () { + if (!this._loaded) { + throw new Error('Set map center and zoom first.'); + } + }, + + // DOM event handling + + // @section Interaction events + _initEvents: function (remove) { + if (!L.DomEvent) { return; } + + this._targets = {}; + this._targets[L.stamp(this._container)] = this; + + var onOff = remove ? 'off' : 'on'; + + // @event click: MouseEvent + // Fired when the user clicks (or taps) the map. + // @event dblclick: MouseEvent + // Fired when the user double-clicks (or double-taps) the map. + // @event mousedown: MouseEvent + // Fired when the user pushes the mouse button on the map. + // @event mouseup: MouseEvent + // Fired when the user releases the mouse button on the map. + // @event mouseover: MouseEvent + // Fired when the mouse enters the map. + // @event mouseout: MouseEvent + // Fired when the mouse leaves the map. + // @event mousemove: MouseEvent + // Fired while the mouse moves over the map. + // @event contextmenu: MouseEvent + // Fired when the user pushes the right mouse button on the map, prevents + // default browser context menu from showing if there are listeners on + // this event. Also fired on mobile when the user holds a single touch + // for a second (also called long press). + // @event keypress: KeyboardEvent + // Fired when the user presses a key from the keyboard while the map is focused. + L.DomEvent[onOff](this._container, 'click dblclick mousedown mouseup ' + + 'mouseover mouseout mousemove contextmenu keypress', this._handleDOMEvent, this); + + if (this.options.trackResize) { + L.DomEvent[onOff](window, 'resize', this._onResize, this); + } + + if (L.Browser.any3d && this.options.transform3DLimit) { + this[onOff]('moveend', this._onMoveEnd); + } + }, + + _onResize: function () { + L.Util.cancelAnimFrame(this._resizeRequest); + this._resizeRequest = L.Util.requestAnimFrame( + function () { this.invalidateSize({debounceMoveend: true}); }, this); + }, + + _onScroll: function () { + this._container.scrollTop = 0; + this._container.scrollLeft = 0; + }, + + _onMoveEnd: function () { + var pos = this._getMapPanePos(); + if (Math.max(Math.abs(pos.x), Math.abs(pos.y)) >= this.options.transform3DLimit) { + // https://bugzilla.mozilla.org/show_bug.cgi?id=1203873 but Webkit also have + // a pixel offset on very high values, see: http://jsfiddle.net/dg6r5hhb/ + this._resetView(this.getCenter(), this.getZoom()); + } + }, + + _findEventTargets: function (e, type) { + var targets = [], + target, + isHover = type === 'mouseout' || type === 'mouseover', + src = e.target || e.srcElement, + dragging = false; + + while (src) { + target = this._targets[L.stamp(src)]; + if (target && (type === 'click' || type === 'preclick') && !e._simulated && this._draggableMoved(target)) { + // Prevent firing click after you just dragged an object. + dragging = true; + break; + } + if (target && target.listens(type, true)) { + if (isHover && !L.DomEvent._isExternalTarget(src, e)) { break; } + targets.push(target); + if (isHover) { break; } + } + if (src === this._container) { break; } + src = src.parentNode; + } + if (!targets.length && !dragging && !isHover && L.DomEvent._isExternalTarget(src, e)) { + targets = [this]; + } + return targets; + }, + + _handleDOMEvent: function (e) { + if (!this._loaded || L.DomEvent._skipped(e)) { return; } + + var type = e.type === 'keypress' && e.keyCode === 13 ? 'click' : e.type; + + if (type === 'mousedown') { + // prevents outline when clicking on keyboard-focusable element + L.DomUtil.preventOutline(e.target || e.srcElement); + } + + this._fireDOMEvent(e, type); + }, + + _fireDOMEvent: function (e, type, targets) { + + if (e.type === 'click') { + // Fire a synthetic 'preclick' event which propagates up (mainly for closing popups). + // @event preclick: MouseEvent + // Fired before mouse click on the map (sometimes useful when you + // want something to happen on click before any existing click + // handlers start running). + var synth = L.Util.extend({}, e); + synth.type = 'preclick'; + this._fireDOMEvent(synth, synth.type, targets); + } + + if (e._stopped) { return; } + + // Find the layer the event is propagating from and its parents. + targets = (targets || []).concat(this._findEventTargets(e, type)); + + if (!targets.length) { return; } + + var target = targets[0]; + if (type === 'contextmenu' && target.listens(type, true)) { + L.DomEvent.preventDefault(e); + } + + var data = { + originalEvent: e + }; + + if (e.type !== 'keypress') { + var isMarker = target instanceof L.Marker; + data.containerPoint = isMarker ? + this.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e); + data.layerPoint = this.containerPointToLayerPoint(data.containerPoint); + data.latlng = isMarker ? target.getLatLng() : this.layerPointToLatLng(data.layerPoint); + } + + for (var i = 0; i < targets.length; i++) { + targets[i].fire(type, data, true); + if (data.originalEvent._stopped || + (targets[i].options.nonBubblingEvents && L.Util.indexOf(targets[i].options.nonBubblingEvents, type) !== -1)) { return; } + } + }, + + _draggableMoved: function (obj) { + obj = obj.dragging && obj.dragging.enabled() ? obj : this; + return (obj.dragging && obj.dragging.moved()) || (this.boxZoom && this.boxZoom.moved()); + }, + + _clearHandlers: function () { + for (var i = 0, len = this._handlers.length; i < len; i++) { + this._handlers[i].disable(); + } + }, + + // @section Other Methods + + // @method whenReady(fn: Function, context?: Object): this + // Runs the given function `fn` when the map gets initialized with + // a view (center and zoom) and at least one layer, or immediately + // if it's already initialized, optionally passing a function context. + whenReady: function (callback, context) { + if (this._loaded) { + callback.call(context || this, {target: this}); + } else { + this.on('load', callback, context); + } + return this; + }, + + + // private methods for getting map state + + _getMapPanePos: function () { + return L.DomUtil.getPosition(this._mapPane) || new L.Point(0, 0); + }, + + _moved: function () { + var pos = this._getMapPanePos(); + return pos && !pos.equals([0, 0]); + }, + + _getTopLeftPoint: function (center, zoom) { + var pixelOrigin = center && zoom !== undefined ? + this._getNewPixelOrigin(center, zoom) : + this.getPixelOrigin(); + return pixelOrigin.subtract(this._getMapPanePos()); + }, + + _getNewPixelOrigin: function (center, zoom) { + var viewHalf = this.getSize()._divideBy(2); + return this.project(center, zoom)._subtract(viewHalf)._add(this._getMapPanePos())._round(); + }, + + _latLngToNewLayerPoint: function (latlng, zoom, center) { + var topLeft = this._getNewPixelOrigin(center, zoom); + return this.project(latlng, zoom)._subtract(topLeft); + }, + + _latLngBoundsToNewLayerBounds: function (latLngBounds, zoom, center) { + var topLeft = this._getNewPixelOrigin(center, zoom); + return L.bounds([ + this.project(latLngBounds.getSouthWest(), zoom)._subtract(topLeft), + this.project(latLngBounds.getNorthWest(), zoom)._subtract(topLeft), + this.project(latLngBounds.getSouthEast(), zoom)._subtract(topLeft), + this.project(latLngBounds.getNorthEast(), zoom)._subtract(topLeft) + ]); + }, + + // layer point of the current center + _getCenterLayerPoint: function () { + return this.containerPointToLayerPoint(this.getSize()._divideBy(2)); + }, + + // offset of the specified place to the current center in pixels + _getCenterOffset: function (latlng) { + return this.latLngToLayerPoint(latlng).subtract(this._getCenterLayerPoint()); + }, + + // adjust center for view to get inside bounds + _limitCenter: function (center, zoom, bounds) { + + if (!bounds) { return center; } + + var centerPoint = this.project(center, zoom), + viewHalf = this.getSize().divideBy(2), + viewBounds = new L.Bounds(centerPoint.subtract(viewHalf), centerPoint.add(viewHalf)), + offset = this._getBoundsOffset(viewBounds, bounds, zoom); + + // If offset is less than a pixel, ignore. + // This prevents unstable projections from getting into + // an infinite loop of tiny offsets. + if (offset.round().equals([0, 0])) { + return center; + } + + return this.unproject(centerPoint.add(offset), zoom); + }, + + // adjust offset for view to get inside bounds + _limitOffset: function (offset, bounds) { + if (!bounds) { return offset; } + + var viewBounds = this.getPixelBounds(), + newBounds = new L.Bounds(viewBounds.min.add(offset), viewBounds.max.add(offset)); + + return offset.add(this._getBoundsOffset(newBounds, bounds)); + }, + + // returns offset needed for pxBounds to get inside maxBounds at a specified zoom + _getBoundsOffset: function (pxBounds, maxBounds, zoom) { + var projectedMaxBounds = L.bounds( + this.project(maxBounds.getNorthEast(), zoom), + this.project(maxBounds.getSouthWest(), zoom) + ), + minOffset = projectedMaxBounds.min.subtract(pxBounds.min), + maxOffset = projectedMaxBounds.max.subtract(pxBounds.max), + + dx = this._rebound(minOffset.x, -maxOffset.x), + dy = this._rebound(minOffset.y, -maxOffset.y); + + return new L.Point(dx, dy); + }, + + _rebound: function (left, right) { + return left + right > 0 ? + Math.round(left - right) / 2 : + Math.max(0, Math.ceil(left)) - Math.max(0, Math.floor(right)); + }, + + _limitZoom: function (zoom) { + var min = this.getMinZoom(), + max = this.getMaxZoom(), + snap = L.Browser.any3d ? this.options.zoomSnap : 1; + if (snap) { + zoom = Math.round(zoom / snap) * snap; + } + return Math.max(min, Math.min(max, zoom)); + }, + + _onPanTransitionStep: function () { + this.fire('move'); + }, + + _onPanTransitionEnd: function () { + L.DomUtil.removeClass(this._mapPane, 'leaflet-pan-anim'); + this.fire('moveend'); + }, + + _tryAnimatedPan: function (center, options) { + // difference between the new and current centers in pixels + var offset = this._getCenterOffset(center)._floor(); + + // don't animate too far unless animate: true specified in options + if ((options && options.animate) !== true && !this.getSize().contains(offset)) { return false; } + + this.panBy(offset, options); + + return true; + }, + + _createAnimProxy: function () { + + var proxy = this._proxy = L.DomUtil.create('div', 'leaflet-proxy leaflet-zoom-animated'); + this._panes.mapPane.appendChild(proxy); + + this.on('zoomanim', function (e) { + var prop = L.DomUtil.TRANSFORM, + transform = proxy.style[prop]; + + L.DomUtil.setTransform(proxy, this.project(e.center, e.zoom), this.getZoomScale(e.zoom, 1)); + + // workaround for case when transform is the same and so transitionend event is not fired + if (transform === proxy.style[prop] && this._animatingZoom) { + this._onZoomTransitionEnd(); + } + }, this); + + this.on('load moveend', function () { + var c = this.getCenter(), + z = this.getZoom(); + L.DomUtil.setTransform(proxy, this.project(c, z), this.getZoomScale(z, 1)); + }, this); + }, + + _catchTransitionEnd: function (e) { + if (this._animatingZoom && e.propertyName.indexOf('transform') >= 0) { + this._onZoomTransitionEnd(); + } + }, + + _nothingToAnimate: function () { + return !this._container.getElementsByClassName('leaflet-zoom-animated').length; + }, + + _tryAnimatedZoom: function (center, zoom, options) { + + if (this._animatingZoom) { return true; } + + options = options || {}; + + // don't animate if disabled, not supported or zoom difference is too large + if (!this._zoomAnimated || options.animate === false || this._nothingToAnimate() || + Math.abs(zoom - this._zoom) > this.options.zoomAnimationThreshold) { return false; } + + // offset is the pixel coords of the zoom origin relative to the current center + var scale = this.getZoomScale(zoom), + offset = this._getCenterOffset(center)._divideBy(1 - 1 / scale); + + // don't animate if the zoom origin isn't within one screen from the current center, unless forced + if (options.animate !== true && !this.getSize().contains(offset)) { return false; } + + L.Util.requestAnimFrame(function () { + this + ._moveStart(true) + ._animateZoom(center, zoom, true); + }, this); + + return true; + }, + + _animateZoom: function (center, zoom, startAnim, noUpdate) { + if (startAnim) { + this._animatingZoom = true; + + // remember what center/zoom to set after animation + this._animateToCenter = center; + this._animateToZoom = zoom; + + L.DomUtil.addClass(this._mapPane, 'leaflet-zoom-anim'); + } + + // @event zoomanim: ZoomAnimEvent + // Fired on every frame of a zoom animation + this.fire('zoomanim', { + center: center, + zoom: zoom, + noUpdate: noUpdate + }); + + // Work around webkit not firing 'transitionend', see https://github.com/Leaflet/Leaflet/issues/3689, 2693 + setTimeout(L.bind(this._onZoomTransitionEnd, this), 250); + }, + + _onZoomTransitionEnd: function () { + if (!this._animatingZoom) { return; } + + L.DomUtil.removeClass(this._mapPane, 'leaflet-zoom-anim'); + + this._animatingZoom = false; + + this._move(this._animateToCenter, this._animateToZoom); + + // This anim frame should prevent an obscure iOS webkit tile loading race condition. + L.Util.requestAnimFrame(function () { + this._moveEnd(true); + }, this); + } +}); + +// @section + +// @factory L.map(id: String, options?: Map options) +// Instantiates a map object given the DOM ID of a `
      ` element +// and optionally an object literal with `Map options`. +// +// @alternative +// @factory L.map(el: HTMLElement, options?: Map options) +// Instantiates a map object given an instance of a `
      ` HTML element +// and optionally an object literal with `Map options`. +L.map = function (id, options) { + return new L.Map(id, options); +}; + + + + +/* + * @class Layer + * @inherits Evented + * @aka L.Layer + * @aka ILayer + * + * A set of methods from the Layer base class that all Leaflet layers use. + * Inherits all methods, options and events from `L.Evented`. + * + * @example + * + * ```js + * var layer = L.Marker(latlng).addTo(map); + * layer.addTo(map); + * layer.remove(); + * ``` + * + * @event add: Event + * Fired after the layer is added to a map + * + * @event remove: Event + * Fired after the layer is removed from a map + */ + + +L.Layer = L.Evented.extend({ + + // Classes extending `L.Layer` will inherit the following options: + options: { + // @option pane: String = 'overlayPane' + // By default the layer will be added to the map's [overlay pane](#map-overlaypane). Overriding this option will cause the layer to be placed on another pane by default. + pane: 'overlayPane', + nonBubblingEvents: [], // Array of events that should not be bubbled to DOM parents (like the map), + + // @option attribution: String = null + // String to be shown in the attribution control, describes the layer data, e.g. "© Mapbox". + attribution: null, + }, + + /* @section + * Classes extending `L.Layer` will inherit the following methods: + * + * @method addTo(map: Map): this + * Adds the layer to the given map + */ + addTo: function (map) { + map.addLayer(this); + return this; + }, + + // @method remove: this + // Removes the layer from the map it is currently active on. + remove: function () { + return this.removeFrom(this._map || this._mapToAdd); + }, + + // @method removeFrom(map: Map): this + // Removes the layer from the given map + removeFrom: function (obj) { + if (obj) { + obj.removeLayer(this); + } + return this; + }, + + // @method getPane(name? : String): HTMLElement + // Returns the `HTMLElement` representing the named pane on the map. If `name` is omitted, returns the pane for this layer. + getPane: function (name) { + return this._map.getPane(name ? (this.options[name] || name) : this.options.pane); + }, + + addInteractiveTarget: function (targetEl) { + this._map._targets[L.stamp(targetEl)] = this; + return this; + }, + + removeInteractiveTarget: function (targetEl) { + delete this._map._targets[L.stamp(targetEl)]; + return this; + }, + + // @method getAttribution: String + // Used by the `attribution control`, returns the [attribution option](#gridlayer-attribution). + getAttribution: function () { + return this.options.attribution; + }, + + _layerAdd: function (e) { + var map = e.target; + + // check in case layer gets added and then removed before the map is ready + if (!map.hasLayer(this)) { return; } + + this._map = map; + this._zoomAnimated = map._zoomAnimated; + + if (this.getEvents) { + var events = this.getEvents(); + map.on(events, this); + this.once('remove', function () { + map.off(events, this); + }, this); + } + + this.onAdd(map); + + if (this.getAttribution && this._map.attributionControl) { + this._map.attributionControl.addAttribution(this.getAttribution()); + } + + this.fire('add'); + map.fire('layeradd', {layer: this}); + } +}); + +/* @section Extension methods + * @uninheritable + * + * Every layer should extend from `L.Layer` and (re-)implement the following methods. + * + * @method onAdd(map: Map): this + * Should contain code that creates DOM elements for the layer, adds them to `map panes` where they should belong and puts listeners on relevant map events. Called on [`map.addLayer(layer)`](#map-addlayer). + * + * @method onRemove(map: Map): this + * Should contain all clean up code that removes the layer's elements from the DOM and removes listeners previously added in [`onAdd`](#layer-onadd). Called on [`map.removeLayer(layer)`](#map-removelayer). + * + * @method getEvents(): Object + * This optional method should return an object like `{ viewreset: this._reset }` for [`addEventListener`](#evented-addeventlistener). The event handlers in this object will be automatically added and removed from the map with your layer. + * + * @method getAttribution(): String + * This optional method should return a string containing HTML to be shown on the `Attribution control` whenever the layer is visible. + * + * @method beforeAdd(map: Map): this + * Optional method. Called on [`map.addLayer(layer)`](#map-addlayer), before the layer is added to the map, before events are initialized, without waiting until the map is in a usable state. Use for early initialization only. + */ + + +/* @namespace Map + * @section Layer events + * + * @event layeradd: LayerEvent + * Fired when a new layer is added to the map. + * + * @event layerremove: LayerEvent + * Fired when some layer is removed from the map + * + * @section Methods for Layers and Controls + */ +L.Map.include({ + // @method addLayer(layer: Layer): this + // Adds the given layer to the map + addLayer: function (layer) { + var id = L.stamp(layer); + if (this._layers[id]) { return this; } + this._layers[id] = layer; + + layer._mapToAdd = this; + + if (layer.beforeAdd) { + layer.beforeAdd(this); + } + + this.whenReady(layer._layerAdd, layer); + + return this; + }, + + // @method removeLayer(layer: Layer): this + // Removes the given layer from the map. + removeLayer: function (layer) { + var id = L.stamp(layer); + + if (!this._layers[id]) { return this; } + + if (this._loaded) { + layer.onRemove(this); + } + + if (layer.getAttribution && this.attributionControl) { + this.attributionControl.removeAttribution(layer.getAttribution()); + } + + delete this._layers[id]; + + if (this._loaded) { + this.fire('layerremove', {layer: layer}); + layer.fire('remove'); + } + + layer._map = layer._mapToAdd = null; + + return this; + }, + + // @method hasLayer(layer: Layer): Boolean + // Returns `true` if the given layer is currently added to the map + hasLayer: function (layer) { + return !!layer && (L.stamp(layer) in this._layers); + }, + + /* @method eachLayer(fn: Function, context?: Object): this + * Iterates over the layers of the map, optionally specifying context of the iterator function. + * ``` + * map.eachLayer(function(layer){ + * layer.bindPopup('Hello'); + * }); + * ``` + */ + eachLayer: function (method, context) { + for (var i in this._layers) { + method.call(context, this._layers[i]); + } + return this; + }, + + _addLayers: function (layers) { + layers = layers ? (L.Util.isArray(layers) ? layers : [layers]) : []; + + for (var i = 0, len = layers.length; i < len; i++) { + this.addLayer(layers[i]); + } + }, + + _addZoomLimit: function (layer) { + if (isNaN(layer.options.maxZoom) || !isNaN(layer.options.minZoom)) { + this._zoomBoundLayers[L.stamp(layer)] = layer; + this._updateZoomLevels(); + } + }, + + _removeZoomLimit: function (layer) { + var id = L.stamp(layer); + + if (this._zoomBoundLayers[id]) { + delete this._zoomBoundLayers[id]; + this._updateZoomLevels(); + } + }, + + _updateZoomLevels: function () { + var minZoom = Infinity, + maxZoom = -Infinity, + oldZoomSpan = this._getZoomSpan(); + + for (var i in this._zoomBoundLayers) { + var options = this._zoomBoundLayers[i].options; + + minZoom = options.minZoom === undefined ? minZoom : Math.min(minZoom, options.minZoom); + maxZoom = options.maxZoom === undefined ? maxZoom : Math.max(maxZoom, options.maxZoom); + } + + this._layersMaxZoom = maxZoom === -Infinity ? undefined : maxZoom; + this._layersMinZoom = minZoom === Infinity ? undefined : minZoom; + + // @section Map state change events + // @event zoomlevelschange: Event + // Fired when the number of zoomlevels on the map is changed due + // to adding or removing a layer. + if (oldZoomSpan !== this._getZoomSpan()) { + this.fire('zoomlevelschange'); + } + + if (this.options.maxZoom === undefined && this._layersMaxZoom && this.getZoom() > this._layersMaxZoom) { + this.setZoom(this._layersMaxZoom); + } + if (this.options.minZoom === undefined && this._layersMinZoom && this.getZoom() < this._layersMinZoom) { + this.setZoom(this._layersMinZoom); + } + } +}); + + + +/* + * @namespace DomEvent + * Utility functions to work with the [DOM events](https://developer.mozilla.org/docs/Web/API/Event), used by Leaflet internally. + */ + +// Inspired by John Resig, Dean Edwards and YUI addEvent implementations. + + + +var eventsKey = '_leaflet_events'; + +L.DomEvent = { + + // @function on(el: HTMLElement, types: String, fn: Function, context?: Object): this + // Adds a listener function (`fn`) to a particular DOM event type of the + // element `el`. You can optionally specify the context of the listener + // (object the `this` keyword will point to). You can also pass several + // space-separated types (e.g. `'click dblclick'`). + + // @alternative + // @function on(el: HTMLElement, eventMap: Object, context?: Object): this + // Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}` + on: function (obj, types, fn, context) { + + if (typeof types === 'object') { + for (var type in types) { + this._on(obj, type, types[type], fn); + } + } else { + types = L.Util.splitWords(types); + + for (var i = 0, len = types.length; i < len; i++) { + this._on(obj, types[i], fn, context); + } + } + + return this; + }, + + // @function off(el: HTMLElement, types: String, fn: Function, context?: Object): this + // Removes a previously added listener function. If no function is specified, + // it will remove all the listeners of that particular DOM event from the element. + // Note that if you passed a custom context to on, you must pass the same + // context to `off` in order to remove the listener. + + // @alternative + // @function off(el: HTMLElement, eventMap: Object, context?: Object): this + // Removes a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}` + off: function (obj, types, fn, context) { + + if (typeof types === 'object') { + for (var type in types) { + this._off(obj, type, types[type], fn); + } + } else { + types = L.Util.splitWords(types); + + for (var i = 0, len = types.length; i < len; i++) { + this._off(obj, types[i], fn, context); + } + } + + return this; + }, + + _on: function (obj, type, fn, context) { + var id = type + L.stamp(fn) + (context ? '_' + L.stamp(context) : ''); + + if (obj[eventsKey] && obj[eventsKey][id]) { return this; } + + var handler = function (e) { + return fn.call(context || obj, e || window.event); + }; + + var originalHandler = handler; + + if (L.Browser.pointer && type.indexOf('touch') === 0) { + this.addPointerListener(obj, type, handler, id); + + } else if (L.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener) { + this.addDoubleTapListener(obj, handler, id); + + } else if ('addEventListener' in obj) { + + if (type === 'mousewheel') { + obj.addEventListener('onwheel' in obj ? 'wheel' : 'mousewheel', handler, false); + + } else if ((type === 'mouseenter') || (type === 'mouseleave')) { + handler = function (e) { + e = e || window.event; + if (L.DomEvent._isExternalTarget(obj, e)) { + originalHandler(e); + } + }; + obj.addEventListener(type === 'mouseenter' ? 'mouseover' : 'mouseout', handler, false); + + } else { + if (type === 'click' && L.Browser.android) { + handler = function (e) { + return L.DomEvent._filterClick(e, originalHandler); + }; + } + obj.addEventListener(type, handler, false); + } + + } else if ('attachEvent' in obj) { + obj.attachEvent('on' + type, handler); + } + + obj[eventsKey] = obj[eventsKey] || {}; + obj[eventsKey][id] = handler; + + return this; + }, + + _off: function (obj, type, fn, context) { + + var id = type + L.stamp(fn) + (context ? '_' + L.stamp(context) : ''), + handler = obj[eventsKey] && obj[eventsKey][id]; + + if (!handler) { return this; } + + if (L.Browser.pointer && type.indexOf('touch') === 0) { + this.removePointerListener(obj, type, id); + + } else if (L.Browser.touch && (type === 'dblclick') && this.removeDoubleTapListener) { + this.removeDoubleTapListener(obj, id); + + } else if ('removeEventListener' in obj) { + + if (type === 'mousewheel') { + obj.removeEventListener('onwheel' in obj ? 'wheel' : 'mousewheel', handler, false); + + } else { + obj.removeEventListener( + type === 'mouseenter' ? 'mouseover' : + type === 'mouseleave' ? 'mouseout' : type, handler, false); + } + + } else if ('detachEvent' in obj) { + obj.detachEvent('on' + type, handler); + } + + obj[eventsKey][id] = null; + + return this; + }, + + // @function stopPropagation(ev: DOMEvent): this + // Stop the given event from propagation to parent elements. Used inside the listener functions: + // ```js + // L.DomEvent.on(div, 'click', function (ev) { + // L.DomEvent.stopPropagation(ev); + // }); + // ``` + stopPropagation: function (e) { + + if (e.stopPropagation) { + e.stopPropagation(); + } else if (e.originalEvent) { // In case of Leaflet event. + e.originalEvent._stopped = true; + } else { + e.cancelBubble = true; + } + L.DomEvent._skipped(e); + + return this; + }, + + // @function disableScrollPropagation(el: HTMLElement): this + // Adds `stopPropagation` to the element's `'mousewheel'` events (plus browser variants). + disableScrollPropagation: function (el) { + return L.DomEvent.on(el, 'mousewheel', L.DomEvent.stopPropagation); + }, + + // @function disableClickPropagation(el: HTMLElement): this + // Adds `stopPropagation` to the element's `'click'`, `'doubleclick'`, + // `'mousedown'` and `'touchstart'` events (plus browser variants). + disableClickPropagation: function (el) { + var stop = L.DomEvent.stopPropagation; + + L.DomEvent.on(el, L.Draggable.START.join(' '), stop); + + return L.DomEvent.on(el, { + click: L.DomEvent._fakeStop, + dblclick: stop + }); + }, + + // @function preventDefault(ev: DOMEvent): this + // Prevents the default action of the DOM Event `ev` from happening (such as + // following a link in the href of the a element, or doing a POST request + // with page reload when a `
      ` is submitted). + // Use it inside listener functions. + preventDefault: function (e) { + + if (e.preventDefault) { + e.preventDefault(); + } else { + e.returnValue = false; + } + return this; + }, + + // @function stop(ev): this + // Does `stopPropagation` and `preventDefault` at the same time. + stop: function (e) { + return L.DomEvent + .preventDefault(e) + .stopPropagation(e); + }, + + // @function getMousePosition(ev: DOMEvent, container?: HTMLElement): Point + // Gets normalized mouse position from a DOM event relative to the + // `container` or to the whole page if not specified. + getMousePosition: function (e, container) { + if (!container) { + return new L.Point(e.clientX, e.clientY); + } + + var rect = container.getBoundingClientRect(); + + return new L.Point( + e.clientX - rect.left - container.clientLeft, + e.clientY - rect.top - container.clientTop); + }, + + // Chrome on Win scrolls double the pixels as in other platforms (see #4538), + // and Firefox scrolls device pixels, not CSS pixels + _wheelPxFactor: (L.Browser.win && L.Browser.chrome) ? 2 : + L.Browser.gecko ? window.devicePixelRatio : + 1, + + // @function getWheelDelta(ev: DOMEvent): Number + // Gets normalized wheel delta from a mousewheel DOM event, in vertical + // pixels scrolled (negative if scrolling down). + // Events from pointing devices without precise scrolling are mapped to + // a best guess of 60 pixels. + getWheelDelta: function (e) { + return (L.Browser.edge) ? e.wheelDeltaY / 2 : // Don't trust window-geometry-based delta + (e.deltaY && e.deltaMode === 0) ? -e.deltaY / L.DomEvent._wheelPxFactor : // Pixels + (e.deltaY && e.deltaMode === 1) ? -e.deltaY * 20 : // Lines + (e.deltaY && e.deltaMode === 2) ? -e.deltaY * 60 : // Pages + (e.deltaX || e.deltaZ) ? 0 : // Skip horizontal/depth wheel events + e.wheelDelta ? (e.wheelDeltaY || e.wheelDelta) / 2 : // Legacy IE pixels + (e.detail && Math.abs(e.detail) < 32765) ? -e.detail * 20 : // Legacy Moz lines + e.detail ? e.detail / -32765 * 60 : // Legacy Moz pages + 0; + }, + + _skipEvents: {}, + + _fakeStop: function (e) { + // fakes stopPropagation by setting a special event flag, checked/reset with L.DomEvent._skipped(e) + L.DomEvent._skipEvents[e.type] = true; + }, + + _skipped: function (e) { + var skipped = this._skipEvents[e.type]; + // reset when checking, as it's only used in map container and propagates outside of the map + this._skipEvents[e.type] = false; + return skipped; + }, + + // check if element really left/entered the event target (for mouseenter/mouseleave) + _isExternalTarget: function (el, e) { + + var related = e.relatedTarget; + + if (!related) { return true; } + + try { + while (related && (related !== el)) { + related = related.parentNode; + } + } catch (err) { + return false; + } + return (related !== el); + }, + + // this is a horrible workaround for a bug in Android where a single touch triggers two click events + _filterClick: function (e, handler) { + var timeStamp = (e.timeStamp || (e.originalEvent && e.originalEvent.timeStamp)), + elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick); + + // are they closer together than 500ms yet more than 100ms? + // Android typically triggers them ~300ms apart while multiple listeners + // on the same event should be triggered far faster; + // or check if click is simulated on the element, and if it is, reject any non-simulated events + + if ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) { + L.DomEvent.stop(e); + return; + } + L.DomEvent._lastClick = timeStamp; + + handler(e); + } +}; + +// @function addListener(…): this +// Alias to [`L.DomEvent.on`](#domevent-on) +L.DomEvent.addListener = L.DomEvent.on; + +// @function removeListener(…): this +// Alias to [`L.DomEvent.off`](#domevent-off) +L.DomEvent.removeListener = L.DomEvent.off; + + + +/* + * @class PosAnimation + * @aka L.PosAnimation + * @inherits Evented + * Used internally for panning animations, utilizing CSS3 Transitions for modern browsers and a timer fallback for IE6-9. + * + * @example + * ```js + * var fx = new L.PosAnimation(); + * fx.run(el, [300, 500], 0.5); + * ``` + * + * @constructor L.PosAnimation() + * Creates a `PosAnimation` object. + * + */ + +L.PosAnimation = L.Evented.extend({ + + // @method run(el: HTMLElement, newPos: Point, duration?: Number, easeLinearity?: Number) + // Run an animation of a given element to a new position, optionally setting + // duration in seconds (`0.25` by default) and easing linearity factor (3rd + // argument of the [cubic bezier curve](http://cubic-bezier.com/#0,0,.5,1), + // `0.5` by default). + run: function (el, newPos, duration, easeLinearity) { + this.stop(); + + this._el = el; + this._inProgress = true; + this._duration = duration || 0.25; + this._easeOutPower = 1 / Math.max(easeLinearity || 0.5, 0.2); + + this._startPos = L.DomUtil.getPosition(el); + this._offset = newPos.subtract(this._startPos); + this._startTime = +new Date(); + + // @event start: Event + // Fired when the animation starts + this.fire('start'); + + this._animate(); + }, + + // @method stop() + // Stops the animation (if currently running). + stop: function () { + if (!this._inProgress) { return; } + + this._step(true); + this._complete(); + }, + + _animate: function () { + // animation loop + this._animId = L.Util.requestAnimFrame(this._animate, this); + this._step(); + }, + + _step: function (round) { + var elapsed = (+new Date()) - this._startTime, + duration = this._duration * 1000; + + if (elapsed < duration) { + this._runFrame(this._easeOut(elapsed / duration), round); + } else { + this._runFrame(1); + this._complete(); + } + }, + + _runFrame: function (progress, round) { + var pos = this._startPos.add(this._offset.multiplyBy(progress)); + if (round) { + pos._round(); + } + L.DomUtil.setPosition(this._el, pos); + + // @event step: Event + // Fired continuously during the animation. + this.fire('step'); + }, + + _complete: function () { + L.Util.cancelAnimFrame(this._animId); + + this._inProgress = false; + // @event end: Event + // Fired when the animation ends. + this.fire('end'); + }, + + _easeOut: function (t) { + return 1 - Math.pow(1 - t, this._easeOutPower); + } +}); + + + +/* + * @namespace Projection + * @projection L.Projection.Mercator + * + * Elliptical Mercator projection — more complex than Spherical Mercator. Takes into account that Earth is a geoid, not a perfect sphere. Used by the EPSG:3395 CRS. + */ + +L.Projection.Mercator = { + R: 6378137, + R_MINOR: 6356752.314245179, + + bounds: L.bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]), + + project: function (latlng) { + var d = Math.PI / 180, + r = this.R, + y = latlng.lat * d, + tmp = this.R_MINOR / r, + e = Math.sqrt(1 - tmp * tmp), + con = e * Math.sin(y); + + var ts = Math.tan(Math.PI / 4 - y / 2) / Math.pow((1 - con) / (1 + con), e / 2); + y = -r * Math.log(Math.max(ts, 1E-10)); + + return new L.Point(latlng.lng * d * r, y); + }, + + unproject: function (point) { + var d = 180 / Math.PI, + r = this.R, + tmp = this.R_MINOR / r, + e = Math.sqrt(1 - tmp * tmp), + ts = Math.exp(-point.y / r), + phi = Math.PI / 2 - 2 * Math.atan(ts); + + for (var i = 0, dphi = 0.1, con; i < 15 && Math.abs(dphi) > 1e-7; i++) { + con = e * Math.sin(phi); + con = Math.pow((1 - con) / (1 + con), e / 2); + dphi = Math.PI / 2 - 2 * Math.atan(ts * con) - phi; + phi += dphi; + } + + return new L.LatLng(phi * d, point.x * d / r); + } +}; + + + +/* + * @namespace CRS + * @crs L.CRS.EPSG3395 + * + * Rarely used by some commercial tile providers. Uses Elliptical Mercator projection. + */ + +L.CRS.EPSG3395 = L.extend({}, L.CRS.Earth, { + code: 'EPSG:3395', + projection: L.Projection.Mercator, + + transformation: (function () { + var scale = 0.5 / (Math.PI * L.Projection.Mercator.R); + return new L.Transformation(scale, 0.5, -scale, 0.5); + }()) +}); + + + +/* + * @class GridLayer + * @inherits Layer + * @aka L.GridLayer + * + * Generic class for handling a tiled grid of HTML elements. This is the base class for all tile layers and replaces `TileLayer.Canvas`. + * GridLayer can be extended to create a tiled grid of HTML elements like ``, `` or `
      `. GridLayer will handle creating and animating these DOM elements for you. + * + * + * @section Synchronous usage + * @example + * + * To create a custom layer, extend GridLayer and implement the `createTile()` method, which will be passed a `Point` object with the `x`, `y`, and `z` (zoom level) coordinates to draw your tile. + * + * ```js + * var CanvasLayer = L.GridLayer.extend({ + * createTile: function(coords){ + * // create a element for drawing + * var tile = L.DomUtil.create('canvas', 'leaflet-tile'); + * + * // setup tile width and height according to the options + * var size = this.getTileSize(); + * tile.width = size.x; + * tile.height = size.y; + * + * // get a canvas context and draw something on it using coords.x, coords.y and coords.z + * var ctx = tile.getContext('2d'); + * + * // return the tile so it can be rendered on screen + * return tile; + * } + * }); + * ``` + * + * @section Asynchronous usage + * @example + * + * Tile creation can also be asynchronous, this is useful when using a third-party drawing library. Once the tile is finished drawing it can be passed to the `done()` callback. + * + * ```js + * var CanvasLayer = L.GridLayer.extend({ + * createTile: function(coords, done){ + * var error; + * + * // create a element for drawing + * var tile = L.DomUtil.create('canvas', 'leaflet-tile'); + * + * // setup tile width and height according to the options + * var size = this.getTileSize(); + * tile.width = size.x; + * tile.height = size.y; + * + * // draw something asynchronously and pass the tile to the done() callback + * setTimeout(function() { + * done(error, tile); + * }, 1000); + * + * return tile; + * } + * }); + * ``` + * + * @section + */ + + +L.GridLayer = L.Layer.extend({ + + // @section + // @aka GridLayer options + options: { + // @option tileSize: Number|Point = 256 + // Width and height of tiles in the grid. Use a number if width and height are equal, or `L.point(width, height)` otherwise. + tileSize: 256, + + // @option opacity: Number = 1.0 + // Opacity of the tiles. Can be used in the `createTile()` function. + opacity: 1, + + // @option updateWhenIdle: Boolean = depends + // If `false`, new tiles are loaded during panning, otherwise only after it (for better performance). `true` by default on mobile browsers, otherwise `false`. + updateWhenIdle: L.Browser.mobile, + + // @option updateWhenZooming: Boolean = true + // By default, a smooth zoom animation (during a [touch zoom](#map-touchzoom) or a [`flyTo()`](#map-flyto)) will update grid layers every integer zoom level. Setting this option to `false` will update the grid layer only when the smooth animation ends. + updateWhenZooming: true, + + // @option updateInterval: Number = 200 + // Tiles will not update more than once every `updateInterval` milliseconds when panning. + updateInterval: 200, + + // @option zIndex: Number = 1 + // The explicit zIndex of the tile layer. + zIndex: 1, + + // @option bounds: LatLngBounds = undefined + // If set, tiles will only be loaded inside the set `LatLngBounds`. + bounds: null, + + // @option minZoom: Number = 0 + // The minimum zoom level that tiles will be loaded at. By default the entire map. + minZoom: 0, + + // @option maxZoom: Number = undefined + // The maximum zoom level that tiles will be loaded at. + maxZoom: undefined, + + // @option noWrap: Boolean = false + // Whether the layer is wrapped around the antimeridian. If `true`, the + // GridLayer will only be displayed once at low zoom levels. Has no + // effect when the [map CRS](#map-crs) doesn't wrap around. + noWrap: false, + + // @option pane: String = 'tilePane' + // `Map pane` where the grid layer will be added. + pane: 'tilePane', + + // @option className: String = '' + // A custom class name to assign to the tile layer. Empty by default. + className: '', + + // @option keepBuffer: Number = 2 + // When panning the map, keep this many rows and columns of tiles before unloading them. + keepBuffer: 2 + }, + + initialize: function (options) { + L.setOptions(this, options); + }, + + onAdd: function () { + this._initContainer(); + + this._levels = {}; + this._tiles = {}; + + this._resetView(); + this._update(); + }, + + beforeAdd: function (map) { + map._addZoomLimit(this); + }, + + onRemove: function (map) { + this._removeAllTiles(); + L.DomUtil.remove(this._container); + map._removeZoomLimit(this); + this._container = null; + this._tileZoom = null; + }, + + // @method bringToFront: this + // Brings the tile layer to the top of all tile layers. + bringToFront: function () { + if (this._map) { + L.DomUtil.toFront(this._container); + this._setAutoZIndex(Math.max); + } + return this; + }, + + // @method bringToBack: this + // Brings the tile layer to the bottom of all tile layers. + bringToBack: function () { + if (this._map) { + L.DomUtil.toBack(this._container); + this._setAutoZIndex(Math.min); + } + return this; + }, + + // @method getContainer: HTMLElement + // Returns the HTML element that contains the tiles for this layer. + getContainer: function () { + return this._container; + }, + + // @method setOpacity(opacity: Number): this + // Changes the [opacity](#gridlayer-opacity) of the grid layer. + setOpacity: function (opacity) { + this.options.opacity = opacity; + this._updateOpacity(); + return this; + }, + + // @method setZIndex(zIndex: Number): this + // Changes the [zIndex](#gridlayer-zindex) of the grid layer. + setZIndex: function (zIndex) { + this.options.zIndex = zIndex; + this._updateZIndex(); + + return this; + }, + + // @method isLoading: Boolean + // Returns `true` if any tile in the grid layer has not finished loading. + isLoading: function () { + return this._loading; + }, + + // @method redraw: this + // Causes the layer to clear all the tiles and request them again. + redraw: function () { + if (this._map) { + this._removeAllTiles(); + this._update(); + } + return this; + }, + + getEvents: function () { + var events = { + viewprereset: this._invalidateAll, + viewreset: this._resetView, + zoom: this._resetView, + moveend: this._onMoveEnd + }; + + if (!this.options.updateWhenIdle) { + // update tiles on move, but not more often than once per given interval + if (!this._onMove) { + this._onMove = L.Util.throttle(this._onMoveEnd, this.options.updateInterval, this); + } + + events.move = this._onMove; + } + + if (this._zoomAnimated) { + events.zoomanim = this._animateZoom; + } + + return events; + }, + + // @section Extension methods + // Layers extending `GridLayer` shall reimplement the following method. + // @method createTile(coords: Object, done?: Function): HTMLElement + // Called only internally, must be overriden by classes extending `GridLayer`. + // Returns the `HTMLElement` corresponding to the given `coords`. If the `done` callback + // is specified, it must be called when the tile has finished loading and drawing. + createTile: function () { + return document.createElement('div'); + }, + + // @section + // @method getTileSize: Point + // Normalizes the [tileSize option](#gridlayer-tilesize) into a point. Used by the `createTile()` method. + getTileSize: function () { + var s = this.options.tileSize; + return s instanceof L.Point ? s : new L.Point(s, s); + }, + + _updateZIndex: function () { + if (this._container && this.options.zIndex !== undefined && this.options.zIndex !== null) { + this._container.style.zIndex = this.options.zIndex; + } + }, + + _setAutoZIndex: function (compare) { + // go through all other layers of the same pane, set zIndex to max + 1 (front) or min - 1 (back) + + var layers = this.getPane().children, + edgeZIndex = -compare(-Infinity, Infinity); // -Infinity for max, Infinity for min + + for (var i = 0, len = layers.length, zIndex; i < len; i++) { + + zIndex = layers[i].style.zIndex; + + if (layers[i] !== this._container && zIndex) { + edgeZIndex = compare(edgeZIndex, +zIndex); + } + } + + if (isFinite(edgeZIndex)) { + this.options.zIndex = edgeZIndex + compare(-1, 1); + this._updateZIndex(); + } + }, + + _updateOpacity: function () { + if (!this._map) { return; } + + // IE doesn't inherit filter opacity properly, so we're forced to set it on tiles + if (L.Browser.ielt9) { return; } + + L.DomUtil.setOpacity(this._container, this.options.opacity); + + var now = +new Date(), + nextFrame = false, + willPrune = false; + + for (var key in this._tiles) { + var tile = this._tiles[key]; + if (!tile.current || !tile.loaded) { continue; } + + var fade = Math.min(1, (now - tile.loaded) / 200); + + L.DomUtil.setOpacity(tile.el, fade); + if (fade < 1) { + nextFrame = true; + } else { + if (tile.active) { willPrune = true; } + tile.active = true; + } + } + + if (willPrune && !this._noPrune) { this._pruneTiles(); } + + if (nextFrame) { + L.Util.cancelAnimFrame(this._fadeFrame); + this._fadeFrame = L.Util.requestAnimFrame(this._updateOpacity, this); + } + }, + + _initContainer: function () { + if (this._container) { return; } + + this._container = L.DomUtil.create('div', 'leaflet-layer ' + (this.options.className || '')); + this._updateZIndex(); + + if (this.options.opacity < 1) { + this._updateOpacity(); + } + + this.getPane().appendChild(this._container); + }, + + _updateLevels: function () { + + var zoom = this._tileZoom, + maxZoom = this.options.maxZoom; + + if (zoom === undefined) { return undefined; } + + for (var z in this._levels) { + if (this._levels[z].el.children.length || z === zoom) { + this._levels[z].el.style.zIndex = maxZoom - Math.abs(zoom - z); + } else { + L.DomUtil.remove(this._levels[z].el); + this._removeTilesAtZoom(z); + delete this._levels[z]; + } + } + + var level = this._levels[zoom], + map = this._map; + + if (!level) { + level = this._levels[zoom] = {}; + + level.el = L.DomUtil.create('div', 'leaflet-tile-container leaflet-zoom-animated', this._container); + level.el.style.zIndex = maxZoom; + + level.origin = map.project(map.unproject(map.getPixelOrigin()), zoom).round(); + level.zoom = zoom; + + this._setZoomTransform(level, map.getCenter(), map.getZoom()); + + // force the browser to consider the newly added element for transition + L.Util.falseFn(level.el.offsetWidth); + } + + this._level = level; + + return level; + }, + + _pruneTiles: function () { + if (!this._map) { + return; + } + + var key, tile; + + var zoom = this._map.getZoom(); + if (zoom > this.options.maxZoom || + zoom < this.options.minZoom) { + this._removeAllTiles(); + return; + } + + for (key in this._tiles) { + tile = this._tiles[key]; + tile.retain = tile.current; + } + + for (key in this._tiles) { + tile = this._tiles[key]; + if (tile.current && !tile.active) { + var coords = tile.coords; + if (!this._retainParent(coords.x, coords.y, coords.z, coords.z - 5)) { + this._retainChildren(coords.x, coords.y, coords.z, coords.z + 2); + } + } + } + + for (key in this._tiles) { + if (!this._tiles[key].retain) { + this._removeTile(key); + } + } + }, + + _removeTilesAtZoom: function (zoom) { + for (var key in this._tiles) { + if (this._tiles[key].coords.z !== zoom) { + continue; + } + this._removeTile(key); + } + }, + + _removeAllTiles: function () { + for (var key in this._tiles) { + this._removeTile(key); + } + }, + + _invalidateAll: function () { + for (var z in this._levels) { + L.DomUtil.remove(this._levels[z].el); + delete this._levels[z]; + } + this._removeAllTiles(); + + this._tileZoom = null; + }, + + _retainParent: function (x, y, z, minZoom) { + var x2 = Math.floor(x / 2), + y2 = Math.floor(y / 2), + z2 = z - 1, + coords2 = new L.Point(+x2, +y2); + coords2.z = +z2; + + var key = this._tileCoordsToKey(coords2), + tile = this._tiles[key]; + + if (tile && tile.active) { + tile.retain = true; + return true; + + } else if (tile && tile.loaded) { + tile.retain = true; + } + + if (z2 > minZoom) { + return this._retainParent(x2, y2, z2, minZoom); + } + + return false; + }, + + _retainChildren: function (x, y, z, maxZoom) { + + for (var i = 2 * x; i < 2 * x + 2; i++) { + for (var j = 2 * y; j < 2 * y + 2; j++) { + + var coords = new L.Point(i, j); + coords.z = z + 1; + + var key = this._tileCoordsToKey(coords), + tile = this._tiles[key]; + + if (tile && tile.active) { + tile.retain = true; + continue; + + } else if (tile && tile.loaded) { + tile.retain = true; + } + + if (z + 1 < maxZoom) { + this._retainChildren(i, j, z + 1, maxZoom); + } + } + } + }, + + _resetView: function (e) { + var animating = e && (e.pinch || e.flyTo); + this._setView(this._map.getCenter(), this._map.getZoom(), animating, animating); + }, + + _animateZoom: function (e) { + this._setView(e.center, e.zoom, true, e.noUpdate); + }, + + _setView: function (center, zoom, noPrune, noUpdate) { + var tileZoom = Math.round(zoom); + if ((this.options.maxZoom !== undefined && tileZoom > this.options.maxZoom) || + (this.options.minZoom !== undefined && tileZoom < this.options.minZoom)) { + tileZoom = undefined; + } + + var tileZoomChanged = this.options.updateWhenZooming && (tileZoom !== this._tileZoom); + + if (!noUpdate || tileZoomChanged) { + + this._tileZoom = tileZoom; + + if (this._abortLoading) { + this._abortLoading(); + } + + this._updateLevels(); + this._resetGrid(); + + if (tileZoom !== undefined) { + this._update(center); + } + + if (!noPrune) { + this._pruneTiles(); + } + + // Flag to prevent _updateOpacity from pruning tiles during + // a zoom anim or a pinch gesture + this._noPrune = !!noPrune; + } + + this._setZoomTransforms(center, zoom); + }, + + _setZoomTransforms: function (center, zoom) { + for (var i in this._levels) { + this._setZoomTransform(this._levels[i], center, zoom); + } + }, + + _setZoomTransform: function (level, center, zoom) { + var scale = this._map.getZoomScale(zoom, level.zoom), + translate = level.origin.multiplyBy(scale) + .subtract(this._map._getNewPixelOrigin(center, zoom)).round(); + + if (L.Browser.any3d) { + L.DomUtil.setTransform(level.el, translate, scale); + } else { + L.DomUtil.setPosition(level.el, translate); + } + }, + + _resetGrid: function () { + var map = this._map, + crs = map.options.crs, + tileSize = this._tileSize = this.getTileSize(), + tileZoom = this._tileZoom; + + var bounds = this._map.getPixelWorldBounds(this._tileZoom); + if (bounds) { + this._globalTileRange = this._pxBoundsToTileRange(bounds); + } + + this._wrapX = crs.wrapLng && !this.options.noWrap && [ + Math.floor(map.project([0, crs.wrapLng[0]], tileZoom).x / tileSize.x), + Math.ceil(map.project([0, crs.wrapLng[1]], tileZoom).x / tileSize.y) + ]; + this._wrapY = crs.wrapLat && !this.options.noWrap && [ + Math.floor(map.project([crs.wrapLat[0], 0], tileZoom).y / tileSize.x), + Math.ceil(map.project([crs.wrapLat[1], 0], tileZoom).y / tileSize.y) + ]; + }, + + _onMoveEnd: function () { + if (!this._map || this._map._animatingZoom) { return; } + + this._update(); + }, + + _getTiledPixelBounds: function (center) { + var map = this._map, + mapZoom = map._animatingZoom ? Math.max(map._animateToZoom, map.getZoom()) : map.getZoom(), + scale = map.getZoomScale(mapZoom, this._tileZoom), + pixelCenter = map.project(center, this._tileZoom).floor(), + halfSize = map.getSize().divideBy(scale * 2); + + return new L.Bounds(pixelCenter.subtract(halfSize), pixelCenter.add(halfSize)); + }, + + // Private method to load tiles in the grid's active zoom level according to map bounds + _update: function (center) { + var map = this._map; + if (!map) { return; } + var zoom = map.getZoom(); + + if (center === undefined) { center = map.getCenter(); } + if (this._tileZoom === undefined) { return; } // if out of minzoom/maxzoom + + var pixelBounds = this._getTiledPixelBounds(center), + tileRange = this._pxBoundsToTileRange(pixelBounds), + tileCenter = tileRange.getCenter(), + queue = [], + margin = this.options.keepBuffer, + noPruneRange = new L.Bounds(tileRange.getBottomLeft().subtract([margin, -margin]), + tileRange.getTopRight().add([margin, -margin])); + + for (var key in this._tiles) { + var c = this._tiles[key].coords; + if (c.z !== this._tileZoom || !noPruneRange.contains(L.point(c.x, c.y))) { + this._tiles[key].current = false; + } + } + + // _update just loads more tiles. If the tile zoom level differs too much + // from the map's, let _setView reset levels and prune old tiles. + if (Math.abs(zoom - this._tileZoom) > 1) { this._setView(center, zoom); return; } + + // create a queue of coordinates to load tiles from + for (var j = tileRange.min.y; j <= tileRange.max.y; j++) { + for (var i = tileRange.min.x; i <= tileRange.max.x; i++) { + var coords = new L.Point(i, j); + coords.z = this._tileZoom; + + if (!this._isValidTile(coords)) { continue; } + + var tile = this._tiles[this._tileCoordsToKey(coords)]; + if (tile) { + tile.current = true; + } else { + queue.push(coords); + } + } + } + + // sort tile queue to load tiles in order of their distance to center + queue.sort(function (a, b) { + return a.distanceTo(tileCenter) - b.distanceTo(tileCenter); + }); + + if (queue.length !== 0) { + // if it's the first batch of tiles to load + if (!this._loading) { + this._loading = true; + // @event loading: Event + // Fired when the grid layer starts loading tiles. + this.fire('loading'); + } + + // create DOM fragment to append tiles in one batch + var fragment = document.createDocumentFragment(); + + for (i = 0; i < queue.length; i++) { + this._addTile(queue[i], fragment); + } + + this._level.el.appendChild(fragment); + } + }, + + _isValidTile: function (coords) { + var crs = this._map.options.crs; + + if (!crs.infinite) { + // don't load tile if it's out of bounds and not wrapped + var bounds = this._globalTileRange; + if ((!crs.wrapLng && (coords.x < bounds.min.x || coords.x > bounds.max.x)) || + (!crs.wrapLat && (coords.y < bounds.min.y || coords.y > bounds.max.y))) { return false; } + } + + if (!this.options.bounds) { return true; } + + // don't load tile if it doesn't intersect the bounds in options + var tileBounds = this._tileCoordsToBounds(coords); + return L.latLngBounds(this.options.bounds).overlaps(tileBounds); + }, + + _keyToBounds: function (key) { + return this._tileCoordsToBounds(this._keyToTileCoords(key)); + }, + + // converts tile coordinates to its geographical bounds + _tileCoordsToBounds: function (coords) { + + var map = this._map, + tileSize = this.getTileSize(), + + nwPoint = coords.scaleBy(tileSize), + sePoint = nwPoint.add(tileSize), + + nw = map.unproject(nwPoint, coords.z), + se = map.unproject(sePoint, coords.z); + + if (!this.options.noWrap) { + nw = map.wrapLatLng(nw); + se = map.wrapLatLng(se); + } + + return new L.LatLngBounds(nw, se); + }, + + // converts tile coordinates to key for the tile cache + _tileCoordsToKey: function (coords) { + return coords.x + ':' + coords.y + ':' + coords.z; + }, + + // converts tile cache key to coordinates + _keyToTileCoords: function (key) { + var k = key.split(':'), + coords = new L.Point(+k[0], +k[1]); + coords.z = +k[2]; + return coords; + }, + + _removeTile: function (key) { + var tile = this._tiles[key]; + if (!tile) { return; } + + L.DomUtil.remove(tile.el); + + delete this._tiles[key]; + + // @event tileunload: TileEvent + // Fired when a tile is removed (e.g. when a tile goes off the screen). + this.fire('tileunload', { + tile: tile.el, + coords: this._keyToTileCoords(key) + }); + }, + + _initTile: function (tile) { + L.DomUtil.addClass(tile, 'leaflet-tile'); + + var tileSize = this.getTileSize(); + tile.style.width = tileSize.x + 'px'; + tile.style.height = tileSize.y + 'px'; + + tile.onselectstart = L.Util.falseFn; + tile.onmousemove = L.Util.falseFn; + + // update opacity on tiles in IE7-8 because of filter inheritance problems + if (L.Browser.ielt9 && this.options.opacity < 1) { + L.DomUtil.setOpacity(tile, this.options.opacity); + } + + // without this hack, tiles disappear after zoom on Chrome for Android + // https://github.com/Leaflet/Leaflet/issues/2078 + if (L.Browser.android && !L.Browser.android23) { + tile.style.WebkitBackfaceVisibility = 'hidden'; + } + }, + + _addTile: function (coords, container) { + var tilePos = this._getTilePos(coords), + key = this._tileCoordsToKey(coords); + + var tile = this.createTile(this._wrapCoords(coords), L.bind(this._tileReady, this, coords)); + + this._initTile(tile); + + // if createTile is defined with a second argument ("done" callback), + // we know that tile is async and will be ready later; otherwise + if (this.createTile.length < 2) { + // mark tile as ready, but delay one frame for opacity animation to happen + L.Util.requestAnimFrame(L.bind(this._tileReady, this, coords, null, tile)); + } + + L.DomUtil.setPosition(tile, tilePos); + + // save tile in cache + this._tiles[key] = { + el: tile, + coords: coords, + current: true + }; + + container.appendChild(tile); + // @event tileloadstart: TileEvent + // Fired when a tile is requested and starts loading. + this.fire('tileloadstart', { + tile: tile, + coords: coords + }); + }, + + _tileReady: function (coords, err, tile) { + if (!this._map) { return; } + + if (err) { + // @event tileerror: TileErrorEvent + // Fired when there is an error loading a tile. + this.fire('tileerror', { + error: err, + tile: tile, + coords: coords + }); + } + + var key = this._tileCoordsToKey(coords); + + tile = this._tiles[key]; + if (!tile) { return; } + + tile.loaded = +new Date(); + if (this._map._fadeAnimated) { + L.DomUtil.setOpacity(tile.el, 0); + L.Util.cancelAnimFrame(this._fadeFrame); + this._fadeFrame = L.Util.requestAnimFrame(this._updateOpacity, this); + } else { + tile.active = true; + this._pruneTiles(); + } + + if (!err) { + L.DomUtil.addClass(tile.el, 'leaflet-tile-loaded'); + + // @event tileload: TileEvent + // Fired when a tile loads. + this.fire('tileload', { + tile: tile.el, + coords: coords + }); + } + + if (this._noTilesToLoad()) { + this._loading = false; + // @event load: Event + // Fired when the grid layer loaded all visible tiles. + this.fire('load'); + + if (L.Browser.ielt9 || !this._map._fadeAnimated) { + L.Util.requestAnimFrame(this._pruneTiles, this); + } else { + // Wait a bit more than 0.2 secs (the duration of the tile fade-in) + // to trigger a pruning. + setTimeout(L.bind(this._pruneTiles, this), 250); + } + } + }, + + _getTilePos: function (coords) { + return coords.scaleBy(this.getTileSize()).subtract(this._level.origin); + }, + + _wrapCoords: function (coords) { + var newCoords = new L.Point( + this._wrapX ? L.Util.wrapNum(coords.x, this._wrapX) : coords.x, + this._wrapY ? L.Util.wrapNum(coords.y, this._wrapY) : coords.y); + newCoords.z = coords.z; + return newCoords; + }, + + _pxBoundsToTileRange: function (bounds) { + var tileSize = this.getTileSize(); + return new L.Bounds( + bounds.min.unscaleBy(tileSize).floor(), + bounds.max.unscaleBy(tileSize).ceil().subtract([1, 1])); + }, + + _noTilesToLoad: function () { + for (var key in this._tiles) { + if (!this._tiles[key].loaded) { return false; } + } + return true; + } +}); + +// @factory L.gridLayer(options?: GridLayer options) +// Creates a new instance of GridLayer with the supplied options. +L.gridLayer = function (options) { + return new L.GridLayer(options); +}; + + + +/* + * @class TileLayer + * @inherits GridLayer + * @aka L.TileLayer + * Used to load and display tile layers on the map. Extends `GridLayer`. + * + * @example + * + * ```js + * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar'}).addTo(map); + * ``` + * + * @section URL template + * @example + * + * A string of the following form: + * + * ``` + * 'http://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png' + * ``` + * + * `{s}` means one of the available subdomains (used sequentially to help with browser parallel requests per domain limitation; subdomain values are specified in options; `a`, `b` or `c` by default, can be omitted), `{z}` — zoom level, `{x}` and `{y}` — tile coordinates. `{r}` can be used to add @2x to the URL to load retina tiles. + * + * You can use custom keys in the template, which will be [evaluated](#util-template) from TileLayer options, like this: + * + * ``` + * L.tileLayer('http://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png', {foo: 'bar'}); + * ``` + */ + + +L.TileLayer = L.GridLayer.extend({ + + // @section + // @aka TileLayer options + options: { + // @option minZoom: Number = 0 + // Minimum zoom number. + minZoom: 0, + + // @option maxZoom: Number = 18 + // Maximum zoom number. + maxZoom: 18, + + // @option maxNativeZoom: Number = null + // Maximum zoom number the tile source has available. If it is specified, + // the tiles on all zoom levels higher than `maxNativeZoom` will be loaded + // from `maxNativeZoom` level and auto-scaled. + maxNativeZoom: null, + + // @option minNativeZoom: Number = null + // Minimum zoom number the tile source has available. If it is specified, + // the tiles on all zoom levels lower than `minNativeZoom` will be loaded + // from `minNativeZoom` level and auto-scaled. + minNativeZoom: null, + + // @option subdomains: String|String[] = 'abc' + // Subdomains of the tile service. Can be passed in the form of one string (where each letter is a subdomain name) or an array of strings. + subdomains: 'abc', + + // @option errorTileUrl: String = '' + // URL to the tile image to show in place of the tile that failed to load. + errorTileUrl: '', + + // @option zoomOffset: Number = 0 + // The zoom number used in tile URLs will be offset with this value. + zoomOffset: 0, + + // @option tms: Boolean = false + // If `true`, inverses Y axis numbering for tiles (turn this on for [TMS](https://en.wikipedia.org/wiki/Tile_Map_Service) services). + tms: false, + + // @option zoomReverse: Boolean = false + // If set to true, the zoom number used in tile URLs will be reversed (`maxZoom - zoom` instead of `zoom`) + zoomReverse: false, + + // @option detectRetina: Boolean = false + // If `true` and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution. + detectRetina: false, + + // @option crossOrigin: Boolean = false + // If true, all tiles will have their crossOrigin attribute set to ''. This is needed if you want to access tile pixel data. + crossOrigin: false + }, + + initialize: function (url, options) { + + this._url = url; + + options = L.setOptions(this, options); + + // detecting retina displays, adjusting tileSize and zoom levels + if (options.detectRetina && L.Browser.retina && options.maxZoom > 0) { + + options.tileSize = Math.floor(options.tileSize / 2); + + if (!options.zoomReverse) { + options.zoomOffset++; + options.maxZoom--; + } else { + options.zoomOffset--; + options.minZoom++; + } + + options.minZoom = Math.max(0, options.minZoom); + } + + if (typeof options.subdomains === 'string') { + options.subdomains = options.subdomains.split(''); + } + + // for https://github.com/Leaflet/Leaflet/issues/137 + if (!L.Browser.android) { + this.on('tileunload', this._onTileRemove); + } + }, + + // @method setUrl(url: String, noRedraw?: Boolean): this + // Updates the layer's URL template and redraws it (unless `noRedraw` is set to `true`). + setUrl: function (url, noRedraw) { + this._url = url; + + if (!noRedraw) { + this.redraw(); + } + return this; + }, + + // @method createTile(coords: Object, done?: Function): HTMLElement + // Called only internally, overrides GridLayer's [`createTile()`](#gridlayer-createtile) + // to return an `` HTML element with the appropiate image URL given `coords`. The `done` + // callback is called when the tile has been loaded. + createTile: function (coords, done) { + var tile = document.createElement('img'); + + L.DomEvent.on(tile, 'load', L.bind(this._tileOnLoad, this, done, tile)); + L.DomEvent.on(tile, 'error', L.bind(this._tileOnError, this, done, tile)); + + if (this.options.crossOrigin) { + tile.crossOrigin = ''; + } + + /* + Alt tag is set to empty string to keep screen readers from reading URL and for compliance reasons + http://www.w3.org/TR/WCAG20-TECHS/H67 + */ + tile.alt = ''; + + /* + Set role="presentation" to force screen readers to ignore this + https://www.w3.org/TR/wai-aria/roles#textalternativecomputation + */ + tile.setAttribute('role', 'presentation'); + + tile.src = this.getTileUrl(coords); + + return tile; + }, + + // @section Extension methods + // @uninheritable + // Layers extending `TileLayer` might reimplement the following method. + // @method getTileUrl(coords: Object): String + // Called only internally, returns the URL for a tile given its coordinates. + // Classes extending `TileLayer` can override this function to provide custom tile URL naming schemes. + getTileUrl: function (coords) { + var data = { + r: L.Browser.retina ? '@2x' : '', + s: this._getSubdomain(coords), + x: coords.x, + y: coords.y, + z: this._getZoomForUrl() + }; + if (this._map && !this._map.options.crs.infinite) { + var invertedY = this._globalTileRange.max.y - coords.y; + if (this.options.tms) { + data['y'] = invertedY; + } + data['-y'] = invertedY; + } + + return L.Util.template(this._url, L.extend(data, this.options)); + }, + + _tileOnLoad: function (done, tile) { + // For https://github.com/Leaflet/Leaflet/issues/3332 + if (L.Browser.ielt9) { + setTimeout(L.bind(done, this, null, tile), 0); + } else { + done(null, tile); + } + }, + + _tileOnError: function (done, tile, e) { + var errorUrl = this.options.errorTileUrl; + if (errorUrl) { + tile.src = errorUrl; + } + done(e, tile); + }, + + getTileSize: function () { + var map = this._map, + tileSize = L.GridLayer.prototype.getTileSize.call(this), + zoom = this._tileZoom + this.options.zoomOffset, + minNativeZoom = this.options.minNativeZoom, + maxNativeZoom = this.options.maxNativeZoom; + + // decrease tile size when scaling below minNativeZoom + if (minNativeZoom !== null && zoom < minNativeZoom) { + return tileSize.divideBy(map.getZoomScale(minNativeZoom, zoom)).round(); + } + + // increase tile size when scaling above maxNativeZoom + if (maxNativeZoom !== null && zoom > maxNativeZoom) { + return tileSize.divideBy(map.getZoomScale(maxNativeZoom, zoom)).round(); + } + + return tileSize; + }, + + _onTileRemove: function (e) { + e.tile.onload = null; + }, + + _getZoomForUrl: function () { + var zoom = this._tileZoom, + maxZoom = this.options.maxZoom, + zoomReverse = this.options.zoomReverse, + zoomOffset = this.options.zoomOffset, + minNativeZoom = this.options.minNativeZoom, + maxNativeZoom = this.options.maxNativeZoom; + + if (zoomReverse) { + zoom = maxZoom - zoom; + } + + zoom += zoomOffset; + + if (minNativeZoom !== null && zoom < minNativeZoom) { + return minNativeZoom; + } + + if (maxNativeZoom !== null && zoom > maxNativeZoom) { + return maxNativeZoom; + } + + return zoom; + }, + + _getSubdomain: function (tilePoint) { + var index = Math.abs(tilePoint.x + tilePoint.y) % this.options.subdomains.length; + return this.options.subdomains[index]; + }, + + // stops loading all tiles in the background layer + _abortLoading: function () { + var i, tile; + for (i in this._tiles) { + if (this._tiles[i].coords.z !== this._tileZoom) { + tile = this._tiles[i].el; + + tile.onload = L.Util.falseFn; + tile.onerror = L.Util.falseFn; + + if (!tile.complete) { + tile.src = L.Util.emptyImageUrl; + L.DomUtil.remove(tile); + } + } + } + } +}); + + +// @factory L.tilelayer(urlTemplate: String, options?: TileLayer options) +// Instantiates a tile layer object given a `URL template` and optionally an options object. + +L.tileLayer = function (url, options) { + return new L.TileLayer(url, options); +}; + + + +/* + * @class TileLayer.WMS + * @inherits TileLayer + * @aka L.TileLayer.WMS + * Used to display [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services as tile layers on the map. Extends `TileLayer`. + * + * @example + * + * ```js + * var nexrad = L.tileLayer.wms("http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi", { + * layers: 'nexrad-n0r-900913', + * format: 'image/png', + * transparent: true, + * attribution: "Weather data © 2012 IEM Nexrad" + * }); + * ``` + */ + +L.TileLayer.WMS = L.TileLayer.extend({ + + // @section + // @aka TileLayer.WMS options + // If any custom options not documented here are used, they will be sent to the + // WMS server as extra parameters in each request URL. This can be useful for + // [non-standard vendor WMS parameters](http://docs.geoserver.org/stable/en/user/services/wms/vendor.html). + defaultWmsParams: { + service: 'WMS', + request: 'GetMap', + + // @option layers: String = '' + // **(required)** Comma-separated list of WMS layers to show. + layers: '', + + // @option styles: String = '' + // Comma-separated list of WMS styles. + styles: '', + + // @option format: String = 'image/jpeg' + // WMS image format (use `'image/png'` for layers with transparency). + format: 'image/jpeg', + + // @option transparent: Boolean = false + // If `true`, the WMS service will return images with transparency. + transparent: false, + + // @option version: String = '1.1.1' + // Version of the WMS service to use + version: '1.1.1' + }, + + options: { + // @option crs: CRS = null + // Coordinate Reference System to use for the WMS requests, defaults to + // map CRS. Don't change this if you're not sure what it means. + crs: null, + + // @option uppercase: Boolean = false + // If `true`, WMS request parameter keys will be uppercase. + uppercase: false + }, + + initialize: function (url, options) { + + this._url = url; + + var wmsParams = L.extend({}, this.defaultWmsParams); + + // all keys that are not TileLayer options go to WMS params + for (var i in options) { + if (!(i in this.options)) { + wmsParams[i] = options[i]; + } + } + + options = L.setOptions(this, options); + + wmsParams.width = wmsParams.height = options.tileSize * (options.detectRetina && L.Browser.retina ? 2 : 1); + + this.wmsParams = wmsParams; + }, + + onAdd: function (map) { + + this._crs = this.options.crs || map.options.crs; + this._wmsVersion = parseFloat(this.wmsParams.version); + + var projectionKey = this._wmsVersion >= 1.3 ? 'crs' : 'srs'; + this.wmsParams[projectionKey] = this._crs.code; + + L.TileLayer.prototype.onAdd.call(this, map); + }, + + getTileUrl: function (coords) { + + var tileBounds = this._tileCoordsToBounds(coords), + nw = this._crs.project(tileBounds.getNorthWest()), + se = this._crs.project(tileBounds.getSouthEast()), + + bbox = (this._wmsVersion >= 1.3 && this._crs === L.CRS.EPSG4326 ? + [se.y, nw.x, nw.y, se.x] : + [nw.x, se.y, se.x, nw.y]).join(','), + + url = L.TileLayer.prototype.getTileUrl.call(this, coords); + + return url + + L.Util.getParamString(this.wmsParams, url, this.options.uppercase) + + (this.options.uppercase ? '&BBOX=' : '&bbox=') + bbox; + }, + + // @method setParams(params: Object, noRedraw?: Boolean): this + // Merges an object with the new parameters and re-requests tiles on the current screen (unless `noRedraw` was set to true). + setParams: function (params, noRedraw) { + + L.extend(this.wmsParams, params); + + if (!noRedraw) { + this.redraw(); + } + + return this; + } +}); + + +// @factory L.tileLayer.wms(baseUrl: String, options: TileLayer.WMS options) +// Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS parameters/options object. +L.tileLayer.wms = function (url, options) { + return new L.TileLayer.WMS(url, options); +}; + + + +/* + * @class ImageOverlay + * @aka L.ImageOverlay + * @inherits Interactive layer + * + * Used to load and display a single image over specific bounds of the map. Extends `Layer`. + * + * @example + * + * ```js + * var imageUrl = 'http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg', + * imageBounds = [[40.712216, -74.22655], [40.773941, -74.12544]]; + * L.imageOverlay(imageUrl, imageBounds).addTo(map); + * ``` + */ + +L.ImageOverlay = L.Layer.extend({ + + // @section + // @aka ImageOverlay options + options: { + // @option opacity: Number = 1.0 + // The opacity of the image overlay. + opacity: 1, + + // @option alt: String = '' + // Text for the `alt` attribute of the image (useful for accessibility). + alt: '', + + // @option interactive: Boolean = false + // If `true`, the image overlay will emit [mouse events](#interactive-layer) when clicked or hovered. + interactive: false, + + // @option crossOrigin: Boolean = false + // If true, the image will have its crossOrigin attribute set to ''. This is needed if you want to access image pixel data. + crossOrigin: false + }, + + initialize: function (url, bounds, options) { // (String, LatLngBounds, Object) + this._url = url; + this._bounds = L.latLngBounds(bounds); + + L.setOptions(this, options); + }, + + onAdd: function () { + if (!this._image) { + this._initImage(); + + if (this.options.opacity < 1) { + this._updateOpacity(); + } + } + + if (this.options.interactive) { + L.DomUtil.addClass(this._image, 'leaflet-interactive'); + this.addInteractiveTarget(this._image); + } + + this.getPane().appendChild(this._image); + this._reset(); + }, + + onRemove: function () { + L.DomUtil.remove(this._image); + if (this.options.interactive) { + this.removeInteractiveTarget(this._image); + } + }, + + // @method setOpacity(opacity: Number): this + // Sets the opacity of the overlay. + setOpacity: function (opacity) { + this.options.opacity = opacity; + + if (this._image) { + this._updateOpacity(); + } + return this; + }, + + setStyle: function (styleOpts) { + if (styleOpts.opacity) { + this.setOpacity(styleOpts.opacity); + } + return this; + }, + + // @method bringToFront(): this + // Brings the layer to the top of all overlays. + bringToFront: function () { + if (this._map) { + L.DomUtil.toFront(this._image); + } + return this; + }, + + // @method bringToBack(): this + // Brings the layer to the bottom of all overlays. + bringToBack: function () { + if (this._map) { + L.DomUtil.toBack(this._image); + } + return this; + }, + + // @method setUrl(url: String): this + // Changes the URL of the image. + setUrl: function (url) { + this._url = url; + + if (this._image) { + this._image.src = url; + } + return this; + }, + + setBounds: function (bounds) { + this._bounds = bounds; + + if (this._map) { + this._reset(); + } + return this; + }, + + getEvents: function () { + var events = { + zoom: this._reset, + viewreset: this._reset + }; + + if (this._zoomAnimated) { + events.zoomanim = this._animateZoom; + } + + return events; + }, + + getBounds: function () { + return this._bounds; + }, + + getElement: function () { + return this._image; + }, + + _initImage: function () { + var img = this._image = L.DomUtil.create('img', + 'leaflet-image-layer ' + (this._zoomAnimated ? 'leaflet-zoom-animated' : '')); + + img.onselectstart = L.Util.falseFn; + img.onmousemove = L.Util.falseFn; + + img.onload = L.bind(this.fire, this, 'load'); + + if (this.options.crossOrigin) { + img.crossOrigin = ''; + } + + img.src = this._url; + img.alt = this.options.alt; + }, + + _animateZoom: function (e) { + var scale = this._map.getZoomScale(e.zoom), + offset = this._map._latLngBoundsToNewLayerBounds(this._bounds, e.zoom, e.center).min; + + L.DomUtil.setTransform(this._image, offset, scale); + }, + + _reset: function () { + var image = this._image, + bounds = new L.Bounds( + this._map.latLngToLayerPoint(this._bounds.getNorthWest()), + this._map.latLngToLayerPoint(this._bounds.getSouthEast())), + size = bounds.getSize(); + + L.DomUtil.setPosition(image, bounds.min); + + image.style.width = size.x + 'px'; + image.style.height = size.y + 'px'; + }, + + _updateOpacity: function () { + L.DomUtil.setOpacity(this._image, this.options.opacity); + } +}); + +// @factory L.imageOverlay(imageUrl: String, bounds: LatLngBounds, options?: ImageOverlay options) +// Instantiates an image overlay object given the URL of the image and the +// geographical bounds it is tied to. +L.imageOverlay = function (url, bounds, options) { + return new L.ImageOverlay(url, bounds, options); +}; + + + +/* + * @class Icon + * @aka L.Icon + * @inherits Layer + * + * Represents an icon to provide when creating a marker. + * + * @example + * + * ```js + * var myIcon = L.icon({ + * iconUrl: 'my-icon.png', + * iconRetinaUrl: 'my-icon@2x.png', + * iconSize: [38, 95], + * iconAnchor: [22, 94], + * popupAnchor: [-3, -76], + * shadowUrl: 'my-icon-shadow.png', + * shadowRetinaUrl: 'my-icon-shadow@2x.png', + * shadowSize: [68, 95], + * shadowAnchor: [22, 94] + * }); + * + * L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); + * ``` + * + * `L.Icon.Default` extends `L.Icon` and is the blue icon Leaflet uses for markers by default. + * + */ + +L.Icon = L.Class.extend({ + + /* @section + * @aka Icon options + * + * @option iconUrl: String = null + * **(required)** The URL to the icon image (absolute or relative to your script path). + * + * @option iconRetinaUrl: String = null + * The URL to a retina sized version of the icon image (absolute or relative to your + * script path). Used for Retina screen devices. + * + * @option iconSize: Point = null + * Size of the icon image in pixels. + * + * @option iconAnchor: Point = null + * The coordinates of the "tip" of the icon (relative to its top left corner). The icon + * will be aligned so that this point is at the marker's geographical location. Centered + * by default if size is specified, also can be set in CSS with negative margins. + * + * @option popupAnchor: Point = null + * The coordinates of the point from which popups will "open", relative to the icon anchor. + * + * @option shadowUrl: String = null + * The URL to the icon shadow image. If not specified, no shadow image will be created. + * + * @option shadowRetinaUrl: String = null + * + * @option shadowSize: Point = null + * Size of the shadow image in pixels. + * + * @option shadowAnchor: Point = null + * The coordinates of the "tip" of the shadow (relative to its top left corner) (the same + * as iconAnchor if not specified). + * + * @option className: String = '' + * A custom class name to assign to both icon and shadow images. Empty by default. + */ + + initialize: function (options) { + L.setOptions(this, options); + }, + + // @method createIcon(oldIcon?: HTMLElement): HTMLElement + // Called internally when the icon has to be shown, returns a `` HTML element + // styled according to the options. + createIcon: function (oldIcon) { + return this._createIcon('icon', oldIcon); + }, + + // @method createShadow(oldIcon?: HTMLElement): HTMLElement + // As `createIcon`, but for the shadow beneath it. + createShadow: function (oldIcon) { + return this._createIcon('shadow', oldIcon); + }, + + _createIcon: function (name, oldIcon) { + var src = this._getIconUrl(name); + + if (!src) { + if (name === 'icon') { + throw new Error('iconUrl not set in Icon options (see the docs).'); + } + return null; + } + + var img = this._createImg(src, oldIcon && oldIcon.tagName === 'IMG' ? oldIcon : null); + this._setIconStyles(img, name); + + return img; + }, + + _setIconStyles: function (img, name) { + var options = this.options; + var sizeOption = options[name + 'Size']; + + if (typeof sizeOption === 'number') { + sizeOption = [sizeOption, sizeOption]; + } + + var size = L.point(sizeOption), + anchor = L.point(name === 'shadow' && options.shadowAnchor || options.iconAnchor || + size && size.divideBy(2, true)); + + img.className = 'leaflet-marker-' + name + ' ' + (options.className || ''); + + if (anchor) { + img.style.marginLeft = (-anchor.x) + 'px'; + img.style.marginTop = (-anchor.y) + 'px'; + } + + if (size) { + img.style.width = size.x + 'px'; + img.style.height = size.y + 'px'; + } + }, + + _createImg: function (src, el) { + el = el || document.createElement('img'); + el.src = src; + return el; + }, + + _getIconUrl: function (name) { + return L.Browser.retina && this.options[name + 'RetinaUrl'] || this.options[name + 'Url']; + } +}); + + +// @factory L.icon(options: Icon options) +// Creates an icon instance with the given options. +L.icon = function (options) { + return new L.Icon(options); +}; + + + +/* + * @miniclass Icon.Default (Icon) + * @aka L.Icon.Default + * @section + * + * A trivial subclass of `Icon`, represents the icon to use in `Marker`s when + * no icon is specified. Points to the blue marker image distributed with Leaflet + * releases. + * + * In order to customize the default icon, just change the properties of `L.Icon.Default.prototype.options` + * (which is a set of `Icon options`). + * + * If you want to _completely_ replace the default icon, override the + * `L.Marker.prototype.options.icon` with your own icon instead. + */ + +L.Icon.Default = L.Icon.extend({ + + options: { + iconUrl: 'marker-icon.png', + iconRetinaUrl: 'marker-icon-2x.png', + shadowUrl: 'marker-shadow.png', + iconSize: [25, 41], + iconAnchor: [12, 41], + popupAnchor: [1, -34], + tooltipAnchor: [16, -28], + shadowSize: [41, 41] + }, + + _getIconUrl: function (name) { + if (!L.Icon.Default.imagePath) { // Deprecated, backwards-compatibility only + L.Icon.Default.imagePath = this._detectIconPath(); + } + + // @option imagePath: String + // `L.Icon.Default` will try to auto-detect the absolute location of the + // blue icon images. If you are placing these images in a non-standard + // way, set this option to point to the right absolute path. + return (this.options.imagePath || L.Icon.Default.imagePath) + L.Icon.prototype._getIconUrl.call(this, name); + }, + + _detectIconPath: function () { + var el = L.DomUtil.create('div', 'leaflet-default-icon-path', document.body); + var path = L.DomUtil.getStyle(el, 'background-image') || + L.DomUtil.getStyle(el, 'backgroundImage'); // IE8 + + document.body.removeChild(el); + + return path.indexOf('url') === 0 ? + path.replace(/^url\([\"\']?/, '').replace(/marker-icon\.png[\"\']?\)$/, '') : ''; + } +}); + + + +/* + * @class Marker + * @inherits Interactive layer + * @aka L.Marker + * L.Marker is used to display clickable/draggable icons on the map. Extends `Layer`. + * + * @example + * + * ```js + * L.marker([50.5, 30.5]).addTo(map); + * ``` + */ + +L.Marker = L.Layer.extend({ + + // @section + // @aka Marker options + options: { + // @option icon: Icon = * + // Icon class to use for rendering the marker. See [Icon documentation](#L.Icon) for details on how to customize the marker icon. If not specified, a new `L.Icon.Default` is used. + icon: new L.Icon.Default(), + + // Option inherited from "Interactive layer" abstract class + interactive: true, + + // @option draggable: Boolean = false + // Whether the marker is draggable with mouse/touch or not. + draggable: false, + + // @option keyboard: Boolean = true + // Whether the marker can be tabbed to with a keyboard and clicked by pressing enter. + keyboard: true, + + // @option title: String = '' + // Text for the browser tooltip that appear on marker hover (no tooltip by default). + title: '', + + // @option alt: String = '' + // Text for the `alt` attribute of the icon image (useful for accessibility). + alt: '', + + // @option zIndexOffset: Number = 0 + // By default, marker images zIndex is set automatically based on its latitude. Use this option if you want to put the marker on top of all others (or below), specifying a high value like `1000` (or high negative value, respectively). + zIndexOffset: 0, + + // @option opacity: Number = 1.0 + // The opacity of the marker. + opacity: 1, + + // @option riseOnHover: Boolean = false + // If `true`, the marker will get on top of others when you hover the mouse over it. + riseOnHover: false, + + // @option riseOffset: Number = 250 + // The z-index offset used for the `riseOnHover` feature. + riseOffset: 250, + + // @option pane: String = 'markerPane' + // `Map pane` where the markers icon will be added. + pane: 'markerPane', + + // FIXME: shadowPane is no longer a valid option + nonBubblingEvents: ['click', 'dblclick', 'mouseover', 'mouseout', 'contextmenu'] + }, + + /* @section + * + * In addition to [shared layer methods](#Layer) like `addTo()` and `remove()` and [popup methods](#Popup) like bindPopup() you can also use the following methods: + */ + + initialize: function (latlng, options) { + L.setOptions(this, options); + this._latlng = L.latLng(latlng); + }, + + onAdd: function (map) { + this._zoomAnimated = this._zoomAnimated && map.options.markerZoomAnimation; + + if (this._zoomAnimated) { + map.on('zoomanim', this._animateZoom, this); + } + + this._initIcon(); + this.update(); + }, + + onRemove: function (map) { + if (this.dragging && this.dragging.enabled()) { + this.options.draggable = true; + this.dragging.removeHooks(); + } + + if (this._zoomAnimated) { + map.off('zoomanim', this._animateZoom, this); + } + + this._removeIcon(); + this._removeShadow(); + }, + + getEvents: function () { + return { + zoom: this.update, + viewreset: this.update + }; + }, + + // @method getLatLng: LatLng + // Returns the current geographical position of the marker. + getLatLng: function () { + return this._latlng; + }, + + // @method setLatLng(latlng: LatLng): this + // Changes the marker position to the given point. + setLatLng: function (latlng) { + var oldLatLng = this._latlng; + this._latlng = L.latLng(latlng); + this.update(); + + // @event move: Event + // Fired when the marker is moved via [`setLatLng`](#marker-setlatlng) or by [dragging](#marker-dragging). Old and new coordinates are included in event arguments as `oldLatLng`, `latlng`. + return this.fire('move', {oldLatLng: oldLatLng, latlng: this._latlng}); + }, + + // @method setZIndexOffset(offset: Number): this + // Changes the [zIndex offset](#marker-zindexoffset) of the marker. + setZIndexOffset: function (offset) { + this.options.zIndexOffset = offset; + return this.update(); + }, + + // @method setIcon(icon: Icon): this + // Changes the marker icon. + setIcon: function (icon) { + + this.options.icon = icon; + + if (this._map) { + this._initIcon(); + this.update(); + } + + if (this._popup) { + this.bindPopup(this._popup, this._popup.options); + } + + return this; + }, + + getElement: function () { + return this._icon; + }, + + update: function () { + + if (this._icon) { + var pos = this._map.latLngToLayerPoint(this._latlng).round(); + this._setPos(pos); + } + + return this; + }, + + _initIcon: function () { + var options = this.options, + classToAdd = 'leaflet-zoom-' + (this._zoomAnimated ? 'animated' : 'hide'); + + var icon = options.icon.createIcon(this._icon), + addIcon = false; + + // if we're not reusing the icon, remove the old one and init new one + if (icon !== this._icon) { + if (this._icon) { + this._removeIcon(); + } + addIcon = true; + + if (options.title) { + icon.title = options.title; + } + if (options.alt) { + icon.alt = options.alt; + } + } + + L.DomUtil.addClass(icon, classToAdd); + + if (options.keyboard) { + icon.tabIndex = '0'; + } + + this._icon = icon; + + if (options.riseOnHover) { + this.on({ + mouseover: this._bringToFront, + mouseout: this._resetZIndex + }); + } + + var newShadow = options.icon.createShadow(this._shadow), + addShadow = false; + + if (newShadow !== this._shadow) { + this._removeShadow(); + addShadow = true; + } + + if (newShadow) { + L.DomUtil.addClass(newShadow, classToAdd); + } + this._shadow = newShadow; + + + if (options.opacity < 1) { + this._updateOpacity(); + } + + + if (addIcon) { + this.getPane().appendChild(this._icon); + } + this._initInteraction(); + if (newShadow && addShadow) { + this.getPane('shadowPane').appendChild(this._shadow); + } + }, + + _removeIcon: function () { + if (this.options.riseOnHover) { + this.off({ + mouseover: this._bringToFront, + mouseout: this._resetZIndex + }); + } + + L.DomUtil.remove(this._icon); + this.removeInteractiveTarget(this._icon); + + this._icon = null; + }, + + _removeShadow: function () { + if (this._shadow) { + L.DomUtil.remove(this._shadow); + } + this._shadow = null; + }, + + _setPos: function (pos) { + L.DomUtil.setPosition(this._icon, pos); + + if (this._shadow) { + L.DomUtil.setPosition(this._shadow, pos); + } + + this._zIndex = pos.y + this.options.zIndexOffset; + + this._resetZIndex(); + }, + + _updateZIndex: function (offset) { + this._icon.style.zIndex = this._zIndex + offset; + }, + + _animateZoom: function (opt) { + var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round(); + + this._setPos(pos); + }, + + _initInteraction: function () { + + if (!this.options.interactive) { return; } + + L.DomUtil.addClass(this._icon, 'leaflet-interactive'); + + this.addInteractiveTarget(this._icon); + + if (L.Handler.MarkerDrag) { + var draggable = this.options.draggable; + if (this.dragging) { + draggable = this.dragging.enabled(); + this.dragging.disable(); + } + + this.dragging = new L.Handler.MarkerDrag(this); + + if (draggable) { + this.dragging.enable(); + } + } + }, + + // @method setOpacity(opacity: Number): this + // Changes the opacity of the marker. + setOpacity: function (opacity) { + this.options.opacity = opacity; + if (this._map) { + this._updateOpacity(); + } + + return this; + }, + + _updateOpacity: function () { + var opacity = this.options.opacity; + + L.DomUtil.setOpacity(this._icon, opacity); + + if (this._shadow) { + L.DomUtil.setOpacity(this._shadow, opacity); + } + }, + + _bringToFront: function () { + this._updateZIndex(this.options.riseOffset); + }, + + _resetZIndex: function () { + this._updateZIndex(0); + }, + + _getPopupAnchor: function () { + return this.options.icon.options.popupAnchor || [0, 0]; + }, + + _getTooltipAnchor: function () { + return this.options.icon.options.tooltipAnchor || [0, 0]; + } +}); + + +// factory L.marker(latlng: LatLng, options? : Marker options) + +// @factory L.marker(latlng: LatLng, options? : Marker options) +// Instantiates a Marker object given a geographical point and optionally an options object. +L.marker = function (latlng, options) { + return new L.Marker(latlng, options); +}; + + + +/* + * @class DivIcon + * @aka L.DivIcon + * @inherits Icon + * + * Represents a lightweight icon for markers that uses a simple `
      ` + * element instead of an image. Inherits from `Icon` but ignores the `iconUrl` and shadow options. + * + * @example + * ```js + * var myIcon = L.divIcon({className: 'my-div-icon'}); + * // you can set .my-div-icon styles in CSS + * + * L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); + * ``` + * + * By default, it has a 'leaflet-div-icon' CSS class and is styled as a little white square with a shadow. + */ + +L.DivIcon = L.Icon.extend({ + options: { + // @section + // @aka DivIcon options + iconSize: [12, 12], // also can be set through CSS + + // iconAnchor: (Point), + // popupAnchor: (Point), + + // @option html: String = '' + // Custom HTML code to put inside the div element, empty by default. + html: false, + + // @option bgPos: Point = [0, 0] + // Optional relative position of the background, in pixels + bgPos: null, + + className: 'leaflet-div-icon' + }, + + createIcon: function (oldIcon) { + var div = (oldIcon && oldIcon.tagName === 'DIV') ? oldIcon : document.createElement('div'), + options = this.options; + + div.innerHTML = options.html !== false ? options.html : ''; + + if (options.bgPos) { + var bgPos = L.point(options.bgPos); + div.style.backgroundPosition = (-bgPos.x) + 'px ' + (-bgPos.y) + 'px'; + } + this._setIconStyles(div, 'icon'); + + return div; + }, + + createShadow: function () { + return null; + } +}); + +// @factory L.divIcon(options: DivIcon options) +// Creates a `DivIcon` instance with the given options. +L.divIcon = function (options) { + return new L.DivIcon(options); +}; + + + +/* + * @class DivOverlay + * @inherits Layer + * @aka L.DivOverlay + * Base model for L.Popup and L.Tooltip. Inherit from it for custom popup like plugins. + */ + +// @namespace DivOverlay +L.DivOverlay = L.Layer.extend({ + + // @section + // @aka DivOverlay options + options: { + // @option offset: Point = Point(0, 7) + // The offset of the popup position. Useful to control the anchor + // of the popup when opening it on some overlays. + offset: [0, 7], + + // @option className: String = '' + // A custom CSS class name to assign to the popup. + className: '', + + // @option pane: String = 'popupPane' + // `Map pane` where the popup will be added. + pane: 'popupPane' + }, + + initialize: function (options, source) { + L.setOptions(this, options); + + this._source = source; + }, + + onAdd: function (map) { + this._zoomAnimated = map._zoomAnimated; + + if (!this._container) { + this._initLayout(); + } + + if (map._fadeAnimated) { + L.DomUtil.setOpacity(this._container, 0); + } + + clearTimeout(this._removeTimeout); + this.getPane().appendChild(this._container); + this.update(); + + if (map._fadeAnimated) { + L.DomUtil.setOpacity(this._container, 1); + } + + this.bringToFront(); + }, + + onRemove: function (map) { + if (map._fadeAnimated) { + L.DomUtil.setOpacity(this._container, 0); + this._removeTimeout = setTimeout(L.bind(L.DomUtil.remove, L.DomUtil, this._container), 200); + } else { + L.DomUtil.remove(this._container); + } + }, + + // @namespace Popup + // @method getLatLng: LatLng + // Returns the geographical point of popup. + getLatLng: function () { + return this._latlng; + }, + + // @method setLatLng(latlng: LatLng): this + // Sets the geographical point where the popup will open. + setLatLng: function (latlng) { + this._latlng = L.latLng(latlng); + if (this._map) { + this._updatePosition(); + this._adjustPan(); + } + return this; + }, + + // @method getContent: String|HTMLElement + // Returns the content of the popup. + getContent: function () { + return this._content; + }, + + // @method setContent(htmlContent: String|HTMLElement|Function): this + // Sets the HTML content of the popup. If a function is passed the source layer will be passed to the function. The function should return a `String` or `HTMLElement` to be used in the popup. + setContent: function (content) { + this._content = content; + this.update(); + return this; + }, + + // @method getElement: String|HTMLElement + // Alias for [getContent()](#popup-getcontent) + getElement: function () { + return this._container; + }, + + // @method update: null + // Updates the popup content, layout and position. Useful for updating the popup after something inside changed, e.g. image loaded. + update: function () { + if (!this._map) { return; } + + this._container.style.visibility = 'hidden'; + + this._updateContent(); + this._updateLayout(); + this._updatePosition(); + + this._container.style.visibility = ''; + + this._adjustPan(); + }, + + getEvents: function () { + var events = { + zoom: this._updatePosition, + viewreset: this._updatePosition + }; + + if (this._zoomAnimated) { + events.zoomanim = this._animateZoom; + } + return events; + }, + + // @method isOpen: Boolean + // Returns `true` when the popup is visible on the map. + isOpen: function () { + return !!this._map && this._map.hasLayer(this); + }, + + // @method bringToFront: this + // Brings this popup in front of other popups (in the same map pane). + bringToFront: function () { + if (this._map) { + L.DomUtil.toFront(this._container); + } + return this; + }, + + // @method bringToBack: this + // Brings this popup to the back of other popups (in the same map pane). + bringToBack: function () { + if (this._map) { + L.DomUtil.toBack(this._container); + } + return this; + }, + + _updateContent: function () { + if (!this._content) { return; } + + var node = this._contentNode; + var content = (typeof this._content === 'function') ? this._content(this._source || this) : this._content; + + if (typeof content === 'string') { + node.innerHTML = content; + } else { + while (node.hasChildNodes()) { + node.removeChild(node.firstChild); + } + node.appendChild(content); + } + this.fire('contentupdate'); + }, + + _updatePosition: function () { + if (!this._map) { return; } + + var pos = this._map.latLngToLayerPoint(this._latlng), + offset = L.point(this.options.offset), + anchor = this._getAnchor(); + + if (this._zoomAnimated) { + L.DomUtil.setPosition(this._container, pos.add(anchor)); + } else { + offset = offset.add(pos).add(anchor); + } + + var bottom = this._containerBottom = -offset.y, + left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x; + + // bottom position the popup in case the height of the popup changes (images loading etc) + this._container.style.bottom = bottom + 'px'; + this._container.style.left = left + 'px'; + }, + + _getAnchor: function () { + return [0, 0]; + } + +}); + + + +/* + * @class Popup + * @inherits DivOverlay + * @aka L.Popup + * Used to open popups in certain places of the map. Use [Map.openPopup](#map-openpopup) to + * open popups while making sure that only one popup is open at one time + * (recommended for usability), or use [Map.addLayer](#map-addlayer) to open as many as you want. + * + * @example + * + * If you want to just bind a popup to marker click and then open it, it's really easy: + * + * ```js + * marker.bindPopup(popupContent).openPopup(); + * ``` + * Path overlays like polylines also have a `bindPopup` method. + * Here's a more complicated way to open a popup on a map: + * + * ```js + * var popup = L.popup() + * .setLatLng(latlng) + * .setContent('

      Hello world!
      This is a nice popup.

      ') + * .openOn(map); + * ``` + */ + + +// @namespace Popup +L.Popup = L.DivOverlay.extend({ + + // @section + // @aka Popup options + options: { + // @option maxWidth: Number = 300 + // Max width of the popup, in pixels. + maxWidth: 300, + + // @option minWidth: Number = 50 + // Min width of the popup, in pixels. + minWidth: 50, + + // @option maxHeight: Number = null + // If set, creates a scrollable container of the given height + // inside a popup if its content exceeds it. + maxHeight: null, + + // @option autoPan: Boolean = true + // Set it to `false` if you don't want the map to do panning animation + // to fit the opened popup. + autoPan: true, + + // @option autoPanPaddingTopLeft: Point = null + // The margin between the popup and the top left corner of the map + // view after autopanning was performed. + autoPanPaddingTopLeft: null, + + // @option autoPanPaddingBottomRight: Point = null + // The margin between the popup and the bottom right corner of the map + // view after autopanning was performed. + autoPanPaddingBottomRight: null, + + // @option autoPanPadding: Point = Point(5, 5) + // Equivalent of setting both top left and bottom right autopan padding to the same value. + autoPanPadding: [5, 5], + + // @option keepInView: Boolean = false + // Set it to `true` if you want to prevent users from panning the popup + // off of the screen while it is open. + keepInView: false, + + // @option closeButton: Boolean = true + // Controls the presence of a close button in the popup. + closeButton: true, + + // @option autoClose: Boolean = true + // Set it to `false` if you want to override the default behavior of + // the popup closing when user clicks the map (set globally by + // the Map's [closePopupOnClick](#map-closepopuponclick) option). + autoClose: true, + + // @option className: String = '' + // A custom CSS class name to assign to the popup. + className: '' + }, + + // @namespace Popup + // @method openOn(map: Map): this + // Adds the popup to the map and closes the previous one. The same as `map.openPopup(popup)`. + openOn: function (map) { + map.openPopup(this); + return this; + }, + + onAdd: function (map) { + L.DivOverlay.prototype.onAdd.call(this, map); + + // @namespace Map + // @section Popup events + // @event popupopen: PopupEvent + // Fired when a popup is opened in the map + map.fire('popupopen', {popup: this}); + + if (this._source) { + // @namespace Layer + // @section Popup events + // @event popupopen: PopupEvent + // Fired when a popup bound to this layer is opened + this._source.fire('popupopen', {popup: this}, true); + // For non-path layers, we toggle the popup when clicking + // again the layer, so prevent the map to reopen it. + if (!(this._source instanceof L.Path)) { + this._source.on('preclick', L.DomEvent.stopPropagation); + } + } + }, + + onRemove: function (map) { + L.DivOverlay.prototype.onRemove.call(this, map); + + // @namespace Map + // @section Popup events + // @event popupclose: PopupEvent + // Fired when a popup in the map is closed + map.fire('popupclose', {popup: this}); + + if (this._source) { + // @namespace Layer + // @section Popup events + // @event popupclose: PopupEvent + // Fired when a popup bound to this layer is closed + this._source.fire('popupclose', {popup: this}, true); + if (!(this._source instanceof L.Path)) { + this._source.off('preclick', L.DomEvent.stopPropagation); + } + } + }, + + getEvents: function () { + var events = L.DivOverlay.prototype.getEvents.call(this); + + if ('closeOnClick' in this.options ? this.options.closeOnClick : this._map.options.closePopupOnClick) { + events.preclick = this._close; + } + + if (this.options.keepInView) { + events.moveend = this._adjustPan; + } + + return events; + }, + + _close: function () { + if (this._map) { + this._map.closePopup(this); + } + }, + + _initLayout: function () { + var prefix = 'leaflet-popup', + container = this._container = L.DomUtil.create('div', + prefix + ' ' + (this.options.className || '') + + ' leaflet-zoom-animated'); + + if (this.options.closeButton) { + var closeButton = this._closeButton = L.DomUtil.create('a', prefix + '-close-button', container); + closeButton.href = '#close'; + closeButton.innerHTML = '×'; + + L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this); + } + + var wrapper = this._wrapper = L.DomUtil.create('div', prefix + '-content-wrapper', container); + this._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper); + + L.DomEvent + .disableClickPropagation(wrapper) + .disableScrollPropagation(this._contentNode) + .on(wrapper, 'contextmenu', L.DomEvent.stopPropagation); + + this._tipContainer = L.DomUtil.create('div', prefix + '-tip-container', container); + this._tip = L.DomUtil.create('div', prefix + '-tip', this._tipContainer); + }, + + _updateLayout: function () { + var container = this._contentNode, + style = container.style; + + style.width = ''; + style.whiteSpace = 'nowrap'; + + var width = container.offsetWidth; + width = Math.min(width, this.options.maxWidth); + width = Math.max(width, this.options.minWidth); + + style.width = (width + 1) + 'px'; + style.whiteSpace = ''; + + style.height = ''; + + var height = container.offsetHeight, + maxHeight = this.options.maxHeight, + scrolledClass = 'leaflet-popup-scrolled'; + + if (maxHeight && height > maxHeight) { + style.height = maxHeight + 'px'; + L.DomUtil.addClass(container, scrolledClass); + } else { + L.DomUtil.removeClass(container, scrolledClass); + } + + this._containerWidth = this._container.offsetWidth; + }, + + _animateZoom: function (e) { + var pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center), + anchor = this._getAnchor(); + L.DomUtil.setPosition(this._container, pos.add(anchor)); + }, + + _adjustPan: function () { + if (!this.options.autoPan || (this._map._panAnim && this._map._panAnim._inProgress)) { return; } + + var map = this._map, + marginBottom = parseInt(L.DomUtil.getStyle(this._container, 'marginBottom'), 10) || 0, + containerHeight = this._container.offsetHeight + marginBottom, + containerWidth = this._containerWidth, + layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom); + + layerPos._add(L.DomUtil.getPosition(this._container)); + + var containerPos = map.layerPointToContainerPoint(layerPos), + padding = L.point(this.options.autoPanPadding), + paddingTL = L.point(this.options.autoPanPaddingTopLeft || padding), + paddingBR = L.point(this.options.autoPanPaddingBottomRight || padding), + size = map.getSize(), + dx = 0, + dy = 0; + + if (containerPos.x + containerWidth + paddingBR.x > size.x) { // right + dx = containerPos.x + containerWidth - size.x + paddingBR.x; + } + if (containerPos.x - dx - paddingTL.x < 0) { // left + dx = containerPos.x - paddingTL.x; + } + if (containerPos.y + containerHeight + paddingBR.y > size.y) { // bottom + dy = containerPos.y + containerHeight - size.y + paddingBR.y; + } + if (containerPos.y - dy - paddingTL.y < 0) { // top + dy = containerPos.y - paddingTL.y; + } + + // @namespace Map + // @section Popup events + // @event autopanstart: Event + // Fired when the map starts autopanning when opening a popup. + if (dx || dy) { + map + .fire('autopanstart') + .panBy([dx, dy]); + } + }, + + _onCloseButtonClick: function (e) { + this._close(); + L.DomEvent.stop(e); + }, + + _getAnchor: function () { + // Where should we anchor the popup on the source layer? + return L.point(this._source && this._source._getPopupAnchor ? this._source._getPopupAnchor() : [0, 0]); + } + +}); + +// @namespace Popup +// @factory L.popup(options?: Popup options, source?: Layer) +// Instantiates a `Popup` object given an optional `options` object that describes its appearance and location and an optional `source` object that is used to tag the popup with a reference to the Layer to which it refers. +L.popup = function (options, source) { + return new L.Popup(options, source); +}; + + +/* @namespace Map + * @section Interaction Options + * @option closePopupOnClick: Boolean = true + * Set it to `false` if you don't want popups to close when user clicks the map. + */ +L.Map.mergeOptions({ + closePopupOnClick: true +}); + + +// @namespace Map +// @section Methods for Layers and Controls +L.Map.include({ + // @method openPopup(popup: Popup): this + // Opens the specified popup while closing the previously opened (to make sure only one is opened at one time for usability). + // @alternative + // @method openPopup(content: String|HTMLElement, latlng: LatLng, options?: Popup options): this + // Creates a popup with the specified content and options and opens it in the given point on a map. + openPopup: function (popup, latlng, options) { + if (!(popup instanceof L.Popup)) { + popup = new L.Popup(options).setContent(popup); + } + + if (latlng) { + popup.setLatLng(latlng); + } + + if (this.hasLayer(popup)) { + return this; + } + + if (this._popup && this._popup.options.autoClose) { + this.closePopup(); + } + + this._popup = popup; + return this.addLayer(popup); + }, + + // @method closePopup(popup?: Popup): this + // Closes the popup previously opened with [openPopup](#map-openpopup) (or the given one). + closePopup: function (popup) { + if (!popup || popup === this._popup) { + popup = this._popup; + this._popup = null; + } + if (popup) { + this.removeLayer(popup); + } + return this; + } +}); + +/* + * @namespace Layer + * @section Popup methods example + * + * All layers share a set of methods convenient for binding popups to it. + * + * ```js + * var layer = L.Polygon(latlngs).bindPopup('Hi There!').addTo(map); + * layer.openPopup(); + * layer.closePopup(); + * ``` + * + * Popups will also be automatically opened when the layer is clicked on and closed when the layer is removed from the map or another popup is opened. + */ + +// @section Popup methods +L.Layer.include({ + + // @method bindPopup(content: String|HTMLElement|Function|Popup, options?: Popup options): this + // Binds a popup to the layer with the passed `content` and sets up the + // neccessary event listeners. If a `Function` is passed it will receive + // the layer as the first argument and should return a `String` or `HTMLElement`. + bindPopup: function (content, options) { + + if (content instanceof L.Popup) { + L.setOptions(content, options); + this._popup = content; + content._source = this; + } else { + if (!this._popup || options) { + this._popup = new L.Popup(options, this); + } + this._popup.setContent(content); + } + + if (!this._popupHandlersAdded) { + this.on({ + click: this._openPopup, + remove: this.closePopup, + move: this._movePopup + }); + this._popupHandlersAdded = true; + } + + return this; + }, + + // @method unbindPopup(): this + // Removes the popup previously bound with `bindPopup`. + unbindPopup: function () { + if (this._popup) { + this.off({ + click: this._openPopup, + remove: this.closePopup, + move: this._movePopup + }); + this._popupHandlersAdded = false; + this._popup = null; + } + return this; + }, + + // @method openPopup(latlng?: LatLng): this + // Opens the bound popup at the specificed `latlng` or at the default popup anchor if no `latlng` is passed. + openPopup: function (layer, latlng) { + if (!(layer instanceof L.Layer)) { + latlng = layer; + layer = this; + } + + if (layer instanceof L.FeatureGroup) { + for (var id in this._layers) { + layer = this._layers[id]; + break; + } + } + + if (!latlng) { + latlng = layer.getCenter ? layer.getCenter() : layer.getLatLng(); + } + + if (this._popup && this._map) { + // set popup source to this layer + this._popup._source = layer; + + // update the popup (content, layout, ect...) + this._popup.update(); + + // open the popup on the map + this._map.openPopup(this._popup, latlng); + } + + return this; + }, + + // @method closePopup(): this + // Closes the popup bound to this layer if it is open. + closePopup: function () { + if (this._popup) { + this._popup._close(); + } + return this; + }, + + // @method togglePopup(): this + // Opens or closes the popup bound to this layer depending on its current state. + togglePopup: function (target) { + if (this._popup) { + if (this._popup._map) { + this.closePopup(); + } else { + this.openPopup(target); + } + } + return this; + }, + + // @method isPopupOpen(): boolean + // Returns `true` if the popup bound to this layer is currently open. + isPopupOpen: function () { + return this._popup.isOpen(); + }, + + // @method setPopupContent(content: String|HTMLElement|Popup): this + // Sets the content of the popup bound to this layer. + setPopupContent: function (content) { + if (this._popup) { + this._popup.setContent(content); + } + return this; + }, + + // @method getPopup(): Popup + // Returns the popup bound to this layer. + getPopup: function () { + return this._popup; + }, + + _openPopup: function (e) { + var layer = e.layer || e.target; + + if (!this._popup) { + return; + } + + if (!this._map) { + return; + } + + // prevent map click + L.DomEvent.stop(e); + + // if this inherits from Path its a vector and we can just + // open the popup at the new location + if (layer instanceof L.Path) { + this.openPopup(e.layer || e.target, e.latlng); + return; + } + + // otherwise treat it like a marker and figure out + // if we should toggle it open/closed + if (this._map.hasLayer(this._popup) && this._popup._source === layer) { + this.closePopup(); + } else { + this.openPopup(layer, e.latlng); + } + }, + + _movePopup: function (e) { + this._popup.setLatLng(e.latlng); + } +}); + + + +/* + * @class Tooltip + * @inherits DivOverlay + * @aka L.Tooltip + * Used to display small texts on top of map layers. + * + * @example + * + * ```js + * marker.bindTooltip("my tooltip text").openTooltip(); + * ``` + * Note about tooltip offset. Leaflet takes two options in consideration + * for computing tooltip offseting: + * - the `offset` Tooltip option: it defaults to [0, 0], and it's specific to one tooltip. + * Add a positive x offset to move the tooltip to the right, and a positive y offset to + * move it to the bottom. Negatives will move to the left and top. + * - the `tooltipAnchor` Icon option: this will only be considered for Marker. You + * should adapt this value if you use a custom icon. + */ + + +// @namespace Tooltip +L.Tooltip = L.DivOverlay.extend({ + + // @section + // @aka Tooltip options + options: { + // @option pane: String = 'tooltipPane' + // `Map pane` where the tooltip will be added. + pane: 'tooltipPane', + + // @option offset: Point = Point(0, 0) + // Optional offset of the tooltip position. + offset: [0, 0], + + // @option direction: String = 'auto' + // Direction where to open the tooltip. Possible values are: `right`, `left`, + // `top`, `bottom`, `center`, `auto`. + // `auto` will dynamicaly switch between `right` and `left` according to the tooltip + // position on the map. + direction: 'auto', + + // @option permanent: Boolean = false + // Whether to open the tooltip permanently or only on mouseover. + permanent: false, + + // @option sticky: Boolean = false + // If true, the tooltip will follow the mouse instead of being fixed at the feature center. + sticky: false, + + // @option interactive: Boolean = false + // If true, the tooltip will listen to the feature events. + interactive: false, + + // @option opacity: Number = 0.9 + // Tooltip container opacity. + opacity: 0.9 + }, + + onAdd: function (map) { + L.DivOverlay.prototype.onAdd.call(this, map); + this.setOpacity(this.options.opacity); + + // @namespace Map + // @section Tooltip events + // @event tooltipopen: TooltipEvent + // Fired when a tooltip is opened in the map. + map.fire('tooltipopen', {tooltip: this}); + + if (this._source) { + // @namespace Layer + // @section Tooltip events + // @event tooltipopen: TooltipEvent + // Fired when a tooltip bound to this layer is opened. + this._source.fire('tooltipopen', {tooltip: this}, true); + } + }, + + onRemove: function (map) { + L.DivOverlay.prototype.onRemove.call(this, map); + + // @namespace Map + // @section Tooltip events + // @event tooltipclose: TooltipEvent + // Fired when a tooltip in the map is closed. + map.fire('tooltipclose', {tooltip: this}); + + if (this._source) { + // @namespace Layer + // @section Tooltip events + // @event tooltipclose: TooltipEvent + // Fired when a tooltip bound to this layer is closed. + this._source.fire('tooltipclose', {tooltip: this}, true); + } + }, + + getEvents: function () { + var events = L.DivOverlay.prototype.getEvents.call(this); + + if (L.Browser.touch && !this.options.permanent) { + events.preclick = this._close; + } + + return events; + }, + + _close: function () { + if (this._map) { + this._map.closeTooltip(this); + } + }, + + _initLayout: function () { + var prefix = 'leaflet-tooltip', + className = prefix + ' ' + (this.options.className || '') + ' leaflet-zoom-' + (this._zoomAnimated ? 'animated' : 'hide'); + + this._contentNode = this._container = L.DomUtil.create('div', className); + }, + + _updateLayout: function () {}, + + _adjustPan: function () {}, + + _setPosition: function (pos) { + var map = this._map, + container = this._container, + centerPoint = map.latLngToContainerPoint(map.getCenter()), + tooltipPoint = map.layerPointToContainerPoint(pos), + direction = this.options.direction, + tooltipWidth = container.offsetWidth, + tooltipHeight = container.offsetHeight, + offset = L.point(this.options.offset), + anchor = this._getAnchor(); + + if (direction === 'top') { + pos = pos.add(L.point(-tooltipWidth / 2 + offset.x, -tooltipHeight + offset.y + anchor.y, true)); + } else if (direction === 'bottom') { + pos = pos.subtract(L.point(tooltipWidth / 2 - offset.x, -offset.y, true)); + } else if (direction === 'center') { + pos = pos.subtract(L.point(tooltipWidth / 2 + offset.x, tooltipHeight / 2 - anchor.y + offset.y, true)); + } else if (direction === 'right' || direction === 'auto' && tooltipPoint.x < centerPoint.x) { + direction = 'right'; + pos = pos.add(L.point(offset.x + anchor.x, anchor.y - tooltipHeight / 2 + offset.y, true)); + } else { + direction = 'left'; + pos = pos.subtract(L.point(tooltipWidth + anchor.x - offset.x, tooltipHeight / 2 - anchor.y - offset.y, true)); + } + + L.DomUtil.removeClass(container, 'leaflet-tooltip-right'); + L.DomUtil.removeClass(container, 'leaflet-tooltip-left'); + L.DomUtil.removeClass(container, 'leaflet-tooltip-top'); + L.DomUtil.removeClass(container, 'leaflet-tooltip-bottom'); + L.DomUtil.addClass(container, 'leaflet-tooltip-' + direction); + L.DomUtil.setPosition(container, pos); + }, + + _updatePosition: function () { + var pos = this._map.latLngToLayerPoint(this._latlng); + this._setPosition(pos); + }, + + setOpacity: function (opacity) { + this.options.opacity = opacity; + + if (this._container) { + L.DomUtil.setOpacity(this._container, opacity); + } + }, + + _animateZoom: function (e) { + var pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center); + this._setPosition(pos); + }, + + _getAnchor: function () { + // Where should we anchor the tooltip on the source layer? + return L.point(this._source && this._source._getTooltipAnchor && !this.options.sticky ? this._source._getTooltipAnchor() : [0, 0]); + } + +}); + +// @namespace Tooltip +// @factory L.tooltip(options?: Tooltip options, source?: Layer) +// Instantiates a Tooltip object given an optional `options` object that describes its appearance and location and an optional `source` object that is used to tag the tooltip with a reference to the Layer to which it refers. +L.tooltip = function (options, source) { + return new L.Tooltip(options, source); +}; + +// @namespace Map +// @section Methods for Layers and Controls +L.Map.include({ + + // @method openTooltip(tooltip: Tooltip): this + // Opens the specified tooltip. + // @alternative + // @method openTooltip(content: String|HTMLElement, latlng: LatLng, options?: Tooltip options): this + // Creates a tooltip with the specified content and options and open it. + openTooltip: function (tooltip, latlng, options) { + if (!(tooltip instanceof L.Tooltip)) { + tooltip = new L.Tooltip(options).setContent(tooltip); + } + + if (latlng) { + tooltip.setLatLng(latlng); + } + + if (this.hasLayer(tooltip)) { + return this; + } + + return this.addLayer(tooltip); + }, + + // @method closeTooltip(tooltip?: Tooltip): this + // Closes the tooltip given as parameter. + closeTooltip: function (tooltip) { + if (tooltip) { + this.removeLayer(tooltip); + } + return this; + } + +}); + +/* + * @namespace Layer + * @section Tooltip methods example + * + * All layers share a set of methods convenient for binding tooltips to it. + * + * ```js + * var layer = L.Polygon(latlngs).bindTooltip('Hi There!').addTo(map); + * layer.openTooltip(); + * layer.closeTooltip(); + * ``` + */ + +// @section Tooltip methods +L.Layer.include({ + + // @method bindTooltip(content: String|HTMLElement|Function|Tooltip, options?: Tooltip options): this + // Binds a tooltip to the layer with the passed `content` and sets up the + // neccessary event listeners. If a `Function` is passed it will receive + // the layer as the first argument and should return a `String` or `HTMLElement`. + bindTooltip: function (content, options) { + + if (content instanceof L.Tooltip) { + L.setOptions(content, options); + this._tooltip = content; + content._source = this; + } else { + if (!this._tooltip || options) { + this._tooltip = L.tooltip(options, this); + } + this._tooltip.setContent(content); + + } + + this._initTooltipInteractions(); + + if (this._tooltip.options.permanent && this._map && this._map.hasLayer(this)) { + this.openTooltip(); + } + + return this; + }, + + // @method unbindTooltip(): this + // Removes the tooltip previously bound with `bindTooltip`. + unbindTooltip: function () { + if (this._tooltip) { + this._initTooltipInteractions(true); + this.closeTooltip(); + this._tooltip = null; + } + return this; + }, + + _initTooltipInteractions: function (remove) { + if (!remove && this._tooltipHandlersAdded) { return; } + var onOff = remove ? 'off' : 'on', + events = { + remove: this.closeTooltip, + move: this._moveTooltip + }; + if (!this._tooltip.options.permanent) { + events.mouseover = this._openTooltip; + events.mouseout = this.closeTooltip; + if (this._tooltip.options.sticky) { + events.mousemove = this._moveTooltip; + } + if (L.Browser.touch) { + events.click = this._openTooltip; + } + } else { + events.add = this._openTooltip; + } + this[onOff](events); + this._tooltipHandlersAdded = !remove; + }, + + // @method openTooltip(latlng?: LatLng): this + // Opens the bound tooltip at the specificed `latlng` or at the default tooltip anchor if no `latlng` is passed. + openTooltip: function (layer, latlng) { + if (!(layer instanceof L.Layer)) { + latlng = layer; + layer = this; + } + + if (layer instanceof L.FeatureGroup) { + for (var id in this._layers) { + layer = this._layers[id]; + break; + } + } + + if (!latlng) { + latlng = layer.getCenter ? layer.getCenter() : layer.getLatLng(); + } + + if (this._tooltip && this._map) { + + // set tooltip source to this layer + this._tooltip._source = layer; + + // update the tooltip (content, layout, ect...) + this._tooltip.update(); + + // open the tooltip on the map + this._map.openTooltip(this._tooltip, latlng); + + // Tooltip container may not be defined if not permanent and never + // opened. + if (this._tooltip.options.interactive && this._tooltip._container) { + L.DomUtil.addClass(this._tooltip._container, 'leaflet-clickable'); + this.addInteractiveTarget(this._tooltip._container); + } + } + + return this; + }, + + // @method closeTooltip(): this + // Closes the tooltip bound to this layer if it is open. + closeTooltip: function () { + if (this._tooltip) { + this._tooltip._close(); + if (this._tooltip.options.interactive && this._tooltip._container) { + L.DomUtil.removeClass(this._tooltip._container, 'leaflet-clickable'); + this.removeInteractiveTarget(this._tooltip._container); + } + } + return this; + }, + + // @method toggleTooltip(): this + // Opens or closes the tooltip bound to this layer depending on its current state. + toggleTooltip: function (target) { + if (this._tooltip) { + if (this._tooltip._map) { + this.closeTooltip(); + } else { + this.openTooltip(target); + } + } + return this; + }, + + // @method isTooltipOpen(): boolean + // Returns `true` if the tooltip bound to this layer is currently open. + isTooltipOpen: function () { + return this._tooltip.isOpen(); + }, + + // @method setTooltipContent(content: String|HTMLElement|Tooltip): this + // Sets the content of the tooltip bound to this layer. + setTooltipContent: function (content) { + if (this._tooltip) { + this._tooltip.setContent(content); + } + return this; + }, + + // @method getTooltip(): Tooltip + // Returns the tooltip bound to this layer. + getTooltip: function () { + return this._tooltip; + }, + + _openTooltip: function (e) { + var layer = e.layer || e.target; + + if (!this._tooltip || !this._map) { + return; + } + this.openTooltip(layer, this._tooltip.options.sticky ? e.latlng : undefined); + }, + + _moveTooltip: function (e) { + var latlng = e.latlng, containerPoint, layerPoint; + if (this._tooltip.options.sticky && e.originalEvent) { + containerPoint = this._map.mouseEventToContainerPoint(e.originalEvent); + layerPoint = this._map.containerPointToLayerPoint(containerPoint); + latlng = this._map.layerPointToLatLng(layerPoint); + } + this._tooltip.setLatLng(latlng); + } +}); + + + +/* + * @class LayerGroup + * @aka L.LayerGroup + * @inherits Layer + * + * Used to group several layers and handle them as one. If you add it to the map, + * any layers added or removed from the group will be added/removed on the map as + * well. Extends `Layer`. + * + * @example + * + * ```js + * L.layerGroup([marker1, marker2]) + * .addLayer(polyline) + * .addTo(map); + * ``` + */ + +L.LayerGroup = L.Layer.extend({ + + initialize: function (layers) { + this._layers = {}; + + var i, len; + + if (layers) { + for (i = 0, len = layers.length; i < len; i++) { + this.addLayer(layers[i]); + } + } + }, + + // @method addLayer(layer: Layer): this + // Adds the given layer to the group. + addLayer: function (layer) { + var id = this.getLayerId(layer); + + this._layers[id] = layer; + + if (this._map) { + this._map.addLayer(layer); + } + + return this; + }, + + // @method removeLayer(layer: Layer): this + // Removes the given layer from the group. + // @alternative + // @method removeLayer(id: Number): this + // Removes the layer with the given internal ID from the group. + removeLayer: function (layer) { + var id = layer in this._layers ? layer : this.getLayerId(layer); + + if (this._map && this._layers[id]) { + this._map.removeLayer(this._layers[id]); + } + + delete this._layers[id]; + + return this; + }, + + // @method hasLayer(layer: Layer): Boolean + // Returns `true` if the given layer is currently added to the group. + hasLayer: function (layer) { + return !!layer && (layer in this._layers || this.getLayerId(layer) in this._layers); + }, + + // @method clearLayers(): this + // Removes all the layers from the group. + clearLayers: function () { + for (var i in this._layers) { + this.removeLayer(this._layers[i]); + } + return this; + }, + + // @method invoke(methodName: String, …): this + // Calls `methodName` on every layer contained in this group, passing any + // additional parameters. Has no effect if the layers contained do not + // implement `methodName`. + invoke: function (methodName) { + var args = Array.prototype.slice.call(arguments, 1), + i, layer; + + for (i in this._layers) { + layer = this._layers[i]; + + if (layer[methodName]) { + layer[methodName].apply(layer, args); + } + } + + return this; + }, + + onAdd: function (map) { + for (var i in this._layers) { + map.addLayer(this._layers[i]); + } + }, + + onRemove: function (map) { + for (var i in this._layers) { + map.removeLayer(this._layers[i]); + } + }, + + // @method eachLayer(fn: Function, context?: Object): this + // Iterates over the layers of the group, optionally specifying context of the iterator function. + // ```js + // group.eachLayer(function (layer) { + // layer.bindPopup('Hello'); + // }); + // ``` + eachLayer: function (method, context) { + for (var i in this._layers) { + method.call(context, this._layers[i]); + } + return this; + }, + + // @method getLayer(id: Number): Layer + // Returns the layer with the given internal ID. + getLayer: function (id) { + return this._layers[id]; + }, + + // @method getLayers(): Layer[] + // Returns an array of all the layers added to the group. + getLayers: function () { + var layers = []; + + for (var i in this._layers) { + layers.push(this._layers[i]); + } + return layers; + }, + + // @method setZIndex(zIndex: Number): this + // Calls `setZIndex` on every layer contained in this group, passing the z-index. + setZIndex: function (zIndex) { + return this.invoke('setZIndex', zIndex); + }, + + // @method getLayerId(layer: Layer): Number + // Returns the internal ID for a layer + getLayerId: function (layer) { + return L.stamp(layer); + } +}); + + +// @factory L.layerGroup(layers: Layer[]) +// Create a layer group, optionally given an initial set of layers. +L.layerGroup = function (layers) { + return new L.LayerGroup(layers); +}; + + + +/* + * @class FeatureGroup + * @aka L.FeatureGroup + * @inherits LayerGroup + * + * Extended `LayerGroup` that makes it easier to do the same thing to all its member layers: + * * [`bindPopup`](#layer-bindpopup) binds a popup to all of the layers at once (likewise with [`bindTooltip`](#layer-bindtooltip)) + * * Events are propagated to the `FeatureGroup`, so if the group has an event + * handler, it will handle events from any of the layers. This includes mouse events + * and custom events. + * * Has `layeradd` and `layerremove` events + * + * @example + * + * ```js + * L.featureGroup([marker1, marker2, polyline]) + * .bindPopup('Hello world!') + * .on('click', function() { alert('Clicked on a member of the group!'); }) + * .addTo(map); + * ``` + */ + +L.FeatureGroup = L.LayerGroup.extend({ + + addLayer: function (layer) { + if (this.hasLayer(layer)) { + return this; + } + + layer.addEventParent(this); + + L.LayerGroup.prototype.addLayer.call(this, layer); + + // @event layeradd: LayerEvent + // Fired when a layer is added to this `FeatureGroup` + return this.fire('layeradd', {layer: layer}); + }, + + removeLayer: function (layer) { + if (!this.hasLayer(layer)) { + return this; + } + if (layer in this._layers) { + layer = this._layers[layer]; + } + + layer.removeEventParent(this); + + L.LayerGroup.prototype.removeLayer.call(this, layer); + + // @event layerremove: LayerEvent + // Fired when a layer is removed from this `FeatureGroup` + return this.fire('layerremove', {layer: layer}); + }, + + // @method setStyle(style: Path options): this + // Sets the given path options to each layer of the group that has a `setStyle` method. + setStyle: function (style) { + return this.invoke('setStyle', style); + }, + + // @method bringToFront(): this + // Brings the layer group to the top of all other layers + bringToFront: function () { + return this.invoke('bringToFront'); + }, + + // @method bringToBack(): this + // Brings the layer group to the top of all other layers + bringToBack: function () { + return this.invoke('bringToBack'); + }, + + // @method getBounds(): LatLngBounds + // Returns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children). + getBounds: function () { + var bounds = new L.LatLngBounds(); + + for (var id in this._layers) { + var layer = this._layers[id]; + bounds.extend(layer.getBounds ? layer.getBounds() : layer.getLatLng()); + } + return bounds; + } +}); + +// @factory L.featureGroup(layers: Layer[]) +// Create a feature group, optionally given an initial set of layers. +L.featureGroup = function (layers) { + return new L.FeatureGroup(layers); +}; + + + +/* + * @class Renderer + * @inherits Layer + * @aka L.Renderer + * + * Base class for vector renderer implementations (`SVG`, `Canvas`). Handles the + * DOM container of the renderer, its bounds, and its zoom animation. + * + * A `Renderer` works as an implicit layer group for all `Path`s - the renderer + * itself can be added or removed to the map. All paths use a renderer, which can + * be implicit (the map will decide the type of renderer and use it automatically) + * or explicit (using the [`renderer`](#path-renderer) option of the path). + * + * Do not use this class directly, use `SVG` and `Canvas` instead. + * + * @event update: Event + * Fired when the renderer updates its bounds, center and zoom, for example when + * its map has moved + */ + +L.Renderer = L.Layer.extend({ + + // @section + // @aka Renderer options + options: { + // @option padding: Number = 0.1 + // How much to extend the clip area around the map view (relative to its size) + // e.g. 0.1 would be 10% of map view in each direction + padding: 0.1 + }, + + initialize: function (options) { + L.setOptions(this, options); + L.stamp(this); + this._layers = this._layers || {}; + }, + + onAdd: function () { + if (!this._container) { + this._initContainer(); // defined by renderer implementations + + if (this._zoomAnimated) { + L.DomUtil.addClass(this._container, 'leaflet-zoom-animated'); + } + } + + this.getPane().appendChild(this._container); + this._update(); + this.on('update', this._updatePaths, this); + }, + + onRemove: function () { + L.DomUtil.remove(this._container); + this.off('update', this._updatePaths, this); + }, + + getEvents: function () { + var events = { + viewreset: this._reset, + zoom: this._onZoom, + moveend: this._update, + zoomend: this._onZoomEnd + }; + if (this._zoomAnimated) { + events.zoomanim = this._onAnimZoom; + } + return events; + }, + + _onAnimZoom: function (ev) { + this._updateTransform(ev.center, ev.zoom); + }, + + _onZoom: function () { + this._updateTransform(this._map.getCenter(), this._map.getZoom()); + }, + + _updateTransform: function (center, zoom) { + var scale = this._map.getZoomScale(zoom, this._zoom), + position = L.DomUtil.getPosition(this._container), + viewHalf = this._map.getSize().multiplyBy(0.5 + this.options.padding), + currentCenterPoint = this._map.project(this._center, zoom), + destCenterPoint = this._map.project(center, zoom), + centerOffset = destCenterPoint.subtract(currentCenterPoint), + + topLeftOffset = viewHalf.multiplyBy(-scale).add(position).add(viewHalf).subtract(centerOffset); + + if (L.Browser.any3d) { + L.DomUtil.setTransform(this._container, topLeftOffset, scale); + } else { + L.DomUtil.setPosition(this._container, topLeftOffset); + } + }, + + _reset: function () { + this._update(); + this._updateTransform(this._center, this._zoom); + + for (var id in this._layers) { + this._layers[id]._reset(); + } + }, + + _onZoomEnd: function () { + for (var id in this._layers) { + this._layers[id]._project(); + } + }, + + _updatePaths: function () { + for (var id in this._layers) { + this._layers[id]._update(); + } + }, + + _update: function () { + // Update pixel bounds of renderer container (for positioning/sizing/clipping later) + // Subclasses are responsible of firing the 'update' event. + var p = this.options.padding, + size = this._map.getSize(), + min = this._map.containerPointToLayerPoint(size.multiplyBy(-p)).round(); + + this._bounds = new L.Bounds(min, min.add(size.multiplyBy(1 + p * 2)).round()); + + this._center = this._map.getCenter(); + this._zoom = this._map.getZoom(); + } +}); + + +L.Map.include({ + // @namespace Map; @method getRenderer(layer: Path): Renderer + // Returns the instance of `Renderer` that should be used to render the given + // `Path`. It will ensure that the `renderer` options of the map and paths + // are respected, and that the renderers do exist on the map. + getRenderer: function (layer) { + // @namespace Path; @option renderer: Renderer + // Use this specific instance of `Renderer` for this path. Takes + // precedence over the map's [default renderer](#map-renderer). + var renderer = layer.options.renderer || this._getPaneRenderer(layer.options.pane) || this.options.renderer || this._renderer; + + if (!renderer) { + // @namespace Map; @option preferCanvas: Boolean = false + // Whether `Path`s should be rendered on a `Canvas` renderer. + // By default, all `Path`s are rendered in a `SVG` renderer. + renderer = this._renderer = (this.options.preferCanvas && L.canvas()) || L.svg(); + } + + if (!this.hasLayer(renderer)) { + this.addLayer(renderer); + } + return renderer; + }, + + _getPaneRenderer: function (name) { + if (name === 'overlayPane' || name === undefined) { + return false; + } + + var renderer = this._paneRenderers[name]; + if (renderer === undefined) { + renderer = (L.SVG && L.svg({pane: name})) || (L.Canvas && L.canvas({pane: name})); + this._paneRenderers[name] = renderer; + } + return renderer; + } +}); + + + +/* + * @class Path + * @aka L.Path + * @inherits Interactive layer + * + * An abstract class that contains options and constants shared between vector + * overlays (Polygon, Polyline, Circle). Do not use it directly. Extends `Layer`. + */ + +L.Path = L.Layer.extend({ + + // @section + // @aka Path options + options: { + // @option stroke: Boolean = true + // Whether to draw stroke along the path. Set it to `false` to disable borders on polygons or circles. + stroke: true, + + // @option color: String = '#3388ff' + // Stroke color + color: '#3388ff', + + // @option weight: Number = 3 + // Stroke width in pixels + weight: 3, + + // @option opacity: Number = 1.0 + // Stroke opacity + opacity: 1, + + // @option lineCap: String= 'round' + // A string that defines [shape to be used at the end](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-linecap) of the stroke. + lineCap: 'round', + + // @option lineJoin: String = 'round' + // A string that defines [shape to be used at the corners](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-linejoin) of the stroke. + lineJoin: 'round', + + // @option dashArray: String = null + // A string that defines the stroke [dash pattern](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-dasharray). Doesn't work on `Canvas`-powered layers in [some old browsers](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility). + dashArray: null, + + // @option dashOffset: String = null + // A string that defines the [distance into the dash pattern to start the dash](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-dashoffset). Doesn't work on `Canvas`-powered layers in [some old browsers](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility). + dashOffset: null, + + // @option fill: Boolean = depends + // Whether to fill the path with color. Set it to `false` to disable filling on polygons or circles. + fill: false, + + // @option fillColor: String = * + // Fill color. Defaults to the value of the [`color`](#path-color) option + fillColor: null, + + // @option fillOpacity: Number = 0.2 + // Fill opacity. + fillOpacity: 0.2, + + // @option fillRule: String = 'evenodd' + // A string that defines [how the inside of a shape](https://developer.mozilla.org/docs/Web/SVG/Attribute/fill-rule) is determined. + fillRule: 'evenodd', + + // className: '', + + // Option inherited from "Interactive layer" abstract class + interactive: true + }, + + beforeAdd: function (map) { + // Renderer is set here because we need to call renderer.getEvents + // before this.getEvents. + this._renderer = map.getRenderer(this); + }, + + onAdd: function () { + this._renderer._initPath(this); + this._reset(); + this._renderer._addPath(this); + }, + + onRemove: function () { + this._renderer._removePath(this); + }, + + // @method redraw(): this + // Redraws the layer. Sometimes useful after you changed the coordinates that the path uses. + redraw: function () { + if (this._map) { + this._renderer._updatePath(this); + } + return this; + }, + + // @method setStyle(style: Path options): this + // Changes the appearance of a Path based on the options in the `Path options` object. + setStyle: function (style) { + L.setOptions(this, style); + if (this._renderer) { + this._renderer._updateStyle(this); + } + return this; + }, + + // @method bringToFront(): this + // Brings the layer to the top of all path layers. + bringToFront: function () { + if (this._renderer) { + this._renderer._bringToFront(this); + } + return this; + }, + + // @method bringToBack(): this + // Brings the layer to the bottom of all path layers. + bringToBack: function () { + if (this._renderer) { + this._renderer._bringToBack(this); + } + return this; + }, + + getElement: function () { + return this._path; + }, + + _reset: function () { + // defined in children classes + this._project(); + this._update(); + }, + + _clickTolerance: function () { + // used when doing hit detection for Canvas layers + return (this.options.stroke ? this.options.weight / 2 : 0) + (L.Browser.touch ? 10 : 0); + } +}); + + + +/* + * @namespace LineUtil + * + * Various utility functions for polyine points processing, used by Leaflet internally to make polylines lightning-fast. + */ + +L.LineUtil = { + + // Simplify polyline with vertex reduction and Douglas-Peucker simplification. + // Improves rendering performance dramatically by lessening the number of points to draw. + + // @function simplify(points: Point[], tolerance: Number): Point[] + // Dramatically reduces the number of points in a polyline while retaining + // its shape and returns a new array of simplified points, using the + // [Douglas-Peucker algorithm](http://en.wikipedia.org/wiki/Douglas-Peucker_algorithm). + // Used for a huge performance boost when processing/displaying Leaflet polylines for + // each zoom level and also reducing visual noise. tolerance affects the amount of + // simplification (lesser value means higher quality but slower and with more points). + // Also released as a separated micro-library [Simplify.js](http://mourner.github.com/simplify-js/). + simplify: function (points, tolerance) { + if (!tolerance || !points.length) { + return points.slice(); + } + + var sqTolerance = tolerance * tolerance; + + // stage 1: vertex reduction + points = this._reducePoints(points, sqTolerance); + + // stage 2: Douglas-Peucker simplification + points = this._simplifyDP(points, sqTolerance); + + return points; + }, + + // @function pointToSegmentDistance(p: Point, p1: Point, p2: Point): Number + // Returns the distance between point `p` and segment `p1` to `p2`. + pointToSegmentDistance: function (p, p1, p2) { + return Math.sqrt(this._sqClosestPointOnSegment(p, p1, p2, true)); + }, + + // @function closestPointOnSegment(p: Point, p1: Point, p2: Point): Number + // Returns the closest point from a point `p` on a segment `p1` to `p2`. + closestPointOnSegment: function (p, p1, p2) { + return this._sqClosestPointOnSegment(p, p1, p2); + }, + + // Douglas-Peucker simplification, see http://en.wikipedia.org/wiki/Douglas-Peucker_algorithm + _simplifyDP: function (points, sqTolerance) { + + var len = points.length, + ArrayConstructor = typeof Uint8Array !== undefined + '' ? Uint8Array : Array, + markers = new ArrayConstructor(len); + + markers[0] = markers[len - 1] = 1; + + this._simplifyDPStep(points, markers, sqTolerance, 0, len - 1); + + var i, + newPoints = []; + + for (i = 0; i < len; i++) { + if (markers[i]) { + newPoints.push(points[i]); + } + } + + return newPoints; + }, + + _simplifyDPStep: function (points, markers, sqTolerance, first, last) { + + var maxSqDist = 0, + index, i, sqDist; + + for (i = first + 1; i <= last - 1; i++) { + sqDist = this._sqClosestPointOnSegment(points[i], points[first], points[last], true); + + if (sqDist > maxSqDist) { + index = i; + maxSqDist = sqDist; + } + } + + if (maxSqDist > sqTolerance) { + markers[index] = 1; + + this._simplifyDPStep(points, markers, sqTolerance, first, index); + this._simplifyDPStep(points, markers, sqTolerance, index, last); + } + }, + + // reduce points that are too close to each other to a single point + _reducePoints: function (points, sqTolerance) { + var reducedPoints = [points[0]]; + + for (var i = 1, prev = 0, len = points.length; i < len; i++) { + if (this._sqDist(points[i], points[prev]) > sqTolerance) { + reducedPoints.push(points[i]); + prev = i; + } + } + if (prev < len - 1) { + reducedPoints.push(points[len - 1]); + } + return reducedPoints; + }, + + + // @function clipSegment(a: Point, b: Point, bounds: Bounds, useLastCode?: Boolean, round?: Boolean): Point[]|Boolean + // Clips the segment a to b by rectangular bounds with the + // [Cohen-Sutherland algorithm](https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm) + // (modifying the segment points directly!). Used by Leaflet to only show polyline + // points that are on the screen or near, increasing performance. + clipSegment: function (a, b, bounds, useLastCode, round) { + var codeA = useLastCode ? this._lastCode : this._getBitCode(a, bounds), + codeB = this._getBitCode(b, bounds), + + codeOut, p, newCode; + + // save 2nd code to avoid calculating it on the next segment + this._lastCode = codeB; + + while (true) { + // if a,b is inside the clip window (trivial accept) + if (!(codeA | codeB)) { + return [a, b]; + } + + // if a,b is outside the clip window (trivial reject) + if (codeA & codeB) { + return false; + } + + // other cases + codeOut = codeA || codeB; + p = this._getEdgeIntersection(a, b, codeOut, bounds, round); + newCode = this._getBitCode(p, bounds); + + if (codeOut === codeA) { + a = p; + codeA = newCode; + } else { + b = p; + codeB = newCode; + } + } + }, + + _getEdgeIntersection: function (a, b, code, bounds, round) { + var dx = b.x - a.x, + dy = b.y - a.y, + min = bounds.min, + max = bounds.max, + x, y; + + if (code & 8) { // top + x = a.x + dx * (max.y - a.y) / dy; + y = max.y; + + } else if (code & 4) { // bottom + x = a.x + dx * (min.y - a.y) / dy; + y = min.y; + + } else if (code & 2) { // right + x = max.x; + y = a.y + dy * (max.x - a.x) / dx; + + } else if (code & 1) { // left + x = min.x; + y = a.y + dy * (min.x - a.x) / dx; + } + + return new L.Point(x, y, round); + }, + + _getBitCode: function (p, bounds) { + var code = 0; + + if (p.x < bounds.min.x) { // left + code |= 1; + } else if (p.x > bounds.max.x) { // right + code |= 2; + } + + if (p.y < bounds.min.y) { // bottom + code |= 4; + } else if (p.y > bounds.max.y) { // top + code |= 8; + } + + return code; + }, + + // square distance (to avoid unnecessary Math.sqrt calls) + _sqDist: function (p1, p2) { + var dx = p2.x - p1.x, + dy = p2.y - p1.y; + return dx * dx + dy * dy; + }, + + // return closest point on segment or distance to that point + _sqClosestPointOnSegment: function (p, p1, p2, sqDist) { + var x = p1.x, + y = p1.y, + dx = p2.x - x, + dy = p2.y - y, + dot = dx * dx + dy * dy, + t; + + if (dot > 0) { + t = ((p.x - x) * dx + (p.y - y) * dy) / dot; + + if (t > 1) { + x = p2.x; + y = p2.y; + } else if (t > 0) { + x += dx * t; + y += dy * t; + } + } + + dx = p.x - x; + dy = p.y - y; + + return sqDist ? dx * dx + dy * dy : new L.Point(x, y); + } +}; + + + +/* + * @class Polyline + * @aka L.Polyline + * @inherits Path + * + * A class for drawing polyline overlays on a map. Extends `Path`. + * + * @example + * + * ```js + * // create a red polyline from an array of LatLng points + * var latlngs = [ + * [-122.68, 45.51], + * [-122.43, 37.77], + * [-118.2, 34.04] + * ]; + * + * var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map); + * + * // zoom the map to the polyline + * map.fitBounds(polyline.getBounds()); + * ``` + * + * You can also pass a multi-dimensional array to represent a `MultiPolyline` shape: + * + * ```js + * // create a red polyline from an array of arrays of LatLng points + * var latlngs = [ + * [[-122.68, 45.51], + * [-122.43, 37.77], + * [-118.2, 34.04]], + * [[-73.91, 40.78], + * [-87.62, 41.83], + * [-96.72, 32.76]] + * ]; + * ``` + */ + +L.Polyline = L.Path.extend({ + + // @section + // @aka Polyline options + options: { + // @option smoothFactor: Number = 1.0 + // How much to simplify the polyline on each zoom level. More means + // better performance and smoother look, and less means more accurate representation. + smoothFactor: 1.0, + + // @option noClip: Boolean = false + // Disable polyline clipping. + noClip: false + }, + + initialize: function (latlngs, options) { + L.setOptions(this, options); + this._setLatLngs(latlngs); + }, + + // @method getLatLngs(): LatLng[] + // Returns an array of the points in the path, or nested arrays of points in case of multi-polyline. + getLatLngs: function () { + return this._latlngs; + }, + + // @method setLatLngs(latlngs: LatLng[]): this + // Replaces all the points in the polyline with the given array of geographical points. + setLatLngs: function (latlngs) { + this._setLatLngs(latlngs); + return this.redraw(); + }, + + // @method isEmpty(): Boolean + // Returns `true` if the Polyline has no LatLngs. + isEmpty: function () { + return !this._latlngs.length; + }, + + closestLayerPoint: function (p) { + var minDistance = Infinity, + minPoint = null, + closest = L.LineUtil._sqClosestPointOnSegment, + p1, p2; + + for (var j = 0, jLen = this._parts.length; j < jLen; j++) { + var points = this._parts[j]; + + for (var i = 1, len = points.length; i < len; i++) { + p1 = points[i - 1]; + p2 = points[i]; + + var sqDist = closest(p, p1, p2, true); + + if (sqDist < minDistance) { + minDistance = sqDist; + minPoint = closest(p, p1, p2); + } + } + } + if (minPoint) { + minPoint.distance = Math.sqrt(minDistance); + } + return minPoint; + }, + + // @method getCenter(): LatLng + // Returns the center ([centroid](http://en.wikipedia.org/wiki/Centroid)) of the polyline. + getCenter: function () { + // throws error when not yet added to map as this center calculation requires projected coordinates + if (!this._map) { + throw new Error('Must add layer to map before using getCenter()'); + } + + var i, halfDist, segDist, dist, p1, p2, ratio, + points = this._rings[0], + len = points.length; + + if (!len) { return null; } + + // polyline centroid algorithm; only uses the first ring if there are multiple + + for (i = 0, halfDist = 0; i < len - 1; i++) { + halfDist += points[i].distanceTo(points[i + 1]) / 2; + } + + // The line is so small in the current view that all points are on the same pixel. + if (halfDist === 0) { + return this._map.layerPointToLatLng(points[0]); + } + + for (i = 0, dist = 0; i < len - 1; i++) { + p1 = points[i]; + p2 = points[i + 1]; + segDist = p1.distanceTo(p2); + dist += segDist; + + if (dist > halfDist) { + ratio = (dist - halfDist) / segDist; + return this._map.layerPointToLatLng([ + p2.x - ratio * (p2.x - p1.x), + p2.y - ratio * (p2.y - p1.y) + ]); + } + } + }, + + // @method getBounds(): LatLngBounds + // Returns the `LatLngBounds` of the path. + getBounds: function () { + return this._bounds; + }, + + // @method addLatLng(latlng: LatLng, latlngs? LatLng[]): this + // Adds a given point to the polyline. By default, adds to the first ring of + // the polyline in case of a multi-polyline, but can be overridden by passing + // a specific ring as a LatLng array (that you can earlier access with [`getLatLngs`](#polyline-getlatlngs)). + addLatLng: function (latlng, latlngs) { + latlngs = latlngs || this._defaultShape(); + latlng = L.latLng(latlng); + latlngs.push(latlng); + this._bounds.extend(latlng); + return this.redraw(); + }, + + _setLatLngs: function (latlngs) { + this._bounds = new L.LatLngBounds(); + this._latlngs = this._convertLatLngs(latlngs); + }, + + _defaultShape: function () { + return L.Polyline._flat(this._latlngs) ? this._latlngs : this._latlngs[0]; + }, + + // recursively convert latlngs input into actual LatLng instances; calculate bounds along the way + _convertLatLngs: function (latlngs) { + var result = [], + flat = L.Polyline._flat(latlngs); + + for (var i = 0, len = latlngs.length; i < len; i++) { + if (flat) { + result[i] = L.latLng(latlngs[i]); + this._bounds.extend(result[i]); + } else { + result[i] = this._convertLatLngs(latlngs[i]); + } + } + + return result; + }, + + _project: function () { + var pxBounds = new L.Bounds(); + this._rings = []; + this._projectLatlngs(this._latlngs, this._rings, pxBounds); + + var w = this._clickTolerance(), + p = new L.Point(w, w); + + if (this._bounds.isValid() && pxBounds.isValid()) { + pxBounds.min._subtract(p); + pxBounds.max._add(p); + this._pxBounds = pxBounds; + } + }, + + // recursively turns latlngs into a set of rings with projected coordinates + _projectLatlngs: function (latlngs, result, projectedBounds) { + var flat = latlngs[0] instanceof L.LatLng, + len = latlngs.length, + i, ring; + + if (flat) { + ring = []; + for (i = 0; i < len; i++) { + ring[i] = this._map.latLngToLayerPoint(latlngs[i]); + projectedBounds.extend(ring[i]); + } + result.push(ring); + } else { + for (i = 0; i < len; i++) { + this._projectLatlngs(latlngs[i], result, projectedBounds); + } + } + }, + + // clip polyline by renderer bounds so that we have less to render for performance + _clipPoints: function () { + var bounds = this._renderer._bounds; + + this._parts = []; + if (!this._pxBounds || !this._pxBounds.intersects(bounds)) { + return; + } + + if (this.options.noClip) { + this._parts = this._rings; + return; + } + + var parts = this._parts, + i, j, k, len, len2, segment, points; + + for (i = 0, k = 0, len = this._rings.length; i < len; i++) { + points = this._rings[i]; + + for (j = 0, len2 = points.length; j < len2 - 1; j++) { + segment = L.LineUtil.clipSegment(points[j], points[j + 1], bounds, j, true); + + if (!segment) { continue; } + + parts[k] = parts[k] || []; + parts[k].push(segment[0]); + + // if segment goes out of screen, or it's the last one, it's the end of the line part + if ((segment[1] !== points[j + 1]) || (j === len2 - 2)) { + parts[k].push(segment[1]); + k++; + } + } + } + }, + + // simplify each clipped part of the polyline for performance + _simplifyPoints: function () { + var parts = this._parts, + tolerance = this.options.smoothFactor; + + for (var i = 0, len = parts.length; i < len; i++) { + parts[i] = L.LineUtil.simplify(parts[i], tolerance); + } + }, + + _update: function () { + if (!this._map) { return; } + + this._clipPoints(); + this._simplifyPoints(); + this._updatePath(); + }, + + _updatePath: function () { + this._renderer._updatePoly(this); + } +}); + +// @factory L.polyline(latlngs: LatLng[], options?: Polyline options) +// Instantiates a polyline object given an array of geographical points and +// optionally an options object. You can create a `Polyline` object with +// multiple separate lines (`MultiPolyline`) by passing an array of arrays +// of geographic points. +L.polyline = function (latlngs, options) { + return new L.Polyline(latlngs, options); +}; + +L.Polyline._flat = function (latlngs) { + // true if it's a flat array of latlngs; false if nested + return !L.Util.isArray(latlngs[0]) || (typeof latlngs[0][0] !== 'object' && typeof latlngs[0][0] !== 'undefined'); +}; + + + +/* + * @namespace PolyUtil + * Various utility functions for polygon geometries. + */ + +L.PolyUtil = {}; + +/* @function clipPolygon(points: Point[], bounds: Bounds, round?: Boolean): Point[] + * Clips the polygon geometry defined by the given `points` by the given bounds (using the [Sutherland-Hodgeman algorithm](https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm)). + * Used by Leaflet to only show polygon points that are on the screen or near, increasing + * performance. Note that polygon points needs different algorithm for clipping + * than polyline, so there's a seperate method for it. + */ +L.PolyUtil.clipPolygon = function (points, bounds, round) { + var clippedPoints, + edges = [1, 4, 2, 8], + i, j, k, + a, b, + len, edge, p, + lu = L.LineUtil; + + for (i = 0, len = points.length; i < len; i++) { + points[i]._code = lu._getBitCode(points[i], bounds); + } + + // for each edge (left, bottom, right, top) + for (k = 0; k < 4; k++) { + edge = edges[k]; + clippedPoints = []; + + for (i = 0, len = points.length, j = len - 1; i < len; j = i++) { + a = points[i]; + b = points[j]; + + // if a is inside the clip window + if (!(a._code & edge)) { + // if b is outside the clip window (a->b goes out of screen) + if (b._code & edge) { + p = lu._getEdgeIntersection(b, a, edge, bounds, round); + p._code = lu._getBitCode(p, bounds); + clippedPoints.push(p); + } + clippedPoints.push(a); + + // else if b is inside the clip window (a->b enters the screen) + } else if (!(b._code & edge)) { + p = lu._getEdgeIntersection(b, a, edge, bounds, round); + p._code = lu._getBitCode(p, bounds); + clippedPoints.push(p); + } + } + points = clippedPoints; + } + + return points; +}; + + + +/* + * @class Polygon + * @aka L.Polygon + * @inherits Polyline + * + * A class for drawing polygon overlays on a map. Extends `Polyline`. + * + * Note that points you pass when creating a polygon shouldn't have an additional last point equal to the first one — it's better to filter out such points. + * + * + * @example + * + * ```js + * // create a red polygon from an array of LatLng points + * var latlngs = [[-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41]]; + * + * var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map); + * + * // zoom the map to the polygon + * map.fitBounds(polygon.getBounds()); + * ``` + * + * You can also pass an array of arrays of latlngs, with the first array representing the outer shape and the other arrays representing holes in the outer shape: + * + * ```js + * var latlngs = [ + * [[-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41]], // outer ring + * [[-108.58,37.29],[-108.58,40.71],[-102.50,40.71],[-102.50,37.29]] // hole + * ]; + * ``` + * + * Additionally, you can pass a multi-dimensional array to represent a MultiPolygon shape. + * + * ```js + * var latlngs = [ + * [ // first polygon + * [[-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41]], // outer ring + * [[-108.58,37.29],[-108.58,40.71],[-102.50,40.71],[-102.50,37.29]] // hole + * ], + * [ // second polygon + * [[-109.05, 37],[-109.03, 41],[-102.05, 41],[-102.04, 37],[-109.05, 38]] + * ] + * ]; + * ``` + */ + +L.Polygon = L.Polyline.extend({ + + options: { + fill: true + }, + + isEmpty: function () { + return !this._latlngs.length || !this._latlngs[0].length; + }, + + getCenter: function () { + // throws error when not yet added to map as this center calculation requires projected coordinates + if (!this._map) { + throw new Error('Must add layer to map before using getCenter()'); + } + + var i, j, p1, p2, f, area, x, y, center, + points = this._rings[0], + len = points.length; + + if (!len) { return null; } + + // polygon centroid algorithm; only uses the first ring if there are multiple + + area = x = y = 0; + + for (i = 0, j = len - 1; i < len; j = i++) { + p1 = points[i]; + p2 = points[j]; + + f = p1.y * p2.x - p2.y * p1.x; + x += (p1.x + p2.x) * f; + y += (p1.y + p2.y) * f; + area += f * 3; + } + + if (area === 0) { + // Polygon is so small that all points are on same pixel. + center = points[0]; + } else { + center = [x / area, y / area]; + } + return this._map.layerPointToLatLng(center); + }, + + _convertLatLngs: function (latlngs) { + var result = L.Polyline.prototype._convertLatLngs.call(this, latlngs), + len = result.length; + + // remove last point if it equals first one + if (len >= 2 && result[0] instanceof L.LatLng && result[0].equals(result[len - 1])) { + result.pop(); + } + return result; + }, + + _setLatLngs: function (latlngs) { + L.Polyline.prototype._setLatLngs.call(this, latlngs); + if (L.Polyline._flat(this._latlngs)) { + this._latlngs = [this._latlngs]; + } + }, + + _defaultShape: function () { + return L.Polyline._flat(this._latlngs[0]) ? this._latlngs[0] : this._latlngs[0][0]; + }, + + _clipPoints: function () { + // polygons need a different clipping algorithm so we redefine that + + var bounds = this._renderer._bounds, + w = this.options.weight, + p = new L.Point(w, w); + + // increase clip padding by stroke width to avoid stroke on clip edges + bounds = new L.Bounds(bounds.min.subtract(p), bounds.max.add(p)); + + this._parts = []; + if (!this._pxBounds || !this._pxBounds.intersects(bounds)) { + return; + } + + if (this.options.noClip) { + this._parts = this._rings; + return; + } + + for (var i = 0, len = this._rings.length, clipped; i < len; i++) { + clipped = L.PolyUtil.clipPolygon(this._rings[i], bounds, true); + if (clipped.length) { + this._parts.push(clipped); + } + } + }, + + _updatePath: function () { + this._renderer._updatePoly(this, true); + } +}); + + +// @factory L.polygon(latlngs: LatLng[], options?: Polyline options) +L.polygon = function (latlngs, options) { + return new L.Polygon(latlngs, options); +}; + + + +/* + * L.Rectangle extends Polygon and creates a rectangle when passed a LatLngBounds object. + */ + +/* + * @class Rectangle + * @aka L.Retangle + * @inherits Polygon + * + * A class for drawing rectangle overlays on a map. Extends `Polygon`. + * + * @example + * + * ```js + * // define rectangle geographical bounds + * var bounds = [[54.559322, -5.767822], [56.1210604, -3.021240]]; + * + * // create an orange rectangle + * L.rectangle(bounds, {color: "#ff7800", weight: 1}).addTo(map); + * + * // zoom the map to the rectangle bounds + * map.fitBounds(bounds); + * ``` + * + */ + + +L.Rectangle = L.Polygon.extend({ + initialize: function (latLngBounds, options) { + L.Polygon.prototype.initialize.call(this, this._boundsToLatLngs(latLngBounds), options); + }, + + // @method setBounds(latLngBounds: LatLngBounds): this + // Redraws the rectangle with the passed bounds. + setBounds: function (latLngBounds) { + return this.setLatLngs(this._boundsToLatLngs(latLngBounds)); + }, + + _boundsToLatLngs: function (latLngBounds) { + latLngBounds = L.latLngBounds(latLngBounds); + return [ + latLngBounds.getSouthWest(), + latLngBounds.getNorthWest(), + latLngBounds.getNorthEast(), + latLngBounds.getSouthEast() + ]; + } +}); + + +// @factory L.rectangle(latLngBounds: LatLngBounds, options?: Polyline options) +L.rectangle = function (latLngBounds, options) { + return new L.Rectangle(latLngBounds, options); +}; + + + +/* + * @class CircleMarker + * @aka L.CircleMarker + * @inherits Path + * + * A circle of a fixed size with radius specified in pixels. Extends `Path`. + */ + +L.CircleMarker = L.Path.extend({ + + // @section + // @aka CircleMarker options + options: { + fill: true, + + // @option radius: Number = 10 + // Radius of the circle marker, in pixels + radius: 10 + }, + + initialize: function (latlng, options) { + L.setOptions(this, options); + this._latlng = L.latLng(latlng); + this._radius = this.options.radius; + }, + + // @method setLatLng(latLng: LatLng): this + // Sets the position of a circle marker to a new location. + setLatLng: function (latlng) { + this._latlng = L.latLng(latlng); + this.redraw(); + return this.fire('move', {latlng: this._latlng}); + }, + + // @method getLatLng(): LatLng + // Returns the current geographical position of the circle marker + getLatLng: function () { + return this._latlng; + }, + + // @method setRadius(radius: Number): this + // Sets the radius of a circle marker. Units are in pixels. + setRadius: function (radius) { + this.options.radius = this._radius = radius; + return this.redraw(); + }, + + // @method getRadius(): Number + // Returns the current radius of the circle + getRadius: function () { + return this._radius; + }, + + setStyle : function (options) { + var radius = options && options.radius || this._radius; + L.Path.prototype.setStyle.call(this, options); + this.setRadius(radius); + return this; + }, + + _project: function () { + this._point = this._map.latLngToLayerPoint(this._latlng); + this._updateBounds(); + }, + + _updateBounds: function () { + var r = this._radius, + r2 = this._radiusY || r, + w = this._clickTolerance(), + p = [r + w, r2 + w]; + this._pxBounds = new L.Bounds(this._point.subtract(p), this._point.add(p)); + }, + + _update: function () { + if (this._map) { + this._updatePath(); + } + }, + + _updatePath: function () { + this._renderer._updateCircle(this); + }, + + _empty: function () { + return this._radius && !this._renderer._bounds.intersects(this._pxBounds); + } +}); + + +// @factory L.circleMarker(latlng: LatLng, options?: CircleMarker options) +// Instantiates a circle marker object given a geographical point, and an optional options object. +L.circleMarker = function (latlng, options) { + return new L.CircleMarker(latlng, options); +}; + + + +/* + * @class Circle + * @aka L.Circle + * @inherits CircleMarker + * + * A class for drawing circle overlays on a map. Extends `CircleMarker`. + * + * It's an approximation and starts to diverge from a real circle closer to poles (due to projection distortion). + * + * @example + * + * ```js + * L.circle([50.5, 30.5], {radius: 200}).addTo(map); + * ``` + */ + +L.Circle = L.CircleMarker.extend({ + + initialize: function (latlng, options, legacyOptions) { + if (typeof options === 'number') { + // Backwards compatibility with 0.7.x factory (latlng, radius, options?) + options = L.extend({}, legacyOptions, {radius: options}); + } + L.setOptions(this, options); + this._latlng = L.latLng(latlng); + + if (isNaN(this.options.radius)) { throw new Error('Circle radius cannot be NaN'); } + + // @section + // @aka Circle options + // @option radius: Number; Radius of the circle, in meters. + this._mRadius = this.options.radius; + }, + + // @method setRadius(radius: Number): this + // Sets the radius of a circle. Units are in meters. + setRadius: function (radius) { + this._mRadius = radius; + return this.redraw(); + }, + + // @method getRadius(): Number + // Returns the current radius of a circle. Units are in meters. + getRadius: function () { + return this._mRadius; + }, + + // @method getBounds(): LatLngBounds + // Returns the `LatLngBounds` of the path. + getBounds: function () { + var half = [this._radius, this._radiusY || this._radius]; + + return new L.LatLngBounds( + this._map.layerPointToLatLng(this._point.subtract(half)), + this._map.layerPointToLatLng(this._point.add(half))); + }, + + setStyle: L.Path.prototype.setStyle, + + _project: function () { + + var lng = this._latlng.lng, + lat = this._latlng.lat, + map = this._map, + crs = map.options.crs; + + if (crs.distance === L.CRS.Earth.distance) { + var d = Math.PI / 180, + latR = (this._mRadius / L.CRS.Earth.R) / d, + top = map.project([lat + latR, lng]), + bottom = map.project([lat - latR, lng]), + p = top.add(bottom).divideBy(2), + lat2 = map.unproject(p).lat, + lngR = Math.acos((Math.cos(latR * d) - Math.sin(lat * d) * Math.sin(lat2 * d)) / + (Math.cos(lat * d) * Math.cos(lat2 * d))) / d; + + if (isNaN(lngR) || lngR === 0) { + lngR = latR / Math.cos(Math.PI / 180 * lat); // Fallback for edge case, #2425 + } + + this._point = p.subtract(map.getPixelOrigin()); + this._radius = isNaN(lngR) ? 0 : Math.max(Math.round(p.x - map.project([lat2, lng - lngR]).x), 1); + this._radiusY = Math.max(Math.round(p.y - top.y), 1); + + } else { + var latlng2 = crs.unproject(crs.project(this._latlng).subtract([this._mRadius, 0])); + + this._point = map.latLngToLayerPoint(this._latlng); + this._radius = this._point.x - map.latLngToLayerPoint(latlng2).x; + } + + this._updateBounds(); + } +}); + +// @factory L.circle(latlng: LatLng, options?: Circle options) +// Instantiates a circle object given a geographical point, and an options object +// which contains the circle radius. +// @alternative +// @factory L.circle(latlng: LatLng, radius: Number, options?: Circle options) +// Obsolete way of instantiating a circle, for compatibility with 0.7.x code. +// Do not use in new applications or plugins. +L.circle = function (latlng, options, legacyOptions) { + return new L.Circle(latlng, options, legacyOptions); +}; + + + +/* + * @class SVG + * @inherits Renderer + * @aka L.SVG + * + * Allows vector layers to be displayed with [SVG](https://developer.mozilla.org/docs/Web/SVG). + * Inherits `Renderer`. + * + * Due to [technical limitations](http://caniuse.com/#search=svg), SVG is not + * available in all web browsers, notably Android 2.x and 3.x. + * + * Although SVG is not available on IE7 and IE8, these browsers support + * [VML](https://en.wikipedia.org/wiki/Vector_Markup_Language) + * (a now deprecated technology), and the SVG renderer will fall back to VML in + * this case. + * + * @example + * + * Use SVG by default for all paths in the map: + * + * ```js + * var map = L.map('map', { + * renderer: L.svg() + * }); + * ``` + * + * Use a SVG renderer with extra padding for specific vector geometries: + * + * ```js + * var map = L.map('map'); + * var myRenderer = L.svg({ padding: 0.5 }); + * var line = L.polyline( coordinates, { renderer: myRenderer } ); + * var circle = L.circle( center, { renderer: myRenderer } ); + * ``` + */ + +L.SVG = L.Renderer.extend({ + + getEvents: function () { + var events = L.Renderer.prototype.getEvents.call(this); + events.zoomstart = this._onZoomStart; + return events; + }, + + _initContainer: function () { + this._container = L.SVG.create('svg'); + + // makes it possible to click through svg root; we'll reset it back in individual paths + this._container.setAttribute('pointer-events', 'none'); + + this._rootGroup = L.SVG.create('g'); + this._container.appendChild(this._rootGroup); + }, + + _onZoomStart: function () { + // Drag-then-pinch interactions might mess up the center and zoom. + // In this case, the easiest way to prevent this is re-do the renderer + // bounds and padding when the zooming starts. + this._update(); + }, + + _update: function () { + if (this._map._animatingZoom && this._bounds) { return; } + + L.Renderer.prototype._update.call(this); + + var b = this._bounds, + size = b.getSize(), + container = this._container; + + // set size of svg-container if changed + if (!this._svgSize || !this._svgSize.equals(size)) { + this._svgSize = size; + container.setAttribute('width', size.x); + container.setAttribute('height', size.y); + } + + // movement: update container viewBox so that we don't have to change coordinates of individual layers + L.DomUtil.setPosition(container, b.min); + container.setAttribute('viewBox', [b.min.x, b.min.y, size.x, size.y].join(' ')); + + this.fire('update'); + }, + + // methods below are called by vector layers implementations + + _initPath: function (layer) { + var path = layer._path = L.SVG.create('path'); + + // @namespace Path + // @option className: String = null + // Custom class name set on an element. Only for SVG renderer. + if (layer.options.className) { + L.DomUtil.addClass(path, layer.options.className); + } + + if (layer.options.interactive) { + L.DomUtil.addClass(path, 'leaflet-interactive'); + } + + this._updateStyle(layer); + this._layers[L.stamp(layer)] = layer; + }, + + _addPath: function (layer) { + this._rootGroup.appendChild(layer._path); + layer.addInteractiveTarget(layer._path); + }, + + _removePath: function (layer) { + L.DomUtil.remove(layer._path); + layer.removeInteractiveTarget(layer._path); + delete this._layers[L.stamp(layer)]; + }, + + _updatePath: function (layer) { + layer._project(); + layer._update(); + }, + + _updateStyle: function (layer) { + var path = layer._path, + options = layer.options; + + if (!path) { return; } + + if (options.stroke) { + path.setAttribute('stroke', options.color); + path.setAttribute('stroke-opacity', options.opacity); + path.setAttribute('stroke-width', options.weight); + path.setAttribute('stroke-linecap', options.lineCap); + path.setAttribute('stroke-linejoin', options.lineJoin); + + if (options.dashArray) { + path.setAttribute('stroke-dasharray', options.dashArray); + } else { + path.removeAttribute('stroke-dasharray'); + } + + if (options.dashOffset) { + path.setAttribute('stroke-dashoffset', options.dashOffset); + } else { + path.removeAttribute('stroke-dashoffset'); + } + } else { + path.setAttribute('stroke', 'none'); + } + + if (options.fill) { + path.setAttribute('fill', options.fillColor || options.color); + path.setAttribute('fill-opacity', options.fillOpacity); + path.setAttribute('fill-rule', options.fillRule || 'evenodd'); + } else { + path.setAttribute('fill', 'none'); + } + }, + + _updatePoly: function (layer, closed) { + this._setPath(layer, L.SVG.pointsToPath(layer._parts, closed)); + }, + + _updateCircle: function (layer) { + var p = layer._point, + r = layer._radius, + r2 = layer._radiusY || r, + arc = 'a' + r + ',' + r2 + ' 0 1,0 '; + + // drawing a circle with two half-arcs + var d = layer._empty() ? 'M0 0' : + 'M' + (p.x - r) + ',' + p.y + + arc + (r * 2) + ',0 ' + + arc + (-r * 2) + ',0 '; + + this._setPath(layer, d); + }, + + _setPath: function (layer, path) { + layer._path.setAttribute('d', path); + }, + + // SVG does not have the concept of zIndex so we resort to changing the DOM order of elements + _bringToFront: function (layer) { + L.DomUtil.toFront(layer._path); + }, + + _bringToBack: function (layer) { + L.DomUtil.toBack(layer._path); + } +}); + + +// @namespace SVG; @section +// There are several static functions which can be called without instantiating L.SVG: +L.extend(L.SVG, { + // @function create(name: String): SVGElement + // Returns a instance of [SVGElement](https://developer.mozilla.org/docs/Web/API/SVGElement), + // corresponding to the class name passed. For example, using 'line' will return + // an instance of [SVGLineElement](https://developer.mozilla.org/docs/Web/API/SVGLineElement). + create: function (name) { + return document.createElementNS('http://www.w3.org/2000/svg', name); + }, + + // @function pointsToPath(rings: Point[], closed: Boolean): String + // Generates a SVG path string for multiple rings, with each ring turning + // into "M..L..L.." instructions + pointsToPath: function (rings, closed) { + var str = '', + i, j, len, len2, points, p; + + for (i = 0, len = rings.length; i < len; i++) { + points = rings[i]; + + for (j = 0, len2 = points.length; j < len2; j++) { + p = points[j]; + str += (j ? 'L' : 'M') + p.x + ' ' + p.y; + } + + // closes the ring for polygons; "x" is VML syntax + str += closed ? (L.Browser.svg ? 'z' : 'x') : ''; + } + + // SVG complains about empty path strings + return str || 'M0 0'; + } +}); + +// @namespace Browser; @property svg: Boolean +// `true` when the browser supports [SVG](https://developer.mozilla.org/docs/Web/SVG). +L.Browser.svg = !!(document.createElementNS && L.SVG.create('svg').createSVGRect); + + +// @namespace SVG +// @factory L.svg(options?: Renderer options) +// Creates a SVG renderer with the given options. +L.svg = function (options) { + return L.Browser.svg || L.Browser.vml ? new L.SVG(options) : null; +}; + + + +/* + * Thanks to Dmitry Baranovsky and his Raphael library for inspiration! + */ + +/* + * @class SVG + * + * Although SVG is not available on IE7 and IE8, these browsers support [VML](https://en.wikipedia.org/wiki/Vector_Markup_Language), and the SVG renderer will fall back to VML in this case. + * + * VML was deprecated in 2012, which means VML functionality exists only for backwards compatibility + * with old versions of Internet Explorer. + */ + +// @namespace Browser; @property vml: Boolean +// `true` if the browser supports [VML](https://en.wikipedia.org/wiki/Vector_Markup_Language). +L.Browser.vml = !L.Browser.svg && (function () { + try { + var div = document.createElement('div'); + div.innerHTML = ''; + + var shape = div.firstChild; + shape.style.behavior = 'url(#default#VML)'; + + return shape && (typeof shape.adj === 'object'); + + } catch (e) { + return false; + } +}()); + +// redefine some SVG methods to handle VML syntax which is similar but with some differences +L.SVG.include(!L.Browser.vml ? {} : { + + _initContainer: function () { + this._container = L.DomUtil.create('div', 'leaflet-vml-container'); + }, + + _update: function () { + if (this._map._animatingZoom) { return; } + L.Renderer.prototype._update.call(this); + this.fire('update'); + }, + + _initPath: function (layer) { + var container = layer._container = L.SVG.create('shape'); + + L.DomUtil.addClass(container, 'leaflet-vml-shape ' + (this.options.className || '')); + + container.coordsize = '1 1'; + + layer._path = L.SVG.create('path'); + container.appendChild(layer._path); + + this._updateStyle(layer); + }, + + _addPath: function (layer) { + var container = layer._container; + this._container.appendChild(container); + + if (layer.options.interactive) { + layer.addInteractiveTarget(container); + } + }, + + _removePath: function (layer) { + var container = layer._container; + L.DomUtil.remove(container); + layer.removeInteractiveTarget(container); + }, + + _updateStyle: function (layer) { + var stroke = layer._stroke, + fill = layer._fill, + options = layer.options, + container = layer._container; + + container.stroked = !!options.stroke; + container.filled = !!options.fill; + + if (options.stroke) { + if (!stroke) { + stroke = layer._stroke = L.SVG.create('stroke'); + } + container.appendChild(stroke); + stroke.weight = options.weight + 'px'; + stroke.color = options.color; + stroke.opacity = options.opacity; + + if (options.dashArray) { + stroke.dashStyle = L.Util.isArray(options.dashArray) ? + options.dashArray.join(' ') : + options.dashArray.replace(/( *, *)/g, ' '); + } else { + stroke.dashStyle = ''; + } + stroke.endcap = options.lineCap.replace('butt', 'flat'); + stroke.joinstyle = options.lineJoin; + + } else if (stroke) { + container.removeChild(stroke); + layer._stroke = null; + } + + if (options.fill) { + if (!fill) { + fill = layer._fill = L.SVG.create('fill'); + } + container.appendChild(fill); + fill.color = options.fillColor || options.color; + fill.opacity = options.fillOpacity; + + } else if (fill) { + container.removeChild(fill); + layer._fill = null; + } + }, + + _updateCircle: function (layer) { + var p = layer._point.round(), + r = Math.round(layer._radius), + r2 = Math.round(layer._radiusY || r); + + this._setPath(layer, layer._empty() ? 'M0 0' : + 'AL ' + p.x + ',' + p.y + ' ' + r + ',' + r2 + ' 0,' + (65535 * 360)); + }, + + _setPath: function (layer, path) { + layer._path.v = path; + }, + + _bringToFront: function (layer) { + L.DomUtil.toFront(layer._container); + }, + + _bringToBack: function (layer) { + L.DomUtil.toBack(layer._container); + } +}); + +if (L.Browser.vml) { + L.SVG.create = (function () { + try { + document.namespaces.add('lvml', 'urn:schemas-microsoft-com:vml'); + return function (name) { + return document.createElement(''); + }; + } catch (e) { + return function (name) { + return document.createElement('<' + name + ' xmlns="urn:schemas-microsoft.com:vml" class="lvml">'); + }; + } + })(); +} + + + +/* + * @class Canvas + * @inherits Renderer + * @aka L.Canvas + * + * Allows vector layers to be displayed with [``](https://developer.mozilla.org/docs/Web/API/Canvas_API). + * Inherits `Renderer`. + * + * Due to [technical limitations](http://caniuse.com/#search=canvas), Canvas is not + * available in all web browsers, notably IE8, and overlapping geometries might + * not display properly in some edge cases. + * + * @example + * + * Use Canvas by default for all paths in the map: + * + * ```js + * var map = L.map('map', { + * renderer: L.canvas() + * }); + * ``` + * + * Use a Canvas renderer with extra padding for specific vector geometries: + * + * ```js + * var map = L.map('map'); + * var myRenderer = L.canvas({ padding: 0.5 }); + * var line = L.polyline( coordinates, { renderer: myRenderer } ); + * var circle = L.circle( center, { renderer: myRenderer } ); + * ``` + */ + +L.Canvas = L.Renderer.extend({ + + onAdd: function () { + L.Renderer.prototype.onAdd.call(this); + + // Redraw vectors since canvas is cleared upon removal, + // in case of removing the renderer itself from the map. + this._draw(); + }, + + _initContainer: function () { + var container = this._container = document.createElement('canvas'); + + L.DomEvent + .on(container, 'mousemove', L.Util.throttle(this._onMouseMove, 32, this), this) + .on(container, 'click dblclick mousedown mouseup contextmenu', this._onClick, this) + .on(container, 'mouseout', this._handleMouseOut, this); + + this._ctx = container.getContext('2d'); + }, + + _updatePaths: function () { + var layer; + this._redrawBounds = null; + for (var id in this._layers) { + layer = this._layers[id]; + layer._update(); + } + this._redraw(); + }, + + _update: function () { + if (this._map._animatingZoom && this._bounds) { return; } + + this._drawnLayers = {}; + + L.Renderer.prototype._update.call(this); + + var b = this._bounds, + container = this._container, + size = b.getSize(), + m = L.Browser.retina ? 2 : 1; + + L.DomUtil.setPosition(container, b.min); + + // set canvas size (also clearing it); use double size on retina + container.width = m * size.x; + container.height = m * size.y; + container.style.width = size.x + 'px'; + container.style.height = size.y + 'px'; + + if (L.Browser.retina) { + this._ctx.scale(2, 2); + } + + // translate so we use the same path coordinates after canvas element moves + this._ctx.translate(-b.min.x, -b.min.y); + + // Tell paths to redraw themselves + this.fire('update'); + }, + + _initPath: function (layer) { + this._updateDashArray(layer); + this._layers[L.stamp(layer)] = layer; + + var order = layer._order = { + layer: layer, + prev: this._drawLast, + next: null + }; + if (this._drawLast) { this._drawLast.next = order; } + this._drawLast = order; + this._drawFirst = this._drawFirst || this._drawLast; + }, + + _addPath: function (layer) { + this._requestRedraw(layer); + }, + + _removePath: function (layer) { + var order = layer._order; + var next = order.next; + var prev = order.prev; + + if (next) { + next.prev = prev; + } else { + this._drawLast = prev; + } + if (prev) { + prev.next = next; + } else { + this._drawFirst = next; + } + + delete layer._order; + + delete this._layers[L.stamp(layer)]; + + this._requestRedraw(layer); + }, + + _updatePath: function (layer) { + // Redraw the union of the layer's old pixel + // bounds and the new pixel bounds. + this._extendRedrawBounds(layer); + layer._project(); + layer._update(); + // The redraw will extend the redraw bounds + // with the new pixel bounds. + this._requestRedraw(layer); + }, + + _updateStyle: function (layer) { + this._updateDashArray(layer); + this._requestRedraw(layer); + }, + + _updateDashArray: function (layer) { + if (layer.options.dashArray) { + var parts = layer.options.dashArray.split(','), + dashArray = [], + i; + for (i = 0; i < parts.length; i++) { + dashArray.push(Number(parts[i])); + } + layer.options._dashArray = dashArray; + } + }, + + _requestRedraw: function (layer) { + if (!this._map) { return; } + + this._extendRedrawBounds(layer); + this._redrawRequest = this._redrawRequest || L.Util.requestAnimFrame(this._redraw, this); + }, + + _extendRedrawBounds: function (layer) { + var padding = (layer.options.weight || 0) + 1; + this._redrawBounds = this._redrawBounds || new L.Bounds(); + this._redrawBounds.extend(layer._pxBounds.min.subtract([padding, padding])); + this._redrawBounds.extend(layer._pxBounds.max.add([padding, padding])); + }, + + _redraw: function () { + this._redrawRequest = null; + + this._clear(); // clear layers in redraw bounds + this._draw(); // draw layers + + this._redrawBounds = null; + }, + + _clear: function () { + var bounds = this._redrawBounds; + if (bounds) { + var size = bounds.getSize(); + this._ctx.clearRect(bounds.min.x, bounds.min.y, size.x, size.y); + } else { + this._ctx.clearRect(0, 0, this._container.width, this._container.height); + } + }, + + _draw: function () { + var layer, bounds = this._redrawBounds; + this._ctx.save(); + if (bounds) { + var size = bounds.getSize(); + this._ctx.beginPath(); + this._ctx.rect(bounds.min.x, bounds.min.y, size.x, size.y); + this._ctx.clip(); + } + + this._drawing = true; + + for (var order = this._drawFirst; order; order = order.next) { + layer = order.layer; + if (!bounds || (layer._pxBounds && layer._pxBounds.intersects(bounds))) { + layer._updatePath(); + } + } + + this._drawing = false; + + this._ctx.restore(); // Restore state before clipping. + }, + + _updatePoly: function (layer, closed) { + if (!this._drawing) { return; } + + var i, j, len2, p, + parts = layer._parts, + len = parts.length, + ctx = this._ctx; + + if (!len) { return; } + + this._drawnLayers[layer._leaflet_id] = layer; + + ctx.beginPath(); + + if (ctx.setLineDash) { + ctx.setLineDash(layer.options && layer.options._dashArray || []); + } + + for (i = 0; i < len; i++) { + for (j = 0, len2 = parts[i].length; j < len2; j++) { + p = parts[i][j]; + ctx[j ? 'lineTo' : 'moveTo'](p.x, p.y); + } + if (closed) { + ctx.closePath(); + } + } + + this._fillStroke(ctx, layer); + + // TODO optimization: 1 fill/stroke for all features with equal style instead of 1 for each feature + }, + + _updateCircle: function (layer) { + + if (!this._drawing || layer._empty()) { return; } + + var p = layer._point, + ctx = this._ctx, + r = layer._radius, + s = (layer._radiusY || r) / r; + + this._drawnLayers[layer._leaflet_id] = layer; + + if (s !== 1) { + ctx.save(); + ctx.scale(1, s); + } + + ctx.beginPath(); + ctx.arc(p.x, p.y / s, r, 0, Math.PI * 2, false); + + if (s !== 1) { + ctx.restore(); + } + + this._fillStroke(ctx, layer); + }, + + _fillStroke: function (ctx, layer) { + var options = layer.options; + + if (options.fill) { + ctx.globalAlpha = options.fillOpacity; + ctx.fillStyle = options.fillColor || options.color; + ctx.fill(options.fillRule || 'evenodd'); + } + + if (options.stroke && options.weight !== 0) { + ctx.globalAlpha = options.opacity; + ctx.lineWidth = options.weight; + ctx.strokeStyle = options.color; + ctx.lineCap = options.lineCap; + ctx.lineJoin = options.lineJoin; + ctx.stroke(); + } + }, + + // Canvas obviously doesn't have mouse events for individual drawn objects, + // so we emulate that by calculating what's under the mouse on mousemove/click manually + + _onClick: function (e) { + var point = this._map.mouseEventToLayerPoint(e), layer, clickedLayer; + + for (var order = this._drawFirst; order; order = order.next) { + layer = order.layer; + if (layer.options.interactive && layer._containsPoint(point) && !this._map._draggableMoved(layer)) { + clickedLayer = layer; + } + } + if (clickedLayer) { + L.DomEvent._fakeStop(e); + this._fireEvent([clickedLayer], e); + } + }, + + _onMouseMove: function (e) { + if (!this._map || this._map.dragging.moving() || this._map._animatingZoom) { return; } + + var point = this._map.mouseEventToLayerPoint(e); + this._handleMouseHover(e, point); + }, + + + _handleMouseOut: function (e) { + var layer = this._hoveredLayer; + if (layer) { + // if we're leaving the layer, fire mouseout + L.DomUtil.removeClass(this._container, 'leaflet-interactive'); + this._fireEvent([layer], e, 'mouseout'); + this._hoveredLayer = null; + } + }, + + _handleMouseHover: function (e, point) { + var layer, candidateHoveredLayer; + + for (var order = this._drawFirst; order; order = order.next) { + layer = order.layer; + if (layer.options.interactive && layer._containsPoint(point)) { + candidateHoveredLayer = layer; + } + } + + if (candidateHoveredLayer !== this._hoveredLayer) { + this._handleMouseOut(e); + + if (candidateHoveredLayer) { + L.DomUtil.addClass(this._container, 'leaflet-interactive'); // change cursor + this._fireEvent([candidateHoveredLayer], e, 'mouseover'); + this._hoveredLayer = candidateHoveredLayer; + } + } + + if (this._hoveredLayer) { + this._fireEvent([this._hoveredLayer], e); + } + }, + + _fireEvent: function (layers, e, type) { + this._map._fireDOMEvent(e, type || e.type, layers); + }, + + _bringToFront: function (layer) { + var order = layer._order; + var next = order.next; + var prev = order.prev; + + if (next) { + next.prev = prev; + } else { + // Already last + return; + } + if (prev) { + prev.next = next; + } else if (next) { + // Update first entry unless this is the + // signle entry + this._drawFirst = next; + } + + order.prev = this._drawLast; + this._drawLast.next = order; + + order.next = null; + this._drawLast = order; + + this._requestRedraw(layer); + }, + + _bringToBack: function (layer) { + var order = layer._order; + var next = order.next; + var prev = order.prev; + + if (prev) { + prev.next = next; + } else { + // Already first + return; + } + if (next) { + next.prev = prev; + } else if (prev) { + // Update last entry unless this is the + // signle entry + this._drawLast = prev; + } + + order.prev = null; + + order.next = this._drawFirst; + this._drawFirst.prev = order; + this._drawFirst = order; + + this._requestRedraw(layer); + } +}); + +// @namespace Browser; @property canvas: Boolean +// `true` when the browser supports [``](https://developer.mozilla.org/docs/Web/API/Canvas_API). +L.Browser.canvas = (function () { + return !!document.createElement('canvas').getContext; +}()); + +// @namespace Canvas +// @factory L.canvas(options?: Renderer options) +// Creates a Canvas renderer with the given options. +L.canvas = function (options) { + return L.Browser.canvas ? new L.Canvas(options) : null; +}; + +L.Polyline.prototype._containsPoint = function (p, closed) { + var i, j, k, len, len2, part, + w = this._clickTolerance(); + + if (!this._pxBounds.contains(p)) { return false; } + + // hit detection for polylines + for (i = 0, len = this._parts.length; i < len; i++) { + part = this._parts[i]; + + for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) { + if (!closed && (j === 0)) { continue; } + + if (L.LineUtil.pointToSegmentDistance(p, part[k], part[j]) <= w) { + return true; + } + } + } + return false; +}; + +L.Polygon.prototype._containsPoint = function (p) { + var inside = false, + part, p1, p2, i, j, k, len, len2; + + if (!this._pxBounds.contains(p)) { return false; } + + // ray casting algorithm for detecting if point is in polygon + for (i = 0, len = this._parts.length; i < len; i++) { + part = this._parts[i]; + + for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) { + p1 = part[j]; + p2 = part[k]; + + if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) { + inside = !inside; + } + } + } + + // also check if it's on polygon stroke + return inside || L.Polyline.prototype._containsPoint.call(this, p, true); +}; + +L.CircleMarker.prototype._containsPoint = function (p) { + return p.distanceTo(this._point) <= this._radius + this._clickTolerance(); +}; + + + +/* + * @class GeoJSON + * @aka L.GeoJSON + * @inherits FeatureGroup + * + * Represents a GeoJSON object or an array of GeoJSON objects. Allows you to parse + * GeoJSON data and display it on the map. Extends `FeatureGroup`. + * + * @example + * + * ```js + * L.geoJSON(data, { + * style: function (feature) { + * return {color: feature.properties.color}; + * } + * }).bindPopup(function (layer) { + * return layer.feature.properties.description; + * }).addTo(map); + * ``` + */ + +L.GeoJSON = L.FeatureGroup.extend({ + + /* @section + * @aka GeoJSON options + * + * @option pointToLayer: Function = * + * A `Function` defining how GeoJSON points spawn Leaflet layers. It is internally + * called when data is added, passing the GeoJSON point feature and its `LatLng`. + * The default is to spawn a default `Marker`: + * ```js + * function(geoJsonPoint, latlng) { + * return L.marker(latlng); + * } + * ``` + * + * @option style: Function = * + * A `Function` defining the `Path options` for styling GeoJSON lines and polygons, + * called internally when data is added. + * The default value is to not override any defaults: + * ```js + * function (geoJsonFeature) { + * return {} + * } + * ``` + * + * @option onEachFeature: Function = * + * A `Function` that will be called once for each created `Feature`, after it has + * been created and styled. Useful for attaching events and popups to features. + * The default is to do nothing with the newly created layers: + * ```js + * function (feature, layer) {} + * ``` + * + * @option filter: Function = * + * A `Function` that will be used to decide whether to include a feature or not. + * The default is to include all features: + * ```js + * function (geoJsonFeature) { + * return true; + * } + * ``` + * Note: dynamically changing the `filter` option will have effect only on newly + * added data. It will _not_ re-evaluate already included features. + * + * @option coordsToLatLng: Function = * + * A `Function` that will be used for converting GeoJSON coordinates to `LatLng`s. + * The default is the `coordsToLatLng` static method. + */ + + initialize: function (geojson, options) { + L.setOptions(this, options); + + this._layers = {}; + + if (geojson) { + this.addData(geojson); + } + }, + + // @method addData( data ): this + // Adds a GeoJSON object to the layer. + addData: function (geojson) { + var features = L.Util.isArray(geojson) ? geojson : geojson.features, + i, len, feature; + + if (features) { + for (i = 0, len = features.length; i < len; i++) { + // only add this if geometry or geometries are set and not null + feature = features[i]; + if (feature.geometries || feature.geometry || feature.features || feature.coordinates) { + this.addData(feature); + } + } + return this; + } + + var options = this.options; + + if (options.filter && !options.filter(geojson)) { return this; } + + var layer = L.GeoJSON.geometryToLayer(geojson, options); + if (!layer) { + return this; + } + layer.feature = L.GeoJSON.asFeature(geojson); + + layer.defaultOptions = layer.options; + this.resetStyle(layer); + + if (options.onEachFeature) { + options.onEachFeature(geojson, layer); + } + + return this.addLayer(layer); + }, + + // @method resetStyle( layer ): this + // Resets the given vector layer's style to the original GeoJSON style, useful for resetting style after hover events. + resetStyle: function (layer) { + // reset any custom styles + layer.options = L.Util.extend({}, layer.defaultOptions); + this._setLayerStyle(layer, this.options.style); + return this; + }, + + // @method setStyle( style ): this + // Changes styles of GeoJSON vector layers with the given style function. + setStyle: function (style) { + return this.eachLayer(function (layer) { + this._setLayerStyle(layer, style); + }, this); + }, + + _setLayerStyle: function (layer, style) { + if (typeof style === 'function') { + style = style(layer.feature); + } + if (layer.setStyle) { + layer.setStyle(style); + } + } +}); + +// @section +// There are several static functions which can be called without instantiating L.GeoJSON: +L.extend(L.GeoJSON, { + // @function geometryToLayer(featureData: Object, options?: GeoJSON options): Layer + // Creates a `Layer` from a given GeoJSON feature. Can use a custom + // [`pointToLayer`](#geojson-pointtolayer) and/or [`coordsToLatLng`](#geojson-coordstolatlng) + // functions if provided as options. + geometryToLayer: function (geojson, options) { + + var geometry = geojson.type === 'Feature' ? geojson.geometry : geojson, + coords = geometry ? geometry.coordinates : null, + layers = [], + pointToLayer = options && options.pointToLayer, + coordsToLatLng = options && options.coordsToLatLng || this.coordsToLatLng, + latlng, latlngs, i, len; + + if (!coords && !geometry) { + return null; + } + + switch (geometry.type) { + case 'Point': + latlng = coordsToLatLng(coords); + return pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng); + + case 'MultiPoint': + for (i = 0, len = coords.length; i < len; i++) { + latlng = coordsToLatLng(coords[i]); + layers.push(pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng)); + } + return new L.FeatureGroup(layers); + + case 'LineString': + case 'MultiLineString': + latlngs = this.coordsToLatLngs(coords, geometry.type === 'LineString' ? 0 : 1, coordsToLatLng); + return new L.Polyline(latlngs, options); + + case 'Polygon': + case 'MultiPolygon': + latlngs = this.coordsToLatLngs(coords, geometry.type === 'Polygon' ? 1 : 2, coordsToLatLng); + return new L.Polygon(latlngs, options); + + case 'GeometryCollection': + for (i = 0, len = geometry.geometries.length; i < len; i++) { + var layer = this.geometryToLayer({ + geometry: geometry.geometries[i], + type: 'Feature', + properties: geojson.properties + }, options); + + if (layer) { + layers.push(layer); + } + } + return new L.FeatureGroup(layers); + + default: + throw new Error('Invalid GeoJSON object.'); + } + }, + + // @function coordsToLatLng(coords: Array): LatLng + // Creates a `LatLng` object from an array of 2 numbers (longitude, latitude) + // or 3 numbers (longitude, latitude, altitude) used in GeoJSON for points. + coordsToLatLng: function (coords) { + return new L.LatLng(coords[1], coords[0], coords[2]); + }, + + // @function coordsToLatLngs(coords: Array, levelsDeep?: Number, coordsToLatLng?: Function): Array + // Creates a multidimensional array of `LatLng`s from a GeoJSON coordinates array. + // `levelsDeep` specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default). + // Can use a custom [`coordsToLatLng`](#geojson-coordstolatlng) function. + coordsToLatLngs: function (coords, levelsDeep, coordsToLatLng) { + var latlngs = []; + + for (var i = 0, len = coords.length, latlng; i < len; i++) { + latlng = levelsDeep ? + this.coordsToLatLngs(coords[i], levelsDeep - 1, coordsToLatLng) : + (coordsToLatLng || this.coordsToLatLng)(coords[i]); + + latlngs.push(latlng); + } + + return latlngs; + }, + + // @function latLngToCoords(latlng: LatLng): Array + // Reverse of [`coordsToLatLng`](#geojson-coordstolatlng) + latLngToCoords: function (latlng) { + return latlng.alt !== undefined ? + [latlng.lng, latlng.lat, latlng.alt] : + [latlng.lng, latlng.lat]; + }, + + // @function latLngsToCoords(latlngs: Array, levelsDeep?: Number, closed?: Boolean): Array + // Reverse of [`coordsToLatLngs`](#geojson-coordstolatlngs) + // `closed` determines whether the first point should be appended to the end of the array to close the feature, only used when `levelsDeep` is 0. False by default. + latLngsToCoords: function (latlngs, levelsDeep, closed) { + var coords = []; + + for (var i = 0, len = latlngs.length; i < len; i++) { + coords.push(levelsDeep ? + L.GeoJSON.latLngsToCoords(latlngs[i], levelsDeep - 1, closed) : + L.GeoJSON.latLngToCoords(latlngs[i])); + } + + if (!levelsDeep && closed) { + coords.push(coords[0]); + } + + return coords; + }, + + getFeature: function (layer, newGeometry) { + return layer.feature ? + L.extend({}, layer.feature, {geometry: newGeometry}) : + L.GeoJSON.asFeature(newGeometry); + }, + + // @function asFeature(geojson: Object): Object + // Normalize GeoJSON geometries/features into GeoJSON features. + asFeature: function (geojson) { + if (geojson.type === 'Feature' || geojson.type === 'FeatureCollection') { + return geojson; + } + + return { + type: 'Feature', + properties: {}, + geometry: geojson + }; + } +}); + +var PointToGeoJSON = { + toGeoJSON: function () { + return L.GeoJSON.getFeature(this, { + type: 'Point', + coordinates: L.GeoJSON.latLngToCoords(this.getLatLng()) + }); + } +}; + +// @namespace Marker +// @method toGeoJSON(): Object +// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the marker (as a GeoJSON `Point` Feature). +L.Marker.include(PointToGeoJSON); + +// @namespace CircleMarker +// @method toGeoJSON(): Object +// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the circle marker (as a GeoJSON `Point` Feature). +L.Circle.include(PointToGeoJSON); +L.CircleMarker.include(PointToGeoJSON); + + +// @namespace Polyline +// @method toGeoJSON(): Object +// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the polyline (as a GeoJSON `LineString` or `MultiLineString` Feature). +L.Polyline.prototype.toGeoJSON = function () { + var multi = !L.Polyline._flat(this._latlngs); + + var coords = L.GeoJSON.latLngsToCoords(this._latlngs, multi ? 1 : 0); + + return L.GeoJSON.getFeature(this, { + type: (multi ? 'Multi' : '') + 'LineString', + coordinates: coords + }); +}; + +// @namespace Polygon +// @method toGeoJSON(): Object +// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the polygon (as a GeoJSON `Polygon` or `MultiPolygon` Feature). +L.Polygon.prototype.toGeoJSON = function () { + var holes = !L.Polyline._flat(this._latlngs), + multi = holes && !L.Polyline._flat(this._latlngs[0]); + + var coords = L.GeoJSON.latLngsToCoords(this._latlngs, multi ? 2 : holes ? 1 : 0, true); + + if (!holes) { + coords = [coords]; + } + + return L.GeoJSON.getFeature(this, { + type: (multi ? 'Multi' : '') + 'Polygon', + coordinates: coords + }); +}; + + +// @namespace LayerGroup +L.LayerGroup.include({ + toMultiPoint: function () { + var coords = []; + + this.eachLayer(function (layer) { + coords.push(layer.toGeoJSON().geometry.coordinates); + }); + + return L.GeoJSON.getFeature(this, { + type: 'MultiPoint', + coordinates: coords + }); + }, + + // @method toGeoJSON(): Object + // Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the layer group (as a GeoJSON `GeometryCollection`). + toGeoJSON: function () { + + var type = this.feature && this.feature.geometry && this.feature.geometry.type; + + if (type === 'MultiPoint') { + return this.toMultiPoint(); + } + + var isGeometryCollection = type === 'GeometryCollection', + jsons = []; + + this.eachLayer(function (layer) { + if (layer.toGeoJSON) { + var json = layer.toGeoJSON(); + jsons.push(isGeometryCollection ? json.geometry : L.GeoJSON.asFeature(json)); + } + }); + + if (isGeometryCollection) { + return L.GeoJSON.getFeature(this, { + geometries: jsons, + type: 'GeometryCollection' + }); + } + + return { + type: 'FeatureCollection', + features: jsons + }; + } +}); + +// @namespace GeoJSON +// @factory L.geoJSON(geojson?: Object, options?: GeoJSON options) +// Creates a GeoJSON layer. Optionally accepts an object in +// [GeoJSON format](http://geojson.org/geojson-spec.html) to display on the map +// (you can alternatively add it later with `addData` method) and an `options` object. +L.geoJSON = function (geojson, options) { + return new L.GeoJSON(geojson, options); +}; +// Backward compatibility. +L.geoJson = L.geoJSON; + + + +/* + * @class Draggable + * @aka L.Draggable + * @inherits Evented + * + * A class for making DOM elements draggable (including touch support). + * Used internally for map and marker dragging. Only works for elements + * that were positioned with [`L.DomUtil.setPosition`](#domutil-setposition). + * + * @example + * ```js + * var draggable = new L.Draggable(elementToDrag); + * draggable.enable(); + * ``` + */ + +L.Draggable = L.Evented.extend({ + + options: { + // @option clickTolerance: Number = 3 + // The max number of pixels a user can shift the mouse pointer during a click + // for it to be considered a valid click (as opposed to a mouse drag). + clickTolerance: 3 + }, + + statics: { + START: L.Browser.touch ? ['touchstart', 'mousedown'] : ['mousedown'], + END: { + mousedown: 'mouseup', + touchstart: 'touchend', + pointerdown: 'touchend', + MSPointerDown: 'touchend' + }, + MOVE: { + mousedown: 'mousemove', + touchstart: 'touchmove', + pointerdown: 'touchmove', + MSPointerDown: 'touchmove' + } + }, + + // @constructor L.Draggable(el: HTMLElement, dragHandle?: HTMLElement, preventOutline: Boolean) + // Creates a `Draggable` object for moving `el` when you start dragging the `dragHandle` element (equals `el` itself by default). + initialize: function (element, dragStartTarget, preventOutline) { + this._element = element; + this._dragStartTarget = dragStartTarget || element; + this._preventOutline = preventOutline; + }, + + // @method enable() + // Enables the dragging ability + enable: function () { + if (this._enabled) { return; } + + L.DomEvent.on(this._dragStartTarget, L.Draggable.START.join(' '), this._onDown, this); + + this._enabled = true; + }, + + // @method disable() + // Disables the dragging ability + disable: function () { + if (!this._enabled) { return; } + + // If we're currently dragging this draggable, + // disabling it counts as first ending the drag. + if (L.Draggable._dragging === this) { + this.finishDrag(); + } + + L.DomEvent.off(this._dragStartTarget, L.Draggable.START.join(' '), this._onDown, this); + + this._enabled = false; + this._moved = false; + }, + + _onDown: function (e) { + // Ignore simulated events, since we handle both touch and + // mouse explicitly; otherwise we risk getting duplicates of + // touch events, see #4315. + // Also ignore the event if disabled; this happens in IE11 + // under some circumstances, see #3666. + if (e._simulated || !this._enabled) { return; } + + this._moved = false; + + if (L.DomUtil.hasClass(this._element, 'leaflet-zoom-anim')) { return; } + + if (L.Draggable._dragging || e.shiftKey || ((e.which !== 1) && (e.button !== 1) && !e.touches)) { return; } + L.Draggable._dragging = this; // Prevent dragging multiple objects at once. + + if (this._preventOutline) { + L.DomUtil.preventOutline(this._element); + } + + L.DomUtil.disableImageDrag(); + L.DomUtil.disableTextSelection(); + + if (this._moving) { return; } + + // @event down: Event + // Fired when a drag is about to start. + this.fire('down'); + + var first = e.touches ? e.touches[0] : e; + + this._startPoint = new L.Point(first.clientX, first.clientY); + + L.DomEvent + .on(document, L.Draggable.MOVE[e.type], this._onMove, this) + .on(document, L.Draggable.END[e.type], this._onUp, this); + }, + + _onMove: function (e) { + // Ignore simulated events, since we handle both touch and + // mouse explicitly; otherwise we risk getting duplicates of + // touch events, see #4315. + // Also ignore the event if disabled; this happens in IE11 + // under some circumstances, see #3666. + if (e._simulated || !this._enabled) { return; } + + if (e.touches && e.touches.length > 1) { + this._moved = true; + return; + } + + var first = (e.touches && e.touches.length === 1 ? e.touches[0] : e), + newPoint = new L.Point(first.clientX, first.clientY), + offset = newPoint.subtract(this._startPoint); + + if (!offset.x && !offset.y) { return; } + if (Math.abs(offset.x) + Math.abs(offset.y) < this.options.clickTolerance) { return; } + + L.DomEvent.preventDefault(e); + + if (!this._moved) { + // @event dragstart: Event + // Fired when a drag starts + this.fire('dragstart'); + + this._moved = true; + this._startPos = L.DomUtil.getPosition(this._element).subtract(offset); + + L.DomUtil.addClass(document.body, 'leaflet-dragging'); + + this._lastTarget = e.target || e.srcElement; + // IE and Edge do not give the element, so fetch it + // if necessary + if ((window.SVGElementInstance) && (this._lastTarget instanceof SVGElementInstance)) { + this._lastTarget = this._lastTarget.correspondingUseElement; + } + L.DomUtil.addClass(this._lastTarget, 'leaflet-drag-target'); + } + + this._newPos = this._startPos.add(offset); + this._moving = true; + + L.Util.cancelAnimFrame(this._animRequest); + this._lastEvent = e; + this._animRequest = L.Util.requestAnimFrame(this._updatePosition, this, true); + }, + + _updatePosition: function () { + var e = {originalEvent: this._lastEvent}; + + // @event predrag: Event + // Fired continuously during dragging *before* each corresponding + // update of the element's position. + this.fire('predrag', e); + L.DomUtil.setPosition(this._element, this._newPos); + + // @event drag: Event + // Fired continuously during dragging. + this.fire('drag', e); + }, + + _onUp: function (e) { + // Ignore simulated events, since we handle both touch and + // mouse explicitly; otherwise we risk getting duplicates of + // touch events, see #4315. + // Also ignore the event if disabled; this happens in IE11 + // under some circumstances, see #3666. + if (e._simulated || !this._enabled) { return; } + this.finishDrag(); + }, + + finishDrag: function () { + L.DomUtil.removeClass(document.body, 'leaflet-dragging'); + + if (this._lastTarget) { + L.DomUtil.removeClass(this._lastTarget, 'leaflet-drag-target'); + this._lastTarget = null; + } + + for (var i in L.Draggable.MOVE) { + L.DomEvent + .off(document, L.Draggable.MOVE[i], this._onMove, this) + .off(document, L.Draggable.END[i], this._onUp, this); + } + + L.DomUtil.enableImageDrag(); + L.DomUtil.enableTextSelection(); + + if (this._moved && this._moving) { + // ensure drag is not fired after dragend + L.Util.cancelAnimFrame(this._animRequest); + + // @event dragend: DragEndEvent + // Fired when the drag ends. + this.fire('dragend', { + distance: this._newPos.distanceTo(this._startPos) + }); + } + + this._moving = false; + L.Draggable._dragging = false; + } + +}); + + + +/* + L.Handler is a base class for handler classes that are used internally to inject + interaction features like dragging to classes like Map and Marker. +*/ + +// @class Handler +// @aka L.Handler +// Abstract class for map interaction handlers + +L.Handler = L.Class.extend({ + initialize: function (map) { + this._map = map; + }, + + // @method enable(): this + // Enables the handler + enable: function () { + if (this._enabled) { return this; } + + this._enabled = true; + this.addHooks(); + return this; + }, + + // @method disable(): this + // Disables the handler + disable: function () { + if (!this._enabled) { return this; } + + this._enabled = false; + this.removeHooks(); + return this; + }, + + // @method enabled(): Boolean + // Returns `true` if the handler is enabled + enabled: function () { + return !!this._enabled; + } + + // @section Extension methods + // Classes inheriting from `Handler` must implement the two following methods: + // @method addHooks() + // Called when the handler is enabled, should add event hooks. + // @method removeHooks() + // Called when the handler is disabled, should remove the event hooks added previously. +}); + + + +/* + * L.Handler.MapDrag is used to make the map draggable (with panning inertia), enabled by default. + */ + +// @namespace Map +// @section Interaction Options +L.Map.mergeOptions({ + // @option dragging: Boolean = true + // Whether the map be draggable with mouse/touch or not. + dragging: true, + + // @section Panning Inertia Options + // @option inertia: Boolean = * + // If enabled, panning of the map will have an inertia effect where + // the map builds momentum while dragging and continues moving in + // the same direction for some time. Feels especially nice on touch + // devices. Enabled by default unless running on old Android devices. + inertia: !L.Browser.android23, + + // @option inertiaDeceleration: Number = 3000 + // The rate with which the inertial movement slows down, in pixels/second². + inertiaDeceleration: 3400, // px/s^2 + + // @option inertiaMaxSpeed: Number = Infinity + // Max speed of the inertial movement, in pixels/second. + inertiaMaxSpeed: Infinity, // px/s + + // @option easeLinearity: Number = 0.2 + easeLinearity: 0.2, + + // TODO refactor, move to CRS + // @option worldCopyJump: Boolean = false + // With this option enabled, the map tracks when you pan to another "copy" + // of the world and seamlessly jumps to the original one so that all overlays + // like markers and vector layers are still visible. + worldCopyJump: false, + + // @option maxBoundsViscosity: Number = 0.0 + // If `maxBounds` is set, this option will control how solid the bounds + // are when dragging the map around. The default value of `0.0` allows the + // user to drag outside the bounds at normal speed, higher values will + // slow down map dragging outside bounds, and `1.0` makes the bounds fully + // solid, preventing the user from dragging outside the bounds. + maxBoundsViscosity: 0.0 +}); + +L.Map.Drag = L.Handler.extend({ + addHooks: function () { + if (!this._draggable) { + var map = this._map; + + this._draggable = new L.Draggable(map._mapPane, map._container); + + this._draggable.on({ + down: this._onDown, + dragstart: this._onDragStart, + drag: this._onDrag, + dragend: this._onDragEnd + }, this); + + this._draggable.on('predrag', this._onPreDragLimit, this); + if (map.options.worldCopyJump) { + this._draggable.on('predrag', this._onPreDragWrap, this); + map.on('zoomend', this._onZoomEnd, this); + + map.whenReady(this._onZoomEnd, this); + } + } + L.DomUtil.addClass(this._map._container, 'leaflet-grab leaflet-touch-drag'); + this._draggable.enable(); + this._positions = []; + this._times = []; + }, + + removeHooks: function () { + L.DomUtil.removeClass(this._map._container, 'leaflet-grab'); + L.DomUtil.removeClass(this._map._container, 'leaflet-touch-drag'); + this._draggable.disable(); + }, + + moved: function () { + return this._draggable && this._draggable._moved; + }, + + moving: function () { + return this._draggable && this._draggable._moving; + }, + + _onDown: function () { + this._map._stop(); + }, + + _onDragStart: function () { + var map = this._map; + + if (this._map.options.maxBounds && this._map.options.maxBoundsViscosity) { + var bounds = L.latLngBounds(this._map.options.maxBounds); + + this._offsetLimit = L.bounds( + this._map.latLngToContainerPoint(bounds.getNorthWest()).multiplyBy(-1), + this._map.latLngToContainerPoint(bounds.getSouthEast()).multiplyBy(-1) + .add(this._map.getSize())); + + this._viscosity = Math.min(1.0, Math.max(0.0, this._map.options.maxBoundsViscosity)); + } else { + this._offsetLimit = null; + } + + map + .fire('movestart') + .fire('dragstart'); + + if (map.options.inertia) { + this._positions = []; + this._times = []; + } + }, + + _onDrag: function (e) { + if (this._map.options.inertia) { + var time = this._lastTime = +new Date(), + pos = this._lastPos = this._draggable._absPos || this._draggable._newPos; + + this._positions.push(pos); + this._times.push(time); + + if (time - this._times[0] > 50) { + this._positions.shift(); + this._times.shift(); + } + } + + this._map + .fire('move', e) + .fire('drag', e); + }, + + _onZoomEnd: function () { + var pxCenter = this._map.getSize().divideBy(2), + pxWorldCenter = this._map.latLngToLayerPoint([0, 0]); + + this._initialWorldOffset = pxWorldCenter.subtract(pxCenter).x; + this._worldWidth = this._map.getPixelWorldBounds().getSize().x; + }, + + _viscousLimit: function (value, threshold) { + return value - (value - threshold) * this._viscosity; + }, + + _onPreDragLimit: function () { + if (!this._viscosity || !this._offsetLimit) { return; } + + var offset = this._draggable._newPos.subtract(this._draggable._startPos); + + var limit = this._offsetLimit; + if (offset.x < limit.min.x) { offset.x = this._viscousLimit(offset.x, limit.min.x); } + if (offset.y < limit.min.y) { offset.y = this._viscousLimit(offset.y, limit.min.y); } + if (offset.x > limit.max.x) { offset.x = this._viscousLimit(offset.x, limit.max.x); } + if (offset.y > limit.max.y) { offset.y = this._viscousLimit(offset.y, limit.max.y); } + + this._draggable._newPos = this._draggable._startPos.add(offset); + }, + + _onPreDragWrap: function () { + // TODO refactor to be able to adjust map pane position after zoom + var worldWidth = this._worldWidth, + halfWidth = Math.round(worldWidth / 2), + dx = this._initialWorldOffset, + x = this._draggable._newPos.x, + newX1 = (x - halfWidth + dx) % worldWidth + halfWidth - dx, + newX2 = (x + halfWidth + dx) % worldWidth - halfWidth - dx, + newX = Math.abs(newX1 + dx) < Math.abs(newX2 + dx) ? newX1 : newX2; + + this._draggable._absPos = this._draggable._newPos.clone(); + this._draggable._newPos.x = newX; + }, + + _onDragEnd: function (e) { + var map = this._map, + options = map.options, + + noInertia = !options.inertia || this._times.length < 2; + + map.fire('dragend', e); + + if (noInertia) { + map.fire('moveend'); + + } else { + + var direction = this._lastPos.subtract(this._positions[0]), + duration = (this._lastTime - this._times[0]) / 1000, + ease = options.easeLinearity, + + speedVector = direction.multiplyBy(ease / duration), + speed = speedVector.distanceTo([0, 0]), + + limitedSpeed = Math.min(options.inertiaMaxSpeed, speed), + limitedSpeedVector = speedVector.multiplyBy(limitedSpeed / speed), + + decelerationDuration = limitedSpeed / (options.inertiaDeceleration * ease), + offset = limitedSpeedVector.multiplyBy(-decelerationDuration / 2).round(); + + if (!offset.x && !offset.y) { + map.fire('moveend'); + + } else { + offset = map._limitOffset(offset, map.options.maxBounds); + + L.Util.requestAnimFrame(function () { + map.panBy(offset, { + duration: decelerationDuration, + easeLinearity: ease, + noMoveStart: true, + animate: true + }); + }); + } + } + } +}); + +// @section Handlers +// @property dragging: Handler +// Map dragging handler (by both mouse and touch). +L.Map.addInitHook('addHandler', 'dragging', L.Map.Drag); + + + +/* + * L.Handler.DoubleClickZoom is used to handle double-click zoom on the map, enabled by default. + */ + +// @namespace Map +// @section Interaction Options + +L.Map.mergeOptions({ + // @option doubleClickZoom: Boolean|String = true + // Whether the map can be zoomed in by double clicking on it and + // zoomed out by double clicking while holding shift. If passed + // `'center'`, double-click zoom will zoom to the center of the + // view regardless of where the mouse was. + doubleClickZoom: true +}); + +L.Map.DoubleClickZoom = L.Handler.extend({ + addHooks: function () { + this._map.on('dblclick', this._onDoubleClick, this); + }, + + removeHooks: function () { + this._map.off('dblclick', this._onDoubleClick, this); + }, + + _onDoubleClick: function (e) { + var map = this._map, + oldZoom = map.getZoom(), + delta = map.options.zoomDelta, + zoom = e.originalEvent.shiftKey ? oldZoom - delta : oldZoom + delta; + + if (map.options.doubleClickZoom === 'center') { + map.setZoom(zoom); + } else { + map.setZoomAround(e.containerPoint, zoom); + } + } +}); + +// @section Handlers +// +// Map properties include interaction handlers that allow you to control +// interaction behavior in runtime, enabling or disabling certain features such +// as dragging or touch zoom (see `Handler` methods). For example: +// +// ```js +// map.doubleClickZoom.disable(); +// ``` +// +// @property doubleClickZoom: Handler +// Double click zoom handler. +L.Map.addInitHook('addHandler', 'doubleClickZoom', L.Map.DoubleClickZoom); + + + +/* + * L.Handler.ScrollWheelZoom is used by L.Map to enable mouse scroll wheel zoom on the map. + */ + +// @namespace Map +// @section Interaction Options +L.Map.mergeOptions({ + // @section Mousewheel options + // @option scrollWheelZoom: Boolean|String = true + // Whether the map can be zoomed by using the mouse wheel. If passed `'center'`, + // it will zoom to the center of the view regardless of where the mouse was. + scrollWheelZoom: true, + + // @option wheelDebounceTime: Number = 40 + // Limits the rate at which a wheel can fire (in milliseconds). By default + // user can't zoom via wheel more often than once per 40 ms. + wheelDebounceTime: 40, + + // @option wheelPxPerZoomLevel: Number = 60 + // How many scroll pixels (as reported by [L.DomEvent.getWheelDelta](#domevent-getwheeldelta)) + // mean a change of one full zoom level. Smaller values will make wheel-zooming + // faster (and vice versa). + wheelPxPerZoomLevel: 60 +}); + +L.Map.ScrollWheelZoom = L.Handler.extend({ + addHooks: function () { + L.DomEvent.on(this._map._container, 'mousewheel', this._onWheelScroll, this); + + this._delta = 0; + }, + + removeHooks: function () { + L.DomEvent.off(this._map._container, 'mousewheel', this._onWheelScroll, this); + }, + + _onWheelScroll: function (e) { + var delta = L.DomEvent.getWheelDelta(e); + + var debounce = this._map.options.wheelDebounceTime; + + this._delta += delta; + this._lastMousePos = this._map.mouseEventToContainerPoint(e); + + if (!this._startTime) { + this._startTime = +new Date(); + } + + var left = Math.max(debounce - (+new Date() - this._startTime), 0); + + clearTimeout(this._timer); + this._timer = setTimeout(L.bind(this._performZoom, this), left); + + L.DomEvent.stop(e); + }, + + _performZoom: function () { + var map = this._map, + zoom = map.getZoom(), + snap = this._map.options.zoomSnap || 0; + + map._stop(); // stop panning and fly animations if any + + // map the delta with a sigmoid function to -4..4 range leaning on -1..1 + var d2 = this._delta / (this._map.options.wheelPxPerZoomLevel * 4), + d3 = 4 * Math.log(2 / (1 + Math.exp(-Math.abs(d2)))) / Math.LN2, + d4 = snap ? Math.ceil(d3 / snap) * snap : d3, + delta = map._limitZoom(zoom + (this._delta > 0 ? d4 : -d4)) - zoom; + + this._delta = 0; + this._startTime = null; + + if (!delta) { return; } + + if (map.options.scrollWheelZoom === 'center') { + map.setZoom(zoom + delta); + } else { + map.setZoomAround(this._lastMousePos, zoom + delta); + } + } +}); + +// @section Handlers +// @property scrollWheelZoom: Handler +// Scroll wheel zoom handler. +L.Map.addInitHook('addHandler', 'scrollWheelZoom', L.Map.ScrollWheelZoom); + + + +/* + * Extends the event handling code with double tap support for mobile browsers. + */ + +L.extend(L.DomEvent, { + + _touchstart: L.Browser.msPointer ? 'MSPointerDown' : L.Browser.pointer ? 'pointerdown' : 'touchstart', + _touchend: L.Browser.msPointer ? 'MSPointerUp' : L.Browser.pointer ? 'pointerup' : 'touchend', + + // inspired by Zepto touch code by Thomas Fuchs + addDoubleTapListener: function (obj, handler, id) { + var last, touch, + doubleTap = false, + delay = 250; + + function onTouchStart(e) { + var count; + + if (L.Browser.pointer) { + count = L.DomEvent._pointersCount; + } else { + count = e.touches.length; + } + + if (count > 1) { return; } + + var now = Date.now(), + delta = now - (last || now); + + touch = e.touches ? e.touches[0] : e; + doubleTap = (delta > 0 && delta <= delay); + last = now; + } + + function onTouchEnd() { + if (doubleTap && !touch.cancelBubble) { + if (L.Browser.pointer) { + // work around .type being readonly with MSPointer* events + var newTouch = {}, + prop, i; + + for (i in touch) { + prop = touch[i]; + newTouch[i] = prop && prop.bind ? prop.bind(touch) : prop; + } + touch = newTouch; + } + touch.type = 'dblclick'; + handler(touch); + last = null; + } + } + + var pre = '_leaflet_', + touchstart = this._touchstart, + touchend = this._touchend; + + obj[pre + touchstart + id] = onTouchStart; + obj[pre + touchend + id] = onTouchEnd; + obj[pre + 'dblclick' + id] = handler; + + obj.addEventListener(touchstart, onTouchStart, false); + obj.addEventListener(touchend, onTouchEnd, false); + + // On some platforms (notably, chrome on win10 + touchscreen + mouse), + // the browser doesn't fire touchend/pointerup events but does fire + // native dblclicks. See #4127. + if (!L.Browser.edge) { + obj.addEventListener('dblclick', handler, false); + } + + return this; + }, + + removeDoubleTapListener: function (obj, id) { + var pre = '_leaflet_', + touchstart = obj[pre + this._touchstart + id], + touchend = obj[pre + this._touchend + id], + dblclick = obj[pre + 'dblclick' + id]; + + obj.removeEventListener(this._touchstart, touchstart, false); + obj.removeEventListener(this._touchend, touchend, false); + if (!L.Browser.edge) { + obj.removeEventListener('dblclick', dblclick, false); + } + + return this; + } +}); + + + +/* + * Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices. + */ + +L.extend(L.DomEvent, { + + POINTER_DOWN: L.Browser.msPointer ? 'MSPointerDown' : 'pointerdown', + POINTER_MOVE: L.Browser.msPointer ? 'MSPointerMove' : 'pointermove', + POINTER_UP: L.Browser.msPointer ? 'MSPointerUp' : 'pointerup', + POINTER_CANCEL: L.Browser.msPointer ? 'MSPointerCancel' : 'pointercancel', + TAG_WHITE_LIST: ['INPUT', 'SELECT', 'OPTION'], + + _pointers: {}, + _pointersCount: 0, + + // Provides a touch events wrapper for (ms)pointer events. + // ref http://www.w3.org/TR/pointerevents/ https://www.w3.org/Bugs/Public/show_bug.cgi?id=22890 + + addPointerListener: function (obj, type, handler, id) { + + if (type === 'touchstart') { + this._addPointerStart(obj, handler, id); + + } else if (type === 'touchmove') { + this._addPointerMove(obj, handler, id); + + } else if (type === 'touchend') { + this._addPointerEnd(obj, handler, id); + } + + return this; + }, + + removePointerListener: function (obj, type, id) { + var handler = obj['_leaflet_' + type + id]; + + if (type === 'touchstart') { + obj.removeEventListener(this.POINTER_DOWN, handler, false); + + } else if (type === 'touchmove') { + obj.removeEventListener(this.POINTER_MOVE, handler, false); + + } else if (type === 'touchend') { + obj.removeEventListener(this.POINTER_UP, handler, false); + obj.removeEventListener(this.POINTER_CANCEL, handler, false); + } + + return this; + }, + + _addPointerStart: function (obj, handler, id) { + var onDown = L.bind(function (e) { + if (e.pointerType !== 'mouse' && e.pointerType !== e.MSPOINTER_TYPE_MOUSE) { + // In IE11, some touch events needs to fire for form controls, or + // the controls will stop working. We keep a whitelist of tag names that + // need these events. For other target tags, we prevent default on the event. + if (this.TAG_WHITE_LIST.indexOf(e.target.tagName) < 0) { + L.DomEvent.preventDefault(e); + } else { + return; + } + } + + this._handlePointer(e, handler); + }, this); + + obj['_leaflet_touchstart' + id] = onDown; + obj.addEventListener(this.POINTER_DOWN, onDown, false); + + // need to keep track of what pointers and how many are active to provide e.touches emulation + if (!this._pointerDocListener) { + var pointerUp = L.bind(this._globalPointerUp, this); + + // we listen documentElement as any drags that end by moving the touch off the screen get fired there + document.documentElement.addEventListener(this.POINTER_DOWN, L.bind(this._globalPointerDown, this), true); + document.documentElement.addEventListener(this.POINTER_MOVE, L.bind(this._globalPointerMove, this), true); + document.documentElement.addEventListener(this.POINTER_UP, pointerUp, true); + document.documentElement.addEventListener(this.POINTER_CANCEL, pointerUp, true); + + this._pointerDocListener = true; + } + }, + + _globalPointerDown: function (e) { + this._pointers[e.pointerId] = e; + this._pointersCount++; + }, + + _globalPointerMove: function (e) { + if (this._pointers[e.pointerId]) { + this._pointers[e.pointerId] = e; + } + }, + + _globalPointerUp: function (e) { + delete this._pointers[e.pointerId]; + this._pointersCount--; + }, + + _handlePointer: function (e, handler) { + e.touches = []; + for (var i in this._pointers) { + e.touches.push(this._pointers[i]); + } + e.changedTouches = [e]; + + handler(e); + }, + + _addPointerMove: function (obj, handler, id) { + var onMove = L.bind(function (e) { + // don't fire touch moves when mouse isn't down + if ((e.pointerType === e.MSPOINTER_TYPE_MOUSE || e.pointerType === 'mouse') && e.buttons === 0) { return; } + + this._handlePointer(e, handler); + }, this); + + obj['_leaflet_touchmove' + id] = onMove; + obj.addEventListener(this.POINTER_MOVE, onMove, false); + }, + + _addPointerEnd: function (obj, handler, id) { + var onUp = L.bind(function (e) { + this._handlePointer(e, handler); + }, this); + + obj['_leaflet_touchend' + id] = onUp; + obj.addEventListener(this.POINTER_UP, onUp, false); + obj.addEventListener(this.POINTER_CANCEL, onUp, false); + } +}); + + + +/* + * L.Handler.TouchZoom is used by L.Map to add pinch zoom on supported mobile browsers. + */ + +// @namespace Map +// @section Interaction Options +L.Map.mergeOptions({ + // @section Touch interaction options + // @option touchZoom: Boolean|String = * + // Whether the map can be zoomed by touch-dragging with two fingers. If + // passed `'center'`, it will zoom to the center of the view regardless of + // where the touch events (fingers) were. Enabled for touch-capable web + // browsers except for old Androids. + touchZoom: L.Browser.touch && !L.Browser.android23, + + // @option bounceAtZoomLimits: Boolean = true + // Set it to false if you don't want the map to zoom beyond min/max zoom + // and then bounce back when pinch-zooming. + bounceAtZoomLimits: true +}); + +L.Map.TouchZoom = L.Handler.extend({ + addHooks: function () { + L.DomUtil.addClass(this._map._container, 'leaflet-touch-zoom'); + L.DomEvent.on(this._map._container, 'touchstart', this._onTouchStart, this); + }, + + removeHooks: function () { + L.DomUtil.removeClass(this._map._container, 'leaflet-touch-zoom'); + L.DomEvent.off(this._map._container, 'touchstart', this._onTouchStart, this); + }, + + _onTouchStart: function (e) { + var map = this._map; + if (!e.touches || e.touches.length !== 2 || map._animatingZoom || this._zooming) { return; } + + var p1 = map.mouseEventToContainerPoint(e.touches[0]), + p2 = map.mouseEventToContainerPoint(e.touches[1]); + + this._centerPoint = map.getSize()._divideBy(2); + this._startLatLng = map.containerPointToLatLng(this._centerPoint); + if (map.options.touchZoom !== 'center') { + this._pinchStartLatLng = map.containerPointToLatLng(p1.add(p2)._divideBy(2)); + } + + this._startDist = p1.distanceTo(p2); + this._startZoom = map.getZoom(); + + this._moved = false; + this._zooming = true; + + map._stop(); + + L.DomEvent + .on(document, 'touchmove', this._onTouchMove, this) + .on(document, 'touchend', this._onTouchEnd, this); + + L.DomEvent.preventDefault(e); + }, + + _onTouchMove: function (e) { + if (!e.touches || e.touches.length !== 2 || !this._zooming) { return; } + + var map = this._map, + p1 = map.mouseEventToContainerPoint(e.touches[0]), + p2 = map.mouseEventToContainerPoint(e.touches[1]), + scale = p1.distanceTo(p2) / this._startDist; + + + this._zoom = map.getScaleZoom(scale, this._startZoom); + + if (!map.options.bounceAtZoomLimits && ( + (this._zoom < map.getMinZoom() && scale < 1) || + (this._zoom > map.getMaxZoom() && scale > 1))) { + this._zoom = map._limitZoom(this._zoom); + } + + if (map.options.touchZoom === 'center') { + this._center = this._startLatLng; + if (scale === 1) { return; } + } else { + // Get delta from pinch to center, so centerLatLng is delta applied to initial pinchLatLng + var delta = p1._add(p2)._divideBy(2)._subtract(this._centerPoint); + if (scale === 1 && delta.x === 0 && delta.y === 0) { return; } + this._center = map.unproject(map.project(this._pinchStartLatLng, this._zoom).subtract(delta), this._zoom); + } + + if (!this._moved) { + map._moveStart(true); + this._moved = true; + } + + L.Util.cancelAnimFrame(this._animRequest); + + var moveFn = L.bind(map._move, map, this._center, this._zoom, {pinch: true, round: false}); + this._animRequest = L.Util.requestAnimFrame(moveFn, this, true); + + L.DomEvent.preventDefault(e); + }, + + _onTouchEnd: function () { + if (!this._moved || !this._zooming) { + this._zooming = false; + return; + } + + this._zooming = false; + L.Util.cancelAnimFrame(this._animRequest); + + L.DomEvent + .off(document, 'touchmove', this._onTouchMove) + .off(document, 'touchend', this._onTouchEnd); + + // Pinch updates GridLayers' levels only when zoomSnap is off, so zoomSnap becomes noUpdate. + if (this._map.options.zoomAnimation) { + this._map._animateZoom(this._center, this._map._limitZoom(this._zoom), true, this._map.options.zoomSnap); + } else { + this._map._resetView(this._center, this._map._limitZoom(this._zoom)); + } + } +}); + +// @section Handlers +// @property touchZoom: Handler +// Touch zoom handler. +L.Map.addInitHook('addHandler', 'touchZoom', L.Map.TouchZoom); + + + +/* + * L.Map.Tap is used to enable mobile hacks like quick taps and long hold. + */ + +// @namespace Map +// @section Interaction Options +L.Map.mergeOptions({ + // @section Touch interaction options + // @option tap: Boolean = true + // Enables mobile hacks for supporting instant taps (fixing 200ms click + // delay on iOS/Android) and touch holds (fired as `contextmenu` events). + tap: true, + + // @option tapTolerance: Number = 15 + // The max number of pixels a user can shift his finger during touch + // for it to be considered a valid tap. + tapTolerance: 15 +}); + +L.Map.Tap = L.Handler.extend({ + addHooks: function () { + L.DomEvent.on(this._map._container, 'touchstart', this._onDown, this); + }, + + removeHooks: function () { + L.DomEvent.off(this._map._container, 'touchstart', this._onDown, this); + }, + + _onDown: function (e) { + if (!e.touches) { return; } + + L.DomEvent.preventDefault(e); + + this._fireClick = true; + + // don't simulate click or track longpress if more than 1 touch + if (e.touches.length > 1) { + this._fireClick = false; + clearTimeout(this._holdTimeout); + return; + } + + var first = e.touches[0], + el = first.target; + + this._startPos = this._newPos = new L.Point(first.clientX, first.clientY); + + // if touching a link, highlight it + if (el.tagName && el.tagName.toLowerCase() === 'a') { + L.DomUtil.addClass(el, 'leaflet-active'); + } + + // simulate long hold but setting a timeout + this._holdTimeout = setTimeout(L.bind(function () { + if (this._isTapValid()) { + this._fireClick = false; + this._onUp(); + this._simulateEvent('contextmenu', first); + } + }, this), 1000); + + this._simulateEvent('mousedown', first); + + L.DomEvent.on(document, { + touchmove: this._onMove, + touchend: this._onUp + }, this); + }, + + _onUp: function (e) { + clearTimeout(this._holdTimeout); + + L.DomEvent.off(document, { + touchmove: this._onMove, + touchend: this._onUp + }, this); + + if (this._fireClick && e && e.changedTouches) { + + var first = e.changedTouches[0], + el = first.target; + + if (el && el.tagName && el.tagName.toLowerCase() === 'a') { + L.DomUtil.removeClass(el, 'leaflet-active'); + } + + this._simulateEvent('mouseup', first); + + // simulate click if the touch didn't move too much + if (this._isTapValid()) { + this._simulateEvent('click', first); + } + } + }, + + _isTapValid: function () { + return this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance; + }, + + _onMove: function (e) { + var first = e.touches[0]; + this._newPos = new L.Point(first.clientX, first.clientY); + this._simulateEvent('mousemove', first); + }, + + _simulateEvent: function (type, e) { + var simulatedEvent = document.createEvent('MouseEvents'); + + simulatedEvent._simulated = true; + e.target._simulatedClick = true; + + simulatedEvent.initMouseEvent( + type, true, true, window, 1, + e.screenX, e.screenY, + e.clientX, e.clientY, + false, false, false, false, 0, null); + + e.target.dispatchEvent(simulatedEvent); + } +}); + +// @section Handlers +// @property tap: Handler +// Mobile touch hacks (quick tap and touch hold) handler. +if (L.Browser.touch && !L.Browser.pointer) { + L.Map.addInitHook('addHandler', 'tap', L.Map.Tap); +} + + + +/* + * L.Handler.BoxZoom is used to add shift-drag zoom interaction to the map + * (zoom to a selected bounding box), enabled by default. + */ + +// @namespace Map +// @section Interaction Options +L.Map.mergeOptions({ + // @option boxZoom: Boolean = true + // Whether the map can be zoomed to a rectangular area specified by + // dragging the mouse while pressing the shift key. + boxZoom: true +}); + +L.Map.BoxZoom = L.Handler.extend({ + initialize: function (map) { + this._map = map; + this._container = map._container; + this._pane = map._panes.overlayPane; + }, + + addHooks: function () { + L.DomEvent.on(this._container, 'mousedown', this._onMouseDown, this); + }, + + removeHooks: function () { + L.DomEvent.off(this._container, 'mousedown', this._onMouseDown, this); + }, + + moved: function () { + return this._moved; + }, + + _resetState: function () { + this._moved = false; + }, + + _onMouseDown: function (e) { + if (!e.shiftKey || ((e.which !== 1) && (e.button !== 1))) { return false; } + + this._resetState(); + + L.DomUtil.disableTextSelection(); + L.DomUtil.disableImageDrag(); + + this._startPoint = this._map.mouseEventToContainerPoint(e); + + L.DomEvent.on(document, { + contextmenu: L.DomEvent.stop, + mousemove: this._onMouseMove, + mouseup: this._onMouseUp, + keydown: this._onKeyDown + }, this); + }, + + _onMouseMove: function (e) { + if (!this._moved) { + this._moved = true; + + this._box = L.DomUtil.create('div', 'leaflet-zoom-box', this._container); + L.DomUtil.addClass(this._container, 'leaflet-crosshair'); + + this._map.fire('boxzoomstart'); + } + + this._point = this._map.mouseEventToContainerPoint(e); + + var bounds = new L.Bounds(this._point, this._startPoint), + size = bounds.getSize(); + + L.DomUtil.setPosition(this._box, bounds.min); + + this._box.style.width = size.x + 'px'; + this._box.style.height = size.y + 'px'; + }, + + _finish: function () { + if (this._moved) { + L.DomUtil.remove(this._box); + L.DomUtil.removeClass(this._container, 'leaflet-crosshair'); + } + + L.DomUtil.enableTextSelection(); + L.DomUtil.enableImageDrag(); + + L.DomEvent.off(document, { + contextmenu: L.DomEvent.stop, + mousemove: this._onMouseMove, + mouseup: this._onMouseUp, + keydown: this._onKeyDown + }, this); + }, + + _onMouseUp: function (e) { + if ((e.which !== 1) && (e.button !== 1)) { return; } + + this._finish(); + + if (!this._moved) { return; } + // Postpone to next JS tick so internal click event handling + // still see it as "moved". + setTimeout(L.bind(this._resetState, this), 0); + + var bounds = new L.LatLngBounds( + this._map.containerPointToLatLng(this._startPoint), + this._map.containerPointToLatLng(this._point)); + + this._map + .fitBounds(bounds) + .fire('boxzoomend', {boxZoomBounds: bounds}); + }, + + _onKeyDown: function (e) { + if (e.keyCode === 27) { + this._finish(); + } + } +}); + +// @section Handlers +// @property boxZoom: Handler +// Box (shift-drag with mouse) zoom handler. +L.Map.addInitHook('addHandler', 'boxZoom', L.Map.BoxZoom); + + + +/* + * L.Map.Keyboard is handling keyboard interaction with the map, enabled by default. + */ + +// @namespace Map +// @section Keyboard Navigation Options +L.Map.mergeOptions({ + // @option keyboard: Boolean = true + // Makes the map focusable and allows users to navigate the map with keyboard + // arrows and `+`/`-` keys. + keyboard: true, + + // @option keyboardPanDelta: Number = 80 + // Amount of pixels to pan when pressing an arrow key. + keyboardPanDelta: 80 +}); + +L.Map.Keyboard = L.Handler.extend({ + + keyCodes: { + left: [37], + right: [39], + down: [40], + up: [38], + zoomIn: [187, 107, 61, 171], + zoomOut: [189, 109, 54, 173] + }, + + initialize: function (map) { + this._map = map; + + this._setPanDelta(map.options.keyboardPanDelta); + this._setZoomDelta(map.options.zoomDelta); + }, + + addHooks: function () { + var container = this._map._container; + + // make the container focusable by tabbing + if (container.tabIndex <= 0) { + container.tabIndex = '0'; + } + + L.DomEvent.on(container, { + focus: this._onFocus, + blur: this._onBlur, + mousedown: this._onMouseDown + }, this); + + this._map.on({ + focus: this._addHooks, + blur: this._removeHooks + }, this); + }, + + removeHooks: function () { + this._removeHooks(); + + L.DomEvent.off(this._map._container, { + focus: this._onFocus, + blur: this._onBlur, + mousedown: this._onMouseDown + }, this); + + this._map.off({ + focus: this._addHooks, + blur: this._removeHooks + }, this); + }, + + _onMouseDown: function () { + if (this._focused) { return; } + + var body = document.body, + docEl = document.documentElement, + top = body.scrollTop || docEl.scrollTop, + left = body.scrollLeft || docEl.scrollLeft; + + this._map._container.focus(); + + window.scrollTo(left, top); + }, + + _onFocus: function () { + this._focused = true; + this._map.fire('focus'); + }, + + _onBlur: function () { + this._focused = false; + this._map.fire('blur'); + }, + + _setPanDelta: function (panDelta) { + var keys = this._panKeys = {}, + codes = this.keyCodes, + i, len; + + for (i = 0, len = codes.left.length; i < len; i++) { + keys[codes.left[i]] = [-1 * panDelta, 0]; + } + for (i = 0, len = codes.right.length; i < len; i++) { + keys[codes.right[i]] = [panDelta, 0]; + } + for (i = 0, len = codes.down.length; i < len; i++) { + keys[codes.down[i]] = [0, panDelta]; + } + for (i = 0, len = codes.up.length; i < len; i++) { + keys[codes.up[i]] = [0, -1 * panDelta]; + } + }, + + _setZoomDelta: function (zoomDelta) { + var keys = this._zoomKeys = {}, + codes = this.keyCodes, + i, len; + + for (i = 0, len = codes.zoomIn.length; i < len; i++) { + keys[codes.zoomIn[i]] = zoomDelta; + } + for (i = 0, len = codes.zoomOut.length; i < len; i++) { + keys[codes.zoomOut[i]] = -zoomDelta; + } + }, + + _addHooks: function () { + L.DomEvent.on(document, 'keydown', this._onKeyDown, this); + }, + + _removeHooks: function () { + L.DomEvent.off(document, 'keydown', this._onKeyDown, this); + }, + + _onKeyDown: function (e) { + if (e.altKey || e.ctrlKey || e.metaKey) { return; } + + var key = e.keyCode, + map = this._map, + offset; + + if (key in this._panKeys) { + + if (map._panAnim && map._panAnim._inProgress) { return; } + + offset = this._panKeys[key]; + if (e.shiftKey) { + offset = L.point(offset).multiplyBy(3); + } + + map.panBy(offset); + + if (map.options.maxBounds) { + map.panInsideBounds(map.options.maxBounds); + } + + } else if (key in this._zoomKeys) { + map.setZoom(map.getZoom() + (e.shiftKey ? 3 : 1) * this._zoomKeys[key]); + + } else if (key === 27) { + map.closePopup(); + + } else { + return; + } + + L.DomEvent.stop(e); + } +}); + +// @section Handlers +// @section Handlers +// @property keyboard: Handler +// Keyboard navigation handler. +L.Map.addInitHook('addHandler', 'keyboard', L.Map.Keyboard); + + + +/* + * L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable. + */ + + +/* @namespace Marker + * @section Interaction handlers + * + * Interaction handlers are properties of a marker instance that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging (see `Handler` methods). Example: + * + * ```js + * marker.dragging.disable(); + * ``` + * + * @property dragging: Handler + * Marker dragging handler (by both mouse and touch). + */ + +L.Handler.MarkerDrag = L.Handler.extend({ + initialize: function (marker) { + this._marker = marker; + }, + + addHooks: function () { + var icon = this._marker._icon; + + if (!this._draggable) { + this._draggable = new L.Draggable(icon, icon, true); + } + + this._draggable.on({ + dragstart: this._onDragStart, + drag: this._onDrag, + dragend: this._onDragEnd + }, this).enable(); + + L.DomUtil.addClass(icon, 'leaflet-marker-draggable'); + }, + + removeHooks: function () { + this._draggable.off({ + dragstart: this._onDragStart, + drag: this._onDrag, + dragend: this._onDragEnd + }, this).disable(); + + if (this._marker._icon) { + L.DomUtil.removeClass(this._marker._icon, 'leaflet-marker-draggable'); + } + }, + + moved: function () { + return this._draggable && this._draggable._moved; + }, + + _onDragStart: function () { + // @section Dragging events + // @event dragstart: Event + // Fired when the user starts dragging the marker. + + // @event movestart: Event + // Fired when the marker starts moving (because of dragging). + + this._oldLatLng = this._marker.getLatLng(); + this._marker + .closePopup() + .fire('movestart') + .fire('dragstart'); + }, + + _onDrag: function (e) { + var marker = this._marker, + shadow = marker._shadow, + iconPos = L.DomUtil.getPosition(marker._icon), + latlng = marker._map.layerPointToLatLng(iconPos); + + // update shadow position + if (shadow) { + L.DomUtil.setPosition(shadow, iconPos); + } + + marker._latlng = latlng; + e.latlng = latlng; + e.oldLatLng = this._oldLatLng; + + // @event drag: Event + // Fired repeatedly while the user drags the marker. + marker + .fire('move', e) + .fire('drag', e); + }, + + _onDragEnd: function (e) { + // @event dragend: DragEndEvent + // Fired when the user stops dragging the marker. + + // @event moveend: Event + // Fired when the marker stops moving (because of dragging). + delete this._oldLatLng; + this._marker + .fire('moveend') + .fire('dragend', e); + } +}); + + + +/* + * @class Control + * @aka L.Control + * @inherits Class + * + * L.Control is a base class for implementing map controls. Handles positioning. + * All other controls extend from this class. + */ + +L.Control = L.Class.extend({ + // @section + // @aka Control options + options: { + // @option position: String = 'topright' + // The position of the control (one of the map corners). Possible values are `'topleft'`, + // `'topright'`, `'bottomleft'` or `'bottomright'` + position: 'topright' + }, + + initialize: function (options) { + L.setOptions(this, options); + }, + + /* @section + * Classes extending L.Control will inherit the following methods: + * + * @method getPosition: string + * Returns the position of the control. + */ + getPosition: function () { + return this.options.position; + }, + + // @method setPosition(position: string): this + // Sets the position of the control. + setPosition: function (position) { + var map = this._map; + + if (map) { + map.removeControl(this); + } + + this.options.position = position; + + if (map) { + map.addControl(this); + } + + return this; + }, + + // @method getContainer: HTMLElement + // Returns the HTMLElement that contains the control. + getContainer: function () { + return this._container; + }, + + // @method addTo(map: Map): this + // Adds the control to the given map. + addTo: function (map) { + this.remove(); + this._map = map; + + var container = this._container = this.onAdd(map), + pos = this.getPosition(), + corner = map._controlCorners[pos]; + + L.DomUtil.addClass(container, 'leaflet-control'); + + if (pos.indexOf('bottom') !== -1) { + corner.insertBefore(container, corner.firstChild); + } else { + corner.appendChild(container); + } + + return this; + }, + + // @method remove: this + // Removes the control from the map it is currently active on. + remove: function () { + if (!this._map) { + return this; + } + + L.DomUtil.remove(this._container); + + if (this.onRemove) { + this.onRemove(this._map); + } + + this._map = null; + + return this; + }, + + _refocusOnMap: function (e) { + // if map exists and event is not a keyboard event + if (this._map && e && e.screenX > 0 && e.screenY > 0) { + this._map.getContainer().focus(); + } + } +}); + +L.control = function (options) { + return new L.Control(options); +}; + +/* @section Extension methods + * @uninheritable + * + * Every control should extend from `L.Control` and (re-)implement the following methods. + * + * @method onAdd(map: Map): HTMLElement + * Should return the container DOM element for the control and add listeners on relevant map events. Called on [`control.addTo(map)`](#control-addTo). + * + * @method onRemove(map: Map) + * Optional method. Should contain all clean up code that removes the listeners previously added in [`onAdd`](#control-onadd). Called on [`control.remove()`](#control-remove). + */ + +/* @namespace Map + * @section Methods for Layers and Controls + */ +L.Map.include({ + // @method addControl(control: Control): this + // Adds the given control to the map + addControl: function (control) { + control.addTo(this); + return this; + }, + + // @method removeControl(control: Control): this + // Removes the given control from the map + removeControl: function (control) { + control.remove(); + return this; + }, + + _initControlPos: function () { + var corners = this._controlCorners = {}, + l = 'leaflet-', + container = this._controlContainer = + L.DomUtil.create('div', l + 'control-container', this._container); + + function createCorner(vSide, hSide) { + var className = l + vSide + ' ' + l + hSide; + + corners[vSide + hSide] = L.DomUtil.create('div', className, container); + } + + createCorner('top', 'left'); + createCorner('top', 'right'); + createCorner('bottom', 'left'); + createCorner('bottom', 'right'); + }, + + _clearControlPos: function () { + L.DomUtil.remove(this._controlContainer); + } +}); + + + +/* + * @class Control.Zoom + * @aka L.Control.Zoom + * @inherits Control + * + * A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its [`zoomControl` option](#map-zoomcontrol) to `false`. Extends `Control`. + */ + +L.Control.Zoom = L.Control.extend({ + // @section + // @aka Control.Zoom options + options: { + position: 'topleft', + + // @option zoomInText: String = '+' + // The text set on the 'zoom in' button. + zoomInText: '+', + + // @option zoomInTitle: String = 'Zoom in' + // The title set on the 'zoom in' button. + zoomInTitle: 'Zoom in', + + // @option zoomOutText: String = '-' + // The text set on the 'zoom out' button. + zoomOutText: '-', + + // @option zoomOutTitle: String = 'Zoom out' + // The title set on the 'zoom out' button. + zoomOutTitle: 'Zoom out' + }, + + onAdd: function (map) { + var zoomName = 'leaflet-control-zoom', + container = L.DomUtil.create('div', zoomName + ' leaflet-bar'), + options = this.options; + + this._zoomInButton = this._createButton(options.zoomInText, options.zoomInTitle, + zoomName + '-in', container, this._zoomIn); + this._zoomOutButton = this._createButton(options.zoomOutText, options.zoomOutTitle, + zoomName + '-out', container, this._zoomOut); + + this._updateDisabled(); + map.on('zoomend zoomlevelschange', this._updateDisabled, this); + + return container; + }, + + onRemove: function (map) { + map.off('zoomend zoomlevelschange', this._updateDisabled, this); + }, + + disable: function () { + this._disabled = true; + this._updateDisabled(); + return this; + }, + + enable: function () { + this._disabled = false; + this._updateDisabled(); + return this; + }, + + _zoomIn: function (e) { + if (!this._disabled && this._map._zoom < this._map.getMaxZoom()) { + this._map.zoomIn(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1)); + } + }, + + _zoomOut: function (e) { + if (!this._disabled && this._map._zoom > this._map.getMinZoom()) { + this._map.zoomOut(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1)); + } + }, + + _createButton: function (html, title, className, container, fn) { + var link = L.DomUtil.create('a', className, container); + link.innerHTML = html; + link.href = '#'; + link.title = title; + + /* + * Will force screen readers like VoiceOver to read this as "Zoom in - button" + */ + link.setAttribute('role', 'button'); + link.setAttribute('aria-label', title); + + L.DomEvent + .on(link, 'mousedown dblclick', L.DomEvent.stopPropagation) + .on(link, 'click', L.DomEvent.stop) + .on(link, 'click', fn, this) + .on(link, 'click', this._refocusOnMap, this); + + return link; + }, + + _updateDisabled: function () { + var map = this._map, + className = 'leaflet-disabled'; + + L.DomUtil.removeClass(this._zoomInButton, className); + L.DomUtil.removeClass(this._zoomOutButton, className); + + if (this._disabled || map._zoom === map.getMinZoom()) { + L.DomUtil.addClass(this._zoomOutButton, className); + } + if (this._disabled || map._zoom === map.getMaxZoom()) { + L.DomUtil.addClass(this._zoomInButton, className); + } + } +}); + +// @namespace Map +// @section Control options +// @option zoomControl: Boolean = true +// Whether a [zoom control](#control-zoom) is added to the map by default. +L.Map.mergeOptions({ + zoomControl: true +}); + +L.Map.addInitHook(function () { + if (this.options.zoomControl) { + this.zoomControl = new L.Control.Zoom(); + this.addControl(this.zoomControl); + } +}); + +// @namespace Control.Zoom +// @factory L.control.zoom(options: Control.Zoom options) +// Creates a zoom control +L.control.zoom = function (options) { + return new L.Control.Zoom(options); +}; + + + +/* + * @class Control.Attribution + * @aka L.Control.Attribution + * @inherits Control + * + * The attribution control allows you to display attribution data in a small text box on a map. It is put on the map by default unless you set its [`attributionControl` option](#map-attributioncontrol) to `false`, and it fetches attribution texts from layers with the [`getAttribution` method](#layer-getattribution) automatically. Extends Control. + */ + +L.Control.Attribution = L.Control.extend({ + // @section + // @aka Control.Attribution options + options: { + position: 'bottomright', + + // @option prefix: String = 'Leaflet' + // The HTML text shown before the attributions. Pass `false` to disable. + prefix: 'Leaflet' + }, + + initialize: function (options) { + L.setOptions(this, options); + + this._attributions = {}; + }, + + onAdd: function (map) { + map.attributionControl = this; + this._container = L.DomUtil.create('div', 'leaflet-control-attribution'); + if (L.DomEvent) { + L.DomEvent.disableClickPropagation(this._container); + } + + // TODO ugly, refactor + for (var i in map._layers) { + if (map._layers[i].getAttribution) { + this.addAttribution(map._layers[i].getAttribution()); + } + } + + this._update(); + + return this._container; + }, + + // @method setPrefix(prefix: String): this + // Sets the text before the attributions. + setPrefix: function (prefix) { + this.options.prefix = prefix; + this._update(); + return this; + }, + + // @method addAttribution(text: String): this + // Adds an attribution text (e.g. `'Vector data © Mapbox'`). + addAttribution: function (text) { + if (!text) { return this; } + + if (!this._attributions[text]) { + this._attributions[text] = 0; + } + this._attributions[text]++; + + this._update(); + + return this; + }, + + // @method removeAttribution(text: String): this + // Removes an attribution text. + removeAttribution: function (text) { + if (!text) { return this; } + + if (this._attributions[text]) { + this._attributions[text]--; + this._update(); + } + + return this; + }, + + _update: function () { + if (!this._map) { return; } + + var attribs = []; + + for (var i in this._attributions) { + if (this._attributions[i]) { + attribs.push(i); + } + } + + var prefixAndAttribs = []; + + if (this.options.prefix) { + prefixAndAttribs.push(this.options.prefix); + } + if (attribs.length) { + prefixAndAttribs.push(attribs.join(', ')); + } + + this._container.innerHTML = prefixAndAttribs.join(' | '); + } +}); + +// @namespace Map +// @section Control options +// @option attributionControl: Boolean = true +// Whether a [attribution control](#control-attribution) is added to the map by default. +L.Map.mergeOptions({ + attributionControl: true +}); + +L.Map.addInitHook(function () { + if (this.options.attributionControl) { + new L.Control.Attribution().addTo(this); + } +}); + +// @namespace Control.Attribution +// @factory L.control.attribution(options: Control.Attribution options) +// Creates an attribution control. +L.control.attribution = function (options) { + return new L.Control.Attribution(options); +}; + + + +/* + * @class Control.Scale + * @aka L.Control.Scale + * @inherits Control + * + * A simple scale control that shows the scale of the current center of screen in metric (m/km) and imperial (mi/ft) systems. Extends `Control`. + * + * @example + * + * ```js + * L.control.scale().addTo(map); + * ``` + */ + +L.Control.Scale = L.Control.extend({ + // @section + // @aka Control.Scale options + options: { + position: 'bottomleft', + + // @option maxWidth: Number = 100 + // Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500). + maxWidth: 100, + + // @option metric: Boolean = True + // Whether to show the metric scale line (m/km). + metric: true, + + // @option imperial: Boolean = True + // Whether to show the imperial scale line (mi/ft). + imperial: true + + // @option updateWhenIdle: Boolean = false + // If `true`, the control is updated on [`moveend`](#map-moveend), otherwise it's always up-to-date (updated on [`move`](#map-move)). + }, + + onAdd: function (map) { + var className = 'leaflet-control-scale', + container = L.DomUtil.create('div', className), + options = this.options; + + this._addScales(options, className + '-line', container); + + map.on(options.updateWhenIdle ? 'moveend' : 'move', this._update, this); + map.whenReady(this._update, this); + + return container; + }, + + onRemove: function (map) { + map.off(this.options.updateWhenIdle ? 'moveend' : 'move', this._update, this); + }, + + _addScales: function (options, className, container) { + if (options.metric) { + this._mScale = L.DomUtil.create('div', className, container); + } + if (options.imperial) { + this._iScale = L.DomUtil.create('div', className, container); + } + }, + + _update: function () { + var map = this._map, + y = map.getSize().y / 2; + + var maxMeters = map.distance( + map.containerPointToLatLng([0, y]), + map.containerPointToLatLng([this.options.maxWidth, y])); + + this._updateScales(maxMeters); + }, + + _updateScales: function (maxMeters) { + if (this.options.metric && maxMeters) { + this._updateMetric(maxMeters); + } + if (this.options.imperial && maxMeters) { + this._updateImperial(maxMeters); + } + }, + + _updateMetric: function (maxMeters) { + var meters = this._getRoundNum(maxMeters), + label = meters < 1000 ? meters + ' m' : (meters / 1000) + ' km'; + + this._updateScale(this._mScale, label, meters / maxMeters); + }, + + _updateImperial: function (maxMeters) { + var maxFeet = maxMeters * 3.2808399, + maxMiles, miles, feet; + + if (maxFeet > 5280) { + maxMiles = maxFeet / 5280; + miles = this._getRoundNum(maxMiles); + this._updateScale(this._iScale, miles + ' mi', miles / maxMiles); + + } else { + feet = this._getRoundNum(maxFeet); + this._updateScale(this._iScale, feet + ' ft', feet / maxFeet); + } + }, + + _updateScale: function (scale, text, ratio) { + scale.style.width = Math.round(this.options.maxWidth * ratio) + 'px'; + scale.innerHTML = text; + }, + + _getRoundNum: function (num) { + var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1), + d = num / pow10; + + d = d >= 10 ? 10 : + d >= 5 ? 5 : + d >= 3 ? 3 : + d >= 2 ? 2 : 1; + + return pow10 * d; + } +}); + + +// @factory L.control.scale(options?: Control.Scale options) +// Creates an scale control with the given options. +L.control.scale = function (options) { + return new L.Control.Scale(options); +}; + + + +/* + * @class Control.Layers + * @aka L.Control.Layers + * @inherits Control + * + * The layers control gives users the ability to switch between different base layers and switch overlays on/off (check out the [detailed example](http://leafletjs.com/examples/layers-control.html)). Extends `Control`. + * + * @example + * + * ```js + * var baseLayers = { + * "Mapbox": mapbox, + * "OpenStreetMap": osm + * }; + * + * var overlays = { + * "Marker": marker, + * "Roads": roadsLayer + * }; + * + * L.control.layers(baseLayers, overlays).addTo(map); + * ``` + * + * The `baseLayers` and `overlays` parameters are object literals with layer names as keys and `Layer` objects as values: + * + * ```js + * { + * "": layer1, + * "": layer2 + * } + * ``` + * + * The layer names can contain HTML, which allows you to add additional styling to the items: + * + * ```js + * {" My Layer": myLayer} + * ``` + */ + + +L.Control.Layers = L.Control.extend({ + // @section + // @aka Control.Layers options + options: { + // @option collapsed: Boolean = true + // If `true`, the control will be collapsed into an icon and expanded on mouse hover or touch. + collapsed: true, + position: 'topright', + + // @option autoZIndex: Boolean = true + // If `true`, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off. + autoZIndex: true, + + // @option hideSingleBase: Boolean = false + // If `true`, the base layers in the control will be hidden when there is only one. + hideSingleBase: false, + + // @option sortLayers: Boolean = false + // Whether to sort the layers. When `false`, layers will keep the order + // in which they were added to the control. + sortLayers: false, + + // @option sortFunction: Function = * + // A [compare function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) + // that will be used for sorting the layers, when `sortLayers` is `true`. + // The function receives both the `L.Layer` instances and their names, as in + // `sortFunction(layerA, layerB, nameA, nameB)`. + // By default, it sorts layers alphabetically by their name. + sortFunction: function (layerA, layerB, nameA, nameB) { + return nameA < nameB ? -1 : (nameB < nameA ? 1 : 0); + } + }, + + initialize: function (baseLayers, overlays, options) { + L.setOptions(this, options); + + this._layers = []; + this._lastZIndex = 0; + this._handlingClick = false; + + for (var i in baseLayers) { + this._addLayer(baseLayers[i], i); + } + + for (i in overlays) { + this._addLayer(overlays[i], i, true); + } + }, + + onAdd: function (map) { + this._initLayout(); + this._update(); + + this._map = map; + map.on('zoomend', this._checkDisabledLayers, this); + + return this._container; + }, + + onRemove: function () { + this._map.off('zoomend', this._checkDisabledLayers, this); + + for (var i = 0; i < this._layers.length; i++) { + this._layers[i].layer.off('add remove', this._onLayerChange, this); + } + }, + + // @method addBaseLayer(layer: Layer, name: String): this + // Adds a base layer (radio button entry) with the given name to the control. + addBaseLayer: function (layer, name) { + this._addLayer(layer, name); + return (this._map) ? this._update() : this; + }, + + // @method addOverlay(layer: Layer, name: String): this + // Adds an overlay (checkbox entry) with the given name to the control. + addOverlay: function (layer, name) { + this._addLayer(layer, name, true); + return (this._map) ? this._update() : this; + }, + + // @method removeLayer(layer: Layer): this + // Remove the given layer from the control. + removeLayer: function (layer) { + layer.off('add remove', this._onLayerChange, this); + + var obj = this._getLayer(L.stamp(layer)); + if (obj) { + this._layers.splice(this._layers.indexOf(obj), 1); + } + return (this._map) ? this._update() : this; + }, + + // @method expand(): this + // Expand the control container if collapsed. + expand: function () { + L.DomUtil.addClass(this._container, 'leaflet-control-layers-expanded'); + this._form.style.height = null; + var acceptableHeight = this._map.getSize().y - (this._container.offsetTop + 50); + if (acceptableHeight < this._form.clientHeight) { + L.DomUtil.addClass(this._form, 'leaflet-control-layers-scrollbar'); + this._form.style.height = acceptableHeight + 'px'; + } else { + L.DomUtil.removeClass(this._form, 'leaflet-control-layers-scrollbar'); + } + this._checkDisabledLayers(); + return this; + }, + + // @method collapse(): this + // Collapse the control container if expanded. + collapse: function () { + L.DomUtil.removeClass(this._container, 'leaflet-control-layers-expanded'); + return this; + }, + + _initLayout: function () { + var className = 'leaflet-control-layers', + container = this._container = L.DomUtil.create('div', className); + + // makes this work on IE touch devices by stopping it from firing a mouseout event when the touch is released + container.setAttribute('aria-haspopup', true); + + L.DomEvent.disableClickPropagation(container); + if (!L.Browser.touch) { + L.DomEvent.disableScrollPropagation(container); + } + + var form = this._form = L.DomUtil.create('form', className + '-list'); + + if (!L.Browser.android) { + L.DomEvent.on(container, { + mouseenter: this.expand, + mouseleave: this.collapse + }, this); + } + + var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container); + link.href = '#'; + link.title = 'Layers'; + + if (L.Browser.touch) { + L.DomEvent + .on(link, 'click', L.DomEvent.stop) + .on(link, 'click', this.expand, this); + } else { + L.DomEvent.on(link, 'focus', this.expand, this); + } + + // work around for Firefox Android issue https://github.com/Leaflet/Leaflet/issues/2033 + L.DomEvent.on(form, 'click', function () { + setTimeout(L.bind(this._onInputClick, this), 0); + }, this); + + this._map.on('click', this.collapse, this); + // TODO keyboard accessibility + + if (!this.options.collapsed) { + this.expand(); + } + + this._baseLayersList = L.DomUtil.create('div', className + '-base', form); + this._separator = L.DomUtil.create('div', className + '-separator', form); + this._overlaysList = L.DomUtil.create('div', className + '-overlays', form); + + container.appendChild(form); + }, + + _getLayer: function (id) { + for (var i = 0; i < this._layers.length; i++) { + + if (this._layers[i] && L.stamp(this._layers[i].layer) === id) { + return this._layers[i]; + } + } + }, + + _addLayer: function (layer, name, overlay) { + layer.on('add remove', this._onLayerChange, this); + + this._layers.push({ + layer: layer, + name: name, + overlay: overlay + }); + + if (this.options.sortLayers) { + this._layers.sort(L.bind(function (a, b) { + return this.options.sortFunction(a.layer, b.layer, a.name, b.name); + }, this)); + } + + if (this.options.autoZIndex && layer.setZIndex) { + this._lastZIndex++; + layer.setZIndex(this._lastZIndex); + } + }, + + _update: function () { + if (!this._container) { return this; } + + L.DomUtil.empty(this._baseLayersList); + L.DomUtil.empty(this._overlaysList); + + var baseLayersPresent, overlaysPresent, i, obj, baseLayersCount = 0; + + for (i = 0; i < this._layers.length; i++) { + obj = this._layers[i]; + this._addItem(obj); + overlaysPresent = overlaysPresent || obj.overlay; + baseLayersPresent = baseLayersPresent || !obj.overlay; + baseLayersCount += !obj.overlay ? 1 : 0; + } + + // Hide base layers section if there's only one layer. + if (this.options.hideSingleBase) { + baseLayersPresent = baseLayersPresent && baseLayersCount > 1; + this._baseLayersList.style.display = baseLayersPresent ? '' : 'none'; + } + + this._separator.style.display = overlaysPresent && baseLayersPresent ? '' : 'none'; + + return this; + }, + + _onLayerChange: function (e) { + if (!this._handlingClick) { + this._update(); + } + + var obj = this._getLayer(L.stamp(e.target)); + + // @namespace Map + // @section Layer events + // @event baselayerchange: LayersControlEvent + // Fired when the base layer is changed through the [layer control](#control-layers). + // @event overlayadd: LayersControlEvent + // Fired when an overlay is selected through the [layer control](#control-layers). + // @event overlayremove: LayersControlEvent + // Fired when an overlay is deselected through the [layer control](#control-layers). + // @namespace Control.Layers + var type = obj.overlay ? + (e.type === 'add' ? 'overlayadd' : 'overlayremove') : + (e.type === 'add' ? 'baselayerchange' : null); + + if (type) { + this._map.fire(type, obj); + } + }, + + // IE7 bugs out if you create a radio dynamically, so you have to do it this hacky way (see http://bit.ly/PqYLBe) + _createRadioElement: function (name, checked) { + + var radioHtml = ''; + + var radioFragment = document.createElement('div'); + radioFragment.innerHTML = radioHtml; + + return radioFragment.firstChild; + }, + + _addItem: function (obj) { + var label = document.createElement('label'), + checked = this._map.hasLayer(obj.layer), + input; + + if (obj.overlay) { + input = document.createElement('input'); + input.type = 'checkbox'; + input.className = 'leaflet-control-layers-selector'; + input.defaultChecked = checked; + } else { + input = this._createRadioElement('leaflet-base-layers', checked); + } + + input.layerId = L.stamp(obj.layer); + + L.DomEvent.on(input, 'click', this._onInputClick, this); + + var name = document.createElement('span'); + name.innerHTML = ' ' + obj.name; + + // Helps from preventing layer control flicker when checkboxes are disabled + // https://github.com/Leaflet/Leaflet/issues/2771 + var holder = document.createElement('div'); + + label.appendChild(holder); + holder.appendChild(input); + holder.appendChild(name); + + var container = obj.overlay ? this._overlaysList : this._baseLayersList; + container.appendChild(label); + + this._checkDisabledLayers(); + return label; + }, + + _onInputClick: function () { + var inputs = this._form.getElementsByTagName('input'), + input, layer, hasLayer; + var addedLayers = [], + removedLayers = []; + + this._handlingClick = true; + + for (var i = inputs.length - 1; i >= 0; i--) { + input = inputs[i]; + layer = this._getLayer(input.layerId).layer; + hasLayer = this._map.hasLayer(layer); + + if (input.checked && !hasLayer) { + addedLayers.push(layer); + + } else if (!input.checked && hasLayer) { + removedLayers.push(layer); + } + } + + // Bugfix issue 2318: Should remove all old layers before readding new ones + for (i = 0; i < removedLayers.length; i++) { + this._map.removeLayer(removedLayers[i]); + } + for (i = 0; i < addedLayers.length; i++) { + this._map.addLayer(addedLayers[i]); + } + + this._handlingClick = false; + + this._refocusOnMap(); + }, + + _checkDisabledLayers: function () { + var inputs = this._form.getElementsByTagName('input'), + input, + layer, + zoom = this._map.getZoom(); + + for (var i = inputs.length - 1; i >= 0; i--) { + input = inputs[i]; + layer = this._getLayer(input.layerId).layer; + input.disabled = (layer.options.minZoom !== undefined && zoom < layer.options.minZoom) || + (layer.options.maxZoom !== undefined && zoom > layer.options.maxZoom); + + } + }, + + _expand: function () { + // Backward compatibility, remove me in 1.1. + return this.expand(); + }, + + _collapse: function () { + // Backward compatibility, remove me in 1.1. + return this.collapse(); + } + +}); + + +// @factory L.control.layers(baselayers?: Object, overlays?: Object, options?: Control.Layers options) +// Creates an attribution control with the given layers. Base layers will be switched with radio buttons, while overlays will be switched with checkboxes. Note that all base layers should be passed in the base layers object, but only one should be added to the map during map instantiation. +L.control.layers = function (baseLayers, overlays, options) { + return new L.Control.Layers(baseLayers, overlays, options); +}; + + + +}(window, document)); +//# sourceMappingURL=leaflet-src.map \ No newline at end of file diff --git a/www7/sites/all/libraries/leaflet/leaflet-src.map b/www7/sites/all/libraries/leaflet/leaflet-src.map new file mode 100644 index 000000000..a781ede13 --- /dev/null +++ b/www7/sites/all/libraries/leaflet/leaflet-src.map @@ -0,0 +1 @@ +{"version":3,"sources":["src/Leaflet.js","src/core/Util.js","src/core/Class.js","src/core/Events.js","src/core/Browser.js","src/geometry/Point.js","src/geometry/Bounds.js","src/geometry/Transformation.js","src/dom/DomUtil.js","src/geo/LatLng.js","src/geo/LatLngBounds.js","src/geo/projection/Projection.LonLat.js","src/geo/projection/Projection.SphericalMercator.js","src/geo/crs/CRS.js","src/geo/crs/CRS.Simple.js","src/geo/crs/CRS.Earth.js","src/geo/crs/CRS.EPSG3857.js","src/geo/crs/CRS.EPSG4326.js","src/map/Map.js","src/layer/Layer.js","src/dom/DomEvent.js","src/dom/PosAnimation.js","src/geo/projection/Projection.Mercator.js","src/geo/crs/CRS.EPSG3395.js","src/layer/tile/GridLayer.js","src/layer/tile/TileLayer.js","src/layer/tile/TileLayer.WMS.js","src/layer/ImageOverlay.js","src/layer/marker/Icon.js","src/layer/marker/Icon.Default.js","src/layer/marker/Marker.js","src/layer/marker/DivIcon.js","src/layer/DivOverlay.js","src/layer/Popup.js","src/layer/Tooltip.js","src/layer/LayerGroup.js","src/layer/FeatureGroup.js","src/layer/vector/Renderer.js","src/layer/vector/Path.js","src/geometry/LineUtil.js","src/layer/vector/Polyline.js","src/geometry/PolyUtil.js","src/layer/vector/Polygon.js","src/layer/vector/Rectangle.js","src/layer/vector/CircleMarker.js","src/layer/vector/Circle.js","src/layer/vector/SVG.js","src/layer/vector/SVG.VML.js","src/layer/vector/Canvas.js","src/layer/GeoJSON.js","src/dom/Draggable.js","src/core/Handler.js","src/map/handler/Map.Drag.js","src/map/handler/Map.DoubleClickZoom.js","src/map/handler/Map.ScrollWheelZoom.js","src/dom/DomEvent.DoubleTap.js","src/dom/DomEvent.Pointer.js","src/map/handler/Map.TouchZoom.js","src/map/handler/Map.Tap.js","src/map/handler/Map.BoxZoom.js","src/map/handler/Map.Keyboard.js","src/layer/marker/Marker.Drag.js","src/control/Control.js","src/control/Control.Zoom.js","src/control/Control.Attribution.js","src/control/Control.Scale.js","src/control/Control.Layers.js"],"names":[],"mappings":";;;;yCAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1PA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACpJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC3JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC3GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC/BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1jDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC/QA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACpTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC/FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC91BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACzRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC/IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACpDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC3fA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC/JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC3FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACvKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACpOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACzSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACvJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACzGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7OA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC3NA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC/CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACpDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACzFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC/HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC3HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9KA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC5HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":["\r\nvar L = {\r\n\tversion: \"1.0.2+4bbb16c\"\r\n};\r\n\r\nfunction expose() {\r\n\tvar oldL = window.L;\r\n\r\n\tL.noConflict = function () {\r\n\t\twindow.L = oldL;\r\n\t\treturn this;\r\n\t};\r\n\r\n\twindow.L = L;\r\n}\r\n\r\n// define Leaflet for Node module pattern loaders, including Browserify\r\nif (typeof module === 'object' && typeof module.exports === 'object') {\r\n\tmodule.exports = L;\r\n\r\n// define Leaflet as an AMD module\r\n} else if (typeof define === 'function' && define.amd) {\r\n\tdefine(L);\r\n}\r\n\r\n// define Leaflet as a global L variable, saving the original L to restore later if needed\r\nif (typeof window !== 'undefined') {\r\n\texpose();\r\n}\r\n","/*\r\n * @namespace Util\r\n *\r\n * Various utility functions, used by Leaflet internally.\r\n */\r\n\r\nL.Util = {\r\n\r\n\t// @function extend(dest: Object, src?: Object): Object\r\n\t// Merges the properties of the `src` object (or multiple objects) into `dest` object and returns the latter. Has an `L.extend` shortcut.\r\n\textend: function (dest) {\r\n\t\tvar i, j, len, src;\r\n\r\n\t\tfor (j = 1, len = arguments.length; j < len; j++) {\r\n\t\t\tsrc = arguments[j];\r\n\t\t\tfor (i in src) {\r\n\t\t\t\tdest[i] = src[i];\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn dest;\r\n\t},\r\n\r\n\t// @function create(proto: Object, properties?: Object): Object\r\n\t// Compatibility polyfill for [Object.create](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/create)\r\n\tcreate: Object.create || (function () {\r\n\t\tfunction F() {}\r\n\t\treturn function (proto) {\r\n\t\t\tF.prototype = proto;\r\n\t\t\treturn new F();\r\n\t\t};\r\n\t})(),\r\n\r\n\t// @function bind(fn: Function, …): Function\r\n\t// Returns a new function bound to the arguments passed, like [Function.prototype.bind](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).\r\n\t// Has a `L.bind()` shortcut.\r\n\tbind: function (fn, obj) {\r\n\t\tvar slice = Array.prototype.slice;\r\n\r\n\t\tif (fn.bind) {\r\n\t\t\treturn fn.bind.apply(fn, slice.call(arguments, 1));\r\n\t\t}\r\n\r\n\t\tvar args = slice.call(arguments, 2);\r\n\r\n\t\treturn function () {\r\n\t\t\treturn fn.apply(obj, args.length ? args.concat(slice.call(arguments)) : arguments);\r\n\t\t};\r\n\t},\r\n\r\n\t// @function stamp(obj: Object): Number\r\n\t// Returns the unique ID of an object, assiging it one if it doesn't have it.\r\n\tstamp: function (obj) {\r\n\t\t/*eslint-disable */\r\n\t\tobj._leaflet_id = obj._leaflet_id || ++L.Util.lastId;\r\n\t\treturn obj._leaflet_id;\r\n\t\t/*eslint-enable */\r\n\t},\r\n\r\n\t// @property lastId: Number\r\n\t// Last unique ID used by [`stamp()`](#util-stamp)\r\n\tlastId: 0,\r\n\r\n\t// @function throttle(fn: Function, time: Number, context: Object): Function\r\n\t// Returns a function which executes function `fn` with the given scope `context`\r\n\t// (so that the `this` keyword refers to `context` inside `fn`'s code). The function\r\n\t// `fn` will be called no more than one time per given amount of `time`. The arguments\r\n\t// received by the bound function will be any arguments passed when binding the\r\n\t// function, followed by any arguments passed when invoking the bound function.\r\n\t// Has an `L.bind` shortcut.\r\n\tthrottle: function (fn, time, context) {\r\n\t\tvar lock, args, wrapperFn, later;\r\n\r\n\t\tlater = function () {\r\n\t\t\t// reset lock and call if queued\r\n\t\t\tlock = false;\r\n\t\t\tif (args) {\r\n\t\t\t\twrapperFn.apply(context, args);\r\n\t\t\t\targs = false;\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\twrapperFn = function () {\r\n\t\t\tif (lock) {\r\n\t\t\t\t// called too soon, queue to call later\r\n\t\t\t\targs = arguments;\r\n\r\n\t\t\t} else {\r\n\t\t\t\t// call and lock until later\r\n\t\t\t\tfn.apply(context, arguments);\r\n\t\t\t\tsetTimeout(later, time);\r\n\t\t\t\tlock = true;\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\treturn wrapperFn;\r\n\t},\r\n\r\n\t// @function wrapNum(num: Number, range: Number[], includeMax?: Boolean): Number\r\n\t// Returns the number `num` modulo `range` in such a way so it lies within\r\n\t// `range[0]` and `range[1]`. The returned value will be always smaller than\r\n\t// `range[1]` unless `includeMax` is set to `true`.\r\n\twrapNum: function (x, range, includeMax) {\r\n\t\tvar max = range[1],\r\n\t\t min = range[0],\r\n\t\t d = max - min;\r\n\t\treturn x === max && includeMax ? x : ((x - min) % d + d) % d + min;\r\n\t},\r\n\r\n\t// @function falseFn(): Function\r\n\t// Returns a function which always returns `false`.\r\n\tfalseFn: function () { return false; },\r\n\r\n\t// @function formatNum(num: Number, digits?: Number): Number\r\n\t// Returns the number `num` rounded to `digits` decimals, or to 5 decimals by default.\r\n\tformatNum: function (num, digits) {\r\n\t\tvar pow = Math.pow(10, digits || 5);\r\n\t\treturn Math.round(num * pow) / pow;\r\n\t},\r\n\r\n\t// @function trim(str: String): String\r\n\t// Compatibility polyfill for [String.prototype.trim](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim)\r\n\ttrim: function (str) {\r\n\t\treturn str.trim ? str.trim() : str.replace(/^\\s+|\\s+$/g, '');\r\n\t},\r\n\r\n\t// @function splitWords(str: String): String[]\r\n\t// Trims and splits the string on whitespace and returns the array of parts.\r\n\tsplitWords: function (str) {\r\n\t\treturn L.Util.trim(str).split(/\\s+/);\r\n\t},\r\n\r\n\t// @function setOptions(obj: Object, options: Object): Object\r\n\t// Merges the given properties to the `options` of the `obj` object, returning the resulting options. See `Class options`. Has an `L.setOptions` shortcut.\r\n\tsetOptions: function (obj, options) {\r\n\t\tif (!obj.hasOwnProperty('options')) {\r\n\t\t\tobj.options = obj.options ? L.Util.create(obj.options) : {};\r\n\t\t}\r\n\t\tfor (var i in options) {\r\n\t\t\tobj.options[i] = options[i];\r\n\t\t}\r\n\t\treturn obj.options;\r\n\t},\r\n\r\n\t// @function getParamString(obj: Object, existingUrl?: String, uppercase?: Boolean): String\r\n\t// Converts an object into a parameter URL string, e.g. `{a: \"foo\", b: \"bar\"}`\r\n\t// translates to `'?a=foo&b=bar'`. If `existingUrl` is set, the parameters will\r\n\t// be appended at the end. If `uppercase` is `true`, the parameter names will\r\n\t// be uppercased (e.g. `'?A=foo&B=bar'`)\r\n\tgetParamString: function (obj, existingUrl, uppercase) {\r\n\t\tvar params = [];\r\n\t\tfor (var i in obj) {\r\n\t\t\tparams.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i]));\r\n\t\t}\r\n\t\treturn ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&');\r\n\t},\r\n\r\n\t// @function template(str: String, data: Object): String\r\n\t// Simple templating facility, accepts a template string of the form `'Hello {a}, {b}'`\r\n\t// and a data object like `{a: 'foo', b: 'bar'}`, returns evaluated string\r\n\t// `('Hello foo, bar')`. You can also specify functions instead of strings for\r\n\t// data values — they will be evaluated passing `data` as an argument.\r\n\ttemplate: function (str, data) {\r\n\t\treturn str.replace(L.Util.templateRe, function (str, key) {\r\n\t\t\tvar value = data[key];\r\n\r\n\t\t\tif (value === undefined) {\r\n\t\t\t\tthrow new Error('No value provided for variable ' + str);\r\n\r\n\t\t\t} else if (typeof value === 'function') {\r\n\t\t\t\tvalue = value(data);\r\n\t\t\t}\r\n\t\t\treturn value;\r\n\t\t});\r\n\t},\r\n\r\n\ttemplateRe: /\\{ *([\\w_\\-]+) *\\}/g,\r\n\r\n\t// @function isArray(obj): Boolean\r\n\t// Compatibility polyfill for [Array.isArray](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)\r\n\tisArray: Array.isArray || function (obj) {\r\n\t\treturn (Object.prototype.toString.call(obj) === '[object Array]');\r\n\t},\r\n\r\n\t// @function indexOf(array: Array, el: Object): Number\r\n\t// Compatibility polyfill for [Array.prototype.indexOf](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)\r\n\tindexOf: function (array, el) {\r\n\t\tfor (var i = 0; i < array.length; i++) {\r\n\t\t\tif (array[i] === el) { return i; }\r\n\t\t}\r\n\t\treturn -1;\r\n\t},\r\n\r\n\t// @property emptyImageUrl: String\r\n\t// Data URI string containing a base64-encoded empty GIF image.\r\n\t// Used as a hack to free memory from unused images on WebKit-powered\r\n\t// mobile devices (by setting image `src` to this string).\r\n\temptyImageUrl: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='\r\n};\r\n\r\n(function () {\r\n\t// inspired by http://paulirish.com/2011/requestanimationframe-for-smart-animating/\r\n\r\n\tfunction getPrefixed(name) {\r\n\t\treturn window['webkit' + name] || window['moz' + name] || window['ms' + name];\r\n\t}\r\n\r\n\tvar lastTime = 0;\r\n\r\n\t// fallback for IE 7-8\r\n\tfunction timeoutDefer(fn) {\r\n\t\tvar time = +new Date(),\r\n\t\t timeToCall = Math.max(0, 16 - (time - lastTime));\r\n\r\n\t\tlastTime = time + timeToCall;\r\n\t\treturn window.setTimeout(fn, timeToCall);\r\n\t}\r\n\r\n\tvar requestFn = window.requestAnimationFrame || getPrefixed('RequestAnimationFrame') || timeoutDefer,\r\n\t cancelFn = window.cancelAnimationFrame || getPrefixed('CancelAnimationFrame') ||\r\n\t getPrefixed('CancelRequestAnimationFrame') || function (id) { window.clearTimeout(id); };\r\n\r\n\r\n\t// @function requestAnimFrame(fn: Function, context?: Object, immediate?: Boolean): Number\r\n\t// Schedules `fn` to be executed when the browser repaints. `fn` is bound to\r\n\t// `context` if given. When `immediate` is set, `fn` is called immediately if\r\n\t// the browser doesn't have native support for\r\n\t// [`window.requestAnimationFrame`](https://developer.mozilla.org/docs/Web/API/window/requestAnimationFrame),\r\n\t// otherwise it's delayed. Returns a request ID that can be used to cancel the request.\r\n\tL.Util.requestAnimFrame = function (fn, context, immediate) {\r\n\t\tif (immediate && requestFn === timeoutDefer) {\r\n\t\t\tfn.call(context);\r\n\t\t} else {\r\n\t\t\treturn requestFn.call(window, L.bind(fn, context));\r\n\t\t}\r\n\t};\r\n\r\n\t// @function cancelAnimFrame(id: Number): undefined\r\n\t// Cancels a previous `requestAnimFrame`. See also [window.cancelAnimationFrame](https://developer.mozilla.org/docs/Web/API/window/cancelAnimationFrame).\r\n\tL.Util.cancelAnimFrame = function (id) {\r\n\t\tif (id) {\r\n\t\t\tcancelFn.call(window, id);\r\n\t\t}\r\n\t};\r\n})();\r\n\r\n// shortcuts for most used utility functions\r\nL.extend = L.Util.extend;\r\nL.bind = L.Util.bind;\r\nL.stamp = L.Util.stamp;\r\nL.setOptions = L.Util.setOptions;\r\n","\r\n// @class Class\r\n// @aka L.Class\r\n\r\n// @section\r\n// @uninheritable\r\n\r\n// Thanks to John Resig and Dean Edwards for inspiration!\r\n\r\nL.Class = function () {};\r\n\r\nL.Class.extend = function (props) {\r\n\r\n\t// @function extend(props: Object): Function\r\n\t// [Extends the current class](#class-inheritance) given the properties to be included.\r\n\t// Returns a Javascript function that is a class constructor (to be called with `new`).\r\n\tvar NewClass = function () {\r\n\r\n\t\t// call the constructor\r\n\t\tif (this.initialize) {\r\n\t\t\tthis.initialize.apply(this, arguments);\r\n\t\t}\r\n\r\n\t\t// call all constructor hooks\r\n\t\tthis.callInitHooks();\r\n\t};\r\n\r\n\tvar parentProto = NewClass.__super__ = this.prototype;\r\n\r\n\tvar proto = L.Util.create(parentProto);\r\n\tproto.constructor = NewClass;\r\n\r\n\tNewClass.prototype = proto;\r\n\r\n\t// inherit parent's statics\r\n\tfor (var i in this) {\r\n\t\tif (this.hasOwnProperty(i) && i !== 'prototype') {\r\n\t\t\tNewClass[i] = this[i];\r\n\t\t}\r\n\t}\r\n\r\n\t// mix static properties into the class\r\n\tif (props.statics) {\r\n\t\tL.extend(NewClass, props.statics);\r\n\t\tdelete props.statics;\r\n\t}\r\n\r\n\t// mix includes into the prototype\r\n\tif (props.includes) {\r\n\t\tL.Util.extend.apply(null, [proto].concat(props.includes));\r\n\t\tdelete props.includes;\r\n\t}\r\n\r\n\t// merge options\r\n\tif (proto.options) {\r\n\t\tprops.options = L.Util.extend(L.Util.create(proto.options), props.options);\r\n\t}\r\n\r\n\t// mix given properties into the prototype\r\n\tL.extend(proto, props);\r\n\r\n\tproto._initHooks = [];\r\n\r\n\t// add method for calling all hooks\r\n\tproto.callInitHooks = function () {\r\n\r\n\t\tif (this._initHooksCalled) { return; }\r\n\r\n\t\tif (parentProto.callInitHooks) {\r\n\t\t\tparentProto.callInitHooks.call(this);\r\n\t\t}\r\n\r\n\t\tthis._initHooksCalled = true;\r\n\r\n\t\tfor (var i = 0, len = proto._initHooks.length; i < len; i++) {\r\n\t\t\tproto._initHooks[i].call(this);\r\n\t\t}\r\n\t};\r\n\r\n\treturn NewClass;\r\n};\r\n\r\n\r\n// @function include(properties: Object): this\r\n// [Includes a mixin](#class-includes) into the current class.\r\nL.Class.include = function (props) {\r\n\tL.extend(this.prototype, props);\r\n\treturn this;\r\n};\r\n\r\n// @function mergeOptions(options: Object): this\r\n// [Merges `options`](#class-options) into the defaults of the class.\r\nL.Class.mergeOptions = function (options) {\r\n\tL.extend(this.prototype.options, options);\r\n\treturn this;\r\n};\r\n\r\n// @function addInitHook(fn: Function): this\r\n// Adds a [constructor hook](#class-constructor-hooks) to the class.\r\nL.Class.addInitHook = function (fn) { // (Function) || (String, args...)\r\n\tvar args = Array.prototype.slice.call(arguments, 1);\r\n\r\n\tvar init = typeof fn === 'function' ? fn : function () {\r\n\t\tthis[fn].apply(this, args);\r\n\t};\r\n\r\n\tthis.prototype._initHooks = this.prototype._initHooks || [];\r\n\tthis.prototype._initHooks.push(init);\r\n\treturn this;\r\n};\r\n","/*\r\n * @class Evented\r\n * @aka L.Evented\r\n * @inherits Class\r\n *\r\n * A set of methods shared between event-powered classes (like `Map` and `Marker`). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire `'click'` event).\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * map.on('click', function(e) {\r\n * \talert(e.latlng);\r\n * } );\r\n * ```\r\n *\r\n * Leaflet deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a function:\r\n *\r\n * ```js\r\n * function onClick(e) { ... }\r\n *\r\n * map.on('click', onClick);\r\n * map.off('click', onClick);\r\n * ```\r\n */\r\n\r\n\r\nL.Evented = L.Class.extend({\r\n\r\n\t/* @method on(type: String, fn: Function, context?: Object): this\r\n\t * Adds a listener function (`fn`) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. `'click dblclick'`).\r\n\t *\r\n\t * @alternative\r\n\t * @method on(eventMap: Object): this\r\n\t * Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}`\r\n\t */\r\n\ton: function (types, fn, context) {\r\n\r\n\t\t// types can be a map of types/handlers\r\n\t\tif (typeof types === 'object') {\r\n\t\t\tfor (var type in types) {\r\n\t\t\t\t// we don't process space-separated events here for performance;\r\n\t\t\t\t// it's a hot path since Layer uses the on(obj) syntax\r\n\t\t\t\tthis._on(type, types[type], fn);\r\n\t\t\t}\r\n\r\n\t\t} else {\r\n\t\t\t// types can be a string of space-separated words\r\n\t\t\ttypes = L.Util.splitWords(types);\r\n\r\n\t\t\tfor (var i = 0, len = types.length; i < len; i++) {\r\n\t\t\t\tthis._on(types[i], fn, context);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t/* @method off(type: String, fn?: Function, context?: Object): this\r\n\t * Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to `on`, you must pass the same context to `off` in order to remove the listener.\r\n\t *\r\n\t * @alternative\r\n\t * @method off(eventMap: Object): this\r\n\t * Removes a set of type/listener pairs.\r\n\t *\r\n\t * @alternative\r\n\t * @method off: this\r\n\t * Removes all listeners to all events on the object.\r\n\t */\r\n\toff: function (types, fn, context) {\r\n\r\n\t\tif (!types) {\r\n\t\t\t// clear all listeners if called without arguments\r\n\t\t\tdelete this._events;\r\n\r\n\t\t} else if (typeof types === 'object') {\r\n\t\t\tfor (var type in types) {\r\n\t\t\t\tthis._off(type, types[type], fn);\r\n\t\t\t}\r\n\r\n\t\t} else {\r\n\t\t\ttypes = L.Util.splitWords(types);\r\n\r\n\t\t\tfor (var i = 0, len = types.length; i < len; i++) {\r\n\t\t\t\tthis._off(types[i], fn, context);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// attach listener (without syntactic sugar now)\r\n\t_on: function (type, fn, context) {\r\n\t\tthis._events = this._events || {};\r\n\r\n\t\t/* get/init listeners for type */\r\n\t\tvar typeListeners = this._events[type];\r\n\t\tif (!typeListeners) {\r\n\t\t\ttypeListeners = [];\r\n\t\t\tthis._events[type] = typeListeners;\r\n\t\t}\r\n\r\n\t\tif (context === this) {\r\n\t\t\t// Less memory footprint.\r\n\t\t\tcontext = undefined;\r\n\t\t}\r\n\t\tvar newListener = {fn: fn, ctx: context},\r\n\t\t listeners = typeListeners;\r\n\r\n\t\t// check if fn already there\r\n\t\tfor (var i = 0, len = listeners.length; i < len; i++) {\r\n\t\t\tif (listeners[i].fn === fn && listeners[i].ctx === context) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlisteners.push(newListener);\r\n\t\ttypeListeners.count++;\r\n\t},\r\n\r\n\t_off: function (type, fn, context) {\r\n\t\tvar listeners,\r\n\t\t i,\r\n\t\t len;\r\n\r\n\t\tif (!this._events) { return; }\r\n\r\n\t\tlisteners = this._events[type];\r\n\r\n\t\tif (!listeners) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (!fn) {\r\n\t\t\t// Set all removed listeners to noop so they are not called if remove happens in fire\r\n\t\t\tfor (i = 0, len = listeners.length; i < len; i++) {\r\n\t\t\t\tlisteners[i].fn = L.Util.falseFn;\r\n\t\t\t}\r\n\t\t\t// clear all listeners for a type if function isn't specified\r\n\t\t\tdelete this._events[type];\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (context === this) {\r\n\t\t\tcontext = undefined;\r\n\t\t}\r\n\r\n\t\tif (listeners) {\r\n\r\n\t\t\t// find fn and remove it\r\n\t\t\tfor (i = 0, len = listeners.length; i < len; i++) {\r\n\t\t\t\tvar l = listeners[i];\r\n\t\t\t\tif (l.ctx !== context) { continue; }\r\n\t\t\t\tif (l.fn === fn) {\r\n\r\n\t\t\t\t\t// set the removed listener to noop so that's not called if remove happens in fire\r\n\t\t\t\t\tl.fn = L.Util.falseFn;\r\n\r\n\t\t\t\t\tif (this._firingCount) {\r\n\t\t\t\t\t\t/* copy array in case events are being fired */\r\n\t\t\t\t\t\tthis._events[type] = listeners = listeners.slice();\r\n\t\t\t\t\t}\r\n\t\t\t\t\tlisteners.splice(i, 1);\r\n\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// @method fire(type: String, data?: Object, propagate?: Boolean): this\r\n\t// Fires an event of the specified type. You can optionally provide an data\r\n\t// object — the first argument of the listener function will contain its\r\n\t// properties. The event can optionally be propagated to event parents.\r\n\tfire: function (type, data, propagate) {\r\n\t\tif (!this.listens(type, propagate)) { return this; }\r\n\r\n\t\tvar event = L.Util.extend({}, data, {type: type, target: this});\r\n\r\n\t\tif (this._events) {\r\n\t\t\tvar listeners = this._events[type];\r\n\r\n\t\t\tif (listeners) {\r\n\t\t\t\tthis._firingCount = (this._firingCount + 1) || 1;\r\n\t\t\t\tfor (var i = 0, len = listeners.length; i < len; i++) {\r\n\t\t\t\t\tvar l = listeners[i];\r\n\t\t\t\t\tl.fn.call(l.ctx || this, event);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis._firingCount--;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (propagate) {\r\n\t\t\t// propagate the event to parents (set with addEventParent)\r\n\t\t\tthis._propagateEvent(event);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method listens(type: String): Boolean\r\n\t// Returns `true` if a particular event type has any listeners attached to it.\r\n\tlistens: function (type, propagate) {\r\n\t\tvar listeners = this._events && this._events[type];\r\n\t\tif (listeners && listeners.length) { return true; }\r\n\r\n\t\tif (propagate) {\r\n\t\t\t// also check parents for listeners if event propagates\r\n\t\t\tfor (var id in this._eventParents) {\r\n\t\t\t\tif (this._eventParents[id].listens(type, propagate)) { return true; }\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t},\r\n\r\n\t// @method once(…): this\r\n\t// Behaves as [`on(…)`](#evented-on), except the listener will only get fired once and then removed.\r\n\tonce: function (types, fn, context) {\r\n\r\n\t\tif (typeof types === 'object') {\r\n\t\t\tfor (var type in types) {\r\n\t\t\t\tthis.once(type, types[type], fn);\r\n\t\t\t}\r\n\t\t\treturn this;\r\n\t\t}\r\n\r\n\t\tvar handler = L.bind(function () {\r\n\t\t\tthis\r\n\t\t\t .off(types, fn, context)\r\n\t\t\t .off(types, handler, context);\r\n\t\t}, this);\r\n\r\n\t\t// add a listener that's executed once and removed after that\r\n\t\treturn this\r\n\t\t .on(types, fn, context)\r\n\t\t .on(types, handler, context);\r\n\t},\r\n\r\n\t// @method addEventParent(obj: Evented): this\r\n\t// Adds an event parent - an `Evented` that will receive propagated events\r\n\taddEventParent: function (obj) {\r\n\t\tthis._eventParents = this._eventParents || {};\r\n\t\tthis._eventParents[L.stamp(obj)] = obj;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method removeEventParent(obj: Evented): this\r\n\t// Removes an event parent, so it will stop receiving propagated events\r\n\tremoveEventParent: function (obj) {\r\n\t\tif (this._eventParents) {\r\n\t\t\tdelete this._eventParents[L.stamp(obj)];\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_propagateEvent: function (e) {\r\n\t\tfor (var id in this._eventParents) {\r\n\t\t\tthis._eventParents[id].fire(e.type, L.extend({layer: e.target}, e), true);\r\n\t\t}\r\n\t}\r\n});\r\n\r\nvar proto = L.Evented.prototype;\r\n\r\n// aliases; we should ditch those eventually\r\n\r\n// @method addEventListener(…): this\r\n// Alias to [`on(…)`](#evented-on)\r\nproto.addEventListener = proto.on;\r\n\r\n// @method removeEventListener(…): this\r\n// Alias to [`off(…)`](#evented-off)\r\n\r\n// @method clearAllEventListeners(…): this\r\n// Alias to [`off()`](#evented-off)\r\nproto.removeEventListener = proto.clearAllEventListeners = proto.off;\r\n\r\n// @method addOneTimeEventListener(…): this\r\n// Alias to [`once(…)`](#evented-once)\r\nproto.addOneTimeEventListener = proto.once;\r\n\r\n// @method fireEvent(…): this\r\n// Alias to [`fire(…)`](#evented-fire)\r\nproto.fireEvent = proto.fire;\r\n\r\n// @method hasEventListeners(…): Boolean\r\n// Alias to [`listens(…)`](#evented-listens)\r\nproto.hasEventListeners = proto.listens;\r\n\r\nL.Mixin = {Events: proto};\r\n","/*\r\n * @namespace Browser\r\n * @aka L.Browser\r\n *\r\n * A namespace with static properties for browser/feature detection used by Leaflet internally.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * if (L.Browser.ielt9) {\r\n * alert('Upgrade your browser, dude!');\r\n * }\r\n * ```\r\n */\r\n\r\n(function () {\r\n\r\n\tvar ua = navigator.userAgent.toLowerCase(),\r\n\t doc = document.documentElement,\r\n\r\n\t ie = 'ActiveXObject' in window,\r\n\r\n\t webkit = ua.indexOf('webkit') !== -1,\r\n\t phantomjs = ua.indexOf('phantom') !== -1,\r\n\t android23 = ua.search('android [23]') !== -1,\r\n\t chrome = ua.indexOf('chrome') !== -1,\r\n\t gecko = ua.indexOf('gecko') !== -1 && !webkit && !window.opera && !ie,\r\n\r\n\t win = navigator.platform.indexOf('Win') === 0,\r\n\r\n\t mobile = typeof orientation !== 'undefined' || ua.indexOf('mobile') !== -1,\r\n\t msPointer = !window.PointerEvent && window.MSPointerEvent,\r\n\t pointer = window.PointerEvent || msPointer,\r\n\r\n\t ie3d = ie && ('transition' in doc.style),\r\n\t webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23,\r\n\t gecko3d = 'MozPerspective' in doc.style,\r\n\t opera12 = 'OTransition' in doc.style;\r\n\r\n\r\n\tvar touch = !window.L_NO_TOUCH && (pointer || 'ontouchstart' in window ||\r\n\t\t\t(window.DocumentTouch && document instanceof window.DocumentTouch));\r\n\r\n\tL.Browser = {\r\n\r\n\t\t// @property ie: Boolean\r\n\t\t// `true` for all Internet Explorer versions (not Edge).\r\n\t\tie: ie,\r\n\r\n\t\t// @property ielt9: Boolean\r\n\t\t// `true` for Internet Explorer versions less than 9.\r\n\t\tielt9: ie && !document.addEventListener,\r\n\r\n\t\t// @property edge: Boolean\r\n\t\t// `true` for the Edge web browser.\r\n\t\tedge: 'msLaunchUri' in navigator && !('documentMode' in document),\r\n\r\n\t\t// @property webkit: Boolean\r\n\t\t// `true` for webkit-based browsers like Chrome and Safari (including mobile versions).\r\n\t\twebkit: webkit,\r\n\r\n\t\t// @property gecko: Boolean\r\n\t\t// `true` for gecko-based browsers like Firefox.\r\n\t\tgecko: gecko,\r\n\r\n\t\t// @property android: Boolean\r\n\t\t// `true` for any browser running on an Android platform.\r\n\t\tandroid: ua.indexOf('android') !== -1,\r\n\r\n\t\t// @property android23: Boolean\r\n\t\t// `true` for browsers running on Android 2 or Android 3.\r\n\t\tandroid23: android23,\r\n\r\n\t\t// @property chrome: Boolean\r\n\t\t// `true` for the Chrome browser.\r\n\t\tchrome: chrome,\r\n\r\n\t\t// @property safari: Boolean\r\n\t\t// `true` for the Safari browser.\r\n\t\tsafari: !chrome && ua.indexOf('safari') !== -1,\r\n\r\n\r\n\t\t// @property win: Boolean\r\n\t\t// `true` when the browser is running in a Windows platform\r\n\t\twin: win,\r\n\r\n\r\n\t\t// @property ie3d: Boolean\r\n\t\t// `true` for all Internet Explorer versions supporting CSS transforms.\r\n\t\tie3d: ie3d,\r\n\r\n\t\t// @property webkit3d: Boolean\r\n\t\t// `true` for webkit-based browsers supporting CSS transforms.\r\n\t\twebkit3d: webkit3d,\r\n\r\n\t\t// @property gecko3d: Boolean\r\n\t\t// `true` for gecko-based browsers supporting CSS transforms.\r\n\t\tgecko3d: gecko3d,\r\n\r\n\t\t// @property opera12: Boolean\r\n\t\t// `true` for the Opera browser supporting CSS transforms (version 12 or later).\r\n\t\topera12: opera12,\r\n\r\n\t\t// @property any3d: Boolean\r\n\t\t// `true` for all browsers supporting CSS transforms.\r\n\t\tany3d: !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d) && !opera12 && !phantomjs,\r\n\r\n\r\n\t\t// @property mobile: Boolean\r\n\t\t// `true` for all browsers running in a mobile device.\r\n\t\tmobile: mobile,\r\n\r\n\t\t// @property mobileWebkit: Boolean\r\n\t\t// `true` for all webkit-based browsers in a mobile device.\r\n\t\tmobileWebkit: mobile && webkit,\r\n\r\n\t\t// @property mobileWebkit3d: Boolean\r\n\t\t// `true` for all webkit-based browsers in a mobile device supporting CSS transforms.\r\n\t\tmobileWebkit3d: mobile && webkit3d,\r\n\r\n\t\t// @property mobileOpera: Boolean\r\n\t\t// `true` for the Opera browser in a mobile device.\r\n\t\tmobileOpera: mobile && window.opera,\r\n\r\n\t\t// @property mobileGecko: Boolean\r\n\t\t// `true` for gecko-based browsers running in a mobile device.\r\n\t\tmobileGecko: mobile && gecko,\r\n\r\n\r\n\t\t// @property touch: Boolean\r\n\t\t// `true` for all browsers supporting [touch events](https://developer.mozilla.org/docs/Web/API/Touch_events).\r\n\t\ttouch: !!touch,\r\n\r\n\t\t// @property msPointer: Boolean\r\n\t\t// `true` for browsers implementing the Microsoft touch events model (notably IE10).\r\n\t\tmsPointer: !!msPointer,\r\n\r\n\t\t// @property pointer: Boolean\r\n\t\t// `true` for all browsers supporting [pointer events](https://msdn.microsoft.com/en-us/library/dn433244%28v=vs.85%29.aspx).\r\n\t\tpointer: !!pointer,\r\n\r\n\r\n\t\t// @property retina: Boolean\r\n\t\t// `true` for browsers on a high-resolution \"retina\" screen.\r\n\t\tretina: (window.devicePixelRatio || (window.screen.deviceXDPI / window.screen.logicalXDPI)) > 1\r\n\t};\r\n\r\n}());\r\n","/*\r\n * @class Point\r\n * @aka L.Point\r\n *\r\n * Represents a point with `x` and `y` coordinates in pixels.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var point = L.point(200, 300);\r\n * ```\r\n *\r\n * All Leaflet methods and options that accept `Point` objects also accept them in a simple Array form (unless noted otherwise), so these lines are equivalent:\r\n *\r\n * ```js\r\n * map.panBy([200, 300]);\r\n * map.panBy(L.point(200, 300));\r\n * ```\r\n */\r\n\r\nL.Point = function (x, y, round) {\r\n\t// @property x: Number; The `x` coordinate of the point\r\n\tthis.x = (round ? Math.round(x) : x);\r\n\t// @property y: Number; The `y` coordinate of the point\r\n\tthis.y = (round ? Math.round(y) : y);\r\n};\r\n\r\nL.Point.prototype = {\r\n\r\n\t// @method clone(): Point\r\n\t// Returns a copy of the current point.\r\n\tclone: function () {\r\n\t\treturn new L.Point(this.x, this.y);\r\n\t},\r\n\r\n\t// @method add(otherPoint: Point): Point\r\n\t// Returns the result of addition of the current and the given points.\r\n\tadd: function (point) {\r\n\t\t// non-destructive, returns a new point\r\n\t\treturn this.clone()._add(L.point(point));\r\n\t},\r\n\r\n\t_add: function (point) {\r\n\t\t// destructive, used directly for performance in situations where it's safe to modify existing point\r\n\t\tthis.x += point.x;\r\n\t\tthis.y += point.y;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method subtract(otherPoint: Point): Point\r\n\t// Returns the result of subtraction of the given point from the current.\r\n\tsubtract: function (point) {\r\n\t\treturn this.clone()._subtract(L.point(point));\r\n\t},\r\n\r\n\t_subtract: function (point) {\r\n\t\tthis.x -= point.x;\r\n\t\tthis.y -= point.y;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method divideBy(num: Number): Point\r\n\t// Returns the result of division of the current point by the given number.\r\n\tdivideBy: function (num) {\r\n\t\treturn this.clone()._divideBy(num);\r\n\t},\r\n\r\n\t_divideBy: function (num) {\r\n\t\tthis.x /= num;\r\n\t\tthis.y /= num;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method multiplyBy(num: Number): Point\r\n\t// Returns the result of multiplication of the current point by the given number.\r\n\tmultiplyBy: function (num) {\r\n\t\treturn this.clone()._multiplyBy(num);\r\n\t},\r\n\r\n\t_multiplyBy: function (num) {\r\n\t\tthis.x *= num;\r\n\t\tthis.y *= num;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method scaleBy(scale: Point): Point\r\n\t// Multiply each coordinate of the current point by each coordinate of\r\n\t// `scale`. In linear algebra terms, multiply the point by the\r\n\t// [scaling matrix](https://en.wikipedia.org/wiki/Scaling_%28geometry%29#Matrix_representation)\r\n\t// defined by `scale`.\r\n\tscaleBy: function (point) {\r\n\t\treturn new L.Point(this.x * point.x, this.y * point.y);\r\n\t},\r\n\r\n\t// @method unscaleBy(scale: Point): Point\r\n\t// Inverse of `scaleBy`. Divide each coordinate of the current point by\r\n\t// each coordinate of `scale`.\r\n\tunscaleBy: function (point) {\r\n\t\treturn new L.Point(this.x / point.x, this.y / point.y);\r\n\t},\r\n\r\n\t// @method round(): Point\r\n\t// Returns a copy of the current point with rounded coordinates.\r\n\tround: function () {\r\n\t\treturn this.clone()._round();\r\n\t},\r\n\r\n\t_round: function () {\r\n\t\tthis.x = Math.round(this.x);\r\n\t\tthis.y = Math.round(this.y);\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method floor(): Point\r\n\t// Returns a copy of the current point with floored coordinates (rounded down).\r\n\tfloor: function () {\r\n\t\treturn this.clone()._floor();\r\n\t},\r\n\r\n\t_floor: function () {\r\n\t\tthis.x = Math.floor(this.x);\r\n\t\tthis.y = Math.floor(this.y);\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method ceil(): Point\r\n\t// Returns a copy of the current point with ceiled coordinates (rounded up).\r\n\tceil: function () {\r\n\t\treturn this.clone()._ceil();\r\n\t},\r\n\r\n\t_ceil: function () {\r\n\t\tthis.x = Math.ceil(this.x);\r\n\t\tthis.y = Math.ceil(this.y);\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method distanceTo(otherPoint: Point): Number\r\n\t// Returns the cartesian distance between the current and the given points.\r\n\tdistanceTo: function (point) {\r\n\t\tpoint = L.point(point);\r\n\r\n\t\tvar x = point.x - this.x,\r\n\t\t y = point.y - this.y;\r\n\r\n\t\treturn Math.sqrt(x * x + y * y);\r\n\t},\r\n\r\n\t// @method equals(otherPoint: Point): Boolean\r\n\t// Returns `true` if the given point has the same coordinates.\r\n\tequals: function (point) {\r\n\t\tpoint = L.point(point);\r\n\r\n\t\treturn point.x === this.x &&\r\n\t\t point.y === this.y;\r\n\t},\r\n\r\n\t// @method contains(otherPoint: Point): Boolean\r\n\t// Returns `true` if both coordinates of the given point are less than the corresponding current point coordinates (in absolute values).\r\n\tcontains: function (point) {\r\n\t\tpoint = L.point(point);\r\n\r\n\t\treturn Math.abs(point.x) <= Math.abs(this.x) &&\r\n\t\t Math.abs(point.y) <= Math.abs(this.y);\r\n\t},\r\n\r\n\t// @method toString(): String\r\n\t// Returns a string representation of the point for debugging purposes.\r\n\ttoString: function () {\r\n\t\treturn 'Point(' +\r\n\t\t L.Util.formatNum(this.x) + ', ' +\r\n\t\t L.Util.formatNum(this.y) + ')';\r\n\t}\r\n};\r\n\r\n// @factory L.point(x: Number, y: Number, round?: Boolean)\r\n// Creates a Point object with the given `x` and `y` coordinates. If optional `round` is set to true, rounds the `x` and `y` values.\r\n\r\n// @alternative\r\n// @factory L.point(coords: Number[])\r\n// Expects an array of the form `[x, y]` instead.\r\n\r\n// @alternative\r\n// @factory L.point(coords: Object)\r\n// Expects a plain object of the form `{x: Number, y: Number}` instead.\r\nL.point = function (x, y, round) {\r\n\tif (x instanceof L.Point) {\r\n\t\treturn x;\r\n\t}\r\n\tif (L.Util.isArray(x)) {\r\n\t\treturn new L.Point(x[0], x[1]);\r\n\t}\r\n\tif (x === undefined || x === null) {\r\n\t\treturn x;\r\n\t}\r\n\tif (typeof x === 'object' && 'x' in x && 'y' in x) {\r\n\t\treturn new L.Point(x.x, x.y);\r\n\t}\r\n\treturn new L.Point(x, y, round);\r\n};\r\n","/*\r\n * @class Bounds\r\n * @aka L.Bounds\r\n *\r\n * Represents a rectangular area in pixel coordinates.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var p1 = L.point(10, 10),\r\n * p2 = L.point(40, 60),\r\n * bounds = L.bounds(p1, p2);\r\n * ```\r\n *\r\n * All Leaflet methods that accept `Bounds` objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:\r\n *\r\n * ```js\r\n * otherBounds.intersects([[10, 10], [40, 60]]);\r\n * ```\r\n */\r\n\r\nL.Bounds = function (a, b) {\r\n\tif (!a) { return; }\r\n\r\n\tvar points = b ? [a, b] : a;\r\n\r\n\tfor (var i = 0, len = points.length; i < len; i++) {\r\n\t\tthis.extend(points[i]);\r\n\t}\r\n};\r\n\r\nL.Bounds.prototype = {\r\n\t// @method extend(point: Point): this\r\n\t// Extends the bounds to contain the given point.\r\n\textend: function (point) { // (Point)\r\n\t\tpoint = L.point(point);\r\n\r\n\t\t// @property min: Point\r\n\t\t// The top left corner of the rectangle.\r\n\t\t// @property max: Point\r\n\t\t// The bottom right corner of the rectangle.\r\n\t\tif (!this.min && !this.max) {\r\n\t\t\tthis.min = point.clone();\r\n\t\t\tthis.max = point.clone();\r\n\t\t} else {\r\n\t\t\tthis.min.x = Math.min(point.x, this.min.x);\r\n\t\t\tthis.max.x = Math.max(point.x, this.max.x);\r\n\t\t\tthis.min.y = Math.min(point.y, this.min.y);\r\n\t\t\tthis.max.y = Math.max(point.y, this.max.y);\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method getCenter(round?: Boolean): Point\r\n\t// Returns the center point of the bounds.\r\n\tgetCenter: function (round) {\r\n\t\treturn new L.Point(\r\n\t\t (this.min.x + this.max.x) / 2,\r\n\t\t (this.min.y + this.max.y) / 2, round);\r\n\t},\r\n\r\n\t// @method getBottomLeft(): Point\r\n\t// Returns the bottom-left point of the bounds.\r\n\tgetBottomLeft: function () {\r\n\t\treturn new L.Point(this.min.x, this.max.y);\r\n\t},\r\n\r\n\t// @method getTopRight(): Point\r\n\t// Returns the top-right point of the bounds.\r\n\tgetTopRight: function () { // -> Point\r\n\t\treturn new L.Point(this.max.x, this.min.y);\r\n\t},\r\n\r\n\t// @method getSize(): Point\r\n\t// Returns the size of the given bounds\r\n\tgetSize: function () {\r\n\t\treturn this.max.subtract(this.min);\r\n\t},\r\n\r\n\t// @method contains(otherBounds: Bounds): Boolean\r\n\t// Returns `true` if the rectangle contains the given one.\r\n\t// @alternative\r\n\t// @method contains(point: Point): Boolean\r\n\t// Returns `true` if the rectangle contains the given point.\r\n\tcontains: function (obj) {\r\n\t\tvar min, max;\r\n\r\n\t\tif (typeof obj[0] === 'number' || obj instanceof L.Point) {\r\n\t\t\tobj = L.point(obj);\r\n\t\t} else {\r\n\t\t\tobj = L.bounds(obj);\r\n\t\t}\r\n\r\n\t\tif (obj instanceof L.Bounds) {\r\n\t\t\tmin = obj.min;\r\n\t\t\tmax = obj.max;\r\n\t\t} else {\r\n\t\t\tmin = max = obj;\r\n\t\t}\r\n\r\n\t\treturn (min.x >= this.min.x) &&\r\n\t\t (max.x <= this.max.x) &&\r\n\t\t (min.y >= this.min.y) &&\r\n\t\t (max.y <= this.max.y);\r\n\t},\r\n\r\n\t// @method intersects(otherBounds: Bounds): Boolean\r\n\t// Returns `true` if the rectangle intersects the given bounds. Two bounds\r\n\t// intersect if they have at least one point in common.\r\n\tintersects: function (bounds) { // (Bounds) -> Boolean\r\n\t\tbounds = L.bounds(bounds);\r\n\r\n\t\tvar min = this.min,\r\n\t\t max = this.max,\r\n\t\t min2 = bounds.min,\r\n\t\t max2 = bounds.max,\r\n\t\t xIntersects = (max2.x >= min.x) && (min2.x <= max.x),\r\n\t\t yIntersects = (max2.y >= min.y) && (min2.y <= max.y);\r\n\r\n\t\treturn xIntersects && yIntersects;\r\n\t},\r\n\r\n\t// @method overlaps(otherBounds: Bounds): Boolean\r\n\t// Returns `true` if the rectangle overlaps the given bounds. Two bounds\r\n\t// overlap if their intersection is an area.\r\n\toverlaps: function (bounds) { // (Bounds) -> Boolean\r\n\t\tbounds = L.bounds(bounds);\r\n\r\n\t\tvar min = this.min,\r\n\t\t max = this.max,\r\n\t\t min2 = bounds.min,\r\n\t\t max2 = bounds.max,\r\n\t\t xOverlaps = (max2.x > min.x) && (min2.x < max.x),\r\n\t\t yOverlaps = (max2.y > min.y) && (min2.y < max.y);\r\n\r\n\t\treturn xOverlaps && yOverlaps;\r\n\t},\r\n\r\n\tisValid: function () {\r\n\t\treturn !!(this.min && this.max);\r\n\t}\r\n};\r\n\r\n\r\n// @factory L.bounds(topLeft: Point, bottomRight: Point)\r\n// Creates a Bounds object from two coordinates (usually top-left and bottom-right corners).\r\n// @alternative\r\n// @factory L.bounds(points: Point[])\r\n// Creates a Bounds object from the points it contains\r\nL.bounds = function (a, b) {\r\n\tif (!a || a instanceof L.Bounds) {\r\n\t\treturn a;\r\n\t}\r\n\treturn new L.Bounds(a, b);\r\n};\r\n","/*\r\n * @class Transformation\r\n * @aka L.Transformation\r\n *\r\n * Represents an affine transformation: a set of coefficients `a`, `b`, `c`, `d`\r\n * for transforming a point of a form `(x, y)` into `(a*x + b, c*y + d)` and doing\r\n * the reverse. Used by Leaflet in its projections code.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var transformation = new L.Transformation(2, 5, -1, 10),\r\n * \tp = L.point(1, 2),\r\n * \tp2 = transformation.transform(p), // L.point(7, 8)\r\n * \tp3 = transformation.untransform(p2); // L.point(1, 2)\r\n * ```\r\n */\r\n\r\n\r\n// factory new L.Transformation(a: Number, b: Number, c: Number, d: Number)\r\n// Creates a `Transformation` object with the given coefficients.\r\nL.Transformation = function (a, b, c, d) {\r\n\tthis._a = a;\r\n\tthis._b = b;\r\n\tthis._c = c;\r\n\tthis._d = d;\r\n};\r\n\r\nL.Transformation.prototype = {\r\n\t// @method transform(point: Point, scale?: Number): Point\r\n\t// Returns a transformed point, optionally multiplied by the given scale.\r\n\t// Only accepts actual `L.Point` instances, not arrays.\r\n\ttransform: function (point, scale) { // (Point, Number) -> Point\r\n\t\treturn this._transform(point.clone(), scale);\r\n\t},\r\n\r\n\t// destructive transform (faster)\r\n\t_transform: function (point, scale) {\r\n\t\tscale = scale || 1;\r\n\t\tpoint.x = scale * (this._a * point.x + this._b);\r\n\t\tpoint.y = scale * (this._c * point.y + this._d);\r\n\t\treturn point;\r\n\t},\r\n\r\n\t// @method untransform(point: Point, scale?: Number): Point\r\n\t// Returns the reverse transformation of the given point, optionally divided\r\n\t// by the given scale. Only accepts actual `L.Point` instances, not arrays.\r\n\tuntransform: function (point, scale) {\r\n\t\tscale = scale || 1;\r\n\t\treturn new L.Point(\r\n\t\t (point.x / scale - this._b) / this._a,\r\n\t\t (point.y / scale - this._d) / this._c);\r\n\t}\r\n};\r\n","/*\r\n * @namespace DomUtil\r\n *\r\n * Utility functions to work with the [DOM](https://developer.mozilla.org/docs/Web/API/Document_Object_Model)\r\n * tree, used by Leaflet internally.\r\n *\r\n * Most functions expecting or returning a `HTMLElement` also work for\r\n * SVG elements. The only difference is that classes refer to CSS classes\r\n * in HTML and SVG classes in SVG.\r\n */\r\n\r\nL.DomUtil = {\r\n\r\n\t// @function get(id: String|HTMLElement): HTMLElement\r\n\t// Returns an element given its DOM id, or returns the element itself\r\n\t// if it was passed directly.\r\n\tget: function (id) {\r\n\t\treturn typeof id === 'string' ? document.getElementById(id) : id;\r\n\t},\r\n\r\n\t// @function getStyle(el: HTMLElement, styleAttrib: String): String\r\n\t// Returns the value for a certain style attribute on an element,\r\n\t// including computed values or values set through CSS.\r\n\tgetStyle: function (el, style) {\r\n\r\n\t\tvar value = el.style[style] || (el.currentStyle && el.currentStyle[style]);\r\n\r\n\t\tif ((!value || value === 'auto') && document.defaultView) {\r\n\t\t\tvar css = document.defaultView.getComputedStyle(el, null);\r\n\t\t\tvalue = css ? css[style] : null;\r\n\t\t}\r\n\r\n\t\treturn value === 'auto' ? null : value;\r\n\t},\r\n\r\n\t// @function create(tagName: String, className?: String, container?: HTMLElement): HTMLElement\r\n\t// Creates an HTML element with `tagName`, sets its class to `className`, and optionally appends it to `container` element.\r\n\tcreate: function (tagName, className, container) {\r\n\r\n\t\tvar el = document.createElement(tagName);\r\n\t\tel.className = className || '';\r\n\r\n\t\tif (container) {\r\n\t\t\tcontainer.appendChild(el);\r\n\t\t}\r\n\r\n\t\treturn el;\r\n\t},\r\n\r\n\t// @function remove(el: HTMLElement)\r\n\t// Removes `el` from its parent element\r\n\tremove: function (el) {\r\n\t\tvar parent = el.parentNode;\r\n\t\tif (parent) {\r\n\t\t\tparent.removeChild(el);\r\n\t\t}\r\n\t},\r\n\r\n\t// @function empty(el: HTMLElement)\r\n\t// Removes all of `el`'s children elements from `el`\r\n\tempty: function (el) {\r\n\t\twhile (el.firstChild) {\r\n\t\t\tel.removeChild(el.firstChild);\r\n\t\t}\r\n\t},\r\n\r\n\t// @function toFront(el: HTMLElement)\r\n\t// Makes `el` the last children of its parent, so it renders in front of the other children.\r\n\ttoFront: function (el) {\r\n\t\tel.parentNode.appendChild(el);\r\n\t},\r\n\r\n\t// @function toBack(el: HTMLElement)\r\n\t// Makes `el` the first children of its parent, so it renders back from the other children.\r\n\ttoBack: function (el) {\r\n\t\tvar parent = el.parentNode;\r\n\t\tparent.insertBefore(el, parent.firstChild);\r\n\t},\r\n\r\n\t// @function hasClass(el: HTMLElement, name: String): Boolean\r\n\t// Returns `true` if the element's class attribute contains `name`.\r\n\thasClass: function (el, name) {\r\n\t\tif (el.classList !== undefined) {\r\n\t\t\treturn el.classList.contains(name);\r\n\t\t}\r\n\t\tvar className = L.DomUtil.getClass(el);\r\n\t\treturn className.length > 0 && new RegExp('(^|\\\\s)' + name + '(\\\\s|$)').test(className);\r\n\t},\r\n\r\n\t// @function addClass(el: HTMLElement, name: String)\r\n\t// Adds `name` to the element's class attribute.\r\n\taddClass: function (el, name) {\r\n\t\tif (el.classList !== undefined) {\r\n\t\t\tvar classes = L.Util.splitWords(name);\r\n\t\t\tfor (var i = 0, len = classes.length; i < len; i++) {\r\n\t\t\t\tel.classList.add(classes[i]);\r\n\t\t\t}\r\n\t\t} else if (!L.DomUtil.hasClass(el, name)) {\r\n\t\t\tvar className = L.DomUtil.getClass(el);\r\n\t\t\tL.DomUtil.setClass(el, (className ? className + ' ' : '') + name);\r\n\t\t}\r\n\t},\r\n\r\n\t// @function removeClass(el: HTMLElement, name: String)\r\n\t// Removes `name` from the element's class attribute.\r\n\tremoveClass: function (el, name) {\r\n\t\tif (el.classList !== undefined) {\r\n\t\t\tel.classList.remove(name);\r\n\t\t} else {\r\n\t\t\tL.DomUtil.setClass(el, L.Util.trim((' ' + L.DomUtil.getClass(el) + ' ').replace(' ' + name + ' ', ' ')));\r\n\t\t}\r\n\t},\r\n\r\n\t// @function setClass(el: HTMLElement, name: String)\r\n\t// Sets the element's class.\r\n\tsetClass: function (el, name) {\r\n\t\tif (el.className.baseVal === undefined) {\r\n\t\t\tel.className = name;\r\n\t\t} else {\r\n\t\t\t// in case of SVG element\r\n\t\t\tel.className.baseVal = name;\r\n\t\t}\r\n\t},\r\n\r\n\t// @function getClass(el: HTMLElement): String\r\n\t// Returns the element's class.\r\n\tgetClass: function (el) {\r\n\t\treturn el.className.baseVal === undefined ? el.className : el.className.baseVal;\r\n\t},\r\n\r\n\t// @function setOpacity(el: HTMLElement, opacity: Number)\r\n\t// Set the opacity of an element (including old IE support).\r\n\t// `opacity` must be a number from `0` to `1`.\r\n\tsetOpacity: function (el, value) {\r\n\r\n\t\tif ('opacity' in el.style) {\r\n\t\t\tel.style.opacity = value;\r\n\r\n\t\t} else if ('filter' in el.style) {\r\n\t\t\tL.DomUtil._setOpacityIE(el, value);\r\n\t\t}\r\n\t},\r\n\r\n\t_setOpacityIE: function (el, value) {\r\n\t\tvar filter = false,\r\n\t\t filterName = 'DXImageTransform.Microsoft.Alpha';\r\n\r\n\t\t// filters collection throws an error if we try to retrieve a filter that doesn't exist\r\n\t\ttry {\r\n\t\t\tfilter = el.filters.item(filterName);\r\n\t\t} catch (e) {\r\n\t\t\t// don't set opacity to 1 if we haven't already set an opacity,\r\n\t\t\t// it isn't needed and breaks transparent pngs.\r\n\t\t\tif (value === 1) { return; }\r\n\t\t}\r\n\r\n\t\tvalue = Math.round(value * 100);\r\n\r\n\t\tif (filter) {\r\n\t\t\tfilter.Enabled = (value !== 100);\r\n\t\t\tfilter.Opacity = value;\r\n\t\t} else {\r\n\t\t\tel.style.filter += ' progid:' + filterName + '(opacity=' + value + ')';\r\n\t\t}\r\n\t},\r\n\r\n\t// @function testProp(props: String[]): String|false\r\n\t// Goes through the array of style names and returns the first name\r\n\t// that is a valid style name for an element. If no such name is found,\r\n\t// it returns false. Useful for vendor-prefixed styles like `transform`.\r\n\ttestProp: function (props) {\r\n\r\n\t\tvar style = document.documentElement.style;\r\n\r\n\t\tfor (var i = 0; i < props.length; i++) {\r\n\t\t\tif (props[i] in style) {\r\n\t\t\t\treturn props[i];\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t},\r\n\r\n\t// @function setTransform(el: HTMLElement, offset: Point, scale?: Number)\r\n\t// Resets the 3D CSS transform of `el` so it is translated by `offset` pixels\r\n\t// and optionally scaled by `scale`. Does not have an effect if the\r\n\t// browser doesn't support 3D CSS transforms.\r\n\tsetTransform: function (el, offset, scale) {\r\n\t\tvar pos = offset || new L.Point(0, 0);\r\n\r\n\t\tel.style[L.DomUtil.TRANSFORM] =\r\n\t\t\t(L.Browser.ie3d ?\r\n\t\t\t\t'translate(' + pos.x + 'px,' + pos.y + 'px)' :\r\n\t\t\t\t'translate3d(' + pos.x + 'px,' + pos.y + 'px,0)') +\r\n\t\t\t(scale ? ' scale(' + scale + ')' : '');\r\n\t},\r\n\r\n\t// @function setPosition(el: HTMLElement, position: Point)\r\n\t// Sets the position of `el` to coordinates specified by `position`,\r\n\t// using CSS translate or top/left positioning depending on the browser\r\n\t// (used by Leaflet internally to position its layers).\r\n\tsetPosition: function (el, point) { // (HTMLElement, Point[, Boolean])\r\n\r\n\t\t/*eslint-disable */\r\n\t\tel._leaflet_pos = point;\r\n\t\t/*eslint-enable */\r\n\r\n\t\tif (L.Browser.any3d) {\r\n\t\t\tL.DomUtil.setTransform(el, point);\r\n\t\t} else {\r\n\t\t\tel.style.left = point.x + 'px';\r\n\t\t\tel.style.top = point.y + 'px';\r\n\t\t}\r\n\t},\r\n\r\n\t// @function getPosition(el: HTMLElement): Point\r\n\t// Returns the coordinates of an element previously positioned with setPosition.\r\n\tgetPosition: function (el) {\r\n\t\t// this method is only used for elements previously positioned using setPosition,\r\n\t\t// so it's safe to cache the position for performance\r\n\r\n\t\treturn el._leaflet_pos || new L.Point(0, 0);\r\n\t}\r\n};\r\n\r\n\r\n(function () {\r\n\t// prefix style property names\r\n\r\n\t// @property TRANSFORM: String\r\n\t// Vendor-prefixed fransform style name (e.g. `'webkitTransform'` for WebKit).\r\n\tL.DomUtil.TRANSFORM = L.DomUtil.testProp(\r\n\t\t\t['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform']);\r\n\r\n\r\n\t// webkitTransition comes first because some browser versions that drop vendor prefix don't do\r\n\t// the same for the transitionend event, in particular the Android 4.1 stock browser\r\n\r\n\t// @property TRANSITION: String\r\n\t// Vendor-prefixed transform style name.\r\n\tvar transition = L.DomUtil.TRANSITION = L.DomUtil.testProp(\r\n\t\t\t['webkitTransition', 'transition', 'OTransition', 'MozTransition', 'msTransition']);\r\n\r\n\tL.DomUtil.TRANSITION_END =\r\n\t\t\ttransition === 'webkitTransition' || transition === 'OTransition' ? transition + 'End' : 'transitionend';\r\n\r\n\t// @function disableTextSelection()\r\n\t// Prevents the user from generating `selectstart` DOM events, usually generated\r\n\t// when the user drags the mouse through a page with text. Used internally\r\n\t// by Leaflet to override the behaviour of any click-and-drag interaction on\r\n\t// the map. Affects drag interactions on the whole document.\r\n\r\n\t// @function enableTextSelection()\r\n\t// Cancels the effects of a previous [`L.DomUtil.disableTextSelection`](#domutil-disabletextselection).\r\n\tif ('onselectstart' in document) {\r\n\t\tL.DomUtil.disableTextSelection = function () {\r\n\t\t\tL.DomEvent.on(window, 'selectstart', L.DomEvent.preventDefault);\r\n\t\t};\r\n\t\tL.DomUtil.enableTextSelection = function () {\r\n\t\t\tL.DomEvent.off(window, 'selectstart', L.DomEvent.preventDefault);\r\n\t\t};\r\n\r\n\t} else {\r\n\t\tvar userSelectProperty = L.DomUtil.testProp(\r\n\t\t\t['userSelect', 'WebkitUserSelect', 'OUserSelect', 'MozUserSelect', 'msUserSelect']);\r\n\r\n\t\tL.DomUtil.disableTextSelection = function () {\r\n\t\t\tif (userSelectProperty) {\r\n\t\t\t\tvar style = document.documentElement.style;\r\n\t\t\t\tthis._userSelect = style[userSelectProperty];\r\n\t\t\t\tstyle[userSelectProperty] = 'none';\r\n\t\t\t}\r\n\t\t};\r\n\t\tL.DomUtil.enableTextSelection = function () {\r\n\t\t\tif (userSelectProperty) {\r\n\t\t\t\tdocument.documentElement.style[userSelectProperty] = this._userSelect;\r\n\t\t\t\tdelete this._userSelect;\r\n\t\t\t}\r\n\t\t};\r\n\t}\r\n\r\n\t// @function disableImageDrag()\r\n\t// As [`L.DomUtil.disableTextSelection`](#domutil-disabletextselection), but\r\n\t// for `dragstart` DOM events, usually generated when the user drags an image.\r\n\tL.DomUtil.disableImageDrag = function () {\r\n\t\tL.DomEvent.on(window, 'dragstart', L.DomEvent.preventDefault);\r\n\t};\r\n\r\n\t// @function enableImageDrag()\r\n\t// Cancels the effects of a previous [`L.DomUtil.disableImageDrag`](#domutil-disabletextselection).\r\n\tL.DomUtil.enableImageDrag = function () {\r\n\t\tL.DomEvent.off(window, 'dragstart', L.DomEvent.preventDefault);\r\n\t};\r\n\r\n\t// @function preventOutline(el: HTMLElement)\r\n\t// Makes the [outline](https://developer.mozilla.org/docs/Web/CSS/outline)\r\n\t// of the element `el` invisible. Used internally by Leaflet to prevent\r\n\t// focusable elements from displaying an outline when the user performs a\r\n\t// drag interaction on them.\r\n\tL.DomUtil.preventOutline = function (element) {\r\n\t\twhile (element.tabIndex === -1) {\r\n\t\t\telement = element.parentNode;\r\n\t\t}\r\n\t\tif (!element || !element.style) { return; }\r\n\t\tL.DomUtil.restoreOutline();\r\n\t\tthis._outlineElement = element;\r\n\t\tthis._outlineStyle = element.style.outline;\r\n\t\telement.style.outline = 'none';\r\n\t\tL.DomEvent.on(window, 'keydown', L.DomUtil.restoreOutline, this);\r\n\t};\r\n\r\n\t// @function restoreOutline()\r\n\t// Cancels the effects of a previous [`L.DomUtil.preventOutline`]().\r\n\tL.DomUtil.restoreOutline = function () {\r\n\t\tif (!this._outlineElement) { return; }\r\n\t\tthis._outlineElement.style.outline = this._outlineStyle;\r\n\t\tdelete this._outlineElement;\r\n\t\tdelete this._outlineStyle;\r\n\t\tL.DomEvent.off(window, 'keydown', L.DomUtil.restoreOutline, this);\r\n\t};\r\n})();\r\n","/* @class LatLng\r\n * @aka L.LatLng\r\n *\r\n * Represents a geographical point with a certain latitude and longitude.\r\n *\r\n * @example\r\n *\r\n * ```\r\n * var latlng = L.latLng(50.5, 30.5);\r\n * ```\r\n *\r\n * All Leaflet methods that accept LatLng objects also accept them in a simple Array form and simple object form (unless noted otherwise), so these lines are equivalent:\r\n *\r\n * ```\r\n * map.panTo([50, 30]);\r\n * map.panTo({lon: 30, lat: 50});\r\n * map.panTo({lat: 50, lng: 30});\r\n * map.panTo(L.latLng(50, 30));\r\n * ```\r\n */\r\n\r\nL.LatLng = function (lat, lng, alt) {\r\n\tif (isNaN(lat) || isNaN(lng)) {\r\n\t\tthrow new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')');\r\n\t}\r\n\r\n\t// @property lat: Number\r\n\t// Latitude in degrees\r\n\tthis.lat = +lat;\r\n\r\n\t// @property lng: Number\r\n\t// Longitude in degrees\r\n\tthis.lng = +lng;\r\n\r\n\t// @property alt: Number\r\n\t// Altitude in meters (optional)\r\n\tif (alt !== undefined) {\r\n\t\tthis.alt = +alt;\r\n\t}\r\n};\r\n\r\nL.LatLng.prototype = {\r\n\t// @method equals(otherLatLng: LatLng, maxMargin?: Number): Boolean\r\n\t// Returns `true` if the given `LatLng` point is at the same position (within a small margin of error). The margin of error can be overriden by setting `maxMargin` to a small number.\r\n\tequals: function (obj, maxMargin) {\r\n\t\tif (!obj) { return false; }\r\n\r\n\t\tobj = L.latLng(obj);\r\n\r\n\t\tvar margin = Math.max(\r\n\t\t Math.abs(this.lat - obj.lat),\r\n\t\t Math.abs(this.lng - obj.lng));\r\n\r\n\t\treturn margin <= (maxMargin === undefined ? 1.0E-9 : maxMargin);\r\n\t},\r\n\r\n\t// @method toString(): String\r\n\t// Returns a string representation of the point (for debugging purposes).\r\n\ttoString: function (precision) {\r\n\t\treturn 'LatLng(' +\r\n\t\t L.Util.formatNum(this.lat, precision) + ', ' +\r\n\t\t L.Util.formatNum(this.lng, precision) + ')';\r\n\t},\r\n\r\n\t// @method distanceTo(otherLatLng: LatLng): Number\r\n\t// Returns the distance (in meters) to the given `LatLng` calculated using the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula).\r\n\tdistanceTo: function (other) {\r\n\t\treturn L.CRS.Earth.distance(this, L.latLng(other));\r\n\t},\r\n\r\n\t// @method wrap(): LatLng\r\n\t// Returns a new `LatLng` object with the longitude wrapped so it's always between -180 and +180 degrees.\r\n\twrap: function () {\r\n\t\treturn L.CRS.Earth.wrapLatLng(this);\r\n\t},\r\n\r\n\t// @method toBounds(sizeInMeters: Number): LatLngBounds\r\n\t// Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters` meters apart from the `LatLng`.\r\n\ttoBounds: function (sizeInMeters) {\r\n\t\tvar latAccuracy = 180 * sizeInMeters / 40075017,\r\n\t\t lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);\r\n\r\n\t\treturn L.latLngBounds(\r\n\t\t [this.lat - latAccuracy, this.lng - lngAccuracy],\r\n\t\t [this.lat + latAccuracy, this.lng + lngAccuracy]);\r\n\t},\r\n\r\n\tclone: function () {\r\n\t\treturn new L.LatLng(this.lat, this.lng, this.alt);\r\n\t}\r\n};\r\n\r\n\r\n\r\n// @factory L.latLng(latitude: Number, longitude: Number, altitude?: Number): LatLng\r\n// Creates an object representing a geographical point with the given latitude and longitude (and optionally altitude).\r\n\r\n// @alternative\r\n// @factory L.latLng(coords: Array): LatLng\r\n// Expects an array of the form `[Number, Number]` or `[Number, Number, Number]` instead.\r\n\r\n// @alternative\r\n// @factory L.latLng(coords: Object): LatLng\r\n// Expects an plain object of the form `{lat: Number, lng: Number}` or `{lat: Number, lng: Number, alt: Number}` instead.\r\n\r\nL.latLng = function (a, b, c) {\r\n\tif (a instanceof L.LatLng) {\r\n\t\treturn a;\r\n\t}\r\n\tif (L.Util.isArray(a) && typeof a[0] !== 'object') {\r\n\t\tif (a.length === 3) {\r\n\t\t\treturn new L.LatLng(a[0], a[1], a[2]);\r\n\t\t}\r\n\t\tif (a.length === 2) {\r\n\t\t\treturn new L.LatLng(a[0], a[1]);\r\n\t\t}\r\n\t\treturn null;\r\n\t}\r\n\tif (a === undefined || a === null) {\r\n\t\treturn a;\r\n\t}\r\n\tif (typeof a === 'object' && 'lat' in a) {\r\n\t\treturn new L.LatLng(a.lat, 'lng' in a ? a.lng : a.lon, a.alt);\r\n\t}\r\n\tif (b === undefined) {\r\n\t\treturn null;\r\n\t}\r\n\treturn new L.LatLng(a, b, c);\r\n};\r\n","/*\r\n * @class LatLngBounds\r\n * @aka L.LatLngBounds\r\n *\r\n * Represents a rectangular geographical area on a map.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var corner1 = L.latLng(40.712, -74.227),\r\n * corner2 = L.latLng(40.774, -74.125),\r\n * bounds = L.latLngBounds(corner1, corner2);\r\n * ```\r\n *\r\n * All Leaflet methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:\r\n *\r\n * ```js\r\n * map.fitBounds([\r\n * \t[40.712, -74.227],\r\n * \t[40.774, -74.125]\r\n * ]);\r\n * ```\r\n *\r\n * Caution: if the area crosses the antimeridian (often confused with the International Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range.\r\n */\r\n\r\nL.LatLngBounds = function (corner1, corner2) { // (LatLng, LatLng) or (LatLng[])\r\n\tif (!corner1) { return; }\r\n\r\n\tvar latlngs = corner2 ? [corner1, corner2] : corner1;\r\n\r\n\tfor (var i = 0, len = latlngs.length; i < len; i++) {\r\n\t\tthis.extend(latlngs[i]);\r\n\t}\r\n};\r\n\r\nL.LatLngBounds.prototype = {\r\n\r\n\t// @method extend(latlng: LatLng): this\r\n\t// Extend the bounds to contain the given point\r\n\r\n\t// @alternative\r\n\t// @method extend(otherBounds: LatLngBounds): this\r\n\t// Extend the bounds to contain the given bounds\r\n\textend: function (obj) {\r\n\t\tvar sw = this._southWest,\r\n\t\t ne = this._northEast,\r\n\t\t sw2, ne2;\r\n\r\n\t\tif (obj instanceof L.LatLng) {\r\n\t\t\tsw2 = obj;\r\n\t\t\tne2 = obj;\r\n\r\n\t\t} else if (obj instanceof L.LatLngBounds) {\r\n\t\t\tsw2 = obj._southWest;\r\n\t\t\tne2 = obj._northEast;\r\n\r\n\t\t\tif (!sw2 || !ne2) { return this; }\r\n\r\n\t\t} else {\r\n\t\t\treturn obj ? this.extend(L.latLng(obj) || L.latLngBounds(obj)) : this;\r\n\t\t}\r\n\r\n\t\tif (!sw && !ne) {\r\n\t\t\tthis._southWest = new L.LatLng(sw2.lat, sw2.lng);\r\n\t\t\tthis._northEast = new L.LatLng(ne2.lat, ne2.lng);\r\n\t\t} else {\r\n\t\t\tsw.lat = Math.min(sw2.lat, sw.lat);\r\n\t\t\tsw.lng = Math.min(sw2.lng, sw.lng);\r\n\t\t\tne.lat = Math.max(ne2.lat, ne.lat);\r\n\t\t\tne.lng = Math.max(ne2.lng, ne.lng);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method pad(bufferRatio: Number): LatLngBounds\r\n\t// Returns bigger bounds created by extending the current bounds by a given percentage in each direction.\r\n\tpad: function (bufferRatio) {\r\n\t\tvar sw = this._southWest,\r\n\t\t ne = this._northEast,\r\n\t\t heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,\r\n\t\t widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;\r\n\r\n\t\treturn new L.LatLngBounds(\r\n\t\t new L.LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer),\r\n\t\t new L.LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));\r\n\t},\r\n\r\n\t// @method getCenter(): LatLng\r\n\t// Returns the center point of the bounds.\r\n\tgetCenter: function () {\r\n\t\treturn new L.LatLng(\r\n\t\t (this._southWest.lat + this._northEast.lat) / 2,\r\n\t\t (this._southWest.lng + this._northEast.lng) / 2);\r\n\t},\r\n\r\n\t// @method getSouthWest(): LatLng\r\n\t// Returns the south-west point of the bounds.\r\n\tgetSouthWest: function () {\r\n\t\treturn this._southWest;\r\n\t},\r\n\r\n\t// @method getNorthEast(): LatLng\r\n\t// Returns the north-east point of the bounds.\r\n\tgetNorthEast: function () {\r\n\t\treturn this._northEast;\r\n\t},\r\n\r\n\t// @method getNorthWest(): LatLng\r\n\t// Returns the north-west point of the bounds.\r\n\tgetNorthWest: function () {\r\n\t\treturn new L.LatLng(this.getNorth(), this.getWest());\r\n\t},\r\n\r\n\t// @method getSouthEast(): LatLng\r\n\t// Returns the south-east point of the bounds.\r\n\tgetSouthEast: function () {\r\n\t\treturn new L.LatLng(this.getSouth(), this.getEast());\r\n\t},\r\n\r\n\t// @method getWest(): Number\r\n\t// Returns the west longitude of the bounds\r\n\tgetWest: function () {\r\n\t\treturn this._southWest.lng;\r\n\t},\r\n\r\n\t// @method getSouth(): Number\r\n\t// Returns the south latitude of the bounds\r\n\tgetSouth: function () {\r\n\t\treturn this._southWest.lat;\r\n\t},\r\n\r\n\t// @method getEast(): Number\r\n\t// Returns the east longitude of the bounds\r\n\tgetEast: function () {\r\n\t\treturn this._northEast.lng;\r\n\t},\r\n\r\n\t// @method getNorth(): Number\r\n\t// Returns the north latitude of the bounds\r\n\tgetNorth: function () {\r\n\t\treturn this._northEast.lat;\r\n\t},\r\n\r\n\t// @method contains(otherBounds: LatLngBounds): Boolean\r\n\t// Returns `true` if the rectangle contains the given one.\r\n\r\n\t// @alternative\r\n\t// @method contains (latlng: LatLng): Boolean\r\n\t// Returns `true` if the rectangle contains the given point.\r\n\tcontains: function (obj) { // (LatLngBounds) or (LatLng) -> Boolean\r\n\t\tif (typeof obj[0] === 'number' || obj instanceof L.LatLng) {\r\n\t\t\tobj = L.latLng(obj);\r\n\t\t} else {\r\n\t\t\tobj = L.latLngBounds(obj);\r\n\t\t}\r\n\r\n\t\tvar sw = this._southWest,\r\n\t\t ne = this._northEast,\r\n\t\t sw2, ne2;\r\n\r\n\t\tif (obj instanceof L.LatLngBounds) {\r\n\t\t\tsw2 = obj.getSouthWest();\r\n\t\t\tne2 = obj.getNorthEast();\r\n\t\t} else {\r\n\t\t\tsw2 = ne2 = obj;\r\n\t\t}\r\n\r\n\t\treturn (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) &&\r\n\t\t (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);\r\n\t},\r\n\r\n\t// @method intersects(otherBounds: LatLngBounds): Boolean\r\n\t// Returns `true` if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common.\r\n\tintersects: function (bounds) {\r\n\t\tbounds = L.latLngBounds(bounds);\r\n\r\n\t\tvar sw = this._southWest,\r\n\t\t ne = this._northEast,\r\n\t\t sw2 = bounds.getSouthWest(),\r\n\t\t ne2 = bounds.getNorthEast(),\r\n\r\n\t\t latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat),\r\n\t\t lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng);\r\n\r\n\t\treturn latIntersects && lngIntersects;\r\n\t},\r\n\r\n\t// @method overlaps(otherBounds: Bounds): Boolean\r\n\t// Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area.\r\n\toverlaps: function (bounds) {\r\n\t\tbounds = L.latLngBounds(bounds);\r\n\r\n\t\tvar sw = this._southWest,\r\n\t\t ne = this._northEast,\r\n\t\t sw2 = bounds.getSouthWest(),\r\n\t\t ne2 = bounds.getNorthEast(),\r\n\r\n\t\t latOverlaps = (ne2.lat > sw.lat) && (sw2.lat < ne.lat),\r\n\t\t lngOverlaps = (ne2.lng > sw.lng) && (sw2.lng < ne.lng);\r\n\r\n\t\treturn latOverlaps && lngOverlaps;\r\n\t},\r\n\r\n\t// @method toBBoxString(): String\r\n\t// Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data.\r\n\ttoBBoxString: function () {\r\n\t\treturn [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',');\r\n\t},\r\n\r\n\t// @method equals(otherBounds: LatLngBounds): Boolean\r\n\t// Returns `true` if the rectangle is equivalent (within a small margin of error) to the given bounds.\r\n\tequals: function (bounds) {\r\n\t\tif (!bounds) { return false; }\r\n\r\n\t\tbounds = L.latLngBounds(bounds);\r\n\r\n\t\treturn this._southWest.equals(bounds.getSouthWest()) &&\r\n\t\t this._northEast.equals(bounds.getNorthEast());\r\n\t},\r\n\r\n\t// @method isValid(): Boolean\r\n\t// Returns `true` if the bounds are properly initialized.\r\n\tisValid: function () {\r\n\t\treturn !!(this._southWest && this._northEast);\r\n\t}\r\n};\r\n\r\n// TODO International date line?\r\n\r\n// @factory L.latLngBounds(corner1: LatLng, corner2: LatLng)\r\n// Creates a `LatLngBounds` object by defining two diagonally opposite corners of the rectangle.\r\n\r\n// @alternative\r\n// @factory L.latLngBounds(latlngs: LatLng[])\r\n// Creates a `LatLngBounds` object defined by the geographical points it contains. Very useful for zooming the map to fit a particular set of locations with [`fitBounds`](#map-fitbounds).\r\nL.latLngBounds = function (a, b) {\r\n\tif (a instanceof L.LatLngBounds) {\r\n\t\treturn a;\r\n\t}\r\n\treturn new L.LatLngBounds(a, b);\r\n};\r\n","/*\r\n * @namespace Projection\r\n * @section\r\n * Leaflet comes with a set of already defined Projections out of the box:\r\n *\r\n * @projection L.Projection.LonLat\r\n *\r\n * Equirectangular, or Plate Carree projection — the most simple projection,\r\n * mostly used by GIS enthusiasts. Directly maps `x` as longitude, and `y` as\r\n * latitude. Also suitable for flat worlds, e.g. game maps. Used by the\r\n * `EPSG:3395` and `Simple` CRS.\r\n */\r\n\r\nL.Projection = {};\r\n\r\nL.Projection.LonLat = {\r\n\tproject: function (latlng) {\r\n\t\treturn new L.Point(latlng.lng, latlng.lat);\r\n\t},\r\n\r\n\tunproject: function (point) {\r\n\t\treturn new L.LatLng(point.y, point.x);\r\n\t},\r\n\r\n\tbounds: L.bounds([-180, -90], [180, 90])\r\n};\r\n","/*\r\n * @namespace Projection\r\n * @projection L.Projection.SphericalMercator\r\n *\r\n * Spherical Mercator projection — the most common projection for online maps,\r\n * used by almost all free and commercial tile providers. Assumes that Earth is\r\n * a sphere. Used by the `EPSG:3857` CRS.\r\n */\r\n\r\nL.Projection.SphericalMercator = {\r\n\r\n\tR: 6378137,\r\n\tMAX_LATITUDE: 85.0511287798,\r\n\r\n\tproject: function (latlng) {\r\n\t\tvar d = Math.PI / 180,\r\n\t\t max = this.MAX_LATITUDE,\r\n\t\t lat = Math.max(Math.min(max, latlng.lat), -max),\r\n\t\t sin = Math.sin(lat * d);\r\n\r\n\t\treturn new L.Point(\r\n\t\t\t\tthis.R * latlng.lng * d,\r\n\t\t\t\tthis.R * Math.log((1 + sin) / (1 - sin)) / 2);\r\n\t},\r\n\r\n\tunproject: function (point) {\r\n\t\tvar d = 180 / Math.PI;\r\n\r\n\t\treturn new L.LatLng(\r\n\t\t\t(2 * Math.atan(Math.exp(point.y / this.R)) - (Math.PI / 2)) * d,\r\n\t\t\tpoint.x * d / this.R);\r\n\t},\r\n\r\n\tbounds: (function () {\r\n\t\tvar d = 6378137 * Math.PI;\r\n\t\treturn L.bounds([-d, -d], [d, d]);\r\n\t})()\r\n};\r\n","/*\r\n * @class CRS\r\n * @aka L.CRS\r\n * Abstract class that defines coordinate reference systems for projecting\r\n * geographical points into pixel (screen) coordinates and back (and to\r\n * coordinates in other units for [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services). See\r\n * [spatial reference system](http://en.wikipedia.org/wiki/Coordinate_reference_system).\r\n *\r\n * Leaflet defines the most usual CRSs by default. If you want to use a\r\n * CRS not defined by default, take a look at the\r\n * [Proj4Leaflet](https://github.com/kartena/Proj4Leaflet) plugin.\r\n */\r\n\r\nL.CRS = {\r\n\t// @method latLngToPoint(latlng: LatLng, zoom: Number): Point\r\n\t// Projects geographical coordinates into pixel coordinates for a given zoom.\r\n\tlatLngToPoint: function (latlng, zoom) {\r\n\t\tvar projectedPoint = this.projection.project(latlng),\r\n\t\t scale = this.scale(zoom);\r\n\r\n\t\treturn this.transformation._transform(projectedPoint, scale);\r\n\t},\r\n\r\n\t// @method pointToLatLng(point: Point, zoom: Number): LatLng\r\n\t// The inverse of `latLngToPoint`. Projects pixel coordinates on a given\r\n\t// zoom into geographical coordinates.\r\n\tpointToLatLng: function (point, zoom) {\r\n\t\tvar scale = this.scale(zoom),\r\n\t\t untransformedPoint = this.transformation.untransform(point, scale);\r\n\r\n\t\treturn this.projection.unproject(untransformedPoint);\r\n\t},\r\n\r\n\t// @method project(latlng: LatLng): Point\r\n\t// Projects geographical coordinates into coordinates in units accepted for\r\n\t// this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).\r\n\tproject: function (latlng) {\r\n\t\treturn this.projection.project(latlng);\r\n\t},\r\n\r\n\t// @method unproject(point: Point): LatLng\r\n\t// Given a projected coordinate returns the corresponding LatLng.\r\n\t// The inverse of `project`.\r\n\tunproject: function (point) {\r\n\t\treturn this.projection.unproject(point);\r\n\t},\r\n\r\n\t// @method scale(zoom: Number): Number\r\n\t// Returns the scale used when transforming projected coordinates into\r\n\t// pixel coordinates for a particular zoom. For example, it returns\r\n\t// `256 * 2^zoom` for Mercator-based CRS.\r\n\tscale: function (zoom) {\r\n\t\treturn 256 * Math.pow(2, zoom);\r\n\t},\r\n\r\n\t// @method zoom(scale: Number): Number\r\n\t// Inverse of `scale()`, returns the zoom level corresponding to a scale\r\n\t// factor of `scale`.\r\n\tzoom: function (scale) {\r\n\t\treturn Math.log(scale / 256) / Math.LN2;\r\n\t},\r\n\r\n\t// @method getProjectedBounds(zoom: Number): Bounds\r\n\t// Returns the projection's bounds scaled and transformed for the provided `zoom`.\r\n\tgetProjectedBounds: function (zoom) {\r\n\t\tif (this.infinite) { return null; }\r\n\r\n\t\tvar b = this.projection.bounds,\r\n\t\t s = this.scale(zoom),\r\n\t\t min = this.transformation.transform(b.min, s),\r\n\t\t max = this.transformation.transform(b.max, s);\r\n\r\n\t\treturn L.bounds(min, max);\r\n\t},\r\n\r\n\t// @method distance(latlng1: LatLng, latlng2: LatLng): Number\r\n\t// Returns the distance between two geographical coordinates.\r\n\r\n\t// @property code: String\r\n\t// Standard code name of the CRS passed into WMS services (e.g. `'EPSG:3857'`)\r\n\t//\r\n\t// @property wrapLng: Number[]\r\n\t// An array of two numbers defining whether the longitude (horizontal) coordinate\r\n\t// axis wraps around a given range and how. Defaults to `[-180, 180]` in most\r\n\t// geographical CRSs. If `undefined`, the longitude axis does not wrap around.\r\n\t//\r\n\t// @property wrapLat: Number[]\r\n\t// Like `wrapLng`, but for the latitude (vertical) axis.\r\n\r\n\t// wrapLng: [min, max],\r\n\t// wrapLat: [min, max],\r\n\r\n\t// @property infinite: Boolean\r\n\t// If true, the coordinate space will be unbounded (infinite in both axes)\r\n\tinfinite: false,\r\n\r\n\t// @method wrapLatLng(latlng: LatLng): LatLng\r\n\t// Returns a `LatLng` where lat and lng has been wrapped according to the\r\n\t// CRS's `wrapLat` and `wrapLng` properties, if they are outside the CRS's bounds.\r\n\twrapLatLng: function (latlng) {\r\n\t\tvar lng = this.wrapLng ? L.Util.wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng,\r\n\t\t lat = this.wrapLat ? L.Util.wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat,\r\n\t\t alt = latlng.alt;\r\n\r\n\t\treturn L.latLng(lat, lng, alt);\r\n\t}\r\n};\r\n","/*\n * @namespace CRS\n * @crs L.CRS.Simple\n *\n * A simple CRS that maps longitude and latitude into `x` and `y` directly.\n * May be used for maps of flat surfaces (e.g. game maps). Note that the `y`\n * axis should still be inverted (going from bottom to top). `distance()` returns\n * simple euclidean distance.\n */\n\nL.CRS.Simple = L.extend({}, L.CRS, {\n\tprojection: L.Projection.LonLat,\n\ttransformation: new L.Transformation(1, 0, -1, 0),\n\n\tscale: function (zoom) {\n\t\treturn Math.pow(2, zoom);\n\t},\n\n\tzoom: function (scale) {\n\t\treturn Math.log(scale) / Math.LN2;\n\t},\n\n\tdistance: function (latlng1, latlng2) {\n\t\tvar dx = latlng2.lng - latlng1.lng,\n\t\t dy = latlng2.lat - latlng1.lat;\n\n\t\treturn Math.sqrt(dx * dx + dy * dy);\n\t},\n\n\tinfinite: true\n});\n","/*\n * @namespace CRS\n * @crs L.CRS.Earth\n *\n * Serves as the base for CRS that are global such that they cover the earth.\n * Can only be used as the base for other CRS and cannot be used directly,\n * since it does not have a `code`, `projection` or `transformation`. `distance()` returns\n * meters.\n */\n\nL.CRS.Earth = L.extend({}, L.CRS, {\n\twrapLng: [-180, 180],\n\n\t// Mean Earth Radius, as recommended for use by\n\t// the International Union of Geodesy and Geophysics,\n\t// see http://rosettacode.org/wiki/Haversine_formula\n\tR: 6371000,\n\n\t// distance between two geographical points using spherical law of cosines approximation\n\tdistance: function (latlng1, latlng2) {\n\t\tvar rad = Math.PI / 180,\n\t\t lat1 = latlng1.lat * rad,\n\t\t lat2 = latlng2.lat * rad,\n\t\t a = Math.sin(lat1) * Math.sin(lat2) +\n\t\t Math.cos(lat1) * Math.cos(lat2) * Math.cos((latlng2.lng - latlng1.lng) * rad);\n\n\t\treturn this.R * Math.acos(Math.min(a, 1));\n\t}\n});\n","/*\r\n * @namespace CRS\r\n * @crs L.CRS.EPSG3857\r\n *\r\n * The most common CRS for online maps, used by almost all free and commercial\r\n * tile providers. Uses Spherical Mercator projection. Set in by default in\r\n * Map's `crs` option.\r\n */\r\n\r\nL.CRS.EPSG3857 = L.extend({}, L.CRS.Earth, {\r\n\tcode: 'EPSG:3857',\r\n\tprojection: L.Projection.SphericalMercator,\r\n\r\n\ttransformation: (function () {\r\n\t\tvar scale = 0.5 / (Math.PI * L.Projection.SphericalMercator.R);\r\n\t\treturn new L.Transformation(scale, 0.5, -scale, 0.5);\r\n\t}())\r\n});\r\n\r\nL.CRS.EPSG900913 = L.extend({}, L.CRS.EPSG3857, {\r\n\tcode: 'EPSG:900913'\r\n});\r\n","/*\r\n * @namespace CRS\r\n * @crs L.CRS.EPSG4326\r\n *\r\n * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.\r\n *\r\n * Leaflet 1.0.x complies with the [TMS coordinate scheme for EPSG:4326](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic),\r\n * which is a breaking change from 0.7.x behaviour. If you are using a `TileLayer`\r\n * with this CRS, ensure that there are two 256x256 pixel tiles covering the\r\n * whole earth at zoom level zero, and that the tile coordinate origin is (-180,+90),\r\n * or (-180,-90) for `TileLayer`s with [the `tms` option](#tilelayer-tms) set.\r\n */\r\n\r\nL.CRS.EPSG4326 = L.extend({}, L.CRS.Earth, {\r\n\tcode: 'EPSG:4326',\r\n\tprojection: L.Projection.LonLat,\r\n\ttransformation: new L.Transformation(1 / 180, 1, -1 / 180, 0.5)\r\n});\r\n","/*\r\n * @class Map\r\n * @aka L.Map\r\n * @inherits Evented\r\n *\r\n * The central class of the API — it is used to create a map on a page and manipulate it.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * // initialize the map on the \"map\" div with a given center and zoom\r\n * var map = L.map('map', {\r\n * \tcenter: [51.505, -0.09],\r\n * \tzoom: 13\r\n * });\r\n * ```\r\n *\r\n */\r\n\r\nL.Map = L.Evented.extend({\r\n\r\n\toptions: {\r\n\t\t// @section Map State Options\r\n\t\t// @option crs: CRS = L.CRS.EPSG3857\r\n\t\t// The [Coordinate Reference System](#crs) to use. Don't change this if you're not\r\n\t\t// sure what it means.\r\n\t\tcrs: L.CRS.EPSG3857,\r\n\r\n\t\t// @option center: LatLng = undefined\r\n\t\t// Initial geographic center of the map\r\n\t\tcenter: undefined,\r\n\r\n\t\t// @option zoom: Number = undefined\r\n\t\t// Initial map zoom level\r\n\t\tzoom: undefined,\r\n\r\n\t\t// @option minZoom: Number = undefined\r\n\t\t// Minimum zoom level of the map. Overrides any `minZoom` option set on map layers.\r\n\t\tminZoom: undefined,\r\n\r\n\t\t// @option maxZoom: Number = undefined\r\n\t\t// Maximum zoom level of the map. Overrides any `maxZoom` option set on map layers.\r\n\t\tmaxZoom: undefined,\r\n\r\n\t\t// @option layers: Layer[] = []\r\n\t\t// Array of layers that will be added to the map initially\r\n\t\tlayers: [],\r\n\r\n\t\t// @option maxBounds: LatLngBounds = null\r\n\t\t// When this option is set, the map restricts the view to the given\r\n\t\t// geographical bounds, bouncing the user back when he tries to pan\r\n\t\t// outside the view. To set the restriction dynamically, use\r\n\t\t// [`setMaxBounds`](#map-setmaxbounds) method.\r\n\t\tmaxBounds: undefined,\r\n\r\n\t\t// @option renderer: Renderer = *\r\n\t\t// The default method for drawing vector layers on the map. `L.SVG`\r\n\t\t// or `L.Canvas` by default depending on browser support.\r\n\t\trenderer: undefined,\r\n\r\n\r\n\t\t// @section Animation Options\r\n\t\t// @option zoomAnimation: Boolean = true\r\n\t\t// Whether the map zoom animation is enabled. By default it's enabled\r\n\t\t// in all browsers that support CSS3 Transitions except Android.\r\n\t\tzoomAnimation: true,\r\n\r\n\t\t// @option zoomAnimationThreshold: Number = 4\r\n\t\t// Won't animate zoom if the zoom difference exceeds this value.\r\n\t\tzoomAnimationThreshold: 4,\r\n\r\n\t\t// @option fadeAnimation: Boolean = true\r\n\t\t// Whether the tile fade animation is enabled. By default it's enabled\r\n\t\t// in all browsers that support CSS3 Transitions except Android.\r\n\t\tfadeAnimation: true,\r\n\r\n\t\t// @option markerZoomAnimation: Boolean = true\r\n\t\t// Whether markers animate their zoom with the zoom animation, if disabled\r\n\t\t// they will disappear for the length of the animation. By default it's\r\n\t\t// enabled in all browsers that support CSS3 Transitions except Android.\r\n\t\tmarkerZoomAnimation: true,\r\n\r\n\t\t// @option transform3DLimit: Number = 2^23\r\n\t\t// Defines the maximum size of a CSS translation transform. The default\r\n\t\t// value should not be changed unless a web browser positions layers in\r\n\t\t// the wrong place after doing a large `panBy`.\r\n\t\ttransform3DLimit: 8388608, // Precision limit of a 32-bit float\r\n\r\n\t\t// @section Interaction Options\r\n\t\t// @option zoomSnap: Number = 1\r\n\t\t// Forces the map's zoom level to always be a multiple of this, particularly\r\n\t\t// right after a [`fitBounds()`](#map-fitbounds) or a pinch-zoom.\r\n\t\t// By default, the zoom level snaps to the nearest integer; lower values\r\n\t\t// (e.g. `0.5` or `0.1`) allow for greater granularity. A value of `0`\r\n\t\t// means the zoom level will not be snapped after `fitBounds` or a pinch-zoom.\r\n\t\tzoomSnap: 1,\r\n\r\n\t\t// @option zoomDelta: Number = 1\r\n\t\t// Controls how much the map's zoom level will change after a\r\n\t\t// [`zoomIn()`](#map-zoomin), [`zoomOut()`](#map-zoomout), pressing `+`\r\n\t\t// or `-` on the keyboard, or using the [zoom controls](#control-zoom).\r\n\t\t// Values smaller than `1` (e.g. `0.5`) allow for greater granularity.\r\n\t\tzoomDelta: 1,\r\n\r\n\t\t// @option trackResize: Boolean = true\r\n\t\t// Whether the map automatically handles browser window resize to update itself.\r\n\t\ttrackResize: true\r\n\t},\r\n\r\n\tinitialize: function (id, options) { // (HTMLElement or String, Object)\r\n\t\toptions = L.setOptions(this, options);\r\n\r\n\t\tthis._initContainer(id);\r\n\t\tthis._initLayout();\r\n\r\n\t\t// hack for https://github.com/Leaflet/Leaflet/issues/1980\r\n\t\tthis._onResize = L.bind(this._onResize, this);\r\n\r\n\t\tthis._initEvents();\r\n\r\n\t\tif (options.maxBounds) {\r\n\t\t\tthis.setMaxBounds(options.maxBounds);\r\n\t\t}\r\n\r\n\t\tif (options.zoom !== undefined) {\r\n\t\t\tthis._zoom = this._limitZoom(options.zoom);\r\n\t\t}\r\n\r\n\t\tif (options.center && options.zoom !== undefined) {\r\n\t\t\tthis.setView(L.latLng(options.center), options.zoom, {reset: true});\r\n\t\t}\r\n\r\n\t\tthis._handlers = [];\r\n\t\tthis._layers = {};\r\n\t\tthis._zoomBoundLayers = {};\r\n\t\tthis._sizeChanged = true;\r\n\r\n\t\tthis.callInitHooks();\r\n\r\n\t\t// don't animate on browsers without hardware-accelerated transitions or old Android/Opera\r\n\t\tthis._zoomAnimated = L.DomUtil.TRANSITION && L.Browser.any3d && !L.Browser.mobileOpera &&\r\n\t\t\t\tthis.options.zoomAnimation;\r\n\r\n\t\t// zoom transitions run with the same duration for all layers, so if one of transitionend events\r\n\t\t// happens after starting zoom animation (propagating to the map pane), we know that it ended globally\r\n\t\tif (this._zoomAnimated) {\r\n\t\t\tthis._createAnimProxy();\r\n\t\t\tL.DomEvent.on(this._proxy, L.DomUtil.TRANSITION_END, this._catchTransitionEnd, this);\r\n\t\t}\r\n\r\n\t\tthis._addLayers(this.options.layers);\r\n\t},\r\n\r\n\r\n\t// @section Methods for modifying map state\r\n\r\n\t// @method setView(center: LatLng, zoom: Number, options?: Zoom/pan options): this\r\n\t// Sets the view of the map (geographical center and zoom) with the given\r\n\t// animation options.\r\n\tsetView: function (center, zoom, options) {\r\n\r\n\t\tzoom = zoom === undefined ? this._zoom : this._limitZoom(zoom);\r\n\t\tcenter = this._limitCenter(L.latLng(center), zoom, this.options.maxBounds);\r\n\t\toptions = options || {};\r\n\r\n\t\tthis._stop();\r\n\r\n\t\tif (this._loaded && !options.reset && options !== true) {\r\n\r\n\t\t\tif (options.animate !== undefined) {\r\n\t\t\t\toptions.zoom = L.extend({animate: options.animate}, options.zoom);\r\n\t\t\t\toptions.pan = L.extend({animate: options.animate, duration: options.duration}, options.pan);\r\n\t\t\t}\r\n\r\n\t\t\t// try animating pan or zoom\r\n\t\t\tvar moved = (this._zoom !== zoom) ?\r\n\t\t\t\tthis._tryAnimatedZoom && this._tryAnimatedZoom(center, zoom, options.zoom) :\r\n\t\t\t\tthis._tryAnimatedPan(center, options.pan);\r\n\r\n\t\t\tif (moved) {\r\n\t\t\t\t// prevent resize handler call, the view will refresh after animation anyway\r\n\t\t\t\tclearTimeout(this._sizeTimer);\r\n\t\t\t\treturn this;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// animation didn't start, just reset the map view\r\n\t\tthis._resetView(center, zoom);\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method setZoom(zoom: Number, options: Zoom/pan options): this\r\n\t// Sets the zoom of the map.\r\n\tsetZoom: function (zoom, options) {\r\n\t\tif (!this._loaded) {\r\n\t\t\tthis._zoom = zoom;\r\n\t\t\treturn this;\r\n\t\t}\r\n\t\treturn this.setView(this.getCenter(), zoom, {zoom: options});\r\n\t},\r\n\r\n\t// @method zoomIn(delta?: Number, options?: Zoom options): this\r\n\t// Increases the zoom of the map by `delta` ([`zoomDelta`](#map-zoomdelta) by default).\r\n\tzoomIn: function (delta, options) {\r\n\t\tdelta = delta || (L.Browser.any3d ? this.options.zoomDelta : 1);\r\n\t\treturn this.setZoom(this._zoom + delta, options);\r\n\t},\r\n\r\n\t// @method zoomOut(delta?: Number, options?: Zoom options): this\r\n\t// Decreases the zoom of the map by `delta` ([`zoomDelta`](#map-zoomdelta) by default).\r\n\tzoomOut: function (delta, options) {\r\n\t\tdelta = delta || (L.Browser.any3d ? this.options.zoomDelta : 1);\r\n\t\treturn this.setZoom(this._zoom - delta, options);\r\n\t},\r\n\r\n\t// @method setZoomAround(latlng: LatLng, zoom: Number, options: Zoom options): this\r\n\t// Zooms the map while keeping a specified geographical point on the map\r\n\t// stationary (e.g. used internally for scroll zoom and double-click zoom).\r\n\t// @alternative\r\n\t// @method setZoomAround(offset: Point, zoom: Number, options: Zoom options): this\r\n\t// Zooms the map while keeping a specified pixel on the map (relative to the top-left corner) stationary.\r\n\tsetZoomAround: function (latlng, zoom, options) {\r\n\t\tvar scale = this.getZoomScale(zoom),\r\n\t\t viewHalf = this.getSize().divideBy(2),\r\n\t\t containerPoint = latlng instanceof L.Point ? latlng : this.latLngToContainerPoint(latlng),\r\n\r\n\t\t centerOffset = containerPoint.subtract(viewHalf).multiplyBy(1 - 1 / scale),\r\n\t\t newCenter = this.containerPointToLatLng(viewHalf.add(centerOffset));\r\n\r\n\t\treturn this.setView(newCenter, zoom, {zoom: options});\r\n\t},\r\n\r\n\t_getBoundsCenterZoom: function (bounds, options) {\r\n\r\n\t\toptions = options || {};\r\n\t\tbounds = bounds.getBounds ? bounds.getBounds() : L.latLngBounds(bounds);\r\n\r\n\t\tvar paddingTL = L.point(options.paddingTopLeft || options.padding || [0, 0]),\r\n\t\t paddingBR = L.point(options.paddingBottomRight || options.padding || [0, 0]),\r\n\r\n\t\t zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR));\r\n\r\n\t\tzoom = (typeof options.maxZoom === 'number') ? Math.min(options.maxZoom, zoom) : zoom;\r\n\r\n\t\tvar paddingOffset = paddingBR.subtract(paddingTL).divideBy(2),\r\n\r\n\t\t swPoint = this.project(bounds.getSouthWest(), zoom),\r\n\t\t nePoint = this.project(bounds.getNorthEast(), zoom),\r\n\t\t center = this.unproject(swPoint.add(nePoint).divideBy(2).add(paddingOffset), zoom);\r\n\r\n\t\treturn {\r\n\t\t\tcenter: center,\r\n\t\t\tzoom: zoom\r\n\t\t};\r\n\t},\r\n\r\n\t// @method fitBounds(bounds: LatLngBounds, options: fitBounds options): this\r\n\t// Sets a map view that contains the given geographical bounds with the\r\n\t// maximum zoom level possible.\r\n\tfitBounds: function (bounds, options) {\r\n\r\n\t\tbounds = L.latLngBounds(bounds);\r\n\r\n\t\tif (!bounds.isValid()) {\r\n\t\t\tthrow new Error('Bounds are not valid.');\r\n\t\t}\r\n\r\n\t\tvar target = this._getBoundsCenterZoom(bounds, options);\r\n\t\treturn this.setView(target.center, target.zoom, options);\r\n\t},\r\n\r\n\t// @method fitWorld(options?: fitBounds options): this\r\n\t// Sets a map view that mostly contains the whole world with the maximum\r\n\t// zoom level possible.\r\n\tfitWorld: function (options) {\r\n\t\treturn this.fitBounds([[-90, -180], [90, 180]], options);\r\n\t},\r\n\r\n\t// @method panTo(latlng: LatLng, options?: Pan options): this\r\n\t// Pans the map to a given center.\r\n\tpanTo: function (center, options) { // (LatLng)\r\n\t\treturn this.setView(center, this._zoom, {pan: options});\r\n\t},\r\n\r\n\t// @method panBy(offset: Point): this\r\n\t// Pans the map by a given number of pixels (animated).\r\n\tpanBy: function (offset, options) {\r\n\t\toffset = L.point(offset).round();\r\n\t\toptions = options || {};\r\n\r\n\t\tif (!offset.x && !offset.y) {\r\n\t\t\treturn this.fire('moveend');\r\n\t\t}\r\n\t\t// If we pan too far, Chrome gets issues with tiles\r\n\t\t// and makes them disappear or appear in the wrong place (slightly offset) #2602\r\n\t\tif (options.animate !== true && !this.getSize().contains(offset)) {\r\n\t\t\tthis._resetView(this.unproject(this.project(this.getCenter()).add(offset)), this.getZoom());\r\n\t\t\treturn this;\r\n\t\t}\r\n\r\n\t\tif (!this._panAnim) {\r\n\t\t\tthis._panAnim = new L.PosAnimation();\r\n\r\n\t\t\tthis._panAnim.on({\r\n\t\t\t\t'step': this._onPanTransitionStep,\r\n\t\t\t\t'end': this._onPanTransitionEnd\r\n\t\t\t}, this);\r\n\t\t}\r\n\r\n\t\t// don't fire movestart if animating inertia\r\n\t\tif (!options.noMoveStart) {\r\n\t\t\tthis.fire('movestart');\r\n\t\t}\r\n\r\n\t\t// animate pan unless animate: false specified\r\n\t\tif (options.animate !== false) {\r\n\t\t\tL.DomUtil.addClass(this._mapPane, 'leaflet-pan-anim');\r\n\r\n\t\t\tvar newPos = this._getMapPanePos().subtract(offset).round();\r\n\t\t\tthis._panAnim.run(this._mapPane, newPos, options.duration || 0.25, options.easeLinearity);\r\n\t\t} else {\r\n\t\t\tthis._rawPanBy(offset);\r\n\t\t\tthis.fire('move').fire('moveend');\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method flyTo(latlng: LatLng, zoom?: Number, options?: Zoom/pan options): this\r\n\t// Sets the view of the map (geographical center and zoom) performing a smooth\r\n\t// pan-zoom animation.\r\n\tflyTo: function (targetCenter, targetZoom, options) {\r\n\r\n\t\toptions = options || {};\r\n\t\tif (options.animate === false || !L.Browser.any3d) {\r\n\t\t\treturn this.setView(targetCenter, targetZoom, options);\r\n\t\t}\r\n\r\n\t\tthis._stop();\r\n\r\n\t\tvar from = this.project(this.getCenter()),\r\n\t\t to = this.project(targetCenter),\r\n\t\t size = this.getSize(),\r\n\t\t startZoom = this._zoom;\r\n\r\n\t\ttargetCenter = L.latLng(targetCenter);\r\n\t\ttargetZoom = targetZoom === undefined ? startZoom : targetZoom;\r\n\r\n\t\tvar w0 = Math.max(size.x, size.y),\r\n\t\t w1 = w0 * this.getZoomScale(startZoom, targetZoom),\r\n\t\t u1 = (to.distanceTo(from)) || 1,\r\n\t\t rho = 1.42,\r\n\t\t rho2 = rho * rho;\r\n\r\n\t\tfunction r(i) {\r\n\t\t\tvar s1 = i ? -1 : 1,\r\n\t\t\t s2 = i ? w1 : w0,\r\n\t\t\t t1 = w1 * w1 - w0 * w0 + s1 * rho2 * rho2 * u1 * u1,\r\n\t\t\t b1 = 2 * s2 * rho2 * u1,\r\n\t\t\t b = t1 / b1,\r\n\t\t\t sq = Math.sqrt(b * b + 1) - b;\r\n\r\n\t\t\t // workaround for floating point precision bug when sq = 0, log = -Infinite,\r\n\t\t\t // thus triggering an infinite loop in flyTo\r\n\t\t\t var log = sq < 0.000000001 ? -18 : Math.log(sq);\r\n\r\n\t\t\treturn log;\r\n\t\t}\r\n\r\n\t\tfunction sinh(n) { return (Math.exp(n) - Math.exp(-n)) / 2; }\r\n\t\tfunction cosh(n) { return (Math.exp(n) + Math.exp(-n)) / 2; }\r\n\t\tfunction tanh(n) { return sinh(n) / cosh(n); }\r\n\r\n\t\tvar r0 = r(0);\r\n\r\n\t\tfunction w(s) { return w0 * (cosh(r0) / cosh(r0 + rho * s)); }\r\n\t\tfunction u(s) { return w0 * (cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2; }\r\n\r\n\t\tfunction easeOut(t) { return 1 - Math.pow(1 - t, 1.5); }\r\n\r\n\t\tvar start = Date.now(),\r\n\t\t S = (r(1) - r0) / rho,\r\n\t\t duration = options.duration ? 1000 * options.duration : 1000 * S * 0.8;\r\n\r\n\t\tfunction frame() {\r\n\t\t\tvar t = (Date.now() - start) / duration,\r\n\t\t\t s = easeOut(t) * S;\r\n\r\n\t\t\tif (t <= 1) {\r\n\t\t\t\tthis._flyToFrame = L.Util.requestAnimFrame(frame, this);\r\n\r\n\t\t\t\tthis._move(\r\n\t\t\t\t\tthis.unproject(from.add(to.subtract(from).multiplyBy(u(s) / u1)), startZoom),\r\n\t\t\t\t\tthis.getScaleZoom(w0 / w(s), startZoom),\r\n\t\t\t\t\t{flyTo: true});\r\n\r\n\t\t\t} else {\r\n\t\t\t\tthis\r\n\t\t\t\t\t._move(targetCenter, targetZoom)\r\n\t\t\t\t\t._moveEnd(true);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis._moveStart(true);\r\n\r\n\t\tframe.call(this);\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method flyToBounds(bounds: LatLngBounds, options?: fitBounds options): this\r\n\t// Sets the view of the map with a smooth animation like [`flyTo`](#map-flyto),\r\n\t// but takes a bounds parameter like [`fitBounds`](#map-fitbounds).\r\n\tflyToBounds: function (bounds, options) {\r\n\t\tvar target = this._getBoundsCenterZoom(bounds, options);\r\n\t\treturn this.flyTo(target.center, target.zoom, options);\r\n\t},\r\n\r\n\t// @method setMaxBounds(bounds: Bounds): this\r\n\t// Restricts the map view to the given bounds (see the [maxBounds](#map-maxbounds) option).\r\n\tsetMaxBounds: function (bounds) {\r\n\t\tbounds = L.latLngBounds(bounds);\r\n\r\n\t\tif (!bounds.isValid()) {\r\n\t\t\tthis.options.maxBounds = null;\r\n\t\t\treturn this.off('moveend', this._panInsideMaxBounds);\r\n\t\t} else if (this.options.maxBounds) {\r\n\t\t\tthis.off('moveend', this._panInsideMaxBounds);\r\n\t\t}\r\n\r\n\t\tthis.options.maxBounds = bounds;\r\n\r\n\t\tif (this._loaded) {\r\n\t\t\tthis._panInsideMaxBounds();\r\n\t\t}\r\n\r\n\t\treturn this.on('moveend', this._panInsideMaxBounds);\r\n\t},\r\n\r\n\t// @method setMinZoom(zoom: Number): this\r\n\t// Sets the lower limit for the available zoom levels (see the [minZoom](#map-minzoom) option).\r\n\tsetMinZoom: function (zoom) {\r\n\t\tthis.options.minZoom = zoom;\r\n\r\n\t\tif (this._loaded && this.getZoom() < this.options.minZoom) {\r\n\t\t\treturn this.setZoom(zoom);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method setMaxZoom(zoom: Number): this\r\n\t// Sets the upper limit for the available zoom levels (see the [maxZoom](#map-maxzoom) option).\r\n\tsetMaxZoom: function (zoom) {\r\n\t\tthis.options.maxZoom = zoom;\r\n\r\n\t\tif (this._loaded && (this.getZoom() > this.options.maxZoom)) {\r\n\t\t\treturn this.setZoom(zoom);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method panInsideBounds(bounds: LatLngBounds, options?: Pan options): this\r\n\t// Pans the map to the closest view that would lie inside the given bounds (if it's not already), controlling the animation using the options specific, if any.\r\n\tpanInsideBounds: function (bounds, options) {\r\n\t\tthis._enforcingBounds = true;\r\n\t\tvar center = this.getCenter(),\r\n\t\t newCenter = this._limitCenter(center, this._zoom, L.latLngBounds(bounds));\r\n\r\n\t\tif (!center.equals(newCenter)) {\r\n\t\t\tthis.panTo(newCenter, options);\r\n\t\t}\r\n\r\n\t\tthis._enforcingBounds = false;\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method invalidateSize(options: Zoom/Pan options): this\r\n\t// Checks if the map container size changed and updates the map if so —\r\n\t// call it after you've changed the map size dynamically, also animating\r\n\t// pan by default. If `options.pan` is `false`, panning will not occur.\r\n\t// If `options.debounceMoveend` is `true`, it will delay `moveend` event so\r\n\t// that it doesn't happen often even if the method is called many\r\n\t// times in a row.\r\n\r\n\t// @alternative\r\n\t// @method invalidateSize(animate: Boolean): this\r\n\t// Checks if the map container size changed and updates the map if so —\r\n\t// call it after you've changed the map size dynamically, also animating\r\n\t// pan by default.\r\n\tinvalidateSize: function (options) {\r\n\t\tif (!this._loaded) { return this; }\r\n\r\n\t\toptions = L.extend({\r\n\t\t\tanimate: false,\r\n\t\t\tpan: true\r\n\t\t}, options === true ? {animate: true} : options);\r\n\r\n\t\tvar oldSize = this.getSize();\r\n\t\tthis._sizeChanged = true;\r\n\t\tthis._lastCenter = null;\r\n\r\n\t\tvar newSize = this.getSize(),\r\n\t\t oldCenter = oldSize.divideBy(2).round(),\r\n\t\t newCenter = newSize.divideBy(2).round(),\r\n\t\t offset = oldCenter.subtract(newCenter);\r\n\r\n\t\tif (!offset.x && !offset.y) { return this; }\r\n\r\n\t\tif (options.animate && options.pan) {\r\n\t\t\tthis.panBy(offset);\r\n\r\n\t\t} else {\r\n\t\t\tif (options.pan) {\r\n\t\t\t\tthis._rawPanBy(offset);\r\n\t\t\t}\r\n\r\n\t\t\tthis.fire('move');\r\n\r\n\t\t\tif (options.debounceMoveend) {\r\n\t\t\t\tclearTimeout(this._sizeTimer);\r\n\t\t\t\tthis._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200);\r\n\t\t\t} else {\r\n\t\t\t\tthis.fire('moveend');\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// @section Map state change events\r\n\t\t// @event resize: ResizeEvent\r\n\t\t// Fired when the map is resized.\r\n\t\treturn this.fire('resize', {\r\n\t\t\toldSize: oldSize,\r\n\t\t\tnewSize: newSize\r\n\t\t});\r\n\t},\r\n\r\n\t// @section Methods for modifying map state\r\n\t// @method stop(): this\r\n\t// Stops the currently running `panTo` or `flyTo` animation, if any.\r\n\tstop: function () {\r\n\t\tthis.setZoom(this._limitZoom(this._zoom));\r\n\t\tif (!this.options.zoomSnap) {\r\n\t\t\tthis.fire('viewreset');\r\n\t\t}\r\n\t\treturn this._stop();\r\n\t},\r\n\r\n\t// @section Geolocation methods\r\n\t// @method locate(options?: Locate options): this\r\n\t// Tries to locate the user using the Geolocation API, firing a [`locationfound`](#map-locationfound)\r\n\t// event with location data on success or a [`locationerror`](#map-locationerror) event on failure,\r\n\t// and optionally sets the map view to the user's location with respect to\r\n\t// detection accuracy (or to the world view if geolocation failed).\r\n\t// Note that, if your page doesn't use HTTPS, this method will fail in\r\n\t// modern browsers ([Chrome 50 and newer](https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-powerful-features-on-insecure-origins))\r\n\t// See `Locate options` for more details.\r\n\tlocate: function (options) {\r\n\r\n\t\toptions = this._locateOptions = L.extend({\r\n\t\t\ttimeout: 10000,\r\n\t\t\twatch: false\r\n\t\t\t// setView: false\r\n\t\t\t// maxZoom: \r\n\t\t\t// maximumAge: 0\r\n\t\t\t// enableHighAccuracy: false\r\n\t\t}, options);\r\n\r\n\t\tif (!('geolocation' in navigator)) {\r\n\t\t\tthis._handleGeolocationError({\r\n\t\t\t\tcode: 0,\r\n\t\t\t\tmessage: 'Geolocation not supported.'\r\n\t\t\t});\r\n\t\t\treturn this;\r\n\t\t}\r\n\r\n\t\tvar onResponse = L.bind(this._handleGeolocationResponse, this),\r\n\t\t onError = L.bind(this._handleGeolocationError, this);\r\n\r\n\t\tif (options.watch) {\r\n\t\t\tthis._locationWatchId =\r\n\t\t\t navigator.geolocation.watchPosition(onResponse, onError, options);\r\n\t\t} else {\r\n\t\t\tnavigator.geolocation.getCurrentPosition(onResponse, onError, options);\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method stopLocate(): this\r\n\t// Stops watching location previously initiated by `map.locate({watch: true})`\r\n\t// and aborts resetting the map view if map.locate was called with\r\n\t// `{setView: true}`.\r\n\tstopLocate: function () {\r\n\t\tif (navigator.geolocation && navigator.geolocation.clearWatch) {\r\n\t\t\tnavigator.geolocation.clearWatch(this._locationWatchId);\r\n\t\t}\r\n\t\tif (this._locateOptions) {\r\n\t\t\tthis._locateOptions.setView = false;\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_handleGeolocationError: function (error) {\r\n\t\tvar c = error.code,\r\n\t\t message = error.message ||\r\n\t\t (c === 1 ? 'permission denied' :\r\n\t\t (c === 2 ? 'position unavailable' : 'timeout'));\r\n\r\n\t\tif (this._locateOptions.setView && !this._loaded) {\r\n\t\t\tthis.fitWorld();\r\n\t\t}\r\n\r\n\t\t// @section Location events\r\n\t\t// @event locationerror: ErrorEvent\r\n\t\t// Fired when geolocation (using the [`locate`](#map-locate) method) failed.\r\n\t\tthis.fire('locationerror', {\r\n\t\t\tcode: c,\r\n\t\t\tmessage: 'Geolocation error: ' + message + '.'\r\n\t\t});\r\n\t},\r\n\r\n\t_handleGeolocationResponse: function (pos) {\r\n\t\tvar lat = pos.coords.latitude,\r\n\t\t lng = pos.coords.longitude,\r\n\t\t latlng = new L.LatLng(lat, lng),\r\n\t\t bounds = latlng.toBounds(pos.coords.accuracy),\r\n\t\t options = this._locateOptions;\r\n\r\n\t\tif (options.setView) {\r\n\t\t\tvar zoom = this.getBoundsZoom(bounds);\r\n\t\t\tthis.setView(latlng, options.maxZoom ? Math.min(zoom, options.maxZoom) : zoom);\r\n\t\t}\r\n\r\n\t\tvar data = {\r\n\t\t\tlatlng: latlng,\r\n\t\t\tbounds: bounds,\r\n\t\t\ttimestamp: pos.timestamp\r\n\t\t};\r\n\r\n\t\tfor (var i in pos.coords) {\r\n\t\t\tif (typeof pos.coords[i] === 'number') {\r\n\t\t\t\tdata[i] = pos.coords[i];\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// @event locationfound: LocationEvent\r\n\t\t// Fired when geolocation (using the [`locate`](#map-locate) method)\r\n\t\t// went successfully.\r\n\t\tthis.fire('locationfound', data);\r\n\t},\r\n\r\n\t// TODO handler.addTo\r\n\t// TODO Appropiate docs section?\r\n\t// @section Other Methods\r\n\t// @method addHandler(name: String, HandlerClass: Function): this\r\n\t// Adds a new `Handler` to the map, given its name and constructor function.\r\n\taddHandler: function (name, HandlerClass) {\r\n\t\tif (!HandlerClass) { return this; }\r\n\r\n\t\tvar handler = this[name] = new HandlerClass(this);\r\n\r\n\t\tthis._handlers.push(handler);\r\n\r\n\t\tif (this.options[name]) {\r\n\t\t\thandler.enable();\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method remove(): this\r\n\t// Destroys the map and clears all related event listeners.\r\n\tremove: function () {\r\n\r\n\t\tthis._initEvents(true);\r\n\r\n\t\tif (this._containerId !== this._container._leaflet_id) {\r\n\t\t\tthrow new Error('Map container is being reused by another instance');\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\t// throws error in IE6-8\r\n\t\t\tdelete this._container._leaflet_id;\r\n\t\t\tdelete this._containerId;\r\n\t\t} catch (e) {\r\n\t\t\t/*eslint-disable */\r\n\t\t\tthis._container._leaflet_id = undefined;\r\n\t\t\t/*eslint-enable */\r\n\t\t\tthis._containerId = undefined;\r\n\t\t}\r\n\r\n\t\tL.DomUtil.remove(this._mapPane);\r\n\r\n\t\tif (this._clearControlPos) {\r\n\t\t\tthis._clearControlPos();\r\n\t\t}\r\n\r\n\t\tthis._clearHandlers();\r\n\r\n\t\tif (this._loaded) {\r\n\t\t\t// @section Map state change events\r\n\t\t\t// @event unload: Event\r\n\t\t\t// Fired when the map is destroyed with [remove](#map-remove) method.\r\n\t\t\tthis.fire('unload');\r\n\t\t}\r\n\r\n\t\tfor (var i in this._layers) {\r\n\t\t\tthis._layers[i].remove();\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @section Other Methods\r\n\t// @method createPane(name: String, container?: HTMLElement): HTMLElement\r\n\t// Creates a new [map pane](#map-pane) with the given name if it doesn't exist already,\r\n\t// then returns it. The pane is created as a children of `container`, or\r\n\t// as a children of the main map pane if not set.\r\n\tcreatePane: function (name, container) {\r\n\t\tvar className = 'leaflet-pane' + (name ? ' leaflet-' + name.replace('Pane', '') + '-pane' : ''),\r\n\t\t pane = L.DomUtil.create('div', className, container || this._mapPane);\r\n\r\n\t\tif (name) {\r\n\t\t\tthis._panes[name] = pane;\r\n\t\t}\r\n\t\treturn pane;\r\n\t},\r\n\r\n\t// @section Methods for Getting Map State\r\n\r\n\t// @method getCenter(): LatLng\r\n\t// Returns the geographical center of the map view\r\n\tgetCenter: function () {\r\n\t\tthis._checkIfLoaded();\r\n\r\n\t\tif (this._lastCenter && !this._moved()) {\r\n\t\t\treturn this._lastCenter;\r\n\t\t}\r\n\t\treturn this.layerPointToLatLng(this._getCenterLayerPoint());\r\n\t},\r\n\r\n\t// @method getZoom(): Number\r\n\t// Returns the current zoom level of the map view\r\n\tgetZoom: function () {\r\n\t\treturn this._zoom;\r\n\t},\r\n\r\n\t// @method getBounds(): LatLngBounds\r\n\t// Returns the geographical bounds visible in the current map view\r\n\tgetBounds: function () {\r\n\t\tvar bounds = this.getPixelBounds(),\r\n\t\t sw = this.unproject(bounds.getBottomLeft()),\r\n\t\t ne = this.unproject(bounds.getTopRight());\r\n\r\n\t\treturn new L.LatLngBounds(sw, ne);\r\n\t},\r\n\r\n\t// @method getMinZoom(): Number\r\n\t// Returns the minimum zoom level of the map (if set in the `minZoom` option of the map or of any layers), or `0` by default.\r\n\tgetMinZoom: function () {\r\n\t\treturn this.options.minZoom === undefined ? this._layersMinZoom || 0 : this.options.minZoom;\r\n\t},\r\n\r\n\t// @method getMaxZoom(): Number\r\n\t// Returns the maximum zoom level of the map (if set in the `maxZoom` option of the map or of any layers).\r\n\tgetMaxZoom: function () {\r\n\t\treturn this.options.maxZoom === undefined ?\r\n\t\t\t(this._layersMaxZoom === undefined ? Infinity : this._layersMaxZoom) :\r\n\t\t\tthis.options.maxZoom;\r\n\t},\r\n\r\n\t// @method getBoundsZoom(bounds: LatLngBounds, inside?: Boolean): Number\r\n\t// Returns the maximum zoom level on which the given bounds fit to the map\r\n\t// view in its entirety. If `inside` (optional) is set to `true`, the method\r\n\t// instead returns the minimum zoom level on which the map view fits into\r\n\t// the given bounds in its entirety.\r\n\tgetBoundsZoom: function (bounds, inside, padding) { // (LatLngBounds[, Boolean, Point]) -> Number\r\n\t\tbounds = L.latLngBounds(bounds);\r\n\t\tpadding = L.point(padding || [0, 0]);\r\n\r\n\t\tvar zoom = this.getZoom() || 0,\r\n\t\t min = this.getMinZoom(),\r\n\t\t max = this.getMaxZoom(),\r\n\t\t nw = bounds.getNorthWest(),\r\n\t\t se = bounds.getSouthEast(),\r\n\t\t size = this.getSize().subtract(padding),\r\n\t\t boundsSize = this.project(se, zoom).subtract(this.project(nw, zoom)),\r\n\t\t snap = L.Browser.any3d ? this.options.zoomSnap : 1;\r\n\r\n\t\tvar scale = Math.min(size.x / boundsSize.x, size.y / boundsSize.y);\r\n\t\tzoom = this.getScaleZoom(scale, zoom);\r\n\r\n\t\tif (snap) {\r\n\t\t\tzoom = Math.round(zoom / (snap / 100)) * (snap / 100); // don't jump if within 1% of a snap level\r\n\t\t\tzoom = inside ? Math.ceil(zoom / snap) * snap : Math.floor(zoom / snap) * snap;\r\n\t\t}\r\n\r\n\t\treturn Math.max(min, Math.min(max, zoom));\r\n\t},\r\n\r\n\t// @method getSize(): Point\r\n\t// Returns the current size of the map container (in pixels).\r\n\tgetSize: function () {\r\n\t\tif (!this._size || this._sizeChanged) {\r\n\t\t\tthis._size = new L.Point(\r\n\t\t\t\tthis._container.clientWidth,\r\n\t\t\t\tthis._container.clientHeight);\r\n\r\n\t\t\tthis._sizeChanged = false;\r\n\t\t}\r\n\t\treturn this._size.clone();\r\n\t},\r\n\r\n\t// @method getPixelBounds(): Bounds\r\n\t// Returns the bounds of the current map view in projected pixel\r\n\t// coordinates (sometimes useful in layer and overlay implementations).\r\n\tgetPixelBounds: function (center, zoom) {\r\n\t\tvar topLeftPoint = this._getTopLeftPoint(center, zoom);\r\n\t\treturn new L.Bounds(topLeftPoint, topLeftPoint.add(this.getSize()));\r\n\t},\r\n\r\n\t// TODO: Check semantics - isn't the pixel origin the 0,0 coord relative to\r\n\t// the map pane? \"left point of the map layer\" can be confusing, specially\r\n\t// since there can be negative offsets.\r\n\t// @method getPixelOrigin(): Point\r\n\t// Returns the projected pixel coordinates of the top left point of\r\n\t// the map layer (useful in custom layer and overlay implementations).\r\n\tgetPixelOrigin: function () {\r\n\t\tthis._checkIfLoaded();\r\n\t\treturn this._pixelOrigin;\r\n\t},\r\n\r\n\t// @method getPixelWorldBounds(zoom?: Number): Bounds\r\n\t// Returns the world's bounds in pixel coordinates for zoom level `zoom`.\r\n\t// If `zoom` is omitted, the map's current zoom level is used.\r\n\tgetPixelWorldBounds: function (zoom) {\r\n\t\treturn this.options.crs.getProjectedBounds(zoom === undefined ? this.getZoom() : zoom);\r\n\t},\r\n\r\n\t// @section Other Methods\r\n\r\n\t// @method getPane(pane: String|HTMLElement): HTMLElement\r\n\t// Returns a [map pane](#map-pane), given its name or its HTML element (its identity).\r\n\tgetPane: function (pane) {\r\n\t\treturn typeof pane === 'string' ? this._panes[pane] : pane;\r\n\t},\r\n\r\n\t// @method getPanes(): Object\r\n\t// Returns a plain object containing the names of all [panes](#map-pane) as keys and\r\n\t// the panes as values.\r\n\tgetPanes: function () {\r\n\t\treturn this._panes;\r\n\t},\r\n\r\n\t// @method getContainer: HTMLElement\r\n\t// Returns the HTML element that contains the map.\r\n\tgetContainer: function () {\r\n\t\treturn this._container;\r\n\t},\r\n\r\n\r\n\t// @section Conversion Methods\r\n\r\n\t// @method getZoomScale(toZoom: Number, fromZoom: Number): Number\r\n\t// Returns the scale factor to be applied to a map transition from zoom level\r\n\t// `fromZoom` to `toZoom`. Used internally to help with zoom animations.\r\n\tgetZoomScale: function (toZoom, fromZoom) {\r\n\t\t// TODO replace with universal implementation after refactoring projections\r\n\t\tvar crs = this.options.crs;\r\n\t\tfromZoom = fromZoom === undefined ? this._zoom : fromZoom;\r\n\t\treturn crs.scale(toZoom) / crs.scale(fromZoom);\r\n\t},\r\n\r\n\t// @method getScaleZoom(scale: Number, fromZoom: Number): Number\r\n\t// Returns the zoom level that the map would end up at, if it is at `fromZoom`\r\n\t// level and everything is scaled by a factor of `scale`. Inverse of\r\n\t// [`getZoomScale`](#map-getZoomScale).\r\n\tgetScaleZoom: function (scale, fromZoom) {\r\n\t\tvar crs = this.options.crs;\r\n\t\tfromZoom = fromZoom === undefined ? this._zoom : fromZoom;\r\n\t\tvar zoom = crs.zoom(scale * crs.scale(fromZoom));\r\n\t\treturn isNaN(zoom) ? Infinity : zoom;\r\n\t},\r\n\r\n\t// @method project(latlng: LatLng, zoom: Number): Point\r\n\t// Projects a geographical coordinate `LatLng` according to the projection\r\n\t// of the map's CRS, then scales it according to `zoom` and the CRS's\r\n\t// `Transformation`. The result is pixel coordinate relative to\r\n\t// the CRS origin.\r\n\tproject: function (latlng, zoom) {\r\n\t\tzoom = zoom === undefined ? this._zoom : zoom;\r\n\t\treturn this.options.crs.latLngToPoint(L.latLng(latlng), zoom);\r\n\t},\r\n\r\n\t// @method unproject(point: Point, zoom: Number): LatLng\r\n\t// Inverse of [`project`](#map-project).\r\n\tunproject: function (point, zoom) {\r\n\t\tzoom = zoom === undefined ? this._zoom : zoom;\r\n\t\treturn this.options.crs.pointToLatLng(L.point(point), zoom);\r\n\t},\r\n\r\n\t// @method layerPointToLatLng(point: Point): LatLng\r\n\t// Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin),\r\n\t// returns the corresponding geographical coordinate (for the current zoom level).\r\n\tlayerPointToLatLng: function (point) {\r\n\t\tvar projectedPoint = L.point(point).add(this.getPixelOrigin());\r\n\t\treturn this.unproject(projectedPoint);\r\n\t},\r\n\r\n\t// @method latLngToLayerPoint(latlng: LatLng): Point\r\n\t// Given a geographical coordinate, returns the corresponding pixel coordinate\r\n\t// relative to the [origin pixel](#map-getpixelorigin).\r\n\tlatLngToLayerPoint: function (latlng) {\r\n\t\tvar projectedPoint = this.project(L.latLng(latlng))._round();\r\n\t\treturn projectedPoint._subtract(this.getPixelOrigin());\r\n\t},\r\n\r\n\t// @method wrapLatLng(latlng: LatLng): LatLng\r\n\t// Returns a `LatLng` where `lat` and `lng` has been wrapped according to the\r\n\t// map's CRS's `wrapLat` and `wrapLng` properties, if they are outside the\r\n\t// CRS's bounds.\r\n\t// By default this means longitude is wrapped around the dateline so its\r\n\t// value is between -180 and +180 degrees.\r\n\twrapLatLng: function (latlng) {\r\n\t\treturn this.options.crs.wrapLatLng(L.latLng(latlng));\r\n\t},\r\n\r\n\t// @method distance(latlng1: LatLng, latlng2: LatLng): Number\r\n\t// Returns the distance between two geographical coordinates according to\r\n\t// the map's CRS. By default this measures distance in meters.\r\n\tdistance: function (latlng1, latlng2) {\r\n\t\treturn this.options.crs.distance(L.latLng(latlng1), L.latLng(latlng2));\r\n\t},\r\n\r\n\t// @method containerPointToLayerPoint(point: Point): Point\r\n\t// Given a pixel coordinate relative to the map container, returns the corresponding\r\n\t// pixel coordinate relative to the [origin pixel](#map-getpixelorigin).\r\n\tcontainerPointToLayerPoint: function (point) { // (Point)\r\n\t\treturn L.point(point).subtract(this._getMapPanePos());\r\n\t},\r\n\r\n\t// @method layerPointToContainerPoint(point: Point): Point\r\n\t// Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin),\r\n\t// returns the corresponding pixel coordinate relative to the map container.\r\n\tlayerPointToContainerPoint: function (point) { // (Point)\r\n\t\treturn L.point(point).add(this._getMapPanePos());\r\n\t},\r\n\r\n\t// @method containerPointToLatLng(point: Point): Point\r\n\t// Given a pixel coordinate relative to the map container, returns\r\n\t// the corresponding geographical coordinate (for the current zoom level).\r\n\tcontainerPointToLatLng: function (point) {\r\n\t\tvar layerPoint = this.containerPointToLayerPoint(L.point(point));\r\n\t\treturn this.layerPointToLatLng(layerPoint);\r\n\t},\r\n\r\n\t// @method latLngToContainerPoint(latlng: LatLng): Point\r\n\t// Given a geographical coordinate, returns the corresponding pixel coordinate\r\n\t// relative to the map container.\r\n\tlatLngToContainerPoint: function (latlng) {\r\n\t\treturn this.layerPointToContainerPoint(this.latLngToLayerPoint(L.latLng(latlng)));\r\n\t},\r\n\r\n\t// @method mouseEventToContainerPoint(ev: MouseEvent): Point\r\n\t// Given a MouseEvent object, returns the pixel coordinate relative to the\r\n\t// map container where the event took place.\r\n\tmouseEventToContainerPoint: function (e) {\r\n\t\treturn L.DomEvent.getMousePosition(e, this._container);\r\n\t},\r\n\r\n\t// @method mouseEventToLayerPoint(ev: MouseEvent): Point\r\n\t// Given a MouseEvent object, returns the pixel coordinate relative to\r\n\t// the [origin pixel](#map-getpixelorigin) where the event took place.\r\n\tmouseEventToLayerPoint: function (e) {\r\n\t\treturn this.containerPointToLayerPoint(this.mouseEventToContainerPoint(e));\r\n\t},\r\n\r\n\t// @method mouseEventToLatLng(ev: MouseEvent): LatLng\r\n\t// Given a MouseEvent object, returns geographical coordinate where the\r\n\t// event took place.\r\n\tmouseEventToLatLng: function (e) { // (MouseEvent)\r\n\t\treturn this.layerPointToLatLng(this.mouseEventToLayerPoint(e));\r\n\t},\r\n\r\n\r\n\t// map initialization methods\r\n\r\n\t_initContainer: function (id) {\r\n\t\tvar container = this._container = L.DomUtil.get(id);\r\n\r\n\t\tif (!container) {\r\n\t\t\tthrow new Error('Map container not found.');\r\n\t\t} else if (container._leaflet_id) {\r\n\t\t\tthrow new Error('Map container is already initialized.');\r\n\t\t}\r\n\r\n\t\tL.DomEvent.addListener(container, 'scroll', this._onScroll, this);\r\n\t\tthis._containerId = L.Util.stamp(container);\r\n\t},\r\n\r\n\t_initLayout: function () {\r\n\t\tvar container = this._container;\r\n\r\n\t\tthis._fadeAnimated = this.options.fadeAnimation && L.Browser.any3d;\r\n\r\n\t\tL.DomUtil.addClass(container, 'leaflet-container' +\r\n\t\t\t(L.Browser.touch ? ' leaflet-touch' : '') +\r\n\t\t\t(L.Browser.retina ? ' leaflet-retina' : '') +\r\n\t\t\t(L.Browser.ielt9 ? ' leaflet-oldie' : '') +\r\n\t\t\t(L.Browser.safari ? ' leaflet-safari' : '') +\r\n\t\t\t(this._fadeAnimated ? ' leaflet-fade-anim' : ''));\r\n\r\n\t\tvar position = L.DomUtil.getStyle(container, 'position');\r\n\r\n\t\tif (position !== 'absolute' && position !== 'relative' && position !== 'fixed') {\r\n\t\t\tcontainer.style.position = 'relative';\r\n\t\t}\r\n\r\n\t\tthis._initPanes();\r\n\r\n\t\tif (this._initControlPos) {\r\n\t\t\tthis._initControlPos();\r\n\t\t}\r\n\t},\r\n\r\n\t_initPanes: function () {\r\n\t\tvar panes = this._panes = {};\r\n\t\tthis._paneRenderers = {};\r\n\r\n\t\t// @section\r\n\t\t//\r\n\t\t// Panes are DOM elements used to control the ordering of layers on the map. You\r\n\t\t// can access panes with [`map.getPane`](#map-getpane) or\r\n\t\t// [`map.getPanes`](#map-getpanes) methods. New panes can be created with the\r\n\t\t// [`map.createPane`](#map-createpane) method.\r\n\t\t//\r\n\t\t// Every map has the following default panes that differ only in zIndex.\r\n\t\t//\r\n\t\t// @pane mapPane: HTMLElement = 'auto'\r\n\t\t// Pane that contains all other map panes\r\n\r\n\t\tthis._mapPane = this.createPane('mapPane', this._container);\r\n\t\tL.DomUtil.setPosition(this._mapPane, new L.Point(0, 0));\r\n\r\n\t\t// @pane tilePane: HTMLElement = 200\r\n\t\t// Pane for `GridLayer`s and `TileLayer`s\r\n\t\tthis.createPane('tilePane');\r\n\t\t// @pane overlayPane: HTMLElement = 400\r\n\t\t// Pane for vector overlays (`Path`s), like `Polyline`s and `Polygon`s\r\n\t\tthis.createPane('shadowPane');\r\n\t\t// @pane shadowPane: HTMLElement = 500\r\n\t\t// Pane for overlay shadows (e.g. `Marker` shadows)\r\n\t\tthis.createPane('overlayPane');\r\n\t\t// @pane markerPane: HTMLElement = 600\r\n\t\t// Pane for `Icon`s of `Marker`s\r\n\t\tthis.createPane('markerPane');\r\n\t\t// @pane tooltipPane: HTMLElement = 650\r\n\t\t// Pane for tooltip.\r\n\t\tthis.createPane('tooltipPane');\r\n\t\t// @pane popupPane: HTMLElement = 700\r\n\t\t// Pane for `Popup`s.\r\n\t\tthis.createPane('popupPane');\r\n\r\n\t\tif (!this.options.markerZoomAnimation) {\r\n\t\t\tL.DomUtil.addClass(panes.markerPane, 'leaflet-zoom-hide');\r\n\t\t\tL.DomUtil.addClass(panes.shadowPane, 'leaflet-zoom-hide');\r\n\t\t}\r\n\t},\r\n\r\n\r\n\t// private methods that modify map state\r\n\r\n\t// @section Map state change events\r\n\t_resetView: function (center, zoom) {\r\n\t\tL.DomUtil.setPosition(this._mapPane, new L.Point(0, 0));\r\n\r\n\t\tvar loading = !this._loaded;\r\n\t\tthis._loaded = true;\r\n\t\tzoom = this._limitZoom(zoom);\r\n\r\n\t\tthis.fire('viewprereset');\r\n\r\n\t\tvar zoomChanged = this._zoom !== zoom;\r\n\t\tthis\r\n\t\t\t._moveStart(zoomChanged)\r\n\t\t\t._move(center, zoom)\r\n\t\t\t._moveEnd(zoomChanged);\r\n\r\n\t\t// @event viewreset: Event\r\n\t\t// Fired when the map needs to redraw its content (this usually happens\r\n\t\t// on map zoom or load). Very useful for creating custom overlays.\r\n\t\tthis.fire('viewreset');\r\n\r\n\t\t// @event load: Event\r\n\t\t// Fired when the map is initialized (when its center and zoom are set\r\n\t\t// for the first time).\r\n\t\tif (loading) {\r\n\t\t\tthis.fire('load');\r\n\t\t}\r\n\t},\r\n\r\n\t_moveStart: function (zoomChanged) {\r\n\t\t// @event zoomstart: Event\r\n\t\t// Fired when the map zoom is about to change (e.g. before zoom animation).\r\n\t\t// @event movestart: Event\r\n\t\t// Fired when the view of the map starts changing (e.g. user starts dragging the map).\r\n\t\tif (zoomChanged) {\r\n\t\t\tthis.fire('zoomstart');\r\n\t\t}\r\n\t\treturn this.fire('movestart');\r\n\t},\r\n\r\n\t_move: function (center, zoom, data) {\r\n\t\tif (zoom === undefined) {\r\n\t\t\tzoom = this._zoom;\r\n\t\t}\r\n\t\tvar zoomChanged = this._zoom !== zoom;\r\n\r\n\t\tthis._zoom = zoom;\r\n\t\tthis._lastCenter = center;\r\n\t\tthis._pixelOrigin = this._getNewPixelOrigin(center);\r\n\r\n\t\t// @event zoom: Event\r\n\t\t// Fired repeatedly during any change in zoom level, including zoom\r\n\t\t// and fly animations.\r\n\t\tif (zoomChanged || (data && data.pinch)) {\t// Always fire 'zoom' if pinching because #3530\r\n\t\t\tthis.fire('zoom', data);\r\n\t\t}\r\n\r\n\t\t// @event move: Event\r\n\t\t// Fired repeatedly during any movement of the map, including pan and\r\n\t\t// fly animations.\r\n\t\treturn this.fire('move', data);\r\n\t},\r\n\r\n\t_moveEnd: function (zoomChanged) {\r\n\t\t// @event zoomend: Event\r\n\t\t// Fired when the map has changed, after any animations.\r\n\t\tif (zoomChanged) {\r\n\t\t\tthis.fire('zoomend');\r\n\t\t}\r\n\r\n\t\t// @event moveend: Event\r\n\t\t// Fired when the center of the map stops changing (e.g. user stopped\r\n\t\t// dragging the map).\r\n\t\treturn this.fire('moveend');\r\n\t},\r\n\r\n\t_stop: function () {\r\n\t\tL.Util.cancelAnimFrame(this._flyToFrame);\r\n\t\tif (this._panAnim) {\r\n\t\t\tthis._panAnim.stop();\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_rawPanBy: function (offset) {\r\n\t\tL.DomUtil.setPosition(this._mapPane, this._getMapPanePos().subtract(offset));\r\n\t},\r\n\r\n\t_getZoomSpan: function () {\r\n\t\treturn this.getMaxZoom() - this.getMinZoom();\r\n\t},\r\n\r\n\t_panInsideMaxBounds: function () {\r\n\t\tif (!this._enforcingBounds) {\r\n\t\t\tthis.panInsideBounds(this.options.maxBounds);\r\n\t\t}\r\n\t},\r\n\r\n\t_checkIfLoaded: function () {\r\n\t\tif (!this._loaded) {\r\n\t\t\tthrow new Error('Set map center and zoom first.');\r\n\t\t}\r\n\t},\r\n\r\n\t// DOM event handling\r\n\r\n\t// @section Interaction events\r\n\t_initEvents: function (remove) {\r\n\t\tif (!L.DomEvent) { return; }\r\n\r\n\t\tthis._targets = {};\r\n\t\tthis._targets[L.stamp(this._container)] = this;\r\n\r\n\t\tvar onOff = remove ? 'off' : 'on';\r\n\r\n\t\t// @event click: MouseEvent\r\n\t\t// Fired when the user clicks (or taps) the map.\r\n\t\t// @event dblclick: MouseEvent\r\n\t\t// Fired when the user double-clicks (or double-taps) the map.\r\n\t\t// @event mousedown: MouseEvent\r\n\t\t// Fired when the user pushes the mouse button on the map.\r\n\t\t// @event mouseup: MouseEvent\r\n\t\t// Fired when the user releases the mouse button on the map.\r\n\t\t// @event mouseover: MouseEvent\r\n\t\t// Fired when the mouse enters the map.\r\n\t\t// @event mouseout: MouseEvent\r\n\t\t// Fired when the mouse leaves the map.\r\n\t\t// @event mousemove: MouseEvent\r\n\t\t// Fired while the mouse moves over the map.\r\n\t\t// @event contextmenu: MouseEvent\r\n\t\t// Fired when the user pushes the right mouse button on the map, prevents\r\n\t\t// default browser context menu from showing if there are listeners on\r\n\t\t// this event. Also fired on mobile when the user holds a single touch\r\n\t\t// for a second (also called long press).\r\n\t\t// @event keypress: KeyboardEvent\r\n\t\t// Fired when the user presses a key from the keyboard while the map is focused.\r\n\t\tL.DomEvent[onOff](this._container, 'click dblclick mousedown mouseup ' +\r\n\t\t\t'mouseover mouseout mousemove contextmenu keypress', this._handleDOMEvent, this);\r\n\r\n\t\tif (this.options.trackResize) {\r\n\t\t\tL.DomEvent[onOff](window, 'resize', this._onResize, this);\r\n\t\t}\r\n\r\n\t\tif (L.Browser.any3d && this.options.transform3DLimit) {\r\n\t\t\tthis[onOff]('moveend', this._onMoveEnd);\r\n\t\t}\r\n\t},\r\n\r\n\t_onResize: function () {\r\n\t\tL.Util.cancelAnimFrame(this._resizeRequest);\r\n\t\tthis._resizeRequest = L.Util.requestAnimFrame(\r\n\t\t function () { this.invalidateSize({debounceMoveend: true}); }, this);\r\n\t},\r\n\r\n\t_onScroll: function () {\r\n\t\tthis._container.scrollTop = 0;\r\n\t\tthis._container.scrollLeft = 0;\r\n\t},\r\n\r\n\t_onMoveEnd: function () {\r\n\t\tvar pos = this._getMapPanePos();\r\n\t\tif (Math.max(Math.abs(pos.x), Math.abs(pos.y)) >= this.options.transform3DLimit) {\r\n\t\t\t// https://bugzilla.mozilla.org/show_bug.cgi?id=1203873 but Webkit also have\r\n\t\t\t// a pixel offset on very high values, see: http://jsfiddle.net/dg6r5hhb/\r\n\t\t\tthis._resetView(this.getCenter(), this.getZoom());\r\n\t\t}\r\n\t},\r\n\r\n\t_findEventTargets: function (e, type) {\r\n\t\tvar targets = [],\r\n\t\t target,\r\n\t\t isHover = type === 'mouseout' || type === 'mouseover',\r\n\t\t src = e.target || e.srcElement,\r\n\t\t dragging = false;\r\n\r\n\t\twhile (src) {\r\n\t\t\ttarget = this._targets[L.stamp(src)];\r\n\t\t\tif (target && (type === 'click' || type === 'preclick') && !e._simulated && this._draggableMoved(target)) {\r\n\t\t\t\t// Prevent firing click after you just dragged an object.\r\n\t\t\t\tdragging = true;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tif (target && target.listens(type, true)) {\r\n\t\t\t\tif (isHover && !L.DomEvent._isExternalTarget(src, e)) { break; }\r\n\t\t\t\ttargets.push(target);\r\n\t\t\t\tif (isHover) { break; }\r\n\t\t\t}\r\n\t\t\tif (src === this._container) { break; }\r\n\t\t\tsrc = src.parentNode;\r\n\t\t}\r\n\t\tif (!targets.length && !dragging && !isHover && L.DomEvent._isExternalTarget(src, e)) {\r\n\t\t\ttargets = [this];\r\n\t\t}\r\n\t\treturn targets;\r\n\t},\r\n\r\n\t_handleDOMEvent: function (e) {\r\n\t\tif (!this._loaded || L.DomEvent._skipped(e)) { return; }\r\n\r\n\t\tvar type = e.type === 'keypress' && e.keyCode === 13 ? 'click' : e.type;\r\n\r\n\t\tif (type === 'mousedown') {\r\n\t\t\t// prevents outline when clicking on keyboard-focusable element\r\n\t\t\tL.DomUtil.preventOutline(e.target || e.srcElement);\r\n\t\t}\r\n\r\n\t\tthis._fireDOMEvent(e, type);\r\n\t},\r\n\r\n\t_fireDOMEvent: function (e, type, targets) {\r\n\r\n\t\tif (e.type === 'click') {\r\n\t\t\t// Fire a synthetic 'preclick' event which propagates up (mainly for closing popups).\r\n\t\t\t// @event preclick: MouseEvent\r\n\t\t\t// Fired before mouse click on the map (sometimes useful when you\r\n\t\t\t// want something to happen on click before any existing click\r\n\t\t\t// handlers start running).\r\n\t\t\tvar synth = L.Util.extend({}, e);\r\n\t\t\tsynth.type = 'preclick';\r\n\t\t\tthis._fireDOMEvent(synth, synth.type, targets);\r\n\t\t}\r\n\r\n\t\tif (e._stopped) { return; }\r\n\r\n\t\t// Find the layer the event is propagating from and its parents.\r\n\t\ttargets = (targets || []).concat(this._findEventTargets(e, type));\r\n\r\n\t\tif (!targets.length) { return; }\r\n\r\n\t\tvar target = targets[0];\r\n\t\tif (type === 'contextmenu' && target.listens(type, true)) {\r\n\t\t\tL.DomEvent.preventDefault(e);\r\n\t\t}\r\n\r\n\t\tvar data = {\r\n\t\t\toriginalEvent: e\r\n\t\t};\r\n\r\n\t\tif (e.type !== 'keypress') {\r\n\t\t\tvar isMarker = target instanceof L.Marker;\r\n\t\t\tdata.containerPoint = isMarker ?\r\n\t\t\t\t\tthis.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e);\r\n\t\t\tdata.layerPoint = this.containerPointToLayerPoint(data.containerPoint);\r\n\t\t\tdata.latlng = isMarker ? target.getLatLng() : this.layerPointToLatLng(data.layerPoint);\r\n\t\t}\r\n\r\n\t\tfor (var i = 0; i < targets.length; i++) {\r\n\t\t\ttargets[i].fire(type, data, true);\r\n\t\t\tif (data.originalEvent._stopped ||\r\n\t\t\t\t(targets[i].options.nonBubblingEvents && L.Util.indexOf(targets[i].options.nonBubblingEvents, type) !== -1)) { return; }\r\n\t\t}\r\n\t},\r\n\r\n\t_draggableMoved: function (obj) {\r\n\t\tobj = obj.dragging && obj.dragging.enabled() ? obj : this;\r\n\t\treturn (obj.dragging && obj.dragging.moved()) || (this.boxZoom && this.boxZoom.moved());\r\n\t},\r\n\r\n\t_clearHandlers: function () {\r\n\t\tfor (var i = 0, len = this._handlers.length; i < len; i++) {\r\n\t\t\tthis._handlers[i].disable();\r\n\t\t}\r\n\t},\r\n\r\n\t// @section Other Methods\r\n\r\n\t// @method whenReady(fn: Function, context?: Object): this\r\n\t// Runs the given function `fn` when the map gets initialized with\r\n\t// a view (center and zoom) and at least one layer, or immediately\r\n\t// if it's already initialized, optionally passing a function context.\r\n\twhenReady: function (callback, context) {\r\n\t\tif (this._loaded) {\r\n\t\t\tcallback.call(context || this, {target: this});\r\n\t\t} else {\r\n\t\t\tthis.on('load', callback, context);\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\r\n\t// private methods for getting map state\r\n\r\n\t_getMapPanePos: function () {\r\n\t\treturn L.DomUtil.getPosition(this._mapPane) || new L.Point(0, 0);\r\n\t},\r\n\r\n\t_moved: function () {\r\n\t\tvar pos = this._getMapPanePos();\r\n\t\treturn pos && !pos.equals([0, 0]);\r\n\t},\r\n\r\n\t_getTopLeftPoint: function (center, zoom) {\r\n\t\tvar pixelOrigin = center && zoom !== undefined ?\r\n\t\t\tthis._getNewPixelOrigin(center, zoom) :\r\n\t\t\tthis.getPixelOrigin();\r\n\t\treturn pixelOrigin.subtract(this._getMapPanePos());\r\n\t},\r\n\r\n\t_getNewPixelOrigin: function (center, zoom) {\r\n\t\tvar viewHalf = this.getSize()._divideBy(2);\r\n\t\treturn this.project(center, zoom)._subtract(viewHalf)._add(this._getMapPanePos())._round();\r\n\t},\r\n\r\n\t_latLngToNewLayerPoint: function (latlng, zoom, center) {\r\n\t\tvar topLeft = this._getNewPixelOrigin(center, zoom);\r\n\t\treturn this.project(latlng, zoom)._subtract(topLeft);\r\n\t},\r\n\r\n\t_latLngBoundsToNewLayerBounds: function (latLngBounds, zoom, center) {\r\n\t\tvar topLeft = this._getNewPixelOrigin(center, zoom);\r\n\t\treturn L.bounds([\r\n\t\t\tthis.project(latLngBounds.getSouthWest(), zoom)._subtract(topLeft),\r\n\t\t\tthis.project(latLngBounds.getNorthWest(), zoom)._subtract(topLeft),\r\n\t\t\tthis.project(latLngBounds.getSouthEast(), zoom)._subtract(topLeft),\r\n\t\t\tthis.project(latLngBounds.getNorthEast(), zoom)._subtract(topLeft)\r\n\t\t]);\r\n\t},\r\n\r\n\t// layer point of the current center\r\n\t_getCenterLayerPoint: function () {\r\n\t\treturn this.containerPointToLayerPoint(this.getSize()._divideBy(2));\r\n\t},\r\n\r\n\t// offset of the specified place to the current center in pixels\r\n\t_getCenterOffset: function (latlng) {\r\n\t\treturn this.latLngToLayerPoint(latlng).subtract(this._getCenterLayerPoint());\r\n\t},\r\n\r\n\t// adjust center for view to get inside bounds\r\n\t_limitCenter: function (center, zoom, bounds) {\r\n\r\n\t\tif (!bounds) { return center; }\r\n\r\n\t\tvar centerPoint = this.project(center, zoom),\r\n\t\t viewHalf = this.getSize().divideBy(2),\r\n\t\t viewBounds = new L.Bounds(centerPoint.subtract(viewHalf), centerPoint.add(viewHalf)),\r\n\t\t offset = this._getBoundsOffset(viewBounds, bounds, zoom);\r\n\r\n\t\t// If offset is less than a pixel, ignore.\r\n\t\t// This prevents unstable projections from getting into\r\n\t\t// an infinite loop of tiny offsets.\r\n\t\tif (offset.round().equals([0, 0])) {\r\n\t\t\treturn center;\r\n\t\t}\r\n\r\n\t\treturn this.unproject(centerPoint.add(offset), zoom);\r\n\t},\r\n\r\n\t// adjust offset for view to get inside bounds\r\n\t_limitOffset: function (offset, bounds) {\r\n\t\tif (!bounds) { return offset; }\r\n\r\n\t\tvar viewBounds = this.getPixelBounds(),\r\n\t\t newBounds = new L.Bounds(viewBounds.min.add(offset), viewBounds.max.add(offset));\r\n\r\n\t\treturn offset.add(this._getBoundsOffset(newBounds, bounds));\r\n\t},\r\n\r\n\t// returns offset needed for pxBounds to get inside maxBounds at a specified zoom\r\n\t_getBoundsOffset: function (pxBounds, maxBounds, zoom) {\r\n\t\tvar projectedMaxBounds = L.bounds(\r\n\t\t this.project(maxBounds.getNorthEast(), zoom),\r\n\t\t this.project(maxBounds.getSouthWest(), zoom)\r\n\t\t ),\r\n\t\t minOffset = projectedMaxBounds.min.subtract(pxBounds.min),\r\n\t\t maxOffset = projectedMaxBounds.max.subtract(pxBounds.max),\r\n\r\n\t\t dx = this._rebound(minOffset.x, -maxOffset.x),\r\n\t\t dy = this._rebound(minOffset.y, -maxOffset.y);\r\n\r\n\t\treturn new L.Point(dx, dy);\r\n\t},\r\n\r\n\t_rebound: function (left, right) {\r\n\t\treturn left + right > 0 ?\r\n\t\t\tMath.round(left - right) / 2 :\r\n\t\t\tMath.max(0, Math.ceil(left)) - Math.max(0, Math.floor(right));\r\n\t},\r\n\r\n\t_limitZoom: function (zoom) {\r\n\t\tvar min = this.getMinZoom(),\r\n\t\t max = this.getMaxZoom(),\r\n\t\t snap = L.Browser.any3d ? this.options.zoomSnap : 1;\r\n\t\tif (snap) {\r\n\t\t\tzoom = Math.round(zoom / snap) * snap;\r\n\t\t}\r\n\t\treturn Math.max(min, Math.min(max, zoom));\r\n\t},\r\n\r\n\t_onPanTransitionStep: function () {\r\n\t\tthis.fire('move');\r\n\t},\r\n\r\n\t_onPanTransitionEnd: function () {\r\n\t\tL.DomUtil.removeClass(this._mapPane, 'leaflet-pan-anim');\r\n\t\tthis.fire('moveend');\r\n\t},\r\n\r\n\t_tryAnimatedPan: function (center, options) {\r\n\t\t// difference between the new and current centers in pixels\r\n\t\tvar offset = this._getCenterOffset(center)._floor();\r\n\r\n\t\t// don't animate too far unless animate: true specified in options\r\n\t\tif ((options && options.animate) !== true && !this.getSize().contains(offset)) { return false; }\r\n\r\n\t\tthis.panBy(offset, options);\r\n\r\n\t\treturn true;\r\n\t},\r\n\r\n\t_createAnimProxy: function () {\r\n\r\n\t\tvar proxy = this._proxy = L.DomUtil.create('div', 'leaflet-proxy leaflet-zoom-animated');\r\n\t\tthis._panes.mapPane.appendChild(proxy);\r\n\r\n\t\tthis.on('zoomanim', function (e) {\r\n\t\t\tvar prop = L.DomUtil.TRANSFORM,\r\n\t\t\t transform = proxy.style[prop];\r\n\r\n\t\t\tL.DomUtil.setTransform(proxy, this.project(e.center, e.zoom), this.getZoomScale(e.zoom, 1));\r\n\r\n\t\t\t// workaround for case when transform is the same and so transitionend event is not fired\r\n\t\t\tif (transform === proxy.style[prop] && this._animatingZoom) {\r\n\t\t\t\tthis._onZoomTransitionEnd();\r\n\t\t\t}\r\n\t\t}, this);\r\n\r\n\t\tthis.on('load moveend', function () {\r\n\t\t\tvar c = this.getCenter(),\r\n\t\t\t z = this.getZoom();\r\n\t\t\tL.DomUtil.setTransform(proxy, this.project(c, z), this.getZoomScale(z, 1));\r\n\t\t}, this);\r\n\t},\r\n\r\n\t_catchTransitionEnd: function (e) {\r\n\t\tif (this._animatingZoom && e.propertyName.indexOf('transform') >= 0) {\r\n\t\t\tthis._onZoomTransitionEnd();\r\n\t\t}\r\n\t},\r\n\r\n\t_nothingToAnimate: function () {\r\n\t\treturn !this._container.getElementsByClassName('leaflet-zoom-animated').length;\r\n\t},\r\n\r\n\t_tryAnimatedZoom: function (center, zoom, options) {\r\n\r\n\t\tif (this._animatingZoom) { return true; }\r\n\r\n\t\toptions = options || {};\r\n\r\n\t\t// don't animate if disabled, not supported or zoom difference is too large\r\n\t\tif (!this._zoomAnimated || options.animate === false || this._nothingToAnimate() ||\r\n\t\t Math.abs(zoom - this._zoom) > this.options.zoomAnimationThreshold) { return false; }\r\n\r\n\t\t// offset is the pixel coords of the zoom origin relative to the current center\r\n\t\tvar scale = this.getZoomScale(zoom),\r\n\t\t offset = this._getCenterOffset(center)._divideBy(1 - 1 / scale);\r\n\r\n\t\t// don't animate if the zoom origin isn't within one screen from the current center, unless forced\r\n\t\tif (options.animate !== true && !this.getSize().contains(offset)) { return false; }\r\n\r\n\t\tL.Util.requestAnimFrame(function () {\r\n\t\t\tthis\r\n\t\t\t ._moveStart(true)\r\n\t\t\t ._animateZoom(center, zoom, true);\r\n\t\t}, this);\r\n\r\n\t\treturn true;\r\n\t},\r\n\r\n\t_animateZoom: function (center, zoom, startAnim, noUpdate) {\r\n\t\tif (startAnim) {\r\n\t\t\tthis._animatingZoom = true;\r\n\r\n\t\t\t// remember what center/zoom to set after animation\r\n\t\t\tthis._animateToCenter = center;\r\n\t\t\tthis._animateToZoom = zoom;\r\n\r\n\t\t\tL.DomUtil.addClass(this._mapPane, 'leaflet-zoom-anim');\r\n\t\t}\r\n\r\n\t\t// @event zoomanim: ZoomAnimEvent\r\n\t\t// Fired on every frame of a zoom animation\r\n\t\tthis.fire('zoomanim', {\r\n\t\t\tcenter: center,\r\n\t\t\tzoom: zoom,\r\n\t\t\tnoUpdate: noUpdate\r\n\t\t});\r\n\r\n\t\t// Work around webkit not firing 'transitionend', see https://github.com/Leaflet/Leaflet/issues/3689, 2693\r\n\t\tsetTimeout(L.bind(this._onZoomTransitionEnd, this), 250);\r\n\t},\r\n\r\n\t_onZoomTransitionEnd: function () {\r\n\t\tif (!this._animatingZoom) { return; }\r\n\r\n\t\tL.DomUtil.removeClass(this._mapPane, 'leaflet-zoom-anim');\r\n\r\n\t\tthis._animatingZoom = false;\r\n\r\n\t\tthis._move(this._animateToCenter, this._animateToZoom);\r\n\r\n\t\t// This anim frame should prevent an obscure iOS webkit tile loading race condition.\r\n\t\tL.Util.requestAnimFrame(function () {\r\n\t\t\tthis._moveEnd(true);\r\n\t\t}, this);\r\n\t}\r\n});\r\n\r\n// @section\r\n\r\n// @factory L.map(id: String, options?: Map options)\r\n// Instantiates a map object given the DOM ID of a `
      ` element\r\n// and optionally an object literal with `Map options`.\r\n//\r\n// @alternative\r\n// @factory L.map(el: HTMLElement, options?: Map options)\r\n// Instantiates a map object given an instance of a `
      ` HTML element\r\n// and optionally an object literal with `Map options`.\r\nL.map = function (id, options) {\r\n\treturn new L.Map(id, options);\r\n};\r\n","\n/*\n * @class Layer\n * @inherits Evented\n * @aka L.Layer\n * @aka ILayer\n *\n * A set of methods from the Layer base class that all Leaflet layers use.\n * Inherits all methods, options and events from `L.Evented`.\n *\n * @example\n *\n * ```js\n * var layer = L.Marker(latlng).addTo(map);\n * layer.addTo(map);\n * layer.remove();\n * ```\n *\n * @event add: Event\n * Fired after the layer is added to a map\n *\n * @event remove: Event\n * Fired after the layer is removed from a map\n */\n\n\nL.Layer = L.Evented.extend({\n\n\t// Classes extending `L.Layer` will inherit the following options:\n\toptions: {\n\t\t// @option pane: String = 'overlayPane'\n\t\t// By default the layer will be added to the map's [overlay pane](#map-overlaypane). Overriding this option will cause the layer to be placed on another pane by default.\n\t\tpane: 'overlayPane',\n\t\tnonBubblingEvents: [], // Array of events that should not be bubbled to DOM parents (like the map),\n\n\t\t// @option attribution: String = null\n\t\t// String to be shown in the attribution control, describes the layer data, e.g. \"© Mapbox\".\n\t\tattribution: null,\n\t},\n\n\t/* @section\n\t * Classes extending `L.Layer` will inherit the following methods:\n\t *\n\t * @method addTo(map: Map): this\n\t * Adds the layer to the given map\n\t */\n\taddTo: function (map) {\n\t\tmap.addLayer(this);\n\t\treturn this;\n\t},\n\n\t// @method remove: this\n\t// Removes the layer from the map it is currently active on.\n\tremove: function () {\n\t\treturn this.removeFrom(this._map || this._mapToAdd);\n\t},\n\n\t// @method removeFrom(map: Map): this\n\t// Removes the layer from the given map\n\tremoveFrom: function (obj) {\n\t\tif (obj) {\n\t\t\tobj.removeLayer(this);\n\t\t}\n\t\treturn this;\n\t},\n\n\t// @method getPane(name? : String): HTMLElement\n\t// Returns the `HTMLElement` representing the named pane on the map. If `name` is omitted, returns the pane for this layer.\n\tgetPane: function (name) {\n\t\treturn this._map.getPane(name ? (this.options[name] || name) : this.options.pane);\n\t},\n\n\taddInteractiveTarget: function (targetEl) {\n\t\tthis._map._targets[L.stamp(targetEl)] = this;\n\t\treturn this;\n\t},\n\n\tremoveInteractiveTarget: function (targetEl) {\n\t\tdelete this._map._targets[L.stamp(targetEl)];\n\t\treturn this;\n\t},\n\n\t// @method getAttribution: String\n\t// Used by the `attribution control`, returns the [attribution option](#gridlayer-attribution).\n\tgetAttribution: function () {\n\t\treturn this.options.attribution;\n\t},\n\n\t_layerAdd: function (e) {\n\t\tvar map = e.target;\n\n\t\t// check in case layer gets added and then removed before the map is ready\n\t\tif (!map.hasLayer(this)) { return; }\n\n\t\tthis._map = map;\n\t\tthis._zoomAnimated = map._zoomAnimated;\n\n\t\tif (this.getEvents) {\n\t\t\tvar events = this.getEvents();\n\t\t\tmap.on(events, this);\n\t\t\tthis.once('remove', function () {\n\t\t\t\tmap.off(events, this);\n\t\t\t}, this);\n\t\t}\n\n\t\tthis.onAdd(map);\n\n\t\tif (this.getAttribution && this._map.attributionControl) {\n\t\t\tthis._map.attributionControl.addAttribution(this.getAttribution());\n\t\t}\n\n\t\tthis.fire('add');\n\t\tmap.fire('layeradd', {layer: this});\n\t}\n});\n\n/* @section Extension methods\n * @uninheritable\n *\n * Every layer should extend from `L.Layer` and (re-)implement the following methods.\n *\n * @method onAdd(map: Map): this\n * Should contain code that creates DOM elements for the layer, adds them to `map panes` where they should belong and puts listeners on relevant map events. Called on [`map.addLayer(layer)`](#map-addlayer).\n *\n * @method onRemove(map: Map): this\n * Should contain all clean up code that removes the layer's elements from the DOM and removes listeners previously added in [`onAdd`](#layer-onadd). Called on [`map.removeLayer(layer)`](#map-removelayer).\n *\n * @method getEvents(): Object\n * This optional method should return an object like `{ viewreset: this._reset }` for [`addEventListener`](#evented-addeventlistener). The event handlers in this object will be automatically added and removed from the map with your layer.\n *\n * @method getAttribution(): String\n * This optional method should return a string containing HTML to be shown on the `Attribution control` whenever the layer is visible.\n *\n * @method beforeAdd(map: Map): this\n * Optional method. Called on [`map.addLayer(layer)`](#map-addlayer), before the layer is added to the map, before events are initialized, without waiting until the map is in a usable state. Use for early initialization only.\n */\n\n\n/* @namespace Map\n * @section Layer events\n *\n * @event layeradd: LayerEvent\n * Fired when a new layer is added to the map.\n *\n * @event layerremove: LayerEvent\n * Fired when some layer is removed from the map\n *\n * @section Methods for Layers and Controls\n */\nL.Map.include({\n\t// @method addLayer(layer: Layer): this\n\t// Adds the given layer to the map\n\taddLayer: function (layer) {\n\t\tvar id = L.stamp(layer);\n\t\tif (this._layers[id]) { return this; }\n\t\tthis._layers[id] = layer;\n\n\t\tlayer._mapToAdd = this;\n\n\t\tif (layer.beforeAdd) {\n\t\t\tlayer.beforeAdd(this);\n\t\t}\n\n\t\tthis.whenReady(layer._layerAdd, layer);\n\n\t\treturn this;\n\t},\n\n\t// @method removeLayer(layer: Layer): this\n\t// Removes the given layer from the map.\n\tremoveLayer: function (layer) {\n\t\tvar id = L.stamp(layer);\n\n\t\tif (!this._layers[id]) { return this; }\n\n\t\tif (this._loaded) {\n\t\t\tlayer.onRemove(this);\n\t\t}\n\n\t\tif (layer.getAttribution && this.attributionControl) {\n\t\t\tthis.attributionControl.removeAttribution(layer.getAttribution());\n\t\t}\n\n\t\tdelete this._layers[id];\n\n\t\tif (this._loaded) {\n\t\t\tthis.fire('layerremove', {layer: layer});\n\t\t\tlayer.fire('remove');\n\t\t}\n\n\t\tlayer._map = layer._mapToAdd = null;\n\n\t\treturn this;\n\t},\n\n\t// @method hasLayer(layer: Layer): Boolean\n\t// Returns `true` if the given layer is currently added to the map\n\thasLayer: function (layer) {\n\t\treturn !!layer && (L.stamp(layer) in this._layers);\n\t},\n\n\t/* @method eachLayer(fn: Function, context?: Object): this\n\t * Iterates over the layers of the map, optionally specifying context of the iterator function.\n\t * ```\n\t * map.eachLayer(function(layer){\n\t * layer.bindPopup('Hello');\n\t * });\n\t * ```\n\t */\n\teachLayer: function (method, context) {\n\t\tfor (var i in this._layers) {\n\t\t\tmethod.call(context, this._layers[i]);\n\t\t}\n\t\treturn this;\n\t},\n\n\t_addLayers: function (layers) {\n\t\tlayers = layers ? (L.Util.isArray(layers) ? layers : [layers]) : [];\n\n\t\tfor (var i = 0, len = layers.length; i < len; i++) {\n\t\t\tthis.addLayer(layers[i]);\n\t\t}\n\t},\n\n\t_addZoomLimit: function (layer) {\n\t\tif (isNaN(layer.options.maxZoom) || !isNaN(layer.options.minZoom)) {\n\t\t\tthis._zoomBoundLayers[L.stamp(layer)] = layer;\n\t\t\tthis._updateZoomLevels();\n\t\t}\n\t},\n\n\t_removeZoomLimit: function (layer) {\n\t\tvar id = L.stamp(layer);\n\n\t\tif (this._zoomBoundLayers[id]) {\n\t\t\tdelete this._zoomBoundLayers[id];\n\t\t\tthis._updateZoomLevels();\n\t\t}\n\t},\n\n\t_updateZoomLevels: function () {\n\t\tvar minZoom = Infinity,\n\t\t maxZoom = -Infinity,\n\t\t oldZoomSpan = this._getZoomSpan();\n\n\t\tfor (var i in this._zoomBoundLayers) {\n\t\t\tvar options = this._zoomBoundLayers[i].options;\n\n\t\t\tminZoom = options.minZoom === undefined ? minZoom : Math.min(minZoom, options.minZoom);\n\t\t\tmaxZoom = options.maxZoom === undefined ? maxZoom : Math.max(maxZoom, options.maxZoom);\n\t\t}\n\n\t\tthis._layersMaxZoom = maxZoom === -Infinity ? undefined : maxZoom;\n\t\tthis._layersMinZoom = minZoom === Infinity ? undefined : minZoom;\n\n\t\t// @section Map state change events\n\t\t// @event zoomlevelschange: Event\n\t\t// Fired when the number of zoomlevels on the map is changed due\n\t\t// to adding or removing a layer.\n\t\tif (oldZoomSpan !== this._getZoomSpan()) {\n\t\t\tthis.fire('zoomlevelschange');\n\t\t}\n\n\t\tif (this.options.maxZoom === undefined && this._layersMaxZoom && this.getZoom() > this._layersMaxZoom) {\n\t\t\tthis.setZoom(this._layersMaxZoom);\n\t\t}\n\t\tif (this.options.minZoom === undefined && this._layersMinZoom && this.getZoom() < this._layersMinZoom) {\n\t\t\tthis.setZoom(this._layersMinZoom);\n\t\t}\n\t}\n});\n","/*\r\n * @namespace DomEvent\r\n * Utility functions to work with the [DOM events](https://developer.mozilla.org/docs/Web/API/Event), used by Leaflet internally.\r\n */\r\n\r\n// Inspired by John Resig, Dean Edwards and YUI addEvent implementations.\r\n\r\n\r\n\r\nvar eventsKey = '_leaflet_events';\r\n\r\nL.DomEvent = {\r\n\r\n\t// @function on(el: HTMLElement, types: String, fn: Function, context?: Object): this\r\n\t// Adds a listener function (`fn`) to a particular DOM event type of the\r\n\t// element `el`. You can optionally specify the context of the listener\r\n\t// (object the `this` keyword will point to). You can also pass several\r\n\t// space-separated types (e.g. `'click dblclick'`).\r\n\r\n\t// @alternative\r\n\t// @function on(el: HTMLElement, eventMap: Object, context?: Object): this\r\n\t// Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}`\r\n\ton: function (obj, types, fn, context) {\r\n\r\n\t\tif (typeof types === 'object') {\r\n\t\t\tfor (var type in types) {\r\n\t\t\t\tthis._on(obj, type, types[type], fn);\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\ttypes = L.Util.splitWords(types);\r\n\r\n\t\t\tfor (var i = 0, len = types.length; i < len; i++) {\r\n\t\t\t\tthis._on(obj, types[i], fn, context);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @function off(el: HTMLElement, types: String, fn: Function, context?: Object): this\r\n\t// Removes a previously added listener function. If no function is specified,\r\n\t// it will remove all the listeners of that particular DOM event from the element.\r\n\t// Note that if you passed a custom context to on, you must pass the same\r\n\t// context to `off` in order to remove the listener.\r\n\r\n\t// @alternative\r\n\t// @function off(el: HTMLElement, eventMap: Object, context?: Object): this\r\n\t// Removes a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}`\r\n\toff: function (obj, types, fn, context) {\r\n\r\n\t\tif (typeof types === 'object') {\r\n\t\t\tfor (var type in types) {\r\n\t\t\t\tthis._off(obj, type, types[type], fn);\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\ttypes = L.Util.splitWords(types);\r\n\r\n\t\t\tfor (var i = 0, len = types.length; i < len; i++) {\r\n\t\t\t\tthis._off(obj, types[i], fn, context);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_on: function (obj, type, fn, context) {\r\n\t\tvar id = type + L.stamp(fn) + (context ? '_' + L.stamp(context) : '');\r\n\r\n\t\tif (obj[eventsKey] && obj[eventsKey][id]) { return this; }\r\n\r\n\t\tvar handler = function (e) {\r\n\t\t\treturn fn.call(context || obj, e || window.event);\r\n\t\t};\r\n\r\n\t\tvar originalHandler = handler;\r\n\r\n\t\tif (L.Browser.pointer && type.indexOf('touch') === 0) {\r\n\t\t\tthis.addPointerListener(obj, type, handler, id);\r\n\r\n\t\t} else if (L.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener) {\r\n\t\t\tthis.addDoubleTapListener(obj, handler, id);\r\n\r\n\t\t} else if ('addEventListener' in obj) {\r\n\r\n\t\t\tif (type === 'mousewheel') {\r\n\t\t\t\tobj.addEventListener('onwheel' in obj ? 'wheel' : 'mousewheel', handler, false);\r\n\r\n\t\t\t} else if ((type === 'mouseenter') || (type === 'mouseleave')) {\r\n\t\t\t\thandler = function (e) {\r\n\t\t\t\t\te = e || window.event;\r\n\t\t\t\t\tif (L.DomEvent._isExternalTarget(obj, e)) {\r\n\t\t\t\t\t\toriginalHandler(e);\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\t\tobj.addEventListener(type === 'mouseenter' ? 'mouseover' : 'mouseout', handler, false);\r\n\r\n\t\t\t} else {\r\n\t\t\t\tif (type === 'click' && L.Browser.android) {\r\n\t\t\t\t\thandler = function (e) {\r\n\t\t\t\t\t\treturn L.DomEvent._filterClick(e, originalHandler);\r\n\t\t\t\t\t};\r\n\t\t\t\t}\r\n\t\t\t\tobj.addEventListener(type, handler, false);\r\n\t\t\t}\r\n\r\n\t\t} else if ('attachEvent' in obj) {\r\n\t\t\tobj.attachEvent('on' + type, handler);\r\n\t\t}\r\n\r\n\t\tobj[eventsKey] = obj[eventsKey] || {};\r\n\t\tobj[eventsKey][id] = handler;\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_off: function (obj, type, fn, context) {\r\n\r\n\t\tvar id = type + L.stamp(fn) + (context ? '_' + L.stamp(context) : ''),\r\n\t\t handler = obj[eventsKey] && obj[eventsKey][id];\r\n\r\n\t\tif (!handler) { return this; }\r\n\r\n\t\tif (L.Browser.pointer && type.indexOf('touch') === 0) {\r\n\t\t\tthis.removePointerListener(obj, type, id);\r\n\r\n\t\t} else if (L.Browser.touch && (type === 'dblclick') && this.removeDoubleTapListener) {\r\n\t\t\tthis.removeDoubleTapListener(obj, id);\r\n\r\n\t\t} else if ('removeEventListener' in obj) {\r\n\r\n\t\t\tif (type === 'mousewheel') {\r\n\t\t\t\tobj.removeEventListener('onwheel' in obj ? 'wheel' : 'mousewheel', handler, false);\r\n\r\n\t\t\t} else {\r\n\t\t\t\tobj.removeEventListener(\r\n\t\t\t\t\ttype === 'mouseenter' ? 'mouseover' :\r\n\t\t\t\t\ttype === 'mouseleave' ? 'mouseout' : type, handler, false);\r\n\t\t\t}\r\n\r\n\t\t} else if ('detachEvent' in obj) {\r\n\t\t\tobj.detachEvent('on' + type, handler);\r\n\t\t}\r\n\r\n\t\tobj[eventsKey][id] = null;\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @function stopPropagation(ev: DOMEvent): this\r\n\t// Stop the given event from propagation to parent elements. Used inside the listener functions:\r\n\t// ```js\r\n\t// L.DomEvent.on(div, 'click', function (ev) {\r\n\t// \tL.DomEvent.stopPropagation(ev);\r\n\t// });\r\n\t// ```\r\n\tstopPropagation: function (e) {\r\n\r\n\t\tif (e.stopPropagation) {\r\n\t\t\te.stopPropagation();\r\n\t\t} else if (e.originalEvent) { // In case of Leaflet event.\r\n\t\t\te.originalEvent._stopped = true;\r\n\t\t} else {\r\n\t\t\te.cancelBubble = true;\r\n\t\t}\r\n\t\tL.DomEvent._skipped(e);\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @function disableScrollPropagation(el: HTMLElement): this\r\n\t// Adds `stopPropagation` to the element's `'mousewheel'` events (plus browser variants).\r\n\tdisableScrollPropagation: function (el) {\r\n\t\treturn L.DomEvent.on(el, 'mousewheel', L.DomEvent.stopPropagation);\r\n\t},\r\n\r\n\t// @function disableClickPropagation(el: HTMLElement): this\r\n\t// Adds `stopPropagation` to the element's `'click'`, `'doubleclick'`,\r\n\t// `'mousedown'` and `'touchstart'` events (plus browser variants).\r\n\tdisableClickPropagation: function (el) {\r\n\t\tvar stop = L.DomEvent.stopPropagation;\r\n\r\n\t\tL.DomEvent.on(el, L.Draggable.START.join(' '), stop);\r\n\r\n\t\treturn L.DomEvent.on(el, {\r\n\t\t\tclick: L.DomEvent._fakeStop,\r\n\t\t\tdblclick: stop\r\n\t\t});\r\n\t},\r\n\r\n\t// @function preventDefault(ev: DOMEvent): this\r\n\t// Prevents the default action of the DOM Event `ev` from happening (such as\r\n\t// following a link in the href of the a element, or doing a POST request\r\n\t// with page reload when a `` is submitted).\r\n\t// Use it inside listener functions.\r\n\tpreventDefault: function (e) {\r\n\r\n\t\tif (e.preventDefault) {\r\n\t\t\te.preventDefault();\r\n\t\t} else {\r\n\t\t\te.returnValue = false;\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @function stop(ev): this\r\n\t// Does `stopPropagation` and `preventDefault` at the same time.\r\n\tstop: function (e) {\r\n\t\treturn L.DomEvent\r\n\t\t\t.preventDefault(e)\r\n\t\t\t.stopPropagation(e);\r\n\t},\r\n\r\n\t// @function getMousePosition(ev: DOMEvent, container?: HTMLElement): Point\r\n\t// Gets normalized mouse position from a DOM event relative to the\r\n\t// `container` or to the whole page if not specified.\r\n\tgetMousePosition: function (e, container) {\r\n\t\tif (!container) {\r\n\t\t\treturn new L.Point(e.clientX, e.clientY);\r\n\t\t}\r\n\r\n\t\tvar rect = container.getBoundingClientRect();\r\n\r\n\t\treturn new L.Point(\r\n\t\t\te.clientX - rect.left - container.clientLeft,\r\n\t\t\te.clientY - rect.top - container.clientTop);\r\n\t},\r\n\r\n\t// Chrome on Win scrolls double the pixels as in other platforms (see #4538),\r\n\t// and Firefox scrolls device pixels, not CSS pixels\r\n\t_wheelPxFactor: (L.Browser.win && L.Browser.chrome) ? 2 :\r\n\t L.Browser.gecko ? window.devicePixelRatio :\r\n\t 1,\r\n\r\n\t// @function getWheelDelta(ev: DOMEvent): Number\r\n\t// Gets normalized wheel delta from a mousewheel DOM event, in vertical\r\n\t// pixels scrolled (negative if scrolling down).\r\n\t// Events from pointing devices without precise scrolling are mapped to\r\n\t// a best guess of 60 pixels.\r\n\tgetWheelDelta: function (e) {\r\n\t\treturn (L.Browser.edge) ? e.wheelDeltaY / 2 : // Don't trust window-geometry-based delta\r\n\t\t (e.deltaY && e.deltaMode === 0) ? -e.deltaY / L.DomEvent._wheelPxFactor : // Pixels\r\n\t\t (e.deltaY && e.deltaMode === 1) ? -e.deltaY * 20 : // Lines\r\n\t\t (e.deltaY && e.deltaMode === 2) ? -e.deltaY * 60 : // Pages\r\n\t\t (e.deltaX || e.deltaZ) ? 0 :\t// Skip horizontal/depth wheel events\r\n\t\t e.wheelDelta ? (e.wheelDeltaY || e.wheelDelta) / 2 : // Legacy IE pixels\r\n\t\t (e.detail && Math.abs(e.detail) < 32765) ? -e.detail * 20 : // Legacy Moz lines\r\n\t\t e.detail ? e.detail / -32765 * 60 : // Legacy Moz pages\r\n\t\t 0;\r\n\t},\r\n\r\n\t_skipEvents: {},\r\n\r\n\t_fakeStop: function (e) {\r\n\t\t// fakes stopPropagation by setting a special event flag, checked/reset with L.DomEvent._skipped(e)\r\n\t\tL.DomEvent._skipEvents[e.type] = true;\r\n\t},\r\n\r\n\t_skipped: function (e) {\r\n\t\tvar skipped = this._skipEvents[e.type];\r\n\t\t// reset when checking, as it's only used in map container and propagates outside of the map\r\n\t\tthis._skipEvents[e.type] = false;\r\n\t\treturn skipped;\r\n\t},\r\n\r\n\t// check if element really left/entered the event target (for mouseenter/mouseleave)\r\n\t_isExternalTarget: function (el, e) {\r\n\r\n\t\tvar related = e.relatedTarget;\r\n\r\n\t\tif (!related) { return true; }\r\n\r\n\t\ttry {\r\n\t\t\twhile (related && (related !== el)) {\r\n\t\t\t\trelated = related.parentNode;\r\n\t\t\t}\r\n\t\t} catch (err) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\treturn (related !== el);\r\n\t},\r\n\r\n\t// this is a horrible workaround for a bug in Android where a single touch triggers two click events\r\n\t_filterClick: function (e, handler) {\r\n\t\tvar timeStamp = (e.timeStamp || (e.originalEvent && e.originalEvent.timeStamp)),\r\n\t\t elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);\r\n\r\n\t\t// are they closer together than 500ms yet more than 100ms?\r\n\t\t// Android typically triggers them ~300ms apart while multiple listeners\r\n\t\t// on the same event should be triggered far faster;\r\n\t\t// or check if click is simulated on the element, and if it is, reject any non-simulated events\r\n\r\n\t\tif ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) {\r\n\t\t\tL.DomEvent.stop(e);\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tL.DomEvent._lastClick = timeStamp;\r\n\r\n\t\thandler(e);\r\n\t}\r\n};\r\n\r\n// @function addListener(…): this\r\n// Alias to [`L.DomEvent.on`](#domevent-on)\r\nL.DomEvent.addListener = L.DomEvent.on;\r\n\r\n// @function removeListener(…): this\r\n// Alias to [`L.DomEvent.off`](#domevent-off)\r\nL.DomEvent.removeListener = L.DomEvent.off;\r\n","/*\n * @class PosAnimation\n * @aka L.PosAnimation\n * @inherits Evented\n * Used internally for panning animations, utilizing CSS3 Transitions for modern browsers and a timer fallback for IE6-9.\n *\n * @example\n * ```js\n * var fx = new L.PosAnimation();\n * fx.run(el, [300, 500], 0.5);\n * ```\n *\n * @constructor L.PosAnimation()\n * Creates a `PosAnimation` object.\n *\n */\n\nL.PosAnimation = L.Evented.extend({\n\n\t// @method run(el: HTMLElement, newPos: Point, duration?: Number, easeLinearity?: Number)\n\t// Run an animation of a given element to a new position, optionally setting\n\t// duration in seconds (`0.25` by default) and easing linearity factor (3rd\n\t// argument of the [cubic bezier curve](http://cubic-bezier.com/#0,0,.5,1),\n\t// `0.5` by default).\n\trun: function (el, newPos, duration, easeLinearity) {\n\t\tthis.stop();\n\n\t\tthis._el = el;\n\t\tthis._inProgress = true;\n\t\tthis._duration = duration || 0.25;\n\t\tthis._easeOutPower = 1 / Math.max(easeLinearity || 0.5, 0.2);\n\n\t\tthis._startPos = L.DomUtil.getPosition(el);\n\t\tthis._offset = newPos.subtract(this._startPos);\n\t\tthis._startTime = +new Date();\n\n\t\t// @event start: Event\n\t\t// Fired when the animation starts\n\t\tthis.fire('start');\n\n\t\tthis._animate();\n\t},\n\n\t// @method stop()\n\t// Stops the animation (if currently running).\n\tstop: function () {\n\t\tif (!this._inProgress) { return; }\n\n\t\tthis._step(true);\n\t\tthis._complete();\n\t},\n\n\t_animate: function () {\n\t\t// animation loop\n\t\tthis._animId = L.Util.requestAnimFrame(this._animate, this);\n\t\tthis._step();\n\t},\n\n\t_step: function (round) {\n\t\tvar elapsed = (+new Date()) - this._startTime,\n\t\t duration = this._duration * 1000;\n\n\t\tif (elapsed < duration) {\n\t\t\tthis._runFrame(this._easeOut(elapsed / duration), round);\n\t\t} else {\n\t\t\tthis._runFrame(1);\n\t\t\tthis._complete();\n\t\t}\n\t},\n\n\t_runFrame: function (progress, round) {\n\t\tvar pos = this._startPos.add(this._offset.multiplyBy(progress));\n\t\tif (round) {\n\t\t\tpos._round();\n\t\t}\n\t\tL.DomUtil.setPosition(this._el, pos);\n\n\t\t// @event step: Event\n\t\t// Fired continuously during the animation.\n\t\tthis.fire('step');\n\t},\n\n\t_complete: function () {\n\t\tL.Util.cancelAnimFrame(this._animId);\n\n\t\tthis._inProgress = false;\n\t\t// @event end: Event\n\t\t// Fired when the animation ends.\n\t\tthis.fire('end');\n\t},\n\n\t_easeOut: function (t) {\n\t\treturn 1 - Math.pow(1 - t, this._easeOutPower);\n\t}\n});\n","/*\r\n * @namespace Projection\r\n * @projection L.Projection.Mercator\r\n *\r\n * Elliptical Mercator projection — more complex than Spherical Mercator. Takes into account that Earth is a geoid, not a perfect sphere. Used by the EPSG:3395 CRS.\r\n */\r\n\r\nL.Projection.Mercator = {\r\n\tR: 6378137,\r\n\tR_MINOR: 6356752.314245179,\r\n\r\n\tbounds: L.bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),\r\n\r\n\tproject: function (latlng) {\r\n\t\tvar d = Math.PI / 180,\r\n\t\t r = this.R,\r\n\t\t y = latlng.lat * d,\r\n\t\t tmp = this.R_MINOR / r,\r\n\t\t e = Math.sqrt(1 - tmp * tmp),\r\n\t\t con = e * Math.sin(y);\r\n\r\n\t\tvar ts = Math.tan(Math.PI / 4 - y / 2) / Math.pow((1 - con) / (1 + con), e / 2);\r\n\t\ty = -r * Math.log(Math.max(ts, 1E-10));\r\n\r\n\t\treturn new L.Point(latlng.lng * d * r, y);\r\n\t},\r\n\r\n\tunproject: function (point) {\r\n\t\tvar d = 180 / Math.PI,\r\n\t\t r = this.R,\r\n\t\t tmp = this.R_MINOR / r,\r\n\t\t e = Math.sqrt(1 - tmp * tmp),\r\n\t\t ts = Math.exp(-point.y / r),\r\n\t\t phi = Math.PI / 2 - 2 * Math.atan(ts);\r\n\r\n\t\tfor (var i = 0, dphi = 0.1, con; i < 15 && Math.abs(dphi) > 1e-7; i++) {\r\n\t\t\tcon = e * Math.sin(phi);\r\n\t\t\tcon = Math.pow((1 - con) / (1 + con), e / 2);\r\n\t\t\tdphi = Math.PI / 2 - 2 * Math.atan(ts * con) - phi;\r\n\t\t\tphi += dphi;\r\n\t\t}\r\n\r\n\t\treturn new L.LatLng(phi * d, point.x * d / r);\r\n\t}\r\n};\r\n","/*\r\n * @namespace CRS\r\n * @crs L.CRS.EPSG3395\r\n *\r\n * Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.\r\n */\r\n\r\nL.CRS.EPSG3395 = L.extend({}, L.CRS.Earth, {\r\n\tcode: 'EPSG:3395',\r\n\tprojection: L.Projection.Mercator,\r\n\r\n\ttransformation: (function () {\r\n\t\tvar scale = 0.5 / (Math.PI * L.Projection.Mercator.R);\r\n\t\treturn new L.Transformation(scale, 0.5, -scale, 0.5);\r\n\t}())\r\n});\r\n","/*\n * @class GridLayer\n * @inherits Layer\n * @aka L.GridLayer\n *\n * Generic class for handling a tiled grid of HTML elements. This is the base class for all tile layers and replaces `TileLayer.Canvas`.\n * GridLayer can be extended to create a tiled grid of HTML elements like ``, `` or `
      `. GridLayer will handle creating and animating these DOM elements for you.\n *\n *\n * @section Synchronous usage\n * @example\n *\n * To create a custom layer, extend GridLayer and implement the `createTile()` method, which will be passed a `Point` object with the `x`, `y`, and `z` (zoom level) coordinates to draw your tile.\n *\n * ```js\n * var CanvasLayer = L.GridLayer.extend({\n * createTile: function(coords){\n * // create a element for drawing\n * var tile = L.DomUtil.create('canvas', 'leaflet-tile');\n *\n * // setup tile width and height according to the options\n * var size = this.getTileSize();\n * tile.width = size.x;\n * tile.height = size.y;\n *\n * // get a canvas context and draw something on it using coords.x, coords.y and coords.z\n * var ctx = tile.getContext('2d');\n *\n * // return the tile so it can be rendered on screen\n * return tile;\n * }\n * });\n * ```\n *\n * @section Asynchronous usage\n * @example\n *\n * Tile creation can also be asynchronous, this is useful when using a third-party drawing library. Once the tile is finished drawing it can be passed to the `done()` callback.\n *\n * ```js\n * var CanvasLayer = L.GridLayer.extend({\n * createTile: function(coords, done){\n * var error;\n *\n * // create a element for drawing\n * var tile = L.DomUtil.create('canvas', 'leaflet-tile');\n *\n * // setup tile width and height according to the options\n * var size = this.getTileSize();\n * tile.width = size.x;\n * tile.height = size.y;\n *\n * // draw something asynchronously and pass the tile to the done() callback\n * setTimeout(function() {\n * done(error, tile);\n * }, 1000);\n *\n * return tile;\n * }\n * });\n * ```\n *\n * @section\n */\n\n\nL.GridLayer = L.Layer.extend({\n\n\t// @section\n\t// @aka GridLayer options\n\toptions: {\n\t\t// @option tileSize: Number|Point = 256\n\t\t// Width and height of tiles in the grid. Use a number if width and height are equal, or `L.point(width, height)` otherwise.\n\t\ttileSize: 256,\n\n\t\t// @option opacity: Number = 1.0\n\t\t// Opacity of the tiles. Can be used in the `createTile()` function.\n\t\topacity: 1,\n\n\t\t// @option updateWhenIdle: Boolean = depends\n\t\t// If `false`, new tiles are loaded during panning, otherwise only after it (for better performance). `true` by default on mobile browsers, otherwise `false`.\n\t\tupdateWhenIdle: L.Browser.mobile,\n\n\t\t// @option updateWhenZooming: Boolean = true\n\t\t// By default, a smooth zoom animation (during a [touch zoom](#map-touchzoom) or a [`flyTo()`](#map-flyto)) will update grid layers every integer zoom level. Setting this option to `false` will update the grid layer only when the smooth animation ends.\n\t\tupdateWhenZooming: true,\n\n\t\t// @option updateInterval: Number = 200\n\t\t// Tiles will not update more than once every `updateInterval` milliseconds when panning.\n\t\tupdateInterval: 200,\n\n\t\t// @option zIndex: Number = 1\n\t\t// The explicit zIndex of the tile layer.\n\t\tzIndex: 1,\n\n\t\t// @option bounds: LatLngBounds = undefined\n\t\t// If set, tiles will only be loaded inside the set `LatLngBounds`.\n\t\tbounds: null,\n\n\t\t// @option minZoom: Number = 0\n\t\t// The minimum zoom level that tiles will be loaded at. By default the entire map.\n\t\tminZoom: 0,\n\n\t\t// @option maxZoom: Number = undefined\n\t\t// The maximum zoom level that tiles will be loaded at.\n\t\tmaxZoom: undefined,\n\n\t\t// @option noWrap: Boolean = false\n\t\t// Whether the layer is wrapped around the antimeridian. If `true`, the\n\t\t// GridLayer will only be displayed once at low zoom levels. Has no\n\t\t// effect when the [map CRS](#map-crs) doesn't wrap around.\n\t\tnoWrap: false,\n\n\t\t// @option pane: String = 'tilePane'\n\t\t// `Map pane` where the grid layer will be added.\n\t\tpane: 'tilePane',\n\n\t\t// @option className: String = ''\n\t\t// A custom class name to assign to the tile layer. Empty by default.\n\t\tclassName: '',\n\n\t\t// @option keepBuffer: Number = 2\n\t\t// When panning the map, keep this many rows and columns of tiles before unloading them.\n\t\tkeepBuffer: 2\n\t},\n\n\tinitialize: function (options) {\n\t\tL.setOptions(this, options);\n\t},\n\n\tonAdd: function () {\n\t\tthis._initContainer();\n\n\t\tthis._levels = {};\n\t\tthis._tiles = {};\n\n\t\tthis._resetView();\n\t\tthis._update();\n\t},\n\n\tbeforeAdd: function (map) {\n\t\tmap._addZoomLimit(this);\n\t},\n\n\tonRemove: function (map) {\n\t\tthis._removeAllTiles();\n\t\tL.DomUtil.remove(this._container);\n\t\tmap._removeZoomLimit(this);\n\t\tthis._container = null;\n\t\tthis._tileZoom = null;\n\t},\n\n\t// @method bringToFront: this\n\t// Brings the tile layer to the top of all tile layers.\n\tbringToFront: function () {\n\t\tif (this._map) {\n\t\t\tL.DomUtil.toFront(this._container);\n\t\t\tthis._setAutoZIndex(Math.max);\n\t\t}\n\t\treturn this;\n\t},\n\n\t// @method bringToBack: this\n\t// Brings the tile layer to the bottom of all tile layers.\n\tbringToBack: function () {\n\t\tif (this._map) {\n\t\t\tL.DomUtil.toBack(this._container);\n\t\t\tthis._setAutoZIndex(Math.min);\n\t\t}\n\t\treturn this;\n\t},\n\n\t// @method getContainer: HTMLElement\n\t// Returns the HTML element that contains the tiles for this layer.\n\tgetContainer: function () {\n\t\treturn this._container;\n\t},\n\n\t// @method setOpacity(opacity: Number): this\n\t// Changes the [opacity](#gridlayer-opacity) of the grid layer.\n\tsetOpacity: function (opacity) {\n\t\tthis.options.opacity = opacity;\n\t\tthis._updateOpacity();\n\t\treturn this;\n\t},\n\n\t// @method setZIndex(zIndex: Number): this\n\t// Changes the [zIndex](#gridlayer-zindex) of the grid layer.\n\tsetZIndex: function (zIndex) {\n\t\tthis.options.zIndex = zIndex;\n\t\tthis._updateZIndex();\n\n\t\treturn this;\n\t},\n\n\t// @method isLoading: Boolean\n\t// Returns `true` if any tile in the grid layer has not finished loading.\n\tisLoading: function () {\n\t\treturn this._loading;\n\t},\n\n\t// @method redraw: this\n\t// Causes the layer to clear all the tiles and request them again.\n\tredraw: function () {\n\t\tif (this._map) {\n\t\t\tthis._removeAllTiles();\n\t\t\tthis._update();\n\t\t}\n\t\treturn this;\n\t},\n\n\tgetEvents: function () {\n\t\tvar events = {\n\t\t\tviewprereset: this._invalidateAll,\n\t\t\tviewreset: this._resetView,\n\t\t\tzoom: this._resetView,\n\t\t\tmoveend: this._onMoveEnd\n\t\t};\n\n\t\tif (!this.options.updateWhenIdle) {\n\t\t\t// update tiles on move, but not more often than once per given interval\n\t\t\tif (!this._onMove) {\n\t\t\t\tthis._onMove = L.Util.throttle(this._onMoveEnd, this.options.updateInterval, this);\n\t\t\t}\n\n\t\t\tevents.move = this._onMove;\n\t\t}\n\n\t\tif (this._zoomAnimated) {\n\t\t\tevents.zoomanim = this._animateZoom;\n\t\t}\n\n\t\treturn events;\n\t},\n\n\t// @section Extension methods\n\t// Layers extending `GridLayer` shall reimplement the following method.\n\t// @method createTile(coords: Object, done?: Function): HTMLElement\n\t// Called only internally, must be overriden by classes extending `GridLayer`.\n\t// Returns the `HTMLElement` corresponding to the given `coords`. If the `done` callback\n\t// is specified, it must be called when the tile has finished loading and drawing.\n\tcreateTile: function () {\n\t\treturn document.createElement('div');\n\t},\n\n\t// @section\n\t// @method getTileSize: Point\n\t// Normalizes the [tileSize option](#gridlayer-tilesize) into a point. Used by the `createTile()` method.\n\tgetTileSize: function () {\n\t\tvar s = this.options.tileSize;\n\t\treturn s instanceof L.Point ? s : new L.Point(s, s);\n\t},\n\n\t_updateZIndex: function () {\n\t\tif (this._container && this.options.zIndex !== undefined && this.options.zIndex !== null) {\n\t\t\tthis._container.style.zIndex = this.options.zIndex;\n\t\t}\n\t},\n\n\t_setAutoZIndex: function (compare) {\n\t\t// go through all other layers of the same pane, set zIndex to max + 1 (front) or min - 1 (back)\n\n\t\tvar layers = this.getPane().children,\n\t\t edgeZIndex = -compare(-Infinity, Infinity); // -Infinity for max, Infinity for min\n\n\t\tfor (var i = 0, len = layers.length, zIndex; i < len; i++) {\n\n\t\t\tzIndex = layers[i].style.zIndex;\n\n\t\t\tif (layers[i] !== this._container && zIndex) {\n\t\t\t\tedgeZIndex = compare(edgeZIndex, +zIndex);\n\t\t\t}\n\t\t}\n\n\t\tif (isFinite(edgeZIndex)) {\n\t\t\tthis.options.zIndex = edgeZIndex + compare(-1, 1);\n\t\t\tthis._updateZIndex();\n\t\t}\n\t},\n\n\t_updateOpacity: function () {\n\t\tif (!this._map) { return; }\n\n\t\t// IE doesn't inherit filter opacity properly, so we're forced to set it on tiles\n\t\tif (L.Browser.ielt9) { return; }\n\n\t\tL.DomUtil.setOpacity(this._container, this.options.opacity);\n\n\t\tvar now = +new Date(),\n\t\t nextFrame = false,\n\t\t willPrune = false;\n\n\t\tfor (var key in this._tiles) {\n\t\t\tvar tile = this._tiles[key];\n\t\t\tif (!tile.current || !tile.loaded) { continue; }\n\n\t\t\tvar fade = Math.min(1, (now - tile.loaded) / 200);\n\n\t\t\tL.DomUtil.setOpacity(tile.el, fade);\n\t\t\tif (fade < 1) {\n\t\t\t\tnextFrame = true;\n\t\t\t} else {\n\t\t\t\tif (tile.active) { willPrune = true; }\n\t\t\t\ttile.active = true;\n\t\t\t}\n\t\t}\n\n\t\tif (willPrune && !this._noPrune) { this._pruneTiles(); }\n\n\t\tif (nextFrame) {\n\t\t\tL.Util.cancelAnimFrame(this._fadeFrame);\n\t\t\tthis._fadeFrame = L.Util.requestAnimFrame(this._updateOpacity, this);\n\t\t}\n\t},\n\n\t_initContainer: function () {\n\t\tif (this._container) { return; }\n\n\t\tthis._container = L.DomUtil.create('div', 'leaflet-layer ' + (this.options.className || ''));\n\t\tthis._updateZIndex();\n\n\t\tif (this.options.opacity < 1) {\n\t\t\tthis._updateOpacity();\n\t\t}\n\n\t\tthis.getPane().appendChild(this._container);\n\t},\n\n\t_updateLevels: function () {\n\n\t\tvar zoom = this._tileZoom,\n\t\t maxZoom = this.options.maxZoom;\n\n\t\tif (zoom === undefined) { return undefined; }\n\n\t\tfor (var z in this._levels) {\n\t\t\tif (this._levels[z].el.children.length || z === zoom) {\n\t\t\t\tthis._levels[z].el.style.zIndex = maxZoom - Math.abs(zoom - z);\n\t\t\t} else {\n\t\t\t\tL.DomUtil.remove(this._levels[z].el);\n\t\t\t\tthis._removeTilesAtZoom(z);\n\t\t\t\tdelete this._levels[z];\n\t\t\t}\n\t\t}\n\n\t\tvar level = this._levels[zoom],\n\t\t map = this._map;\n\n\t\tif (!level) {\n\t\t\tlevel = this._levels[zoom] = {};\n\n\t\t\tlevel.el = L.DomUtil.create('div', 'leaflet-tile-container leaflet-zoom-animated', this._container);\n\t\t\tlevel.el.style.zIndex = maxZoom;\n\n\t\t\tlevel.origin = map.project(map.unproject(map.getPixelOrigin()), zoom).round();\n\t\t\tlevel.zoom = zoom;\n\n\t\t\tthis._setZoomTransform(level, map.getCenter(), map.getZoom());\n\n\t\t\t// force the browser to consider the newly added element for transition\n\t\t\tL.Util.falseFn(level.el.offsetWidth);\n\t\t}\n\n\t\tthis._level = level;\n\n\t\treturn level;\n\t},\n\n\t_pruneTiles: function () {\n\t\tif (!this._map) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar key, tile;\n\n\t\tvar zoom = this._map.getZoom();\n\t\tif (zoom > this.options.maxZoom ||\n\t\t\tzoom < this.options.minZoom) {\n\t\t\tthis._removeAllTiles();\n\t\t\treturn;\n\t\t}\n\n\t\tfor (key in this._tiles) {\n\t\t\ttile = this._tiles[key];\n\t\t\ttile.retain = tile.current;\n\t\t}\n\n\t\tfor (key in this._tiles) {\n\t\t\ttile = this._tiles[key];\n\t\t\tif (tile.current && !tile.active) {\n\t\t\t\tvar coords = tile.coords;\n\t\t\t\tif (!this._retainParent(coords.x, coords.y, coords.z, coords.z - 5)) {\n\t\t\t\t\tthis._retainChildren(coords.x, coords.y, coords.z, coords.z + 2);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (key in this._tiles) {\n\t\t\tif (!this._tiles[key].retain) {\n\t\t\t\tthis._removeTile(key);\n\t\t\t}\n\t\t}\n\t},\n\n\t_removeTilesAtZoom: function (zoom) {\n\t\tfor (var key in this._tiles) {\n\t\t\tif (this._tiles[key].coords.z !== zoom) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis._removeTile(key);\n\t\t}\n\t},\n\n\t_removeAllTiles: function () {\n\t\tfor (var key in this._tiles) {\n\t\t\tthis._removeTile(key);\n\t\t}\n\t},\n\n\t_invalidateAll: function () {\n\t\tfor (var z in this._levels) {\n\t\t\tL.DomUtil.remove(this._levels[z].el);\n\t\t\tdelete this._levels[z];\n\t\t}\n\t\tthis._removeAllTiles();\n\n\t\tthis._tileZoom = null;\n\t},\n\n\t_retainParent: function (x, y, z, minZoom) {\n\t\tvar x2 = Math.floor(x / 2),\n\t\t y2 = Math.floor(y / 2),\n\t\t z2 = z - 1,\n\t\t coords2 = new L.Point(+x2, +y2);\n\t\tcoords2.z = +z2;\n\n\t\tvar key = this._tileCoordsToKey(coords2),\n\t\t tile = this._tiles[key];\n\n\t\tif (tile && tile.active) {\n\t\t\ttile.retain = true;\n\t\t\treturn true;\n\n\t\t} else if (tile && tile.loaded) {\n\t\t\ttile.retain = true;\n\t\t}\n\n\t\tif (z2 > minZoom) {\n\t\t\treturn this._retainParent(x2, y2, z2, minZoom);\n\t\t}\n\n\t\treturn false;\n\t},\n\n\t_retainChildren: function (x, y, z, maxZoom) {\n\n\t\tfor (var i = 2 * x; i < 2 * x + 2; i++) {\n\t\t\tfor (var j = 2 * y; j < 2 * y + 2; j++) {\n\n\t\t\t\tvar coords = new L.Point(i, j);\n\t\t\t\tcoords.z = z + 1;\n\n\t\t\t\tvar key = this._tileCoordsToKey(coords),\n\t\t\t\t tile = this._tiles[key];\n\n\t\t\t\tif (tile && tile.active) {\n\t\t\t\t\ttile.retain = true;\n\t\t\t\t\tcontinue;\n\n\t\t\t\t} else if (tile && tile.loaded) {\n\t\t\t\t\ttile.retain = true;\n\t\t\t\t}\n\n\t\t\t\tif (z + 1 < maxZoom) {\n\t\t\t\t\tthis._retainChildren(i, j, z + 1, maxZoom);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\t_resetView: function (e) {\n\t\tvar animating = e && (e.pinch || e.flyTo);\n\t\tthis._setView(this._map.getCenter(), this._map.getZoom(), animating, animating);\n\t},\n\n\t_animateZoom: function (e) {\n\t\tthis._setView(e.center, e.zoom, true, e.noUpdate);\n\t},\n\n\t_setView: function (center, zoom, noPrune, noUpdate) {\n\t\tvar tileZoom = Math.round(zoom);\n\t\tif ((this.options.maxZoom !== undefined && tileZoom > this.options.maxZoom) ||\n\t\t (this.options.minZoom !== undefined && tileZoom < this.options.minZoom)) {\n\t\t\ttileZoom = undefined;\n\t\t}\n\n\t\tvar tileZoomChanged = this.options.updateWhenZooming && (tileZoom !== this._tileZoom);\n\n\t\tif (!noUpdate || tileZoomChanged) {\n\n\t\t\tthis._tileZoom = tileZoom;\n\n\t\t\tif (this._abortLoading) {\n\t\t\t\tthis._abortLoading();\n\t\t\t}\n\n\t\t\tthis._updateLevels();\n\t\t\tthis._resetGrid();\n\n\t\t\tif (tileZoom !== undefined) {\n\t\t\t\tthis._update(center);\n\t\t\t}\n\n\t\t\tif (!noPrune) {\n\t\t\t\tthis._pruneTiles();\n\t\t\t}\n\n\t\t\t// Flag to prevent _updateOpacity from pruning tiles during\n\t\t\t// a zoom anim or a pinch gesture\n\t\t\tthis._noPrune = !!noPrune;\n\t\t}\n\n\t\tthis._setZoomTransforms(center, zoom);\n\t},\n\n\t_setZoomTransforms: function (center, zoom) {\n\t\tfor (var i in this._levels) {\n\t\t\tthis._setZoomTransform(this._levels[i], center, zoom);\n\t\t}\n\t},\n\n\t_setZoomTransform: function (level, center, zoom) {\n\t\tvar scale = this._map.getZoomScale(zoom, level.zoom),\n\t\t translate = level.origin.multiplyBy(scale)\n\t\t .subtract(this._map._getNewPixelOrigin(center, zoom)).round();\n\n\t\tif (L.Browser.any3d) {\n\t\t\tL.DomUtil.setTransform(level.el, translate, scale);\n\t\t} else {\n\t\t\tL.DomUtil.setPosition(level.el, translate);\n\t\t}\n\t},\n\n\t_resetGrid: function () {\n\t\tvar map = this._map,\n\t\t crs = map.options.crs,\n\t\t tileSize = this._tileSize = this.getTileSize(),\n\t\t tileZoom = this._tileZoom;\n\n\t\tvar bounds = this._map.getPixelWorldBounds(this._tileZoom);\n\t\tif (bounds) {\n\t\t\tthis._globalTileRange = this._pxBoundsToTileRange(bounds);\n\t\t}\n\n\t\tthis._wrapX = crs.wrapLng && !this.options.noWrap && [\n\t\t\tMath.floor(map.project([0, crs.wrapLng[0]], tileZoom).x / tileSize.x),\n\t\t\tMath.ceil(map.project([0, crs.wrapLng[1]], tileZoom).x / tileSize.y)\n\t\t];\n\t\tthis._wrapY = crs.wrapLat && !this.options.noWrap && [\n\t\t\tMath.floor(map.project([crs.wrapLat[0], 0], tileZoom).y / tileSize.x),\n\t\t\tMath.ceil(map.project([crs.wrapLat[1], 0], tileZoom).y / tileSize.y)\n\t\t];\n\t},\n\n\t_onMoveEnd: function () {\n\t\tif (!this._map || this._map._animatingZoom) { return; }\n\n\t\tthis._update();\n\t},\n\n\t_getTiledPixelBounds: function (center) {\n\t\tvar map = this._map,\n\t\t mapZoom = map._animatingZoom ? Math.max(map._animateToZoom, map.getZoom()) : map.getZoom(),\n\t\t scale = map.getZoomScale(mapZoom, this._tileZoom),\n\t\t pixelCenter = map.project(center, this._tileZoom).floor(),\n\t\t halfSize = map.getSize().divideBy(scale * 2);\n\n\t\treturn new L.Bounds(pixelCenter.subtract(halfSize), pixelCenter.add(halfSize));\n\t},\n\n\t// Private method to load tiles in the grid's active zoom level according to map bounds\n\t_update: function (center) {\n\t\tvar map = this._map;\n\t\tif (!map) { return; }\n\t\tvar zoom = map.getZoom();\n\n\t\tif (center === undefined) { center = map.getCenter(); }\n\t\tif (this._tileZoom === undefined) { return; }\t// if out of minzoom/maxzoom\n\n\t\tvar pixelBounds = this._getTiledPixelBounds(center),\n\t\t tileRange = this._pxBoundsToTileRange(pixelBounds),\n\t\t tileCenter = tileRange.getCenter(),\n\t\t queue = [],\n\t\t margin = this.options.keepBuffer,\n\t\t noPruneRange = new L.Bounds(tileRange.getBottomLeft().subtract([margin, -margin]),\n\t\t tileRange.getTopRight().add([margin, -margin]));\n\n\t\tfor (var key in this._tiles) {\n\t\t\tvar c = this._tiles[key].coords;\n\t\t\tif (c.z !== this._tileZoom || !noPruneRange.contains(L.point(c.x, c.y))) {\n\t\t\t\tthis._tiles[key].current = false;\n\t\t\t}\n\t\t}\n\n\t\t// _update just loads more tiles. If the tile zoom level differs too much\n\t\t// from the map's, let _setView reset levels and prune old tiles.\n\t\tif (Math.abs(zoom - this._tileZoom) > 1) { this._setView(center, zoom); return; }\n\n\t\t// create a queue of coordinates to load tiles from\n\t\tfor (var j = tileRange.min.y; j <= tileRange.max.y; j++) {\n\t\t\tfor (var i = tileRange.min.x; i <= tileRange.max.x; i++) {\n\t\t\t\tvar coords = new L.Point(i, j);\n\t\t\t\tcoords.z = this._tileZoom;\n\n\t\t\t\tif (!this._isValidTile(coords)) { continue; }\n\n\t\t\t\tvar tile = this._tiles[this._tileCoordsToKey(coords)];\n\t\t\t\tif (tile) {\n\t\t\t\t\ttile.current = true;\n\t\t\t\t} else {\n\t\t\t\t\tqueue.push(coords);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// sort tile queue to load tiles in order of their distance to center\n\t\tqueue.sort(function (a, b) {\n\t\t\treturn a.distanceTo(tileCenter) - b.distanceTo(tileCenter);\n\t\t});\n\n\t\tif (queue.length !== 0) {\n\t\t\t// if it's the first batch of tiles to load\n\t\t\tif (!this._loading) {\n\t\t\t\tthis._loading = true;\n\t\t\t\t// @event loading: Event\n\t\t\t\t// Fired when the grid layer starts loading tiles.\n\t\t\t\tthis.fire('loading');\n\t\t\t}\n\n\t\t\t// create DOM fragment to append tiles in one batch\n\t\t\tvar fragment = document.createDocumentFragment();\n\n\t\t\tfor (i = 0; i < queue.length; i++) {\n\t\t\t\tthis._addTile(queue[i], fragment);\n\t\t\t}\n\n\t\t\tthis._level.el.appendChild(fragment);\n\t\t}\n\t},\n\n\t_isValidTile: function (coords) {\n\t\tvar crs = this._map.options.crs;\n\n\t\tif (!crs.infinite) {\n\t\t\t// don't load tile if it's out of bounds and not wrapped\n\t\t\tvar bounds = this._globalTileRange;\n\t\t\tif ((!crs.wrapLng && (coords.x < bounds.min.x || coords.x > bounds.max.x)) ||\n\t\t\t (!crs.wrapLat && (coords.y < bounds.min.y || coords.y > bounds.max.y))) { return false; }\n\t\t}\n\n\t\tif (!this.options.bounds) { return true; }\n\n\t\t// don't load tile if it doesn't intersect the bounds in options\n\t\tvar tileBounds = this._tileCoordsToBounds(coords);\n\t\treturn L.latLngBounds(this.options.bounds).overlaps(tileBounds);\n\t},\n\n\t_keyToBounds: function (key) {\n\t\treturn this._tileCoordsToBounds(this._keyToTileCoords(key));\n\t},\n\n\t// converts tile coordinates to its geographical bounds\n\t_tileCoordsToBounds: function (coords) {\n\n\t\tvar map = this._map,\n\t\t tileSize = this.getTileSize(),\n\n\t\t nwPoint = coords.scaleBy(tileSize),\n\t\t sePoint = nwPoint.add(tileSize),\n\n\t\t nw = map.unproject(nwPoint, coords.z),\n\t\t se = map.unproject(sePoint, coords.z);\n\n\t\tif (!this.options.noWrap) {\n\t\t\tnw = map.wrapLatLng(nw);\n\t\t\tse = map.wrapLatLng(se);\n\t\t}\n\n\t\treturn new L.LatLngBounds(nw, se);\n\t},\n\n\t// converts tile coordinates to key for the tile cache\n\t_tileCoordsToKey: function (coords) {\n\t\treturn coords.x + ':' + coords.y + ':' + coords.z;\n\t},\n\n\t// converts tile cache key to coordinates\n\t_keyToTileCoords: function (key) {\n\t\tvar k = key.split(':'),\n\t\t coords = new L.Point(+k[0], +k[1]);\n\t\tcoords.z = +k[2];\n\t\treturn coords;\n\t},\n\n\t_removeTile: function (key) {\n\t\tvar tile = this._tiles[key];\n\t\tif (!tile) { return; }\n\n\t\tL.DomUtil.remove(tile.el);\n\n\t\tdelete this._tiles[key];\n\n\t\t// @event tileunload: TileEvent\n\t\t// Fired when a tile is removed (e.g. when a tile goes off the screen).\n\t\tthis.fire('tileunload', {\n\t\t\ttile: tile.el,\n\t\t\tcoords: this._keyToTileCoords(key)\n\t\t});\n\t},\n\n\t_initTile: function (tile) {\n\t\tL.DomUtil.addClass(tile, 'leaflet-tile');\n\n\t\tvar tileSize = this.getTileSize();\n\t\ttile.style.width = tileSize.x + 'px';\n\t\ttile.style.height = tileSize.y + 'px';\n\n\t\ttile.onselectstart = L.Util.falseFn;\n\t\ttile.onmousemove = L.Util.falseFn;\n\n\t\t// update opacity on tiles in IE7-8 because of filter inheritance problems\n\t\tif (L.Browser.ielt9 && this.options.opacity < 1) {\n\t\t\tL.DomUtil.setOpacity(tile, this.options.opacity);\n\t\t}\n\n\t\t// without this hack, tiles disappear after zoom on Chrome for Android\n\t\t// https://github.com/Leaflet/Leaflet/issues/2078\n\t\tif (L.Browser.android && !L.Browser.android23) {\n\t\t\ttile.style.WebkitBackfaceVisibility = 'hidden';\n\t\t}\n\t},\n\n\t_addTile: function (coords, container) {\n\t\tvar tilePos = this._getTilePos(coords),\n\t\t key = this._tileCoordsToKey(coords);\n\n\t\tvar tile = this.createTile(this._wrapCoords(coords), L.bind(this._tileReady, this, coords));\n\n\t\tthis._initTile(tile);\n\n\t\t// if createTile is defined with a second argument (\"done\" callback),\n\t\t// we know that tile is async and will be ready later; otherwise\n\t\tif (this.createTile.length < 2) {\n\t\t\t// mark tile as ready, but delay one frame for opacity animation to happen\n\t\t\tL.Util.requestAnimFrame(L.bind(this._tileReady, this, coords, null, tile));\n\t\t}\n\n\t\tL.DomUtil.setPosition(tile, tilePos);\n\n\t\t// save tile in cache\n\t\tthis._tiles[key] = {\n\t\t\tel: tile,\n\t\t\tcoords: coords,\n\t\t\tcurrent: true\n\t\t};\n\n\t\tcontainer.appendChild(tile);\n\t\t// @event tileloadstart: TileEvent\n\t\t// Fired when a tile is requested and starts loading.\n\t\tthis.fire('tileloadstart', {\n\t\t\ttile: tile,\n\t\t\tcoords: coords\n\t\t});\n\t},\n\n\t_tileReady: function (coords, err, tile) {\n\t\tif (!this._map) { return; }\n\n\t\tif (err) {\n\t\t\t// @event tileerror: TileErrorEvent\n\t\t\t// Fired when there is an error loading a tile.\n\t\t\tthis.fire('tileerror', {\n\t\t\t\terror: err,\n\t\t\t\ttile: tile,\n\t\t\t\tcoords: coords\n\t\t\t});\n\t\t}\n\n\t\tvar key = this._tileCoordsToKey(coords);\n\n\t\ttile = this._tiles[key];\n\t\tif (!tile) { return; }\n\n\t\ttile.loaded = +new Date();\n\t\tif (this._map._fadeAnimated) {\n\t\t\tL.DomUtil.setOpacity(tile.el, 0);\n\t\t\tL.Util.cancelAnimFrame(this._fadeFrame);\n\t\t\tthis._fadeFrame = L.Util.requestAnimFrame(this._updateOpacity, this);\n\t\t} else {\n\t\t\ttile.active = true;\n\t\t\tthis._pruneTiles();\n\t\t}\n\n\t\tif (!err) {\n\t\t\tL.DomUtil.addClass(tile.el, 'leaflet-tile-loaded');\n\n\t\t\t// @event tileload: TileEvent\n\t\t\t// Fired when a tile loads.\n\t\t\tthis.fire('tileload', {\n\t\t\t\ttile: tile.el,\n\t\t\t\tcoords: coords\n\t\t\t});\n\t\t}\n\n\t\tif (this._noTilesToLoad()) {\n\t\t\tthis._loading = false;\n\t\t\t// @event load: Event\n\t\t\t// Fired when the grid layer loaded all visible tiles.\n\t\t\tthis.fire('load');\n\n\t\t\tif (L.Browser.ielt9 || !this._map._fadeAnimated) {\n\t\t\t\tL.Util.requestAnimFrame(this._pruneTiles, this);\n\t\t\t} else {\n\t\t\t\t// Wait a bit more than 0.2 secs (the duration of the tile fade-in)\n\t\t\t\t// to trigger a pruning.\n\t\t\t\tsetTimeout(L.bind(this._pruneTiles, this), 250);\n\t\t\t}\n\t\t}\n\t},\n\n\t_getTilePos: function (coords) {\n\t\treturn coords.scaleBy(this.getTileSize()).subtract(this._level.origin);\n\t},\n\n\t_wrapCoords: function (coords) {\n\t\tvar newCoords = new L.Point(\n\t\t\tthis._wrapX ? L.Util.wrapNum(coords.x, this._wrapX) : coords.x,\n\t\t\tthis._wrapY ? L.Util.wrapNum(coords.y, this._wrapY) : coords.y);\n\t\tnewCoords.z = coords.z;\n\t\treturn newCoords;\n\t},\n\n\t_pxBoundsToTileRange: function (bounds) {\n\t\tvar tileSize = this.getTileSize();\n\t\treturn new L.Bounds(\n\t\t\tbounds.min.unscaleBy(tileSize).floor(),\n\t\t\tbounds.max.unscaleBy(tileSize).ceil().subtract([1, 1]));\n\t},\n\n\t_noTilesToLoad: function () {\n\t\tfor (var key in this._tiles) {\n\t\t\tif (!this._tiles[key].loaded) { return false; }\n\t\t}\n\t\treturn true;\n\t}\n});\n\n// @factory L.gridLayer(options?: GridLayer options)\n// Creates a new instance of GridLayer with the supplied options.\nL.gridLayer = function (options) {\n\treturn new L.GridLayer(options);\n};\n","/*\r\n * @class TileLayer\r\n * @inherits GridLayer\r\n * @aka L.TileLayer\r\n * Used to load and display tile layers on the map. Extends `GridLayer`.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar'}).addTo(map);\r\n * ```\r\n *\r\n * @section URL template\r\n * @example\r\n *\r\n * A string of the following form:\r\n *\r\n * ```\r\n * 'http://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png'\r\n * ```\r\n *\r\n * `{s}` means one of the available subdomains (used sequentially to help with browser parallel requests per domain limitation; subdomain values are specified in options; `a`, `b` or `c` by default, can be omitted), `{z}` — zoom level, `{x}` and `{y}` — tile coordinates. `{r}` can be used to add @2x to the URL to load retina tiles.\r\n *\r\n * You can use custom keys in the template, which will be [evaluated](#util-template) from TileLayer options, like this:\r\n *\r\n * ```\r\n * L.tileLayer('http://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png', {foo: 'bar'});\r\n * ```\r\n */\r\n\r\n\r\nL.TileLayer = L.GridLayer.extend({\r\n\r\n\t// @section\r\n\t// @aka TileLayer options\r\n\toptions: {\r\n\t\t// @option minZoom: Number = 0\r\n\t\t// Minimum zoom number.\r\n\t\tminZoom: 0,\r\n\r\n\t\t// @option maxZoom: Number = 18\r\n\t\t// Maximum zoom number.\r\n\t\tmaxZoom: 18,\r\n\r\n\t\t// @option maxNativeZoom: Number = null\r\n\t\t// Maximum zoom number the tile source has available. If it is specified,\r\n\t\t// the tiles on all zoom levels higher than `maxNativeZoom` will be loaded\r\n\t\t// from `maxNativeZoom` level and auto-scaled.\r\n\t\tmaxNativeZoom: null,\r\n\r\n\t\t// @option minNativeZoom: Number = null\r\n\t\t// Minimum zoom number the tile source has available. If it is specified,\r\n\t\t// the tiles on all zoom levels lower than `minNativeZoom` will be loaded\r\n\t\t// from `minNativeZoom` level and auto-scaled.\r\n\t\tminNativeZoom: null,\r\n\r\n\t\t// @option subdomains: String|String[] = 'abc'\r\n\t\t// Subdomains of the tile service. Can be passed in the form of one string (where each letter is a subdomain name) or an array of strings.\r\n\t\tsubdomains: 'abc',\r\n\r\n\t\t// @option errorTileUrl: String = ''\r\n\t\t// URL to the tile image to show in place of the tile that failed to load.\r\n\t\terrorTileUrl: '',\r\n\r\n\t\t// @option zoomOffset: Number = 0\r\n\t\t// The zoom number used in tile URLs will be offset with this value.\r\n\t\tzoomOffset: 0,\r\n\r\n\t\t// @option tms: Boolean = false\r\n\t\t// If `true`, inverses Y axis numbering for tiles (turn this on for [TMS](https://en.wikipedia.org/wiki/Tile_Map_Service) services).\r\n\t\ttms: false,\r\n\r\n\t\t// @option zoomReverse: Boolean = false\r\n\t\t// If set to true, the zoom number used in tile URLs will be reversed (`maxZoom - zoom` instead of `zoom`)\r\n\t\tzoomReverse: false,\r\n\r\n\t\t// @option detectRetina: Boolean = false\r\n\t\t// If `true` and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution.\r\n\t\tdetectRetina: false,\r\n\r\n\t\t// @option crossOrigin: Boolean = false\r\n\t\t// If true, all tiles will have their crossOrigin attribute set to ''. This is needed if you want to access tile pixel data.\r\n\t\tcrossOrigin: false\r\n\t},\r\n\r\n\tinitialize: function (url, options) {\r\n\r\n\t\tthis._url = url;\r\n\r\n\t\toptions = L.setOptions(this, options);\r\n\r\n\t\t// detecting retina displays, adjusting tileSize and zoom levels\r\n\t\tif (options.detectRetina && L.Browser.retina && options.maxZoom > 0) {\r\n\r\n\t\t\toptions.tileSize = Math.floor(options.tileSize / 2);\r\n\r\n\t\t\tif (!options.zoomReverse) {\r\n\t\t\t\toptions.zoomOffset++;\r\n\t\t\t\toptions.maxZoom--;\r\n\t\t\t} else {\r\n\t\t\t\toptions.zoomOffset--;\r\n\t\t\t\toptions.minZoom++;\r\n\t\t\t}\r\n\r\n\t\t\toptions.minZoom = Math.max(0, options.minZoom);\r\n\t\t}\r\n\r\n\t\tif (typeof options.subdomains === 'string') {\r\n\t\t\toptions.subdomains = options.subdomains.split('');\r\n\t\t}\r\n\r\n\t\t// for https://github.com/Leaflet/Leaflet/issues/137\r\n\t\tif (!L.Browser.android) {\r\n\t\t\tthis.on('tileunload', this._onTileRemove);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method setUrl(url: String, noRedraw?: Boolean): this\r\n\t// Updates the layer's URL template and redraws it (unless `noRedraw` is set to `true`).\r\n\tsetUrl: function (url, noRedraw) {\r\n\t\tthis._url = url;\r\n\r\n\t\tif (!noRedraw) {\r\n\t\t\tthis.redraw();\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method createTile(coords: Object, done?: Function): HTMLElement\r\n\t// Called only internally, overrides GridLayer's [`createTile()`](#gridlayer-createtile)\r\n\t// to return an `` HTML element with the appropiate image URL given `coords`. The `done`\r\n\t// callback is called when the tile has been loaded.\r\n\tcreateTile: function (coords, done) {\r\n\t\tvar tile = document.createElement('img');\r\n\r\n\t\tL.DomEvent.on(tile, 'load', L.bind(this._tileOnLoad, this, done, tile));\r\n\t\tL.DomEvent.on(tile, 'error', L.bind(this._tileOnError, this, done, tile));\r\n\r\n\t\tif (this.options.crossOrigin) {\r\n\t\t\ttile.crossOrigin = '';\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\t Alt tag is set to empty string to keep screen readers from reading URL and for compliance reasons\r\n\t\t http://www.w3.org/TR/WCAG20-TECHS/H67\r\n\t\t*/\r\n\t\ttile.alt = '';\r\n\r\n\t\t/*\r\n\t\t Set role=\"presentation\" to force screen readers to ignore this\r\n\t\t https://www.w3.org/TR/wai-aria/roles#textalternativecomputation\r\n\t\t*/\r\n\t\ttile.setAttribute('role', 'presentation');\r\n\r\n\t\ttile.src = this.getTileUrl(coords);\r\n\r\n\t\treturn tile;\r\n\t},\r\n\r\n\t// @section Extension methods\r\n\t// @uninheritable\r\n\t// Layers extending `TileLayer` might reimplement the following method.\r\n\t// @method getTileUrl(coords: Object): String\r\n\t// Called only internally, returns the URL for a tile given its coordinates.\r\n\t// Classes extending `TileLayer` can override this function to provide custom tile URL naming schemes.\r\n\tgetTileUrl: function (coords) {\r\n\t\tvar data = {\r\n\t\t\tr: L.Browser.retina ? '@2x' : '',\r\n\t\t\ts: this._getSubdomain(coords),\r\n\t\t\tx: coords.x,\r\n\t\t\ty: coords.y,\r\n\t\t\tz: this._getZoomForUrl()\r\n\t\t};\r\n\t\tif (this._map && !this._map.options.crs.infinite) {\r\n\t\t\tvar invertedY = this._globalTileRange.max.y - coords.y;\r\n\t\t\tif (this.options.tms) {\r\n\t\t\t\tdata['y'] = invertedY;\r\n\t\t\t}\r\n\t\t\tdata['-y'] = invertedY;\r\n\t\t}\r\n\r\n\t\treturn L.Util.template(this._url, L.extend(data, this.options));\r\n\t},\r\n\r\n\t_tileOnLoad: function (done, tile) {\r\n\t\t// For https://github.com/Leaflet/Leaflet/issues/3332\r\n\t\tif (L.Browser.ielt9) {\r\n\t\t\tsetTimeout(L.bind(done, this, null, tile), 0);\r\n\t\t} else {\r\n\t\t\tdone(null, tile);\r\n\t\t}\r\n\t},\r\n\r\n\t_tileOnError: function (done, tile, e) {\r\n\t\tvar errorUrl = this.options.errorTileUrl;\r\n\t\tif (errorUrl) {\r\n\t\t\ttile.src = errorUrl;\r\n\t\t}\r\n\t\tdone(e, tile);\r\n\t},\r\n\r\n\tgetTileSize: function () {\r\n\t\tvar map = this._map,\r\n\t\ttileSize = L.GridLayer.prototype.getTileSize.call(this),\r\n\t\tzoom = this._tileZoom + this.options.zoomOffset,\r\n\t\tminNativeZoom = this.options.minNativeZoom,\r\n\t\tmaxNativeZoom = this.options.maxNativeZoom;\r\n\r\n\t\t// decrease tile size when scaling below minNativeZoom\r\n\t\tif (minNativeZoom !== null && zoom < minNativeZoom) {\r\n\t\t\treturn tileSize.divideBy(map.getZoomScale(minNativeZoom, zoom)).round();\r\n\t\t}\r\n\r\n\t\t// increase tile size when scaling above maxNativeZoom\r\n\t\tif (maxNativeZoom !== null && zoom > maxNativeZoom) {\r\n\t\t\treturn tileSize.divideBy(map.getZoomScale(maxNativeZoom, zoom)).round();\r\n\t\t}\r\n\r\n\t\treturn tileSize;\r\n\t},\r\n\r\n\t_onTileRemove: function (e) {\r\n\t\te.tile.onload = null;\r\n\t},\r\n\r\n\t_getZoomForUrl: function () {\r\n\t\tvar zoom = this._tileZoom,\r\n\t\tmaxZoom = this.options.maxZoom,\r\n\t\tzoomReverse = this.options.zoomReverse,\r\n\t\tzoomOffset = this.options.zoomOffset,\r\n\t\tminNativeZoom = this.options.minNativeZoom,\r\n\t\tmaxNativeZoom = this.options.maxNativeZoom;\r\n\r\n\t\tif (zoomReverse) {\r\n\t\t\tzoom = maxZoom - zoom;\r\n\t\t}\r\n\r\n\t\tzoom += zoomOffset;\r\n\r\n\t\tif (minNativeZoom !== null && zoom < minNativeZoom) {\r\n\t\t\treturn minNativeZoom;\r\n\t\t}\r\n\r\n\t\tif (maxNativeZoom !== null && zoom > maxNativeZoom) {\r\n\t\t\treturn maxNativeZoom;\r\n\t\t}\r\n\r\n\t\treturn zoom;\r\n\t},\r\n\r\n\t_getSubdomain: function (tilePoint) {\r\n\t\tvar index = Math.abs(tilePoint.x + tilePoint.y) % this.options.subdomains.length;\r\n\t\treturn this.options.subdomains[index];\r\n\t},\r\n\r\n\t// stops loading all tiles in the background layer\r\n\t_abortLoading: function () {\r\n\t\tvar i, tile;\r\n\t\tfor (i in this._tiles) {\r\n\t\t\tif (this._tiles[i].coords.z !== this._tileZoom) {\r\n\t\t\t\ttile = this._tiles[i].el;\r\n\r\n\t\t\t\ttile.onload = L.Util.falseFn;\r\n\t\t\t\ttile.onerror = L.Util.falseFn;\r\n\r\n\t\t\t\tif (!tile.complete) {\r\n\t\t\t\t\ttile.src = L.Util.emptyImageUrl;\r\n\t\t\t\t\tL.DomUtil.remove(tile);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n});\r\n\r\n\r\n// @factory L.tilelayer(urlTemplate: String, options?: TileLayer options)\r\n// Instantiates a tile layer object given a `URL template` and optionally an options object.\r\n\r\nL.tileLayer = function (url, options) {\r\n\treturn new L.TileLayer(url, options);\r\n};\r\n","/*\r\n * @class TileLayer.WMS\r\n * @inherits TileLayer\r\n * @aka L.TileLayer.WMS\r\n * Used to display [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services as tile layers on the map. Extends `TileLayer`.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var nexrad = L.tileLayer.wms(\"http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi\", {\r\n * \tlayers: 'nexrad-n0r-900913',\r\n * \tformat: 'image/png',\r\n * \ttransparent: true,\r\n * \tattribution: \"Weather data © 2012 IEM Nexrad\"\r\n * });\r\n * ```\r\n */\r\n\r\nL.TileLayer.WMS = L.TileLayer.extend({\r\n\r\n\t// @section\r\n\t// @aka TileLayer.WMS options\r\n\t// If any custom options not documented here are used, they will be sent to the\r\n\t// WMS server as extra parameters in each request URL. This can be useful for\r\n\t// [non-standard vendor WMS parameters](http://docs.geoserver.org/stable/en/user/services/wms/vendor.html).\r\n\tdefaultWmsParams: {\r\n\t\tservice: 'WMS',\r\n\t\trequest: 'GetMap',\r\n\r\n\t\t// @option layers: String = ''\r\n\t\t// **(required)** Comma-separated list of WMS layers to show.\r\n\t\tlayers: '',\r\n\r\n\t\t// @option styles: String = ''\r\n\t\t// Comma-separated list of WMS styles.\r\n\t\tstyles: '',\r\n\r\n\t\t// @option format: String = 'image/jpeg'\r\n\t\t// WMS image format (use `'image/png'` for layers with transparency).\r\n\t\tformat: 'image/jpeg',\r\n\r\n\t\t// @option transparent: Boolean = false\r\n\t\t// If `true`, the WMS service will return images with transparency.\r\n\t\ttransparent: false,\r\n\r\n\t\t// @option version: String = '1.1.1'\r\n\t\t// Version of the WMS service to use\r\n\t\tversion: '1.1.1'\r\n\t},\r\n\r\n\toptions: {\r\n\t\t// @option crs: CRS = null\r\n\t\t// Coordinate Reference System to use for the WMS requests, defaults to\r\n\t\t// map CRS. Don't change this if you're not sure what it means.\r\n\t\tcrs: null,\r\n\r\n\t\t// @option uppercase: Boolean = false\r\n\t\t// If `true`, WMS request parameter keys will be uppercase.\r\n\t\tuppercase: false\r\n\t},\r\n\r\n\tinitialize: function (url, options) {\r\n\r\n\t\tthis._url = url;\r\n\r\n\t\tvar wmsParams = L.extend({}, this.defaultWmsParams);\r\n\r\n\t\t// all keys that are not TileLayer options go to WMS params\r\n\t\tfor (var i in options) {\r\n\t\t\tif (!(i in this.options)) {\r\n\t\t\t\twmsParams[i] = options[i];\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\toptions = L.setOptions(this, options);\r\n\r\n\t\twmsParams.width = wmsParams.height = options.tileSize * (options.detectRetina && L.Browser.retina ? 2 : 1);\r\n\r\n\t\tthis.wmsParams = wmsParams;\r\n\t},\r\n\r\n\tonAdd: function (map) {\r\n\r\n\t\tthis._crs = this.options.crs || map.options.crs;\r\n\t\tthis._wmsVersion = parseFloat(this.wmsParams.version);\r\n\r\n\t\tvar projectionKey = this._wmsVersion >= 1.3 ? 'crs' : 'srs';\r\n\t\tthis.wmsParams[projectionKey] = this._crs.code;\r\n\r\n\t\tL.TileLayer.prototype.onAdd.call(this, map);\r\n\t},\r\n\r\n\tgetTileUrl: function (coords) {\r\n\r\n\t\tvar tileBounds = this._tileCoordsToBounds(coords),\r\n\t\t nw = this._crs.project(tileBounds.getNorthWest()),\r\n\t\t se = this._crs.project(tileBounds.getSouthEast()),\r\n\r\n\t\t bbox = (this._wmsVersion >= 1.3 && this._crs === L.CRS.EPSG4326 ?\r\n\t\t\t [se.y, nw.x, nw.y, se.x] :\r\n\t\t\t [nw.x, se.y, se.x, nw.y]).join(','),\r\n\r\n\t\t url = L.TileLayer.prototype.getTileUrl.call(this, coords);\r\n\r\n\t\treturn url +\r\n\t\t\tL.Util.getParamString(this.wmsParams, url, this.options.uppercase) +\r\n\t\t\t(this.options.uppercase ? '&BBOX=' : '&bbox=') + bbox;\r\n\t},\r\n\r\n\t// @method setParams(params: Object, noRedraw?: Boolean): this\r\n\t// Merges an object with the new parameters and re-requests tiles on the current screen (unless `noRedraw` was set to true).\r\n\tsetParams: function (params, noRedraw) {\r\n\r\n\t\tL.extend(this.wmsParams, params);\r\n\r\n\t\tif (!noRedraw) {\r\n\t\t\tthis.redraw();\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t}\r\n});\r\n\r\n\r\n// @factory L.tileLayer.wms(baseUrl: String, options: TileLayer.WMS options)\r\n// Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS parameters/options object.\r\nL.tileLayer.wms = function (url, options) {\r\n\treturn new L.TileLayer.WMS(url, options);\r\n};\r\n","/*\r\n * @class ImageOverlay\r\n * @aka L.ImageOverlay\r\n * @inherits Interactive layer\r\n *\r\n * Used to load and display a single image over specific bounds of the map. Extends `Layer`.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var imageUrl = 'http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg',\r\n * \timageBounds = [[40.712216, -74.22655], [40.773941, -74.12544]];\r\n * L.imageOverlay(imageUrl, imageBounds).addTo(map);\r\n * ```\r\n */\r\n\r\nL.ImageOverlay = L.Layer.extend({\r\n\r\n\t// @section\r\n\t// @aka ImageOverlay options\r\n\toptions: {\r\n\t\t// @option opacity: Number = 1.0\r\n\t\t// The opacity of the image overlay.\r\n\t\topacity: 1,\r\n\r\n\t\t// @option alt: String = ''\r\n\t\t// Text for the `alt` attribute of the image (useful for accessibility).\r\n\t\talt: '',\r\n\r\n\t\t// @option interactive: Boolean = false\r\n\t\t// If `true`, the image overlay will emit [mouse events](#interactive-layer) when clicked or hovered.\r\n\t\tinteractive: false,\r\n\r\n\t\t// @option crossOrigin: Boolean = false\r\n\t\t// If true, the image will have its crossOrigin attribute set to ''. This is needed if you want to access image pixel data.\r\n\t\tcrossOrigin: false\r\n\t},\r\n\r\n\tinitialize: function (url, bounds, options) { // (String, LatLngBounds, Object)\r\n\t\tthis._url = url;\r\n\t\tthis._bounds = L.latLngBounds(bounds);\r\n\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\tonAdd: function () {\r\n\t\tif (!this._image) {\r\n\t\t\tthis._initImage();\r\n\r\n\t\t\tif (this.options.opacity < 1) {\r\n\t\t\t\tthis._updateOpacity();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (this.options.interactive) {\r\n\t\t\tL.DomUtil.addClass(this._image, 'leaflet-interactive');\r\n\t\t\tthis.addInteractiveTarget(this._image);\r\n\t\t}\r\n\r\n\t\tthis.getPane().appendChild(this._image);\r\n\t\tthis._reset();\r\n\t},\r\n\r\n\tonRemove: function () {\r\n\t\tL.DomUtil.remove(this._image);\r\n\t\tif (this.options.interactive) {\r\n\t\t\tthis.removeInteractiveTarget(this._image);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method setOpacity(opacity: Number): this\r\n\t// Sets the opacity of the overlay.\r\n\tsetOpacity: function (opacity) {\r\n\t\tthis.options.opacity = opacity;\r\n\r\n\t\tif (this._image) {\r\n\t\t\tthis._updateOpacity();\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\tsetStyle: function (styleOpts) {\r\n\t\tif (styleOpts.opacity) {\r\n\t\t\tthis.setOpacity(styleOpts.opacity);\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method bringToFront(): this\r\n\t// Brings the layer to the top of all overlays.\r\n\tbringToFront: function () {\r\n\t\tif (this._map) {\r\n\t\t\tL.DomUtil.toFront(this._image);\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method bringToBack(): this\r\n\t// Brings the layer to the bottom of all overlays.\r\n\tbringToBack: function () {\r\n\t\tif (this._map) {\r\n\t\t\tL.DomUtil.toBack(this._image);\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method setUrl(url: String): this\r\n\t// Changes the URL of the image.\r\n\tsetUrl: function (url) {\r\n\t\tthis._url = url;\r\n\r\n\t\tif (this._image) {\r\n\t\t\tthis._image.src = url;\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\tsetBounds: function (bounds) {\r\n\t\tthis._bounds = bounds;\r\n\r\n\t\tif (this._map) {\r\n\t\t\tthis._reset();\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\tgetEvents: function () {\r\n\t\tvar events = {\r\n\t\t\tzoom: this._reset,\r\n\t\t\tviewreset: this._reset\r\n\t\t};\r\n\r\n\t\tif (this._zoomAnimated) {\r\n\t\t\tevents.zoomanim = this._animateZoom;\r\n\t\t}\r\n\r\n\t\treturn events;\r\n\t},\r\n\r\n\tgetBounds: function () {\r\n\t\treturn this._bounds;\r\n\t},\r\n\r\n\tgetElement: function () {\r\n\t\treturn this._image;\r\n\t},\r\n\r\n\t_initImage: function () {\r\n\t\tvar img = this._image = L.DomUtil.create('img',\r\n\t\t\t\t'leaflet-image-layer ' + (this._zoomAnimated ? 'leaflet-zoom-animated' : ''));\r\n\r\n\t\timg.onselectstart = L.Util.falseFn;\r\n\t\timg.onmousemove = L.Util.falseFn;\r\n\r\n\t\timg.onload = L.bind(this.fire, this, 'load');\r\n\r\n\t\tif (this.options.crossOrigin) {\r\n\t\t\timg.crossOrigin = '';\r\n\t\t}\r\n\r\n\t\timg.src = this._url;\r\n\t\timg.alt = this.options.alt;\r\n\t},\r\n\r\n\t_animateZoom: function (e) {\r\n\t\tvar scale = this._map.getZoomScale(e.zoom),\r\n\t\t offset = this._map._latLngBoundsToNewLayerBounds(this._bounds, e.zoom, e.center).min;\r\n\r\n\t\tL.DomUtil.setTransform(this._image, offset, scale);\r\n\t},\r\n\r\n\t_reset: function () {\r\n\t\tvar image = this._image,\r\n\t\t bounds = new L.Bounds(\r\n\t\t this._map.latLngToLayerPoint(this._bounds.getNorthWest()),\r\n\t\t this._map.latLngToLayerPoint(this._bounds.getSouthEast())),\r\n\t\t size = bounds.getSize();\r\n\r\n\t\tL.DomUtil.setPosition(image, bounds.min);\r\n\r\n\t\timage.style.width = size.x + 'px';\r\n\t\timage.style.height = size.y + 'px';\r\n\t},\r\n\r\n\t_updateOpacity: function () {\r\n\t\tL.DomUtil.setOpacity(this._image, this.options.opacity);\r\n\t}\r\n});\r\n\r\n// @factory L.imageOverlay(imageUrl: String, bounds: LatLngBounds, options?: ImageOverlay options)\r\n// Instantiates an image overlay object given the URL of the image and the\r\n// geographical bounds it is tied to.\r\nL.imageOverlay = function (url, bounds, options) {\r\n\treturn new L.ImageOverlay(url, bounds, options);\r\n};\r\n","/*\r\n * @class Icon\r\n * @aka L.Icon\r\n * @inherits Layer\r\n *\r\n * Represents an icon to provide when creating a marker.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var myIcon = L.icon({\r\n * iconUrl: 'my-icon.png',\r\n * iconRetinaUrl: 'my-icon@2x.png',\r\n * iconSize: [38, 95],\r\n * iconAnchor: [22, 94],\r\n * popupAnchor: [-3, -76],\r\n * shadowUrl: 'my-icon-shadow.png',\r\n * shadowRetinaUrl: 'my-icon-shadow@2x.png',\r\n * shadowSize: [68, 95],\r\n * shadowAnchor: [22, 94]\r\n * });\r\n *\r\n * L.marker([50.505, 30.57], {icon: myIcon}).addTo(map);\r\n * ```\r\n *\r\n * `L.Icon.Default` extends `L.Icon` and is the blue icon Leaflet uses for markers by default.\r\n *\r\n */\r\n\r\nL.Icon = L.Class.extend({\r\n\r\n\t/* @section\r\n\t * @aka Icon options\r\n\t *\r\n\t * @option iconUrl: String = null\r\n\t * **(required)** The URL to the icon image (absolute or relative to your script path).\r\n\t *\r\n\t * @option iconRetinaUrl: String = null\r\n\t * The URL to a retina sized version of the icon image (absolute or relative to your\r\n\t * script path). Used for Retina screen devices.\r\n\t *\r\n\t * @option iconSize: Point = null\r\n\t * Size of the icon image in pixels.\r\n\t *\r\n\t * @option iconAnchor: Point = null\r\n\t * The coordinates of the \"tip\" of the icon (relative to its top left corner). The icon\r\n\t * will be aligned so that this point is at the marker's geographical location. Centered\r\n\t * by default if size is specified, also can be set in CSS with negative margins.\r\n\t *\r\n\t * @option popupAnchor: Point = null\r\n\t * The coordinates of the point from which popups will \"open\", relative to the icon anchor.\r\n\t *\r\n\t * @option shadowUrl: String = null\r\n\t * The URL to the icon shadow image. If not specified, no shadow image will be created.\r\n\t *\r\n\t * @option shadowRetinaUrl: String = null\r\n\t *\r\n\t * @option shadowSize: Point = null\r\n\t * Size of the shadow image in pixels.\r\n\t *\r\n\t * @option shadowAnchor: Point = null\r\n\t * The coordinates of the \"tip\" of the shadow (relative to its top left corner) (the same\r\n\t * as iconAnchor if not specified).\r\n\t *\r\n\t * @option className: String = ''\r\n\t * A custom class name to assign to both icon and shadow images. Empty by default.\r\n\t */\r\n\r\n\tinitialize: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t// @method createIcon(oldIcon?: HTMLElement): HTMLElement\r\n\t// Called internally when the icon has to be shown, returns a `` HTML element\r\n\t// styled according to the options.\r\n\tcreateIcon: function (oldIcon) {\r\n\t\treturn this._createIcon('icon', oldIcon);\r\n\t},\r\n\r\n\t// @method createShadow(oldIcon?: HTMLElement): HTMLElement\r\n\t// As `createIcon`, but for the shadow beneath it.\r\n\tcreateShadow: function (oldIcon) {\r\n\t\treturn this._createIcon('shadow', oldIcon);\r\n\t},\r\n\r\n\t_createIcon: function (name, oldIcon) {\r\n\t\tvar src = this._getIconUrl(name);\r\n\r\n\t\tif (!src) {\r\n\t\t\tif (name === 'icon') {\r\n\t\t\t\tthrow new Error('iconUrl not set in Icon options (see the docs).');\r\n\t\t\t}\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tvar img = this._createImg(src, oldIcon && oldIcon.tagName === 'IMG' ? oldIcon : null);\r\n\t\tthis._setIconStyles(img, name);\r\n\r\n\t\treturn img;\r\n\t},\r\n\r\n\t_setIconStyles: function (img, name) {\r\n\t\tvar options = this.options;\r\n\t\tvar sizeOption = options[name + 'Size'];\r\n\r\n\t\tif (typeof sizeOption === 'number') {\r\n\t\t\tsizeOption = [sizeOption, sizeOption];\r\n\t\t}\r\n\r\n\t\tvar size = L.point(sizeOption),\r\n\t\t anchor = L.point(name === 'shadow' && options.shadowAnchor || options.iconAnchor ||\r\n\t\t size && size.divideBy(2, true));\r\n\r\n\t\timg.className = 'leaflet-marker-' + name + ' ' + (options.className || '');\r\n\r\n\t\tif (anchor) {\r\n\t\t\timg.style.marginLeft = (-anchor.x) + 'px';\r\n\t\t\timg.style.marginTop = (-anchor.y) + 'px';\r\n\t\t}\r\n\r\n\t\tif (size) {\r\n\t\t\timg.style.width = size.x + 'px';\r\n\t\t\timg.style.height = size.y + 'px';\r\n\t\t}\r\n\t},\r\n\r\n\t_createImg: function (src, el) {\r\n\t\tel = el || document.createElement('img');\r\n\t\tel.src = src;\r\n\t\treturn el;\r\n\t},\r\n\r\n\t_getIconUrl: function (name) {\r\n\t\treturn L.Browser.retina && this.options[name + 'RetinaUrl'] || this.options[name + 'Url'];\r\n\t}\r\n});\r\n\r\n\r\n// @factory L.icon(options: Icon options)\r\n// Creates an icon instance with the given options.\r\nL.icon = function (options) {\r\n\treturn new L.Icon(options);\r\n};\r\n","/*\n * @miniclass Icon.Default (Icon)\n * @aka L.Icon.Default\n * @section\n *\n * A trivial subclass of `Icon`, represents the icon to use in `Marker`s when\n * no icon is specified. Points to the blue marker image distributed with Leaflet\n * releases.\n *\n * In order to customize the default icon, just change the properties of `L.Icon.Default.prototype.options`\n * (which is a set of `Icon options`).\n *\n * If you want to _completely_ replace the default icon, override the\n * `L.Marker.prototype.options.icon` with your own icon instead.\n */\n\nL.Icon.Default = L.Icon.extend({\n\n\toptions: {\n\t\ticonUrl: 'marker-icon.png',\n\t\ticonRetinaUrl: 'marker-icon-2x.png',\n\t\tshadowUrl: 'marker-shadow.png',\n\t\ticonSize: [25, 41],\n\t\ticonAnchor: [12, 41],\n\t\tpopupAnchor: [1, -34],\n\t\ttooltipAnchor: [16, -28],\n\t\tshadowSize: [41, 41]\n\t},\n\n\t_getIconUrl: function (name) {\n\t\tif (!L.Icon.Default.imagePath) {\t// Deprecated, backwards-compatibility only\n\t\t\tL.Icon.Default.imagePath = this._detectIconPath();\n\t\t}\n\n\t\t// @option imagePath: String\n\t\t// `L.Icon.Default` will try to auto-detect the absolute location of the\n\t\t// blue icon images. If you are placing these images in a non-standard\n\t\t// way, set this option to point to the right absolute path.\n\t\treturn (this.options.imagePath || L.Icon.Default.imagePath) + L.Icon.prototype._getIconUrl.call(this, name);\n\t},\n\n\t_detectIconPath: function () {\n\t\tvar el = L.DomUtil.create('div', 'leaflet-default-icon-path', document.body);\n\t\tvar path = L.DomUtil.getStyle(el, 'background-image') ||\n\t\t L.DomUtil.getStyle(el, 'backgroundImage');\t// IE8\n\n\t\tdocument.body.removeChild(el);\n\n\t\treturn path.indexOf('url') === 0 ?\n\t\t\tpath.replace(/^url\\([\\\"\\']?/, '').replace(/marker-icon\\.png[\\\"\\']?\\)$/, '') : '';\n\t}\n});\n","/*\r\n * @class Marker\r\n * @inherits Interactive layer\r\n * @aka L.Marker\r\n * L.Marker is used to display clickable/draggable icons on the map. Extends `Layer`.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * L.marker([50.5, 30.5]).addTo(map);\r\n * ```\r\n */\r\n\r\nL.Marker = L.Layer.extend({\r\n\r\n\t// @section\r\n\t// @aka Marker options\r\n\toptions: {\r\n\t\t// @option icon: Icon = *\r\n\t\t// Icon class to use for rendering the marker. See [Icon documentation](#L.Icon) for details on how to customize the marker icon. If not specified, a new `L.Icon.Default` is used.\r\n\t\ticon: new L.Icon.Default(),\r\n\r\n\t\t// Option inherited from \"Interactive layer\" abstract class\r\n\t\tinteractive: true,\r\n\r\n\t\t// @option draggable: Boolean = false\r\n\t\t// Whether the marker is draggable with mouse/touch or not.\r\n\t\tdraggable: false,\r\n\r\n\t\t// @option keyboard: Boolean = true\r\n\t\t// Whether the marker can be tabbed to with a keyboard and clicked by pressing enter.\r\n\t\tkeyboard: true,\r\n\r\n\t\t// @option title: String = ''\r\n\t\t// Text for the browser tooltip that appear on marker hover (no tooltip by default).\r\n\t\ttitle: '',\r\n\r\n\t\t// @option alt: String = ''\r\n\t\t// Text for the `alt` attribute of the icon image (useful for accessibility).\r\n\t\talt: '',\r\n\r\n\t\t// @option zIndexOffset: Number = 0\r\n\t\t// By default, marker images zIndex is set automatically based on its latitude. Use this option if you want to put the marker on top of all others (or below), specifying a high value like `1000` (or high negative value, respectively).\r\n\t\tzIndexOffset: 0,\r\n\r\n\t\t// @option opacity: Number = 1.0\r\n\t\t// The opacity of the marker.\r\n\t\topacity: 1,\r\n\r\n\t\t// @option riseOnHover: Boolean = false\r\n\t\t// If `true`, the marker will get on top of others when you hover the mouse over it.\r\n\t\triseOnHover: false,\r\n\r\n\t\t// @option riseOffset: Number = 250\r\n\t\t// The z-index offset used for the `riseOnHover` feature.\r\n\t\triseOffset: 250,\r\n\r\n\t\t// @option pane: String = 'markerPane'\r\n\t\t// `Map pane` where the markers icon will be added.\r\n\t\tpane: 'markerPane',\r\n\r\n\t\t// FIXME: shadowPane is no longer a valid option\r\n\t\tnonBubblingEvents: ['click', 'dblclick', 'mouseover', 'mouseout', 'contextmenu']\r\n\t},\r\n\r\n\t/* @section\r\n\t *\r\n\t * In addition to [shared layer methods](#Layer) like `addTo()` and `remove()` and [popup methods](#Popup) like bindPopup() you can also use the following methods:\r\n\t */\r\n\r\n\tinitialize: function (latlng, options) {\r\n\t\tL.setOptions(this, options);\r\n\t\tthis._latlng = L.latLng(latlng);\r\n\t},\r\n\r\n\tonAdd: function (map) {\r\n\t\tthis._zoomAnimated = this._zoomAnimated && map.options.markerZoomAnimation;\r\n\r\n\t\tif (this._zoomAnimated) {\r\n\t\t\tmap.on('zoomanim', this._animateZoom, this);\r\n\t\t}\r\n\r\n\t\tthis._initIcon();\r\n\t\tthis.update();\r\n\t},\r\n\r\n\tonRemove: function (map) {\r\n\t\tif (this.dragging && this.dragging.enabled()) {\r\n\t\t\tthis.options.draggable = true;\r\n\t\t\tthis.dragging.removeHooks();\r\n\t\t}\r\n\r\n\t\tif (this._zoomAnimated) {\r\n\t\t\tmap.off('zoomanim', this._animateZoom, this);\r\n\t\t}\r\n\r\n\t\tthis._removeIcon();\r\n\t\tthis._removeShadow();\r\n\t},\r\n\r\n\tgetEvents: function () {\r\n\t\treturn {\r\n\t\t\tzoom: this.update,\r\n\t\t\tviewreset: this.update\r\n\t\t};\r\n\t},\r\n\r\n\t// @method getLatLng: LatLng\r\n\t// Returns the current geographical position of the marker.\r\n\tgetLatLng: function () {\r\n\t\treturn this._latlng;\r\n\t},\r\n\r\n\t// @method setLatLng(latlng: LatLng): this\r\n\t// Changes the marker position to the given point.\r\n\tsetLatLng: function (latlng) {\r\n\t\tvar oldLatLng = this._latlng;\r\n\t\tthis._latlng = L.latLng(latlng);\r\n\t\tthis.update();\r\n\r\n\t\t// @event move: Event\r\n\t\t// Fired when the marker is moved via [`setLatLng`](#marker-setlatlng) or by [dragging](#marker-dragging). Old and new coordinates are included in event arguments as `oldLatLng`, `latlng`.\r\n\t\treturn this.fire('move', {oldLatLng: oldLatLng, latlng: this._latlng});\r\n\t},\r\n\r\n\t// @method setZIndexOffset(offset: Number): this\r\n\t// Changes the [zIndex offset](#marker-zindexoffset) of the marker.\r\n\tsetZIndexOffset: function (offset) {\r\n\t\tthis.options.zIndexOffset = offset;\r\n\t\treturn this.update();\r\n\t},\r\n\r\n\t// @method setIcon(icon: Icon): this\r\n\t// Changes the marker icon.\r\n\tsetIcon: function (icon) {\r\n\r\n\t\tthis.options.icon = icon;\r\n\r\n\t\tif (this._map) {\r\n\t\t\tthis._initIcon();\r\n\t\t\tthis.update();\r\n\t\t}\r\n\r\n\t\tif (this._popup) {\r\n\t\t\tthis.bindPopup(this._popup, this._popup.options);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\tgetElement: function () {\r\n\t\treturn this._icon;\r\n\t},\r\n\r\n\tupdate: function () {\r\n\r\n\t\tif (this._icon) {\r\n\t\t\tvar pos = this._map.latLngToLayerPoint(this._latlng).round();\r\n\t\t\tthis._setPos(pos);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_initIcon: function () {\r\n\t\tvar options = this.options,\r\n\t\t classToAdd = 'leaflet-zoom-' + (this._zoomAnimated ? 'animated' : 'hide');\r\n\r\n\t\tvar icon = options.icon.createIcon(this._icon),\r\n\t\t addIcon = false;\r\n\r\n\t\t// if we're not reusing the icon, remove the old one and init new one\r\n\t\tif (icon !== this._icon) {\r\n\t\t\tif (this._icon) {\r\n\t\t\t\tthis._removeIcon();\r\n\t\t\t}\r\n\t\t\taddIcon = true;\r\n\r\n\t\t\tif (options.title) {\r\n\t\t\t\ticon.title = options.title;\r\n\t\t\t}\r\n\t\t\tif (options.alt) {\r\n\t\t\t\ticon.alt = options.alt;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tL.DomUtil.addClass(icon, classToAdd);\r\n\r\n\t\tif (options.keyboard) {\r\n\t\t\ticon.tabIndex = '0';\r\n\t\t}\r\n\r\n\t\tthis._icon = icon;\r\n\r\n\t\tif (options.riseOnHover) {\r\n\t\t\tthis.on({\r\n\t\t\t\tmouseover: this._bringToFront,\r\n\t\t\t\tmouseout: this._resetZIndex\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tvar newShadow = options.icon.createShadow(this._shadow),\r\n\t\t addShadow = false;\r\n\r\n\t\tif (newShadow !== this._shadow) {\r\n\t\t\tthis._removeShadow();\r\n\t\t\taddShadow = true;\r\n\t\t}\r\n\r\n\t\tif (newShadow) {\r\n\t\t\tL.DomUtil.addClass(newShadow, classToAdd);\r\n\t\t}\r\n\t\tthis._shadow = newShadow;\r\n\r\n\r\n\t\tif (options.opacity < 1) {\r\n\t\t\tthis._updateOpacity();\r\n\t\t}\r\n\r\n\r\n\t\tif (addIcon) {\r\n\t\t\tthis.getPane().appendChild(this._icon);\r\n\t\t}\r\n\t\tthis._initInteraction();\r\n\t\tif (newShadow && addShadow) {\r\n\t\t\tthis.getPane('shadowPane').appendChild(this._shadow);\r\n\t\t}\r\n\t},\r\n\r\n\t_removeIcon: function () {\r\n\t\tif (this.options.riseOnHover) {\r\n\t\t\tthis.off({\r\n\t\t\t\tmouseover: this._bringToFront,\r\n\t\t\t\tmouseout: this._resetZIndex\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tL.DomUtil.remove(this._icon);\r\n\t\tthis.removeInteractiveTarget(this._icon);\r\n\r\n\t\tthis._icon = null;\r\n\t},\r\n\r\n\t_removeShadow: function () {\r\n\t\tif (this._shadow) {\r\n\t\t\tL.DomUtil.remove(this._shadow);\r\n\t\t}\r\n\t\tthis._shadow = null;\r\n\t},\r\n\r\n\t_setPos: function (pos) {\r\n\t\tL.DomUtil.setPosition(this._icon, pos);\r\n\r\n\t\tif (this._shadow) {\r\n\t\t\tL.DomUtil.setPosition(this._shadow, pos);\r\n\t\t}\r\n\r\n\t\tthis._zIndex = pos.y + this.options.zIndexOffset;\r\n\r\n\t\tthis._resetZIndex();\r\n\t},\r\n\r\n\t_updateZIndex: function (offset) {\r\n\t\tthis._icon.style.zIndex = this._zIndex + offset;\r\n\t},\r\n\r\n\t_animateZoom: function (opt) {\r\n\t\tvar pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round();\r\n\r\n\t\tthis._setPos(pos);\r\n\t},\r\n\r\n\t_initInteraction: function () {\r\n\r\n\t\tif (!this.options.interactive) { return; }\r\n\r\n\t\tL.DomUtil.addClass(this._icon, 'leaflet-interactive');\r\n\r\n\t\tthis.addInteractiveTarget(this._icon);\r\n\r\n\t\tif (L.Handler.MarkerDrag) {\r\n\t\t\tvar draggable = this.options.draggable;\r\n\t\t\tif (this.dragging) {\r\n\t\t\t\tdraggable = this.dragging.enabled();\r\n\t\t\t\tthis.dragging.disable();\r\n\t\t\t}\r\n\r\n\t\t\tthis.dragging = new L.Handler.MarkerDrag(this);\r\n\r\n\t\t\tif (draggable) {\r\n\t\t\t\tthis.dragging.enable();\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// @method setOpacity(opacity: Number): this\r\n\t// Changes the opacity of the marker.\r\n\tsetOpacity: function (opacity) {\r\n\t\tthis.options.opacity = opacity;\r\n\t\tif (this._map) {\r\n\t\t\tthis._updateOpacity();\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_updateOpacity: function () {\r\n\t\tvar opacity = this.options.opacity;\r\n\r\n\t\tL.DomUtil.setOpacity(this._icon, opacity);\r\n\r\n\t\tif (this._shadow) {\r\n\t\t\tL.DomUtil.setOpacity(this._shadow, opacity);\r\n\t\t}\r\n\t},\r\n\r\n\t_bringToFront: function () {\r\n\t\tthis._updateZIndex(this.options.riseOffset);\r\n\t},\r\n\r\n\t_resetZIndex: function () {\r\n\t\tthis._updateZIndex(0);\r\n\t},\r\n\r\n\t_getPopupAnchor: function () {\r\n\t\treturn this.options.icon.options.popupAnchor || [0, 0];\r\n\t},\r\n\r\n\t_getTooltipAnchor: function () {\r\n\t\treturn this.options.icon.options.tooltipAnchor || [0, 0];\r\n\t}\r\n});\r\n\r\n\r\n// factory L.marker(latlng: LatLng, options? : Marker options)\r\n\r\n// @factory L.marker(latlng: LatLng, options? : Marker options)\r\n// Instantiates a Marker object given a geographical point and optionally an options object.\r\nL.marker = function (latlng, options) {\r\n\treturn new L.Marker(latlng, options);\r\n};\r\n","/*\n * @class DivIcon\n * @aka L.DivIcon\n * @inherits Icon\n *\n * Represents a lightweight icon for markers that uses a simple `
      `\n * element instead of an image. Inherits from `Icon` but ignores the `iconUrl` and shadow options.\n *\n * @example\n * ```js\n * var myIcon = L.divIcon({className: 'my-div-icon'});\n * // you can set .my-div-icon styles in CSS\n *\n * L.marker([50.505, 30.57], {icon: myIcon}).addTo(map);\n * ```\n *\n * By default, it has a 'leaflet-div-icon' CSS class and is styled as a little white square with a shadow.\n */\n\nL.DivIcon = L.Icon.extend({\n\toptions: {\n\t\t// @section\n\t\t// @aka DivIcon options\n\t\ticonSize: [12, 12], // also can be set through CSS\n\n\t\t// iconAnchor: (Point),\n\t\t// popupAnchor: (Point),\n\n\t\t// @option html: String = ''\n\t\t// Custom HTML code to put inside the div element, empty by default.\n\t\thtml: false,\n\n\t\t// @option bgPos: Point = [0, 0]\n\t\t// Optional relative position of the background, in pixels\n\t\tbgPos: null,\n\n\t\tclassName: 'leaflet-div-icon'\n\t},\n\n\tcreateIcon: function (oldIcon) {\n\t\tvar div = (oldIcon && oldIcon.tagName === 'DIV') ? oldIcon : document.createElement('div'),\n\t\t options = this.options;\n\n\t\tdiv.innerHTML = options.html !== false ? options.html : '';\n\n\t\tif (options.bgPos) {\n\t\t\tvar bgPos = L.point(options.bgPos);\n\t\t\tdiv.style.backgroundPosition = (-bgPos.x) + 'px ' + (-bgPos.y) + 'px';\n\t\t}\n\t\tthis._setIconStyles(div, 'icon');\n\n\t\treturn div;\n\t},\n\n\tcreateShadow: function () {\n\t\treturn null;\n\t}\n});\n\n// @factory L.divIcon(options: DivIcon options)\n// Creates a `DivIcon` instance with the given options.\nL.divIcon = function (options) {\n\treturn new L.DivIcon(options);\n};\n","/*\r\n * @class DivOverlay\r\n * @inherits Layer\r\n * @aka L.DivOverlay\r\n * Base model for L.Popup and L.Tooltip. Inherit from it for custom popup like plugins.\r\n */\r\n\r\n// @namespace DivOverlay\r\nL.DivOverlay = L.Layer.extend({\r\n\r\n\t// @section\r\n\t// @aka DivOverlay options\r\n\toptions: {\r\n\t\t// @option offset: Point = Point(0, 7)\r\n\t\t// The offset of the popup position. Useful to control the anchor\r\n\t\t// of the popup when opening it on some overlays.\r\n\t\toffset: [0, 7],\r\n\r\n\t\t// @option className: String = ''\r\n\t\t// A custom CSS class name to assign to the popup.\r\n\t\tclassName: '',\r\n\r\n\t\t// @option pane: String = 'popupPane'\r\n\t\t// `Map pane` where the popup will be added.\r\n\t\tpane: 'popupPane'\r\n\t},\r\n\r\n\tinitialize: function (options, source) {\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tthis._source = source;\r\n\t},\r\n\r\n\tonAdd: function (map) {\r\n\t\tthis._zoomAnimated = map._zoomAnimated;\r\n\r\n\t\tif (!this._container) {\r\n\t\t\tthis._initLayout();\r\n\t\t}\r\n\r\n\t\tif (map._fadeAnimated) {\r\n\t\t\tL.DomUtil.setOpacity(this._container, 0);\r\n\t\t}\r\n\r\n\t\tclearTimeout(this._removeTimeout);\r\n\t\tthis.getPane().appendChild(this._container);\r\n\t\tthis.update();\r\n\r\n\t\tif (map._fadeAnimated) {\r\n\t\t\tL.DomUtil.setOpacity(this._container, 1);\r\n\t\t}\r\n\r\n\t\tthis.bringToFront();\r\n\t},\r\n\r\n\tonRemove: function (map) {\r\n\t\tif (map._fadeAnimated) {\r\n\t\t\tL.DomUtil.setOpacity(this._container, 0);\r\n\t\t\tthis._removeTimeout = setTimeout(L.bind(L.DomUtil.remove, L.DomUtil, this._container), 200);\r\n\t\t} else {\r\n\t\t\tL.DomUtil.remove(this._container);\r\n\t\t}\r\n\t},\r\n\r\n\t// @namespace Popup\r\n\t// @method getLatLng: LatLng\r\n\t// Returns the geographical point of popup.\r\n\tgetLatLng: function () {\r\n\t\treturn this._latlng;\r\n\t},\r\n\r\n\t// @method setLatLng(latlng: LatLng): this\r\n\t// Sets the geographical point where the popup will open.\r\n\tsetLatLng: function (latlng) {\r\n\t\tthis._latlng = L.latLng(latlng);\r\n\t\tif (this._map) {\r\n\t\t\tthis._updatePosition();\r\n\t\t\tthis._adjustPan();\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method getContent: String|HTMLElement\r\n\t// Returns the content of the popup.\r\n\tgetContent: function () {\r\n\t\treturn this._content;\r\n\t},\r\n\r\n\t// @method setContent(htmlContent: String|HTMLElement|Function): this\r\n\t// Sets the HTML content of the popup. If a function is passed the source layer will be passed to the function. The function should return a `String` or `HTMLElement` to be used in the popup.\r\n\tsetContent: function (content) {\r\n\t\tthis._content = content;\r\n\t\tthis.update();\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method getElement: String|HTMLElement\r\n\t// Alias for [getContent()](#popup-getcontent)\r\n\tgetElement: function () {\r\n\t\treturn this._container;\r\n\t},\r\n\r\n\t// @method update: null\r\n\t// Updates the popup content, layout and position. Useful for updating the popup after something inside changed, e.g. image loaded.\r\n\tupdate: function () {\r\n\t\tif (!this._map) { return; }\r\n\r\n\t\tthis._container.style.visibility = 'hidden';\r\n\r\n\t\tthis._updateContent();\r\n\t\tthis._updateLayout();\r\n\t\tthis._updatePosition();\r\n\r\n\t\tthis._container.style.visibility = '';\r\n\r\n\t\tthis._adjustPan();\r\n\t},\r\n\r\n\tgetEvents: function () {\r\n\t\tvar events = {\r\n\t\t\tzoom: this._updatePosition,\r\n\t\t\tviewreset: this._updatePosition\r\n\t\t};\r\n\r\n\t\tif (this._zoomAnimated) {\r\n\t\t\tevents.zoomanim = this._animateZoom;\r\n\t\t}\r\n\t\treturn events;\r\n\t},\r\n\r\n\t// @method isOpen: Boolean\r\n\t// Returns `true` when the popup is visible on the map.\r\n\tisOpen: function () {\r\n\t\treturn !!this._map && this._map.hasLayer(this);\r\n\t},\r\n\r\n\t// @method bringToFront: this\r\n\t// Brings this popup in front of other popups (in the same map pane).\r\n\tbringToFront: function () {\r\n\t\tif (this._map) {\r\n\t\t\tL.DomUtil.toFront(this._container);\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method bringToBack: this\r\n\t// Brings this popup to the back of other popups (in the same map pane).\r\n\tbringToBack: function () {\r\n\t\tif (this._map) {\r\n\t\t\tL.DomUtil.toBack(this._container);\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_updateContent: function () {\r\n\t\tif (!this._content) { return; }\r\n\r\n\t\tvar node = this._contentNode;\r\n\t\tvar content = (typeof this._content === 'function') ? this._content(this._source || this) : this._content;\r\n\r\n\t\tif (typeof content === 'string') {\r\n\t\t\tnode.innerHTML = content;\r\n\t\t} else {\r\n\t\t\twhile (node.hasChildNodes()) {\r\n\t\t\t\tnode.removeChild(node.firstChild);\r\n\t\t\t}\r\n\t\t\tnode.appendChild(content);\r\n\t\t}\r\n\t\tthis.fire('contentupdate');\r\n\t},\r\n\r\n\t_updatePosition: function () {\r\n\t\tif (!this._map) { return; }\r\n\r\n\t\tvar pos = this._map.latLngToLayerPoint(this._latlng),\r\n\t\t offset = L.point(this.options.offset),\r\n\t\t anchor = this._getAnchor();\r\n\r\n\t\tif (this._zoomAnimated) {\r\n\t\t\tL.DomUtil.setPosition(this._container, pos.add(anchor));\r\n\t\t} else {\r\n\t\t\toffset = offset.add(pos).add(anchor);\r\n\t\t}\r\n\r\n\t\tvar bottom = this._containerBottom = -offset.y,\r\n\t\t left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x;\r\n\r\n\t\t// bottom position the popup in case the height of the popup changes (images loading etc)\r\n\t\tthis._container.style.bottom = bottom + 'px';\r\n\t\tthis._container.style.left = left + 'px';\r\n\t},\r\n\r\n\t_getAnchor: function () {\r\n\t\treturn [0, 0];\r\n\t}\r\n\r\n});\r\n","/*\r\n * @class Popup\r\n * @inherits DivOverlay\r\n * @aka L.Popup\r\n * Used to open popups in certain places of the map. Use [Map.openPopup](#map-openpopup) to\r\n * open popups while making sure that only one popup is open at one time\r\n * (recommended for usability), or use [Map.addLayer](#map-addlayer) to open as many as you want.\r\n *\r\n * @example\r\n *\r\n * If you want to just bind a popup to marker click and then open it, it's really easy:\r\n *\r\n * ```js\r\n * marker.bindPopup(popupContent).openPopup();\r\n * ```\r\n * Path overlays like polylines also have a `bindPopup` method.\r\n * Here's a more complicated way to open a popup on a map:\r\n *\r\n * ```js\r\n * var popup = L.popup()\r\n * \t.setLatLng(latlng)\r\n * \t.setContent('

      Hello world!
      This is a nice popup.

      ')\r\n * \t.openOn(map);\r\n * ```\r\n */\r\n\r\n\r\n// @namespace Popup\r\nL.Popup = L.DivOverlay.extend({\r\n\r\n\t// @section\r\n\t// @aka Popup options\r\n\toptions: {\r\n\t\t// @option maxWidth: Number = 300\r\n\t\t// Max width of the popup, in pixels.\r\n\t\tmaxWidth: 300,\r\n\r\n\t\t// @option minWidth: Number = 50\r\n\t\t// Min width of the popup, in pixels.\r\n\t\tminWidth: 50,\r\n\r\n\t\t// @option maxHeight: Number = null\r\n\t\t// If set, creates a scrollable container of the given height\r\n\t\t// inside a popup if its content exceeds it.\r\n\t\tmaxHeight: null,\r\n\r\n\t\t// @option autoPan: Boolean = true\r\n\t\t// Set it to `false` if you don't want the map to do panning animation\r\n\t\t// to fit the opened popup.\r\n\t\tautoPan: true,\r\n\r\n\t\t// @option autoPanPaddingTopLeft: Point = null\r\n\t\t// The margin between the popup and the top left corner of the map\r\n\t\t// view after autopanning was performed.\r\n\t\tautoPanPaddingTopLeft: null,\r\n\r\n\t\t// @option autoPanPaddingBottomRight: Point = null\r\n\t\t// The margin between the popup and the bottom right corner of the map\r\n\t\t// view after autopanning was performed.\r\n\t\tautoPanPaddingBottomRight: null,\r\n\r\n\t\t// @option autoPanPadding: Point = Point(5, 5)\r\n\t\t// Equivalent of setting both top left and bottom right autopan padding to the same value.\r\n\t\tautoPanPadding: [5, 5],\r\n\r\n\t\t// @option keepInView: Boolean = false\r\n\t\t// Set it to `true` if you want to prevent users from panning the popup\r\n\t\t// off of the screen while it is open.\r\n\t\tkeepInView: false,\r\n\r\n\t\t// @option closeButton: Boolean = true\r\n\t\t// Controls the presence of a close button in the popup.\r\n\t\tcloseButton: true,\r\n\r\n\t\t// @option autoClose: Boolean = true\r\n\t\t// Set it to `false` if you want to override the default behavior of\r\n\t\t// the popup closing when user clicks the map (set globally by\r\n\t\t// the Map's [closePopupOnClick](#map-closepopuponclick) option).\r\n\t\tautoClose: true,\r\n\r\n\t\t// @option className: String = ''\r\n\t\t// A custom CSS class name to assign to the popup.\r\n\t\tclassName: ''\r\n\t},\r\n\r\n\t// @namespace Popup\r\n\t// @method openOn(map: Map): this\r\n\t// Adds the popup to the map and closes the previous one. The same as `map.openPopup(popup)`.\r\n\topenOn: function (map) {\r\n\t\tmap.openPopup(this);\r\n\t\treturn this;\r\n\t},\r\n\r\n\tonAdd: function (map) {\r\n\t\tL.DivOverlay.prototype.onAdd.call(this, map);\r\n\r\n\t\t// @namespace Map\r\n\t\t// @section Popup events\r\n\t\t// @event popupopen: PopupEvent\r\n\t\t// Fired when a popup is opened in the map\r\n\t\tmap.fire('popupopen', {popup: this});\r\n\r\n\t\tif (this._source) {\r\n\t\t\t// @namespace Layer\r\n\t\t\t// @section Popup events\r\n\t\t\t// @event popupopen: PopupEvent\r\n\t\t\t// Fired when a popup bound to this layer is opened\r\n\t\t\tthis._source.fire('popupopen', {popup: this}, true);\r\n\t\t\t// For non-path layers, we toggle the popup when clicking\r\n\t\t\t// again the layer, so prevent the map to reopen it.\r\n\t\t\tif (!(this._source instanceof L.Path)) {\r\n\t\t\t\tthis._source.on('preclick', L.DomEvent.stopPropagation);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\tonRemove: function (map) {\r\n\t\tL.DivOverlay.prototype.onRemove.call(this, map);\r\n\r\n\t\t// @namespace Map\r\n\t\t// @section Popup events\r\n\t\t// @event popupclose: PopupEvent\r\n\t\t// Fired when a popup in the map is closed\r\n\t\tmap.fire('popupclose', {popup: this});\r\n\r\n\t\tif (this._source) {\r\n\t\t\t// @namespace Layer\r\n\t\t\t// @section Popup events\r\n\t\t\t// @event popupclose: PopupEvent\r\n\t\t\t// Fired when a popup bound to this layer is closed\r\n\t\t\tthis._source.fire('popupclose', {popup: this}, true);\r\n\t\t\tif (!(this._source instanceof L.Path)) {\r\n\t\t\t\tthis._source.off('preclick', L.DomEvent.stopPropagation);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\tgetEvents: function () {\r\n\t\tvar events = L.DivOverlay.prototype.getEvents.call(this);\r\n\r\n\t\tif ('closeOnClick' in this.options ? this.options.closeOnClick : this._map.options.closePopupOnClick) {\r\n\t\t\tevents.preclick = this._close;\r\n\t\t}\r\n\r\n\t\tif (this.options.keepInView) {\r\n\t\t\tevents.moveend = this._adjustPan;\r\n\t\t}\r\n\r\n\t\treturn events;\r\n\t},\r\n\r\n\t_close: function () {\r\n\t\tif (this._map) {\r\n\t\t\tthis._map.closePopup(this);\r\n\t\t}\r\n\t},\r\n\r\n\t_initLayout: function () {\r\n\t\tvar prefix = 'leaflet-popup',\r\n\t\t container = this._container = L.DomUtil.create('div',\r\n\t\t\tprefix + ' ' + (this.options.className || '') +\r\n\t\t\t' leaflet-zoom-animated');\r\n\r\n\t\tif (this.options.closeButton) {\r\n\t\t\tvar closeButton = this._closeButton = L.DomUtil.create('a', prefix + '-close-button', container);\r\n\t\t\tcloseButton.href = '#close';\r\n\t\t\tcloseButton.innerHTML = '×';\r\n\r\n\t\t\tL.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this);\r\n\t\t}\r\n\r\n\t\tvar wrapper = this._wrapper = L.DomUtil.create('div', prefix + '-content-wrapper', container);\r\n\t\tthis._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper);\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.disableClickPropagation(wrapper)\r\n\t\t\t.disableScrollPropagation(this._contentNode)\r\n\t\t\t.on(wrapper, 'contextmenu', L.DomEvent.stopPropagation);\r\n\r\n\t\tthis._tipContainer = L.DomUtil.create('div', prefix + '-tip-container', container);\r\n\t\tthis._tip = L.DomUtil.create('div', prefix + '-tip', this._tipContainer);\r\n\t},\r\n\r\n\t_updateLayout: function () {\r\n\t\tvar container = this._contentNode,\r\n\t\t style = container.style;\r\n\r\n\t\tstyle.width = '';\r\n\t\tstyle.whiteSpace = 'nowrap';\r\n\r\n\t\tvar width = container.offsetWidth;\r\n\t\twidth = Math.min(width, this.options.maxWidth);\r\n\t\twidth = Math.max(width, this.options.minWidth);\r\n\r\n\t\tstyle.width = (width + 1) + 'px';\r\n\t\tstyle.whiteSpace = '';\r\n\r\n\t\tstyle.height = '';\r\n\r\n\t\tvar height = container.offsetHeight,\r\n\t\t maxHeight = this.options.maxHeight,\r\n\t\t scrolledClass = 'leaflet-popup-scrolled';\r\n\r\n\t\tif (maxHeight && height > maxHeight) {\r\n\t\t\tstyle.height = maxHeight + 'px';\r\n\t\t\tL.DomUtil.addClass(container, scrolledClass);\r\n\t\t} else {\r\n\t\t\tL.DomUtil.removeClass(container, scrolledClass);\r\n\t\t}\r\n\r\n\t\tthis._containerWidth = this._container.offsetWidth;\r\n\t},\r\n\r\n\t_animateZoom: function (e) {\r\n\t\tvar pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center),\r\n\t\t anchor = this._getAnchor();\r\n\t\tL.DomUtil.setPosition(this._container, pos.add(anchor));\r\n\t},\r\n\r\n\t_adjustPan: function () {\r\n\t\tif (!this.options.autoPan || (this._map._panAnim && this._map._panAnim._inProgress)) { return; }\r\n\r\n\t\tvar map = this._map,\r\n\t\t marginBottom = parseInt(L.DomUtil.getStyle(this._container, 'marginBottom'), 10) || 0,\r\n\t\t containerHeight = this._container.offsetHeight + marginBottom,\r\n\t\t containerWidth = this._containerWidth,\r\n\t\t layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom);\r\n\r\n\t\tlayerPos._add(L.DomUtil.getPosition(this._container));\r\n\r\n\t\tvar containerPos = map.layerPointToContainerPoint(layerPos),\r\n\t\t padding = L.point(this.options.autoPanPadding),\r\n\t\t paddingTL = L.point(this.options.autoPanPaddingTopLeft || padding),\r\n\t\t paddingBR = L.point(this.options.autoPanPaddingBottomRight || padding),\r\n\t\t size = map.getSize(),\r\n\t\t dx = 0,\r\n\t\t dy = 0;\r\n\r\n\t\tif (containerPos.x + containerWidth + paddingBR.x > size.x) { // right\r\n\t\t\tdx = containerPos.x + containerWidth - size.x + paddingBR.x;\r\n\t\t}\r\n\t\tif (containerPos.x - dx - paddingTL.x < 0) { // left\r\n\t\t\tdx = containerPos.x - paddingTL.x;\r\n\t\t}\r\n\t\tif (containerPos.y + containerHeight + paddingBR.y > size.y) { // bottom\r\n\t\t\tdy = containerPos.y + containerHeight - size.y + paddingBR.y;\r\n\t\t}\r\n\t\tif (containerPos.y - dy - paddingTL.y < 0) { // top\r\n\t\t\tdy = containerPos.y - paddingTL.y;\r\n\t\t}\r\n\r\n\t\t// @namespace Map\r\n\t\t// @section Popup events\r\n\t\t// @event autopanstart: Event\r\n\t\t// Fired when the map starts autopanning when opening a popup.\r\n\t\tif (dx || dy) {\r\n\t\t\tmap\r\n\t\t\t .fire('autopanstart')\r\n\t\t\t .panBy([dx, dy]);\r\n\t\t}\r\n\t},\r\n\r\n\t_onCloseButtonClick: function (e) {\r\n\t\tthis._close();\r\n\t\tL.DomEvent.stop(e);\r\n\t},\r\n\r\n\t_getAnchor: function () {\r\n\t\t// Where should we anchor the popup on the source layer?\r\n\t\treturn L.point(this._source && this._source._getPopupAnchor ? this._source._getPopupAnchor() : [0, 0]);\r\n\t}\r\n\r\n});\r\n\r\n// @namespace Popup\r\n// @factory L.popup(options?: Popup options, source?: Layer)\r\n// Instantiates a `Popup` object given an optional `options` object that describes its appearance and location and an optional `source` object that is used to tag the popup with a reference to the Layer to which it refers.\r\nL.popup = function (options, source) {\r\n\treturn new L.Popup(options, source);\r\n};\r\n\r\n\r\n/* @namespace Map\r\n * @section Interaction Options\r\n * @option closePopupOnClick: Boolean = true\r\n * Set it to `false` if you don't want popups to close when user clicks the map.\r\n */\r\nL.Map.mergeOptions({\r\n\tclosePopupOnClick: true\r\n});\r\n\r\n\r\n// @namespace Map\r\n// @section Methods for Layers and Controls\r\nL.Map.include({\r\n\t// @method openPopup(popup: Popup): this\r\n\t// Opens the specified popup while closing the previously opened (to make sure only one is opened at one time for usability).\r\n\t// @alternative\r\n\t// @method openPopup(content: String|HTMLElement, latlng: LatLng, options?: Popup options): this\r\n\t// Creates a popup with the specified content and options and opens it in the given point on a map.\r\n\topenPopup: function (popup, latlng, options) {\r\n\t\tif (!(popup instanceof L.Popup)) {\r\n\t\t\tpopup = new L.Popup(options).setContent(popup);\r\n\t\t}\r\n\r\n\t\tif (latlng) {\r\n\t\t\tpopup.setLatLng(latlng);\r\n\t\t}\r\n\r\n\t\tif (this.hasLayer(popup)) {\r\n\t\t\treturn this;\r\n\t\t}\r\n\r\n\t\tif (this._popup && this._popup.options.autoClose) {\r\n\t\t\tthis.closePopup();\r\n\t\t}\r\n\r\n\t\tthis._popup = popup;\r\n\t\treturn this.addLayer(popup);\r\n\t},\r\n\r\n\t// @method closePopup(popup?: Popup): this\r\n\t// Closes the popup previously opened with [openPopup](#map-openpopup) (or the given one).\r\n\tclosePopup: function (popup) {\r\n\t\tif (!popup || popup === this._popup) {\r\n\t\t\tpopup = this._popup;\r\n\t\t\tthis._popup = null;\r\n\t\t}\r\n\t\tif (popup) {\r\n\t\t\tthis.removeLayer(popup);\r\n\t\t}\r\n\t\treturn this;\r\n\t}\r\n});\r\n\r\n/*\r\n * @namespace Layer\r\n * @section Popup methods example\r\n *\r\n * All layers share a set of methods convenient for binding popups to it.\r\n *\r\n * ```js\r\n * var layer = L.Polygon(latlngs).bindPopup('Hi There!').addTo(map);\r\n * layer.openPopup();\r\n * layer.closePopup();\r\n * ```\r\n *\r\n * Popups will also be automatically opened when the layer is clicked on and closed when the layer is removed from the map or another popup is opened.\r\n */\r\n\r\n// @section Popup methods\r\nL.Layer.include({\r\n\r\n\t// @method bindPopup(content: String|HTMLElement|Function|Popup, options?: Popup options): this\r\n\t// Binds a popup to the layer with the passed `content` and sets up the\r\n\t// neccessary event listeners. If a `Function` is passed it will receive\r\n\t// the layer as the first argument and should return a `String` or `HTMLElement`.\r\n\tbindPopup: function (content, options) {\r\n\r\n\t\tif (content instanceof L.Popup) {\r\n\t\t\tL.setOptions(content, options);\r\n\t\t\tthis._popup = content;\r\n\t\t\tcontent._source = this;\r\n\t\t} else {\r\n\t\t\tif (!this._popup || options) {\r\n\t\t\t\tthis._popup = new L.Popup(options, this);\r\n\t\t\t}\r\n\t\t\tthis._popup.setContent(content);\r\n\t\t}\r\n\r\n\t\tif (!this._popupHandlersAdded) {\r\n\t\t\tthis.on({\r\n\t\t\t\tclick: this._openPopup,\r\n\t\t\t\tremove: this.closePopup,\r\n\t\t\t\tmove: this._movePopup\r\n\t\t\t});\r\n\t\t\tthis._popupHandlersAdded = true;\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method unbindPopup(): this\r\n\t// Removes the popup previously bound with `bindPopup`.\r\n\tunbindPopup: function () {\r\n\t\tif (this._popup) {\r\n\t\t\tthis.off({\r\n\t\t\t\tclick: this._openPopup,\r\n\t\t\t\tremove: this.closePopup,\r\n\t\t\t\tmove: this._movePopup\r\n\t\t\t});\r\n\t\t\tthis._popupHandlersAdded = false;\r\n\t\t\tthis._popup = null;\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method openPopup(latlng?: LatLng): this\r\n\t// Opens the bound popup at the specificed `latlng` or at the default popup anchor if no `latlng` is passed.\r\n\topenPopup: function (layer, latlng) {\r\n\t\tif (!(layer instanceof L.Layer)) {\r\n\t\t\tlatlng = layer;\r\n\t\t\tlayer = this;\r\n\t\t}\r\n\r\n\t\tif (layer instanceof L.FeatureGroup) {\r\n\t\t\tfor (var id in this._layers) {\r\n\t\t\t\tlayer = this._layers[id];\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!latlng) {\r\n\t\t\tlatlng = layer.getCenter ? layer.getCenter() : layer.getLatLng();\r\n\t\t}\r\n\r\n\t\tif (this._popup && this._map) {\r\n\t\t\t// set popup source to this layer\r\n\t\t\tthis._popup._source = layer;\r\n\r\n\t\t\t// update the popup (content, layout, ect...)\r\n\t\t\tthis._popup.update();\r\n\r\n\t\t\t// open the popup on the map\r\n\t\t\tthis._map.openPopup(this._popup, latlng);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method closePopup(): this\r\n\t// Closes the popup bound to this layer if it is open.\r\n\tclosePopup: function () {\r\n\t\tif (this._popup) {\r\n\t\t\tthis._popup._close();\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method togglePopup(): this\r\n\t// Opens or closes the popup bound to this layer depending on its current state.\r\n\ttogglePopup: function (target) {\r\n\t\tif (this._popup) {\r\n\t\t\tif (this._popup._map) {\r\n\t\t\t\tthis.closePopup();\r\n\t\t\t} else {\r\n\t\t\t\tthis.openPopup(target);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method isPopupOpen(): boolean\r\n\t// Returns `true` if the popup bound to this layer is currently open.\r\n\tisPopupOpen: function () {\r\n\t\treturn this._popup.isOpen();\r\n\t},\r\n\r\n\t// @method setPopupContent(content: String|HTMLElement|Popup): this\r\n\t// Sets the content of the popup bound to this layer.\r\n\tsetPopupContent: function (content) {\r\n\t\tif (this._popup) {\r\n\t\t\tthis._popup.setContent(content);\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method getPopup(): Popup\r\n\t// Returns the popup bound to this layer.\r\n\tgetPopup: function () {\r\n\t\treturn this._popup;\r\n\t},\r\n\r\n\t_openPopup: function (e) {\r\n\t\tvar layer = e.layer || e.target;\r\n\r\n\t\tif (!this._popup) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (!this._map) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// prevent map click\r\n\t\tL.DomEvent.stop(e);\r\n\r\n\t\t// if this inherits from Path its a vector and we can just\r\n\t\t// open the popup at the new location\r\n\t\tif (layer instanceof L.Path) {\r\n\t\t\tthis.openPopup(e.layer || e.target, e.latlng);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// otherwise treat it like a marker and figure out\r\n\t\t// if we should toggle it open/closed\r\n\t\tif (this._map.hasLayer(this._popup) && this._popup._source === layer) {\r\n\t\t\tthis.closePopup();\r\n\t\t} else {\r\n\t\t\tthis.openPopup(layer, e.latlng);\r\n\t\t}\r\n\t},\r\n\r\n\t_movePopup: function (e) {\r\n\t\tthis._popup.setLatLng(e.latlng);\r\n\t}\r\n});\r\n","/*\n * @class Tooltip\n * @inherits DivOverlay\n * @aka L.Tooltip\n * Used to display small texts on top of map layers.\n *\n * @example\n *\n * ```js\n * marker.bindTooltip(\"my tooltip text\").openTooltip();\n * ```\n * Note about tooltip offset. Leaflet takes two options in consideration\n * for computing tooltip offseting:\n * - the `offset` Tooltip option: it defaults to [0, 0], and it's specific to one tooltip.\n * Add a positive x offset to move the tooltip to the right, and a positive y offset to\n * move it to the bottom. Negatives will move to the left and top.\n * - the `tooltipAnchor` Icon option: this will only be considered for Marker. You\n * should adapt this value if you use a custom icon.\n */\n\n\n// @namespace Tooltip\nL.Tooltip = L.DivOverlay.extend({\n\n\t// @section\n\t// @aka Tooltip options\n\toptions: {\n\t\t// @option pane: String = 'tooltipPane'\n\t\t// `Map pane` where the tooltip will be added.\n\t\tpane: 'tooltipPane',\n\n\t\t// @option offset: Point = Point(0, 0)\n\t\t// Optional offset of the tooltip position.\n\t\toffset: [0, 0],\n\n\t\t// @option direction: String = 'auto'\n\t\t// Direction where to open the tooltip. Possible values are: `right`, `left`,\n\t\t// `top`, `bottom`, `center`, `auto`.\n\t\t// `auto` will dynamicaly switch between `right` and `left` according to the tooltip\n\t\t// position on the map.\n\t\tdirection: 'auto',\n\n\t\t// @option permanent: Boolean = false\n\t\t// Whether to open the tooltip permanently or only on mouseover.\n\t\tpermanent: false,\n\n\t\t// @option sticky: Boolean = false\n\t\t// If true, the tooltip will follow the mouse instead of being fixed at the feature center.\n\t\tsticky: false,\n\n\t\t// @option interactive: Boolean = false\n\t\t// If true, the tooltip will listen to the feature events.\n\t\tinteractive: false,\n\n\t\t// @option opacity: Number = 0.9\n\t\t// Tooltip container opacity.\n\t\topacity: 0.9\n\t},\n\n\tonAdd: function (map) {\n\t\tL.DivOverlay.prototype.onAdd.call(this, map);\n\t\tthis.setOpacity(this.options.opacity);\n\n\t\t// @namespace Map\n\t\t// @section Tooltip events\n\t\t// @event tooltipopen: TooltipEvent\n\t\t// Fired when a tooltip is opened in the map.\n\t\tmap.fire('tooltipopen', {tooltip: this});\n\n\t\tif (this._source) {\n\t\t\t// @namespace Layer\n\t\t\t// @section Tooltip events\n\t\t\t// @event tooltipopen: TooltipEvent\n\t\t\t// Fired when a tooltip bound to this layer is opened.\n\t\t\tthis._source.fire('tooltipopen', {tooltip: this}, true);\n\t\t}\n\t},\n\n\tonRemove: function (map) {\n\t\tL.DivOverlay.prototype.onRemove.call(this, map);\n\n\t\t// @namespace Map\n\t\t// @section Tooltip events\n\t\t// @event tooltipclose: TooltipEvent\n\t\t// Fired when a tooltip in the map is closed.\n\t\tmap.fire('tooltipclose', {tooltip: this});\n\n\t\tif (this._source) {\n\t\t\t// @namespace Layer\n\t\t\t// @section Tooltip events\n\t\t\t// @event tooltipclose: TooltipEvent\n\t\t\t// Fired when a tooltip bound to this layer is closed.\n\t\t\tthis._source.fire('tooltipclose', {tooltip: this}, true);\n\t\t}\n\t},\n\n\tgetEvents: function () {\n\t\tvar events = L.DivOverlay.prototype.getEvents.call(this);\n\n\t\tif (L.Browser.touch && !this.options.permanent) {\n\t\t\tevents.preclick = this._close;\n\t\t}\n\n\t\treturn events;\n\t},\n\n\t_close: function () {\n\t\tif (this._map) {\n\t\t\tthis._map.closeTooltip(this);\n\t\t}\n\t},\n\n\t_initLayout: function () {\n\t\tvar prefix = 'leaflet-tooltip',\n\t\t className = prefix + ' ' + (this.options.className || '') + ' leaflet-zoom-' + (this._zoomAnimated ? 'animated' : 'hide');\n\n\t\tthis._contentNode = this._container = L.DomUtil.create('div', className);\n\t},\n\n\t_updateLayout: function () {},\n\n\t_adjustPan: function () {},\n\n\t_setPosition: function (pos) {\n\t\tvar map = this._map,\n\t\t container = this._container,\n\t\t centerPoint = map.latLngToContainerPoint(map.getCenter()),\n\t\t tooltipPoint = map.layerPointToContainerPoint(pos),\n\t\t direction = this.options.direction,\n\t\t tooltipWidth = container.offsetWidth,\n\t\t tooltipHeight = container.offsetHeight,\n\t\t offset = L.point(this.options.offset),\n\t\t anchor = this._getAnchor();\n\n\t\tif (direction === 'top') {\n\t\t\tpos = pos.add(L.point(-tooltipWidth / 2 + offset.x, -tooltipHeight + offset.y + anchor.y, true));\n\t\t} else if (direction === 'bottom') {\n\t\t\tpos = pos.subtract(L.point(tooltipWidth / 2 - offset.x, -offset.y, true));\n\t\t} else if (direction === 'center') {\n\t\t\tpos = pos.subtract(L.point(tooltipWidth / 2 + offset.x, tooltipHeight / 2 - anchor.y + offset.y, true));\n\t\t} else if (direction === 'right' || direction === 'auto' && tooltipPoint.x < centerPoint.x) {\n\t\t\tdirection = 'right';\n\t\t\tpos = pos.add(L.point(offset.x + anchor.x, anchor.y - tooltipHeight / 2 + offset.y, true));\n\t\t} else {\n\t\t\tdirection = 'left';\n\t\t\tpos = pos.subtract(L.point(tooltipWidth + anchor.x - offset.x, tooltipHeight / 2 - anchor.y - offset.y, true));\n\t\t}\n\n\t\tL.DomUtil.removeClass(container, 'leaflet-tooltip-right');\n\t\tL.DomUtil.removeClass(container, 'leaflet-tooltip-left');\n\t\tL.DomUtil.removeClass(container, 'leaflet-tooltip-top');\n\t\tL.DomUtil.removeClass(container, 'leaflet-tooltip-bottom');\n\t\tL.DomUtil.addClass(container, 'leaflet-tooltip-' + direction);\n\t\tL.DomUtil.setPosition(container, pos);\n\t},\n\n\t_updatePosition: function () {\n\t\tvar pos = this._map.latLngToLayerPoint(this._latlng);\n\t\tthis._setPosition(pos);\n\t},\n\n\tsetOpacity: function (opacity) {\n\t\tthis.options.opacity = opacity;\n\n\t\tif (this._container) {\n\t\t\tL.DomUtil.setOpacity(this._container, opacity);\n\t\t}\n\t},\n\n\t_animateZoom: function (e) {\n\t\tvar pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center);\n\t\tthis._setPosition(pos);\n\t},\n\n\t_getAnchor: function () {\n\t\t// Where should we anchor the tooltip on the source layer?\n\t\treturn L.point(this._source && this._source._getTooltipAnchor && !this.options.sticky ? this._source._getTooltipAnchor() : [0, 0]);\n\t}\n\n});\n\n// @namespace Tooltip\n// @factory L.tooltip(options?: Tooltip options, source?: Layer)\n// Instantiates a Tooltip object given an optional `options` object that describes its appearance and location and an optional `source` object that is used to tag the tooltip with a reference to the Layer to which it refers.\nL.tooltip = function (options, source) {\n\treturn new L.Tooltip(options, source);\n};\n\n// @namespace Map\n// @section Methods for Layers and Controls\nL.Map.include({\n\n\t// @method openTooltip(tooltip: Tooltip): this\n\t// Opens the specified tooltip.\n\t// @alternative\n\t// @method openTooltip(content: String|HTMLElement, latlng: LatLng, options?: Tooltip options): this\n\t// Creates a tooltip with the specified content and options and open it.\n\topenTooltip: function (tooltip, latlng, options) {\n\t\tif (!(tooltip instanceof L.Tooltip)) {\n\t\t\ttooltip = new L.Tooltip(options).setContent(tooltip);\n\t\t}\n\n\t\tif (latlng) {\n\t\t\ttooltip.setLatLng(latlng);\n\t\t}\n\n\t\tif (this.hasLayer(tooltip)) {\n\t\t\treturn this;\n\t\t}\n\n\t\treturn this.addLayer(tooltip);\n\t},\n\n\t// @method closeTooltip(tooltip?: Tooltip): this\n\t// Closes the tooltip given as parameter.\n\tcloseTooltip: function (tooltip) {\n\t\tif (tooltip) {\n\t\t\tthis.removeLayer(tooltip);\n\t\t}\n\t\treturn this;\n\t}\n\n});\n\n/*\n * @namespace Layer\n * @section Tooltip methods example\n *\n * All layers share a set of methods convenient for binding tooltips to it.\n *\n * ```js\n * var layer = L.Polygon(latlngs).bindTooltip('Hi There!').addTo(map);\n * layer.openTooltip();\n * layer.closeTooltip();\n * ```\n */\n\n// @section Tooltip methods\nL.Layer.include({\n\n\t// @method bindTooltip(content: String|HTMLElement|Function|Tooltip, options?: Tooltip options): this\n\t// Binds a tooltip to the layer with the passed `content` and sets up the\n\t// neccessary event listeners. If a `Function` is passed it will receive\n\t// the layer as the first argument and should return a `String` or `HTMLElement`.\n\tbindTooltip: function (content, options) {\n\n\t\tif (content instanceof L.Tooltip) {\n\t\t\tL.setOptions(content, options);\n\t\t\tthis._tooltip = content;\n\t\t\tcontent._source = this;\n\t\t} else {\n\t\t\tif (!this._tooltip || options) {\n\t\t\t\tthis._tooltip = L.tooltip(options, this);\n\t\t\t}\n\t\t\tthis._tooltip.setContent(content);\n\n\t\t}\n\n\t\tthis._initTooltipInteractions();\n\n\t\tif (this._tooltip.options.permanent && this._map && this._map.hasLayer(this)) {\n\t\t\tthis.openTooltip();\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t// @method unbindTooltip(): this\n\t// Removes the tooltip previously bound with `bindTooltip`.\n\tunbindTooltip: function () {\n\t\tif (this._tooltip) {\n\t\t\tthis._initTooltipInteractions(true);\n\t\t\tthis.closeTooltip();\n\t\t\tthis._tooltip = null;\n\t\t}\n\t\treturn this;\n\t},\n\n\t_initTooltipInteractions: function (remove) {\n\t\tif (!remove && this._tooltipHandlersAdded) { return; }\n\t\tvar onOff = remove ? 'off' : 'on',\n\t\t events = {\n\t\t\tremove: this.closeTooltip,\n\t\t\tmove: this._moveTooltip\n\t\t };\n\t\tif (!this._tooltip.options.permanent) {\n\t\t\tevents.mouseover = this._openTooltip;\n\t\t\tevents.mouseout = this.closeTooltip;\n\t\t\tif (this._tooltip.options.sticky) {\n\t\t\t\tevents.mousemove = this._moveTooltip;\n\t\t\t}\n\t\t\tif (L.Browser.touch) {\n\t\t\t\tevents.click = this._openTooltip;\n\t\t\t}\n\t\t} else {\n\t\t\tevents.add = this._openTooltip;\n\t\t}\n\t\tthis[onOff](events);\n\t\tthis._tooltipHandlersAdded = !remove;\n\t},\n\n\t// @method openTooltip(latlng?: LatLng): this\n\t// Opens the bound tooltip at the specificed `latlng` or at the default tooltip anchor if no `latlng` is passed.\n\topenTooltip: function (layer, latlng) {\n\t\tif (!(layer instanceof L.Layer)) {\n\t\t\tlatlng = layer;\n\t\t\tlayer = this;\n\t\t}\n\n\t\tif (layer instanceof L.FeatureGroup) {\n\t\t\tfor (var id in this._layers) {\n\t\t\t\tlayer = this._layers[id];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (!latlng) {\n\t\t\tlatlng = layer.getCenter ? layer.getCenter() : layer.getLatLng();\n\t\t}\n\n\t\tif (this._tooltip && this._map) {\n\n\t\t\t// set tooltip source to this layer\n\t\t\tthis._tooltip._source = layer;\n\n\t\t\t// update the tooltip (content, layout, ect...)\n\t\t\tthis._tooltip.update();\n\n\t\t\t// open the tooltip on the map\n\t\t\tthis._map.openTooltip(this._tooltip, latlng);\n\n\t\t\t// Tooltip container may not be defined if not permanent and never\n\t\t\t// opened.\n\t\t\tif (this._tooltip.options.interactive && this._tooltip._container) {\n\t\t\t\tL.DomUtil.addClass(this._tooltip._container, 'leaflet-clickable');\n\t\t\t\tthis.addInteractiveTarget(this._tooltip._container);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t// @method closeTooltip(): this\n\t// Closes the tooltip bound to this layer if it is open.\n\tcloseTooltip: function () {\n\t\tif (this._tooltip) {\n\t\t\tthis._tooltip._close();\n\t\t\tif (this._tooltip.options.interactive && this._tooltip._container) {\n\t\t\t\tL.DomUtil.removeClass(this._tooltip._container, 'leaflet-clickable');\n\t\t\t\tthis.removeInteractiveTarget(this._tooltip._container);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t},\n\n\t// @method toggleTooltip(): this\n\t// Opens or closes the tooltip bound to this layer depending on its current state.\n\ttoggleTooltip: function (target) {\n\t\tif (this._tooltip) {\n\t\t\tif (this._tooltip._map) {\n\t\t\t\tthis.closeTooltip();\n\t\t\t} else {\n\t\t\t\tthis.openTooltip(target);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t},\n\n\t// @method isTooltipOpen(): boolean\n\t// Returns `true` if the tooltip bound to this layer is currently open.\n\tisTooltipOpen: function () {\n\t\treturn this._tooltip.isOpen();\n\t},\n\n\t// @method setTooltipContent(content: String|HTMLElement|Tooltip): this\n\t// Sets the content of the tooltip bound to this layer.\n\tsetTooltipContent: function (content) {\n\t\tif (this._tooltip) {\n\t\t\tthis._tooltip.setContent(content);\n\t\t}\n\t\treturn this;\n\t},\n\n\t// @method getTooltip(): Tooltip\n\t// Returns the tooltip bound to this layer.\n\tgetTooltip: function () {\n\t\treturn this._tooltip;\n\t},\n\n\t_openTooltip: function (e) {\n\t\tvar layer = e.layer || e.target;\n\n\t\tif (!this._tooltip || !this._map) {\n\t\t\treturn;\n\t\t}\n\t\tthis.openTooltip(layer, this._tooltip.options.sticky ? e.latlng : undefined);\n\t},\n\n\t_moveTooltip: function (e) {\n\t\tvar latlng = e.latlng, containerPoint, layerPoint;\n\t\tif (this._tooltip.options.sticky && e.originalEvent) {\n\t\t\tcontainerPoint = this._map.mouseEventToContainerPoint(e.originalEvent);\n\t\t\tlayerPoint = this._map.containerPointToLayerPoint(containerPoint);\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\n\t\t}\n\t\tthis._tooltip.setLatLng(latlng);\n\t}\n});\n","/*\r\n * @class LayerGroup\r\n * @aka L.LayerGroup\r\n * @inherits Layer\r\n *\r\n * Used to group several layers and handle them as one. If you add it to the map,\r\n * any layers added or removed from the group will be added/removed on the map as\r\n * well. Extends `Layer`.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * L.layerGroup([marker1, marker2])\r\n * \t.addLayer(polyline)\r\n * \t.addTo(map);\r\n * ```\r\n */\r\n\r\nL.LayerGroup = L.Layer.extend({\r\n\r\n\tinitialize: function (layers) {\r\n\t\tthis._layers = {};\r\n\r\n\t\tvar i, len;\r\n\r\n\t\tif (layers) {\r\n\t\t\tfor (i = 0, len = layers.length; i < len; i++) {\r\n\t\t\t\tthis.addLayer(layers[i]);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t// @method addLayer(layer: Layer): this\r\n\t// Adds the given layer to the group.\r\n\taddLayer: function (layer) {\r\n\t\tvar id = this.getLayerId(layer);\r\n\r\n\t\tthis._layers[id] = layer;\r\n\r\n\t\tif (this._map) {\r\n\t\t\tthis._map.addLayer(layer);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method removeLayer(layer: Layer): this\r\n\t// Removes the given layer from the group.\r\n\t// @alternative\r\n\t// @method removeLayer(id: Number): this\r\n\t// Removes the layer with the given internal ID from the group.\r\n\tremoveLayer: function (layer) {\r\n\t\tvar id = layer in this._layers ? layer : this.getLayerId(layer);\r\n\r\n\t\tif (this._map && this._layers[id]) {\r\n\t\t\tthis._map.removeLayer(this._layers[id]);\r\n\t\t}\r\n\r\n\t\tdelete this._layers[id];\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method hasLayer(layer: Layer): Boolean\r\n\t// Returns `true` if the given layer is currently added to the group.\r\n\thasLayer: function (layer) {\r\n\t\treturn !!layer && (layer in this._layers || this.getLayerId(layer) in this._layers);\r\n\t},\r\n\r\n\t// @method clearLayers(): this\r\n\t// Removes all the layers from the group.\r\n\tclearLayers: function () {\r\n\t\tfor (var i in this._layers) {\r\n\t\t\tthis.removeLayer(this._layers[i]);\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method invoke(methodName: String, …): this\r\n\t// Calls `methodName` on every layer contained in this group, passing any\r\n\t// additional parameters. Has no effect if the layers contained do not\r\n\t// implement `methodName`.\r\n\tinvoke: function (methodName) {\r\n\t\tvar args = Array.prototype.slice.call(arguments, 1),\r\n\t\t i, layer;\r\n\r\n\t\tfor (i in this._layers) {\r\n\t\t\tlayer = this._layers[i];\r\n\r\n\t\t\tif (layer[methodName]) {\r\n\t\t\t\tlayer[methodName].apply(layer, args);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\tonAdd: function (map) {\r\n\t\tfor (var i in this._layers) {\r\n\t\t\tmap.addLayer(this._layers[i]);\r\n\t\t}\r\n\t},\r\n\r\n\tonRemove: function (map) {\r\n\t\tfor (var i in this._layers) {\r\n\t\t\tmap.removeLayer(this._layers[i]);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method eachLayer(fn: Function, context?: Object): this\r\n\t// Iterates over the layers of the group, optionally specifying context of the iterator function.\r\n\t// ```js\r\n\t// group.eachLayer(function (layer) {\r\n\t// \tlayer.bindPopup('Hello');\r\n\t// });\r\n\t// ```\r\n\teachLayer: function (method, context) {\r\n\t\tfor (var i in this._layers) {\r\n\t\t\tmethod.call(context, this._layers[i]);\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method getLayer(id: Number): Layer\r\n\t// Returns the layer with the given internal ID.\r\n\tgetLayer: function (id) {\r\n\t\treturn this._layers[id];\r\n\t},\r\n\r\n\t// @method getLayers(): Layer[]\r\n\t// Returns an array of all the layers added to the group.\r\n\tgetLayers: function () {\r\n\t\tvar layers = [];\r\n\r\n\t\tfor (var i in this._layers) {\r\n\t\t\tlayers.push(this._layers[i]);\r\n\t\t}\r\n\t\treturn layers;\r\n\t},\r\n\r\n\t// @method setZIndex(zIndex: Number): this\r\n\t// Calls `setZIndex` on every layer contained in this group, passing the z-index.\r\n\tsetZIndex: function (zIndex) {\r\n\t\treturn this.invoke('setZIndex', zIndex);\r\n\t},\r\n\r\n\t// @method getLayerId(layer: Layer): Number\r\n\t// Returns the internal ID for a layer\r\n\tgetLayerId: function (layer) {\r\n\t\treturn L.stamp(layer);\r\n\t}\r\n});\r\n\r\n\r\n// @factory L.layerGroup(layers: Layer[])\r\n// Create a layer group, optionally given an initial set of layers.\r\nL.layerGroup = function (layers) {\r\n\treturn new L.LayerGroup(layers);\r\n};\r\n","/*\r\n * @class FeatureGroup\r\n * @aka L.FeatureGroup\r\n * @inherits LayerGroup\r\n *\r\n * Extended `LayerGroup` that makes it easier to do the same thing to all its member layers:\r\n * * [`bindPopup`](#layer-bindpopup) binds a popup to all of the layers at once (likewise with [`bindTooltip`](#layer-bindtooltip))\r\n * * Events are propagated to the `FeatureGroup`, so if the group has an event\r\n * handler, it will handle events from any of the layers. This includes mouse events\r\n * and custom events.\r\n * * Has `layeradd` and `layerremove` events\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * L.featureGroup([marker1, marker2, polyline])\r\n * \t.bindPopup('Hello world!')\r\n * \t.on('click', function() { alert('Clicked on a member of the group!'); })\r\n * \t.addTo(map);\r\n * ```\r\n */\r\n\r\nL.FeatureGroup = L.LayerGroup.extend({\r\n\r\n\taddLayer: function (layer) {\r\n\t\tif (this.hasLayer(layer)) {\r\n\t\t\treturn this;\r\n\t\t}\r\n\r\n\t\tlayer.addEventParent(this);\r\n\r\n\t\tL.LayerGroup.prototype.addLayer.call(this, layer);\r\n\r\n\t\t// @event layeradd: LayerEvent\r\n\t\t// Fired when a layer is added to this `FeatureGroup`\r\n\t\treturn this.fire('layeradd', {layer: layer});\r\n\t},\r\n\r\n\tremoveLayer: function (layer) {\r\n\t\tif (!this.hasLayer(layer)) {\r\n\t\t\treturn this;\r\n\t\t}\r\n\t\tif (layer in this._layers) {\r\n\t\t\tlayer = this._layers[layer];\r\n\t\t}\r\n\r\n\t\tlayer.removeEventParent(this);\r\n\r\n\t\tL.LayerGroup.prototype.removeLayer.call(this, layer);\r\n\r\n\t\t// @event layerremove: LayerEvent\r\n\t\t// Fired when a layer is removed from this `FeatureGroup`\r\n\t\treturn this.fire('layerremove', {layer: layer});\r\n\t},\r\n\r\n\t// @method setStyle(style: Path options): this\r\n\t// Sets the given path options to each layer of the group that has a `setStyle` method.\r\n\tsetStyle: function (style) {\r\n\t\treturn this.invoke('setStyle', style);\r\n\t},\r\n\r\n\t// @method bringToFront(): this\r\n\t// Brings the layer group to the top of all other layers\r\n\tbringToFront: function () {\r\n\t\treturn this.invoke('bringToFront');\r\n\t},\r\n\r\n\t// @method bringToBack(): this\r\n\t// Brings the layer group to the top of all other layers\r\n\tbringToBack: function () {\r\n\t\treturn this.invoke('bringToBack');\r\n\t},\r\n\r\n\t// @method getBounds(): LatLngBounds\r\n\t// Returns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children).\r\n\tgetBounds: function () {\r\n\t\tvar bounds = new L.LatLngBounds();\r\n\r\n\t\tfor (var id in this._layers) {\r\n\t\t\tvar layer = this._layers[id];\r\n\t\t\tbounds.extend(layer.getBounds ? layer.getBounds() : layer.getLatLng());\r\n\t\t}\r\n\t\treturn bounds;\r\n\t}\r\n});\r\n\r\n// @factory L.featureGroup(layers: Layer[])\r\n// Create a feature group, optionally given an initial set of layers.\r\nL.featureGroup = function (layers) {\r\n\treturn new L.FeatureGroup(layers);\r\n};\r\n","/*\n * @class Renderer\n * @inherits Layer\n * @aka L.Renderer\n *\n * Base class for vector renderer implementations (`SVG`, `Canvas`). Handles the\n * DOM container of the renderer, its bounds, and its zoom animation.\n *\n * A `Renderer` works as an implicit layer group for all `Path`s - the renderer\n * itself can be added or removed to the map. All paths use a renderer, which can\n * be implicit (the map will decide the type of renderer and use it automatically)\n * or explicit (using the [`renderer`](#path-renderer) option of the path).\n *\n * Do not use this class directly, use `SVG` and `Canvas` instead.\n *\n * @event update: Event\n * Fired when the renderer updates its bounds, center and zoom, for example when\n * its map has moved\n */\n\nL.Renderer = L.Layer.extend({\n\n\t// @section\n\t// @aka Renderer options\n\toptions: {\n\t\t// @option padding: Number = 0.1\n\t\t// How much to extend the clip area around the map view (relative to its size)\n\t\t// e.g. 0.1 would be 10% of map view in each direction\n\t\tpadding: 0.1\n\t},\n\n\tinitialize: function (options) {\n\t\tL.setOptions(this, options);\n\t\tL.stamp(this);\n\t\tthis._layers = this._layers || {};\n\t},\n\n\tonAdd: function () {\n\t\tif (!this._container) {\n\t\t\tthis._initContainer(); // defined by renderer implementations\n\n\t\t\tif (this._zoomAnimated) {\n\t\t\t\tL.DomUtil.addClass(this._container, 'leaflet-zoom-animated');\n\t\t\t}\n\t\t}\n\n\t\tthis.getPane().appendChild(this._container);\n\t\tthis._update();\n\t\tthis.on('update', this._updatePaths, this);\n\t},\n\n\tonRemove: function () {\n\t\tL.DomUtil.remove(this._container);\n\t\tthis.off('update', this._updatePaths, this);\n\t},\n\n\tgetEvents: function () {\n\t\tvar events = {\n\t\t\tviewreset: this._reset,\n\t\t\tzoom: this._onZoom,\n\t\t\tmoveend: this._update,\n\t\t\tzoomend: this._onZoomEnd\n\t\t};\n\t\tif (this._zoomAnimated) {\n\t\t\tevents.zoomanim = this._onAnimZoom;\n\t\t}\n\t\treturn events;\n\t},\n\n\t_onAnimZoom: function (ev) {\n\t\tthis._updateTransform(ev.center, ev.zoom);\n\t},\n\n\t_onZoom: function () {\n\t\tthis._updateTransform(this._map.getCenter(), this._map.getZoom());\n\t},\n\n\t_updateTransform: function (center, zoom) {\n\t\tvar scale = this._map.getZoomScale(zoom, this._zoom),\n\t\t position = L.DomUtil.getPosition(this._container),\n\t\t viewHalf = this._map.getSize().multiplyBy(0.5 + this.options.padding),\n\t\t currentCenterPoint = this._map.project(this._center, zoom),\n\t\t destCenterPoint = this._map.project(center, zoom),\n\t\t centerOffset = destCenterPoint.subtract(currentCenterPoint),\n\n\t\t topLeftOffset = viewHalf.multiplyBy(-scale).add(position).add(viewHalf).subtract(centerOffset);\n\n\t\tif (L.Browser.any3d) {\n\t\t\tL.DomUtil.setTransform(this._container, topLeftOffset, scale);\n\t\t} else {\n\t\t\tL.DomUtil.setPosition(this._container, topLeftOffset);\n\t\t}\n\t},\n\n\t_reset: function () {\n\t\tthis._update();\n\t\tthis._updateTransform(this._center, this._zoom);\n\n\t\tfor (var id in this._layers) {\n\t\t\tthis._layers[id]._reset();\n\t\t}\n\t},\n\n\t_onZoomEnd: function () {\n\t\tfor (var id in this._layers) {\n\t\t\tthis._layers[id]._project();\n\t\t}\n\t},\n\n\t_updatePaths: function () {\n\t\tfor (var id in this._layers) {\n\t\t\tthis._layers[id]._update();\n\t\t}\n\t},\n\n\t_update: function () {\n\t\t// Update pixel bounds of renderer container (for positioning/sizing/clipping later)\n\t\t// Subclasses are responsible of firing the 'update' event.\n\t\tvar p = this.options.padding,\n\t\t size = this._map.getSize(),\n\t\t min = this._map.containerPointToLayerPoint(size.multiplyBy(-p)).round();\n\n\t\tthis._bounds = new L.Bounds(min, min.add(size.multiplyBy(1 + p * 2)).round());\n\n\t\tthis._center = this._map.getCenter();\n\t\tthis._zoom = this._map.getZoom();\n\t}\n});\n\n\nL.Map.include({\n\t// @namespace Map; @method getRenderer(layer: Path): Renderer\n\t// Returns the instance of `Renderer` that should be used to render the given\n\t// `Path`. It will ensure that the `renderer` options of the map and paths\n\t// are respected, and that the renderers do exist on the map.\n\tgetRenderer: function (layer) {\n\t\t// @namespace Path; @option renderer: Renderer\n\t\t// Use this specific instance of `Renderer` for this path. Takes\n\t\t// precedence over the map's [default renderer](#map-renderer).\n\t\tvar renderer = layer.options.renderer || this._getPaneRenderer(layer.options.pane) || this.options.renderer || this._renderer;\n\n\t\tif (!renderer) {\n\t\t\t// @namespace Map; @option preferCanvas: Boolean = false\n\t\t\t// Whether `Path`s should be rendered on a `Canvas` renderer.\n\t\t\t// By default, all `Path`s are rendered in a `SVG` renderer.\n\t\t\trenderer = this._renderer = (this.options.preferCanvas && L.canvas()) || L.svg();\n\t\t}\n\n\t\tif (!this.hasLayer(renderer)) {\n\t\t\tthis.addLayer(renderer);\n\t\t}\n\t\treturn renderer;\n\t},\n\n\t_getPaneRenderer: function (name) {\n\t\tif (name === 'overlayPane' || name === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tvar renderer = this._paneRenderers[name];\n\t\tif (renderer === undefined) {\n\t\t\trenderer = (L.SVG && L.svg({pane: name})) || (L.Canvas && L.canvas({pane: name}));\n\t\t\tthis._paneRenderers[name] = renderer;\n\t\t}\n\t\treturn renderer;\n\t}\n});\n","/*\n * @class Path\n * @aka L.Path\n * @inherits Interactive layer\n *\n * An abstract class that contains options and constants shared between vector\n * overlays (Polygon, Polyline, Circle). Do not use it directly. Extends `Layer`.\n */\n\nL.Path = L.Layer.extend({\n\n\t// @section\n\t// @aka Path options\n\toptions: {\n\t\t// @option stroke: Boolean = true\n\t\t// Whether to draw stroke along the path. Set it to `false` to disable borders on polygons or circles.\n\t\tstroke: true,\n\n\t\t// @option color: String = '#3388ff'\n\t\t// Stroke color\n\t\tcolor: '#3388ff',\n\n\t\t// @option weight: Number = 3\n\t\t// Stroke width in pixels\n\t\tweight: 3,\n\n\t\t// @option opacity: Number = 1.0\n\t\t// Stroke opacity\n\t\topacity: 1,\n\n\t\t// @option lineCap: String= 'round'\n\t\t// A string that defines [shape to be used at the end](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-linecap) of the stroke.\n\t\tlineCap: 'round',\n\n\t\t// @option lineJoin: String = 'round'\n\t\t// A string that defines [shape to be used at the corners](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-linejoin) of the stroke.\n\t\tlineJoin: 'round',\n\n\t\t// @option dashArray: String = null\n\t\t// A string that defines the stroke [dash pattern](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-dasharray). Doesn't work on `Canvas`-powered layers in [some old browsers](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility).\n\t\tdashArray: null,\n\n\t\t// @option dashOffset: String = null\n\t\t// A string that defines the [distance into the dash pattern to start the dash](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-dashoffset). Doesn't work on `Canvas`-powered layers in [some old browsers](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility).\n\t\tdashOffset: null,\n\n\t\t// @option fill: Boolean = depends\n\t\t// Whether to fill the path with color. Set it to `false` to disable filling on polygons or circles.\n\t\tfill: false,\n\n\t\t// @option fillColor: String = *\n\t\t// Fill color. Defaults to the value of the [`color`](#path-color) option\n\t\tfillColor: null,\n\n\t\t// @option fillOpacity: Number = 0.2\n\t\t// Fill opacity.\n\t\tfillOpacity: 0.2,\n\n\t\t// @option fillRule: String = 'evenodd'\n\t\t// A string that defines [how the inside of a shape](https://developer.mozilla.org/docs/Web/SVG/Attribute/fill-rule) is determined.\n\t\tfillRule: 'evenodd',\n\n\t\t// className: '',\n\n\t\t// Option inherited from \"Interactive layer\" abstract class\n\t\tinteractive: true\n\t},\n\n\tbeforeAdd: function (map) {\n\t\t// Renderer is set here because we need to call renderer.getEvents\n\t\t// before this.getEvents.\n\t\tthis._renderer = map.getRenderer(this);\n\t},\n\n\tonAdd: function () {\n\t\tthis._renderer._initPath(this);\n\t\tthis._reset();\n\t\tthis._renderer._addPath(this);\n\t},\n\n\tonRemove: function () {\n\t\tthis._renderer._removePath(this);\n\t},\n\n\t// @method redraw(): this\n\t// Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.\n\tredraw: function () {\n\t\tif (this._map) {\n\t\t\tthis._renderer._updatePath(this);\n\t\t}\n\t\treturn this;\n\t},\n\n\t// @method setStyle(style: Path options): this\n\t// Changes the appearance of a Path based on the options in the `Path options` object.\n\tsetStyle: function (style) {\n\t\tL.setOptions(this, style);\n\t\tif (this._renderer) {\n\t\t\tthis._renderer._updateStyle(this);\n\t\t}\n\t\treturn this;\n\t},\n\n\t// @method bringToFront(): this\n\t// Brings the layer to the top of all path layers.\n\tbringToFront: function () {\n\t\tif (this._renderer) {\n\t\t\tthis._renderer._bringToFront(this);\n\t\t}\n\t\treturn this;\n\t},\n\n\t// @method bringToBack(): this\n\t// Brings the layer to the bottom of all path layers.\n\tbringToBack: function () {\n\t\tif (this._renderer) {\n\t\t\tthis._renderer._bringToBack(this);\n\t\t}\n\t\treturn this;\n\t},\n\n\tgetElement: function () {\n\t\treturn this._path;\n\t},\n\n\t_reset: function () {\n\t\t// defined in children classes\n\t\tthis._project();\n\t\tthis._update();\n\t},\n\n\t_clickTolerance: function () {\n\t\t// used when doing hit detection for Canvas layers\n\t\treturn (this.options.stroke ? this.options.weight / 2 : 0) + (L.Browser.touch ? 10 : 0);\n\t}\n});\n","/*\r\n * @namespace LineUtil\r\n *\r\n * Various utility functions for polyine points processing, used by Leaflet internally to make polylines lightning-fast.\r\n */\r\n\r\nL.LineUtil = {\r\n\r\n\t// Simplify polyline with vertex reduction and Douglas-Peucker simplification.\r\n\t// Improves rendering performance dramatically by lessening the number of points to draw.\r\n\r\n\t// @function simplify(points: Point[], tolerance: Number): Point[]\r\n\t// Dramatically reduces the number of points in a polyline while retaining\r\n\t// its shape and returns a new array of simplified points, using the\r\n\t// [Douglas-Peucker algorithm](http://en.wikipedia.org/wiki/Douglas-Peucker_algorithm).\r\n\t// Used for a huge performance boost when processing/displaying Leaflet polylines for\r\n\t// each zoom level and also reducing visual noise. tolerance affects the amount of\r\n\t// simplification (lesser value means higher quality but slower and with more points).\r\n\t// Also released as a separated micro-library [Simplify.js](http://mourner.github.com/simplify-js/).\r\n\tsimplify: function (points, tolerance) {\r\n\t\tif (!tolerance || !points.length) {\r\n\t\t\treturn points.slice();\r\n\t\t}\r\n\r\n\t\tvar sqTolerance = tolerance * tolerance;\r\n\r\n\t\t// stage 1: vertex reduction\r\n\t\tpoints = this._reducePoints(points, sqTolerance);\r\n\r\n\t\t// stage 2: Douglas-Peucker simplification\r\n\t\tpoints = this._simplifyDP(points, sqTolerance);\r\n\r\n\t\treturn points;\r\n\t},\r\n\r\n\t// @function pointToSegmentDistance(p: Point, p1: Point, p2: Point): Number\r\n\t// Returns the distance between point `p` and segment `p1` to `p2`.\r\n\tpointToSegmentDistance: function (p, p1, p2) {\r\n\t\treturn Math.sqrt(this._sqClosestPointOnSegment(p, p1, p2, true));\r\n\t},\r\n\r\n\t// @function closestPointOnSegment(p: Point, p1: Point, p2: Point): Number\r\n\t// Returns the closest point from a point `p` on a segment `p1` to `p2`.\r\n\tclosestPointOnSegment: function (p, p1, p2) {\r\n\t\treturn this._sqClosestPointOnSegment(p, p1, p2);\r\n\t},\r\n\r\n\t// Douglas-Peucker simplification, see http://en.wikipedia.org/wiki/Douglas-Peucker_algorithm\r\n\t_simplifyDP: function (points, sqTolerance) {\r\n\r\n\t\tvar len = points.length,\r\n\t\t ArrayConstructor = typeof Uint8Array !== undefined + '' ? Uint8Array : Array,\r\n\t\t markers = new ArrayConstructor(len);\r\n\r\n\t\tmarkers[0] = markers[len - 1] = 1;\r\n\r\n\t\tthis._simplifyDPStep(points, markers, sqTolerance, 0, len - 1);\r\n\r\n\t\tvar i,\r\n\t\t newPoints = [];\r\n\r\n\t\tfor (i = 0; i < len; i++) {\r\n\t\t\tif (markers[i]) {\r\n\t\t\t\tnewPoints.push(points[i]);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn newPoints;\r\n\t},\r\n\r\n\t_simplifyDPStep: function (points, markers, sqTolerance, first, last) {\r\n\r\n\t\tvar maxSqDist = 0,\r\n\t\t index, i, sqDist;\r\n\r\n\t\tfor (i = first + 1; i <= last - 1; i++) {\r\n\t\t\tsqDist = this._sqClosestPointOnSegment(points[i], points[first], points[last], true);\r\n\r\n\t\t\tif (sqDist > maxSqDist) {\r\n\t\t\t\tindex = i;\r\n\t\t\t\tmaxSqDist = sqDist;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (maxSqDist > sqTolerance) {\r\n\t\t\tmarkers[index] = 1;\r\n\r\n\t\t\tthis._simplifyDPStep(points, markers, sqTolerance, first, index);\r\n\t\t\tthis._simplifyDPStep(points, markers, sqTolerance, index, last);\r\n\t\t}\r\n\t},\r\n\r\n\t// reduce points that are too close to each other to a single point\r\n\t_reducePoints: function (points, sqTolerance) {\r\n\t\tvar reducedPoints = [points[0]];\r\n\r\n\t\tfor (var i = 1, prev = 0, len = points.length; i < len; i++) {\r\n\t\t\tif (this._sqDist(points[i], points[prev]) > sqTolerance) {\r\n\t\t\t\treducedPoints.push(points[i]);\r\n\t\t\t\tprev = i;\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (prev < len - 1) {\r\n\t\t\treducedPoints.push(points[len - 1]);\r\n\t\t}\r\n\t\treturn reducedPoints;\r\n\t},\r\n\r\n\r\n\t// @function clipSegment(a: Point, b: Point, bounds: Bounds, useLastCode?: Boolean, round?: Boolean): Point[]|Boolean\r\n\t// Clips the segment a to b by rectangular bounds with the\r\n\t// [Cohen-Sutherland algorithm](https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm)\r\n\t// (modifying the segment points directly!). Used by Leaflet to only show polyline\r\n\t// points that are on the screen or near, increasing performance.\r\n\tclipSegment: function (a, b, bounds, useLastCode, round) {\r\n\t\tvar codeA = useLastCode ? this._lastCode : this._getBitCode(a, bounds),\r\n\t\t codeB = this._getBitCode(b, bounds),\r\n\r\n\t\t codeOut, p, newCode;\r\n\r\n\t\t// save 2nd code to avoid calculating it on the next segment\r\n\t\tthis._lastCode = codeB;\r\n\r\n\t\twhile (true) {\r\n\t\t\t// if a,b is inside the clip window (trivial accept)\r\n\t\t\tif (!(codeA | codeB)) {\r\n\t\t\t\treturn [a, b];\r\n\t\t\t}\r\n\r\n\t\t\t// if a,b is outside the clip window (trivial reject)\r\n\t\t\tif (codeA & codeB) {\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\t// other cases\r\n\t\t\tcodeOut = codeA || codeB;\r\n\t\t\tp = this._getEdgeIntersection(a, b, codeOut, bounds, round);\r\n\t\t\tnewCode = this._getBitCode(p, bounds);\r\n\r\n\t\t\tif (codeOut === codeA) {\r\n\t\t\t\ta = p;\r\n\t\t\t\tcodeA = newCode;\r\n\t\t\t} else {\r\n\t\t\t\tb = p;\r\n\t\t\t\tcodeB = newCode;\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_getEdgeIntersection: function (a, b, code, bounds, round) {\r\n\t\tvar dx = b.x - a.x,\r\n\t\t dy = b.y - a.y,\r\n\t\t min = bounds.min,\r\n\t\t max = bounds.max,\r\n\t\t x, y;\r\n\r\n\t\tif (code & 8) { // top\r\n\t\t\tx = a.x + dx * (max.y - a.y) / dy;\r\n\t\t\ty = max.y;\r\n\r\n\t\t} else if (code & 4) { // bottom\r\n\t\t\tx = a.x + dx * (min.y - a.y) / dy;\r\n\t\t\ty = min.y;\r\n\r\n\t\t} else if (code & 2) { // right\r\n\t\t\tx = max.x;\r\n\t\t\ty = a.y + dy * (max.x - a.x) / dx;\r\n\r\n\t\t} else if (code & 1) { // left\r\n\t\t\tx = min.x;\r\n\t\t\ty = a.y + dy * (min.x - a.x) / dx;\r\n\t\t}\r\n\r\n\t\treturn new L.Point(x, y, round);\r\n\t},\r\n\r\n\t_getBitCode: function (p, bounds) {\r\n\t\tvar code = 0;\r\n\r\n\t\tif (p.x < bounds.min.x) { // left\r\n\t\t\tcode |= 1;\r\n\t\t} else if (p.x > bounds.max.x) { // right\r\n\t\t\tcode |= 2;\r\n\t\t}\r\n\r\n\t\tif (p.y < bounds.min.y) { // bottom\r\n\t\t\tcode |= 4;\r\n\t\t} else if (p.y > bounds.max.y) { // top\r\n\t\t\tcode |= 8;\r\n\t\t}\r\n\r\n\t\treturn code;\r\n\t},\r\n\r\n\t// square distance (to avoid unnecessary Math.sqrt calls)\r\n\t_sqDist: function (p1, p2) {\r\n\t\tvar dx = p2.x - p1.x,\r\n\t\t dy = p2.y - p1.y;\r\n\t\treturn dx * dx + dy * dy;\r\n\t},\r\n\r\n\t// return closest point on segment or distance to that point\r\n\t_sqClosestPointOnSegment: function (p, p1, p2, sqDist) {\r\n\t\tvar x = p1.x,\r\n\t\t y = p1.y,\r\n\t\t dx = p2.x - x,\r\n\t\t dy = p2.y - y,\r\n\t\t dot = dx * dx + dy * dy,\r\n\t\t t;\r\n\r\n\t\tif (dot > 0) {\r\n\t\t\tt = ((p.x - x) * dx + (p.y - y) * dy) / dot;\r\n\r\n\t\t\tif (t > 1) {\r\n\t\t\t\tx = p2.x;\r\n\t\t\t\ty = p2.y;\r\n\t\t\t} else if (t > 0) {\r\n\t\t\t\tx += dx * t;\r\n\t\t\t\ty += dy * t;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tdx = p.x - x;\r\n\t\tdy = p.y - y;\r\n\r\n\t\treturn sqDist ? dx * dx + dy * dy : new L.Point(x, y);\r\n\t}\r\n};\r\n","/*\n * @class Polyline\n * @aka L.Polyline\n * @inherits Path\n *\n * A class for drawing polyline overlays on a map. Extends `Path`.\n *\n * @example\n *\n * ```js\n * // create a red polyline from an array of LatLng points\n * var latlngs = [\n * \t[-122.68, 45.51],\n * \t[-122.43, 37.77],\n * \t[-118.2, 34.04]\n * ];\n *\n * var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map);\n *\n * // zoom the map to the polyline\n * map.fitBounds(polyline.getBounds());\n * ```\n *\n * You can also pass a multi-dimensional array to represent a `MultiPolyline` shape:\n *\n * ```js\n * // create a red polyline from an array of arrays of LatLng points\n * var latlngs = [\n * \t[[-122.68, 45.51],\n * \t [-122.43, 37.77],\n * \t [-118.2, 34.04]],\n * \t[[-73.91, 40.78],\n * \t [-87.62, 41.83],\n * \t [-96.72, 32.76]]\n * ];\n * ```\n */\n\nL.Polyline = L.Path.extend({\n\n\t// @section\n\t// @aka Polyline options\n\toptions: {\n\t\t// @option smoothFactor: Number = 1.0\n\t\t// How much to simplify the polyline on each zoom level. More means\n\t\t// better performance and smoother look, and less means more accurate representation.\n\t\tsmoothFactor: 1.0,\n\n\t\t// @option noClip: Boolean = false\n\t\t// Disable polyline clipping.\n\t\tnoClip: false\n\t},\n\n\tinitialize: function (latlngs, options) {\n\t\tL.setOptions(this, options);\n\t\tthis._setLatLngs(latlngs);\n\t},\n\n\t// @method getLatLngs(): LatLng[]\n\t// Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.\n\tgetLatLngs: function () {\n\t\treturn this._latlngs;\n\t},\n\n\t// @method setLatLngs(latlngs: LatLng[]): this\n\t// Replaces all the points in the polyline with the given array of geographical points.\n\tsetLatLngs: function (latlngs) {\n\t\tthis._setLatLngs(latlngs);\n\t\treturn this.redraw();\n\t},\n\n\t// @method isEmpty(): Boolean\n\t// Returns `true` if the Polyline has no LatLngs.\n\tisEmpty: function () {\n\t\treturn !this._latlngs.length;\n\t},\n\n\tclosestLayerPoint: function (p) {\n\t\tvar minDistance = Infinity,\n\t\t minPoint = null,\n\t\t closest = L.LineUtil._sqClosestPointOnSegment,\n\t\t p1, p2;\n\n\t\tfor (var j = 0, jLen = this._parts.length; j < jLen; j++) {\n\t\t\tvar points = this._parts[j];\n\n\t\t\tfor (var i = 1, len = points.length; i < len; i++) {\n\t\t\t\tp1 = points[i - 1];\n\t\t\t\tp2 = points[i];\n\n\t\t\t\tvar sqDist = closest(p, p1, p2, true);\n\n\t\t\t\tif (sqDist < minDistance) {\n\t\t\t\t\tminDistance = sqDist;\n\t\t\t\t\tminPoint = closest(p, p1, p2);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (minPoint) {\n\t\t\tminPoint.distance = Math.sqrt(minDistance);\n\t\t}\n\t\treturn minPoint;\n\t},\n\n\t// @method getCenter(): LatLng\n\t// Returns the center ([centroid](http://en.wikipedia.org/wiki/Centroid)) of the polyline.\n\tgetCenter: function () {\n\t\t// throws error when not yet added to map as this center calculation requires projected coordinates\n\t\tif (!this._map) {\n\t\t\tthrow new Error('Must add layer to map before using getCenter()');\n\t\t}\n\n\t\tvar i, halfDist, segDist, dist, p1, p2, ratio,\n\t\t points = this._rings[0],\n\t\t len = points.length;\n\n\t\tif (!len) { return null; }\n\n\t\t// polyline centroid algorithm; only uses the first ring if there are multiple\n\n\t\tfor (i = 0, halfDist = 0; i < len - 1; i++) {\n\t\t\thalfDist += points[i].distanceTo(points[i + 1]) / 2;\n\t\t}\n\n\t\t// The line is so small in the current view that all points are on the same pixel.\n\t\tif (halfDist === 0) {\n\t\t\treturn this._map.layerPointToLatLng(points[0]);\n\t\t}\n\n\t\tfor (i = 0, dist = 0; i < len - 1; i++) {\n\t\t\tp1 = points[i];\n\t\t\tp2 = points[i + 1];\n\t\t\tsegDist = p1.distanceTo(p2);\n\t\t\tdist += segDist;\n\n\t\t\tif (dist > halfDist) {\n\t\t\t\tratio = (dist - halfDist) / segDist;\n\t\t\t\treturn this._map.layerPointToLatLng([\n\t\t\t\t\tp2.x - ratio * (p2.x - p1.x),\n\t\t\t\t\tp2.y - ratio * (p2.y - p1.y)\n\t\t\t\t]);\n\t\t\t}\n\t\t}\n\t},\n\n\t// @method getBounds(): LatLngBounds\n\t// Returns the `LatLngBounds` of the path.\n\tgetBounds: function () {\n\t\treturn this._bounds;\n\t},\n\n\t// @method addLatLng(latlng: LatLng, latlngs? LatLng[]): this\n\t// Adds a given point to the polyline. By default, adds to the first ring of\n\t// the polyline in case of a multi-polyline, but can be overridden by passing\n\t// a specific ring as a LatLng array (that you can earlier access with [`getLatLngs`](#polyline-getlatlngs)).\n\taddLatLng: function (latlng, latlngs) {\n\t\tlatlngs = latlngs || this._defaultShape();\n\t\tlatlng = L.latLng(latlng);\n\t\tlatlngs.push(latlng);\n\t\tthis._bounds.extend(latlng);\n\t\treturn this.redraw();\n\t},\n\n\t_setLatLngs: function (latlngs) {\n\t\tthis._bounds = new L.LatLngBounds();\n\t\tthis._latlngs = this._convertLatLngs(latlngs);\n\t},\n\n\t_defaultShape: function () {\n\t\treturn L.Polyline._flat(this._latlngs) ? this._latlngs : this._latlngs[0];\n\t},\n\n\t// recursively convert latlngs input into actual LatLng instances; calculate bounds along the way\n\t_convertLatLngs: function (latlngs) {\n\t\tvar result = [],\n\t\t flat = L.Polyline._flat(latlngs);\n\n\t\tfor (var i = 0, len = latlngs.length; i < len; i++) {\n\t\t\tif (flat) {\n\t\t\t\tresult[i] = L.latLng(latlngs[i]);\n\t\t\t\tthis._bounds.extend(result[i]);\n\t\t\t} else {\n\t\t\t\tresult[i] = this._convertLatLngs(latlngs[i]);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t},\n\n\t_project: function () {\n\t\tvar pxBounds = new L.Bounds();\n\t\tthis._rings = [];\n\t\tthis._projectLatlngs(this._latlngs, this._rings, pxBounds);\n\n\t\tvar w = this._clickTolerance(),\n\t\t p = new L.Point(w, w);\n\n\t\tif (this._bounds.isValid() && pxBounds.isValid()) {\n\t\t\tpxBounds.min._subtract(p);\n\t\t\tpxBounds.max._add(p);\n\t\t\tthis._pxBounds = pxBounds;\n\t\t}\n\t},\n\n\t// recursively turns latlngs into a set of rings with projected coordinates\n\t_projectLatlngs: function (latlngs, result, projectedBounds) {\n\t\tvar flat = latlngs[0] instanceof L.LatLng,\n\t\t len = latlngs.length,\n\t\t i, ring;\n\n\t\tif (flat) {\n\t\t\tring = [];\n\t\t\tfor (i = 0; i < len; i++) {\n\t\t\t\tring[i] = this._map.latLngToLayerPoint(latlngs[i]);\n\t\t\t\tprojectedBounds.extend(ring[i]);\n\t\t\t}\n\t\t\tresult.push(ring);\n\t\t} else {\n\t\t\tfor (i = 0; i < len; i++) {\n\t\t\t\tthis._projectLatlngs(latlngs[i], result, projectedBounds);\n\t\t\t}\n\t\t}\n\t},\n\n\t// clip polyline by renderer bounds so that we have less to render for performance\n\t_clipPoints: function () {\n\t\tvar bounds = this._renderer._bounds;\n\n\t\tthis._parts = [];\n\t\tif (!this._pxBounds || !this._pxBounds.intersects(bounds)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.options.noClip) {\n\t\t\tthis._parts = this._rings;\n\t\t\treturn;\n\t\t}\n\n\t\tvar parts = this._parts,\n\t\t i, j, k, len, len2, segment, points;\n\n\t\tfor (i = 0, k = 0, len = this._rings.length; i < len; i++) {\n\t\t\tpoints = this._rings[i];\n\n\t\t\tfor (j = 0, len2 = points.length; j < len2 - 1; j++) {\n\t\t\t\tsegment = L.LineUtil.clipSegment(points[j], points[j + 1], bounds, j, true);\n\n\t\t\t\tif (!segment) { continue; }\n\n\t\t\t\tparts[k] = parts[k] || [];\n\t\t\t\tparts[k].push(segment[0]);\n\n\t\t\t\t// if segment goes out of screen, or it's the last one, it's the end of the line part\n\t\t\t\tif ((segment[1] !== points[j + 1]) || (j === len2 - 2)) {\n\t\t\t\t\tparts[k].push(segment[1]);\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\t// simplify each clipped part of the polyline for performance\n\t_simplifyPoints: function () {\n\t\tvar parts = this._parts,\n\t\t tolerance = this.options.smoothFactor;\n\n\t\tfor (var i = 0, len = parts.length; i < len; i++) {\n\t\t\tparts[i] = L.LineUtil.simplify(parts[i], tolerance);\n\t\t}\n\t},\n\n\t_update: function () {\n\t\tif (!this._map) { return; }\n\n\t\tthis._clipPoints();\n\t\tthis._simplifyPoints();\n\t\tthis._updatePath();\n\t},\n\n\t_updatePath: function () {\n\t\tthis._renderer._updatePoly(this);\n\t}\n});\n\n// @factory L.polyline(latlngs: LatLng[], options?: Polyline options)\n// Instantiates a polyline object given an array of geographical points and\n// optionally an options object. You can create a `Polyline` object with\n// multiple separate lines (`MultiPolyline`) by passing an array of arrays\n// of geographic points.\nL.polyline = function (latlngs, options) {\n\treturn new L.Polyline(latlngs, options);\n};\n\nL.Polyline._flat = function (latlngs) {\n\t// true if it's a flat array of latlngs; false if nested\n\treturn !L.Util.isArray(latlngs[0]) || (typeof latlngs[0][0] !== 'object' && typeof latlngs[0][0] !== 'undefined');\n};\n","/*\r\n * @namespace PolyUtil\r\n * Various utility functions for polygon geometries.\r\n */\r\n\r\nL.PolyUtil = {};\r\n\r\n/* @function clipPolygon(points: Point[], bounds: Bounds, round?: Boolean): Point[]\r\n * Clips the polygon geometry defined by the given `points` by the given bounds (using the [Sutherland-Hodgeman algorithm](https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm)).\r\n * Used by Leaflet to only show polygon points that are on the screen or near, increasing\r\n * performance. Note that polygon points needs different algorithm for clipping\r\n * than polyline, so there's a seperate method for it.\r\n */\r\nL.PolyUtil.clipPolygon = function (points, bounds, round) {\r\n\tvar clippedPoints,\r\n\t edges = [1, 4, 2, 8],\r\n\t i, j, k,\r\n\t a, b,\r\n\t len, edge, p,\r\n\t lu = L.LineUtil;\r\n\r\n\tfor (i = 0, len = points.length; i < len; i++) {\r\n\t\tpoints[i]._code = lu._getBitCode(points[i], bounds);\r\n\t}\r\n\r\n\t// for each edge (left, bottom, right, top)\r\n\tfor (k = 0; k < 4; k++) {\r\n\t\tedge = edges[k];\r\n\t\tclippedPoints = [];\r\n\r\n\t\tfor (i = 0, len = points.length, j = len - 1; i < len; j = i++) {\r\n\t\t\ta = points[i];\r\n\t\t\tb = points[j];\r\n\r\n\t\t\t// if a is inside the clip window\r\n\t\t\tif (!(a._code & edge)) {\r\n\t\t\t\t// if b is outside the clip window (a->b goes out of screen)\r\n\t\t\t\tif (b._code & edge) {\r\n\t\t\t\t\tp = lu._getEdgeIntersection(b, a, edge, bounds, round);\r\n\t\t\t\t\tp._code = lu._getBitCode(p, bounds);\r\n\t\t\t\t\tclippedPoints.push(p);\r\n\t\t\t\t}\r\n\t\t\t\tclippedPoints.push(a);\r\n\r\n\t\t\t// else if b is inside the clip window (a->b enters the screen)\r\n\t\t\t} else if (!(b._code & edge)) {\r\n\t\t\t\tp = lu._getEdgeIntersection(b, a, edge, bounds, round);\r\n\t\t\t\tp._code = lu._getBitCode(p, bounds);\r\n\t\t\t\tclippedPoints.push(p);\r\n\t\t\t}\r\n\t\t}\r\n\t\tpoints = clippedPoints;\r\n\t}\r\n\r\n\treturn points;\r\n};\r\n","/*\n * @class Polygon\n * @aka L.Polygon\n * @inherits Polyline\n *\n * A class for drawing polygon overlays on a map. Extends `Polyline`.\n *\n * Note that points you pass when creating a polygon shouldn't have an additional last point equal to the first one — it's better to filter out such points.\n *\n *\n * @example\n *\n * ```js\n * // create a red polygon from an array of LatLng points\n * var latlngs = [[-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41]];\n *\n * var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map);\n *\n * // zoom the map to the polygon\n * map.fitBounds(polygon.getBounds());\n * ```\n *\n * You can also pass an array of arrays of latlngs, with the first array representing the outer shape and the other arrays representing holes in the outer shape:\n *\n * ```js\n * var latlngs = [\n * [[-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41]], // outer ring\n * [[-108.58,37.29],[-108.58,40.71],[-102.50,40.71],[-102.50,37.29]] // hole\n * ];\n * ```\n *\n * Additionally, you can pass a multi-dimensional array to represent a MultiPolygon shape.\n *\n * ```js\n * var latlngs = [\n * [ // first polygon\n * [[-111.03, 41],[-111.04, 45],[-104.05, 45],[-104.05, 41]], // outer ring\n * [[-108.58,37.29],[-108.58,40.71],[-102.50,40.71],[-102.50,37.29]] // hole\n * ],\n * [ // second polygon\n * [[-109.05, 37],[-109.03, 41],[-102.05, 41],[-102.04, 37],[-109.05, 38]]\n * ]\n * ];\n * ```\n */\n\nL.Polygon = L.Polyline.extend({\n\n\toptions: {\n\t\tfill: true\n\t},\n\n\tisEmpty: function () {\n\t\treturn !this._latlngs.length || !this._latlngs[0].length;\n\t},\n\n\tgetCenter: function () {\n\t\t// throws error when not yet added to map as this center calculation requires projected coordinates\n\t\tif (!this._map) {\n\t\t\tthrow new Error('Must add layer to map before using getCenter()');\n\t\t}\n\n\t\tvar i, j, p1, p2, f, area, x, y, center,\n\t\t points = this._rings[0],\n\t\t len = points.length;\n\n\t\tif (!len) { return null; }\n\n\t\t// polygon centroid algorithm; only uses the first ring if there are multiple\n\n\t\tarea = x = y = 0;\n\n\t\tfor (i = 0, j = len - 1; i < len; j = i++) {\n\t\t\tp1 = points[i];\n\t\t\tp2 = points[j];\n\n\t\t\tf = p1.y * p2.x - p2.y * p1.x;\n\t\t\tx += (p1.x + p2.x) * f;\n\t\t\ty += (p1.y + p2.y) * f;\n\t\t\tarea += f * 3;\n\t\t}\n\n\t\tif (area === 0) {\n\t\t\t// Polygon is so small that all points are on same pixel.\n\t\t\tcenter = points[0];\n\t\t} else {\n\t\t\tcenter = [x / area, y / area];\n\t\t}\n\t\treturn this._map.layerPointToLatLng(center);\n\t},\n\n\t_convertLatLngs: function (latlngs) {\n\t\tvar result = L.Polyline.prototype._convertLatLngs.call(this, latlngs),\n\t\t len = result.length;\n\n\t\t// remove last point if it equals first one\n\t\tif (len >= 2 && result[0] instanceof L.LatLng && result[0].equals(result[len - 1])) {\n\t\t\tresult.pop();\n\t\t}\n\t\treturn result;\n\t},\n\n\t_setLatLngs: function (latlngs) {\n\t\tL.Polyline.prototype._setLatLngs.call(this, latlngs);\n\t\tif (L.Polyline._flat(this._latlngs)) {\n\t\t\tthis._latlngs = [this._latlngs];\n\t\t}\n\t},\n\n\t_defaultShape: function () {\n\t\treturn L.Polyline._flat(this._latlngs[0]) ? this._latlngs[0] : this._latlngs[0][0];\n\t},\n\n\t_clipPoints: function () {\n\t\t// polygons need a different clipping algorithm so we redefine that\n\n\t\tvar bounds = this._renderer._bounds,\n\t\t w = this.options.weight,\n\t\t p = new L.Point(w, w);\n\n\t\t// increase clip padding by stroke width to avoid stroke on clip edges\n\t\tbounds = new L.Bounds(bounds.min.subtract(p), bounds.max.add(p));\n\n\t\tthis._parts = [];\n\t\tif (!this._pxBounds || !this._pxBounds.intersects(bounds)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.options.noClip) {\n\t\t\tthis._parts = this._rings;\n\t\t\treturn;\n\t\t}\n\n\t\tfor (var i = 0, len = this._rings.length, clipped; i < len; i++) {\n\t\t\tclipped = L.PolyUtil.clipPolygon(this._rings[i], bounds, true);\n\t\t\tif (clipped.length) {\n\t\t\t\tthis._parts.push(clipped);\n\t\t\t}\n\t\t}\n\t},\n\n\t_updatePath: function () {\n\t\tthis._renderer._updatePoly(this, true);\n\t}\n});\n\n\n// @factory L.polygon(latlngs: LatLng[], options?: Polyline options)\nL.polygon = function (latlngs, options) {\n\treturn new L.Polygon(latlngs, options);\n};\n","/*\n * L.Rectangle extends Polygon and creates a rectangle when passed a LatLngBounds object.\n */\n\n/*\n * @class Rectangle\n * @aka L.Retangle\n * @inherits Polygon\n *\n * A class for drawing rectangle overlays on a map. Extends `Polygon`.\n *\n * @example\n *\n * ```js\n * // define rectangle geographical bounds\n * var bounds = [[54.559322, -5.767822], [56.1210604, -3.021240]];\n *\n * // create an orange rectangle\n * L.rectangle(bounds, {color: \"#ff7800\", weight: 1}).addTo(map);\n *\n * // zoom the map to the rectangle bounds\n * map.fitBounds(bounds);\n * ```\n *\n */\n\n\nL.Rectangle = L.Polygon.extend({\n\tinitialize: function (latLngBounds, options) {\n\t\tL.Polygon.prototype.initialize.call(this, this._boundsToLatLngs(latLngBounds), options);\n\t},\n\n\t// @method setBounds(latLngBounds: LatLngBounds): this\n\t// Redraws the rectangle with the passed bounds.\n\tsetBounds: function (latLngBounds) {\n\t\treturn this.setLatLngs(this._boundsToLatLngs(latLngBounds));\n\t},\n\n\t_boundsToLatLngs: function (latLngBounds) {\n\t\tlatLngBounds = L.latLngBounds(latLngBounds);\n\t\treturn [\n\t\t\tlatLngBounds.getSouthWest(),\n\t\t\tlatLngBounds.getNorthWest(),\n\t\t\tlatLngBounds.getNorthEast(),\n\t\t\tlatLngBounds.getSouthEast()\n\t\t];\n\t}\n});\n\n\n// @factory L.rectangle(latLngBounds: LatLngBounds, options?: Polyline options)\nL.rectangle = function (latLngBounds, options) {\n\treturn new L.Rectangle(latLngBounds, options);\n};\n","/*\n * @class CircleMarker\n * @aka L.CircleMarker\n * @inherits Path\n *\n * A circle of a fixed size with radius specified in pixels. Extends `Path`.\n */\n\nL.CircleMarker = L.Path.extend({\n\n\t// @section\n\t// @aka CircleMarker options\n\toptions: {\n\t\tfill: true,\n\n\t\t// @option radius: Number = 10\n\t\t// Radius of the circle marker, in pixels\n\t\tradius: 10\n\t},\n\n\tinitialize: function (latlng, options) {\n\t\tL.setOptions(this, options);\n\t\tthis._latlng = L.latLng(latlng);\n\t\tthis._radius = this.options.radius;\n\t},\n\n\t// @method setLatLng(latLng: LatLng): this\n\t// Sets the position of a circle marker to a new location.\n\tsetLatLng: function (latlng) {\n\t\tthis._latlng = L.latLng(latlng);\n\t\tthis.redraw();\n\t\treturn this.fire('move', {latlng: this._latlng});\n\t},\n\n\t// @method getLatLng(): LatLng\n\t// Returns the current geographical position of the circle marker\n\tgetLatLng: function () {\n\t\treturn this._latlng;\n\t},\n\n\t// @method setRadius(radius: Number): this\n\t// Sets the radius of a circle marker. Units are in pixels.\n\tsetRadius: function (radius) {\n\t\tthis.options.radius = this._radius = radius;\n\t\treturn this.redraw();\n\t},\n\n\t// @method getRadius(): Number\n\t// Returns the current radius of the circle\n\tgetRadius: function () {\n\t\treturn this._radius;\n\t},\n\n\tsetStyle : function (options) {\n\t\tvar radius = options && options.radius || this._radius;\n\t\tL.Path.prototype.setStyle.call(this, options);\n\t\tthis.setRadius(radius);\n\t\treturn this;\n\t},\n\n\t_project: function () {\n\t\tthis._point = this._map.latLngToLayerPoint(this._latlng);\n\t\tthis._updateBounds();\n\t},\n\n\t_updateBounds: function () {\n\t\tvar r = this._radius,\n\t\t r2 = this._radiusY || r,\n\t\t w = this._clickTolerance(),\n\t\t p = [r + w, r2 + w];\n\t\tthis._pxBounds = new L.Bounds(this._point.subtract(p), this._point.add(p));\n\t},\n\n\t_update: function () {\n\t\tif (this._map) {\n\t\t\tthis._updatePath();\n\t\t}\n\t},\n\n\t_updatePath: function () {\n\t\tthis._renderer._updateCircle(this);\n\t},\n\n\t_empty: function () {\n\t\treturn this._radius && !this._renderer._bounds.intersects(this._pxBounds);\n\t}\n});\n\n\n// @factory L.circleMarker(latlng: LatLng, options?: CircleMarker options)\n// Instantiates a circle marker object given a geographical point, and an optional options object.\nL.circleMarker = function (latlng, options) {\n\treturn new L.CircleMarker(latlng, options);\n};\n","/*\n * @class Circle\n * @aka L.Circle\n * @inherits CircleMarker\n *\n * A class for drawing circle overlays on a map. Extends `CircleMarker`.\n *\n * It's an approximation and starts to diverge from a real circle closer to poles (due to projection distortion).\n *\n * @example\n *\n * ```js\n * L.circle([50.5, 30.5], {radius: 200}).addTo(map);\n * ```\n */\n\nL.Circle = L.CircleMarker.extend({\n\n\tinitialize: function (latlng, options, legacyOptions) {\n\t\tif (typeof options === 'number') {\n\t\t\t// Backwards compatibility with 0.7.x factory (latlng, radius, options?)\n\t\t\toptions = L.extend({}, legacyOptions, {radius: options});\n\t\t}\n\t\tL.setOptions(this, options);\n\t\tthis._latlng = L.latLng(latlng);\n\n\t\tif (isNaN(this.options.radius)) { throw new Error('Circle radius cannot be NaN'); }\n\n\t\t// @section\n\t\t// @aka Circle options\n\t\t// @option radius: Number; Radius of the circle, in meters.\n\t\tthis._mRadius = this.options.radius;\n\t},\n\n\t// @method setRadius(radius: Number): this\n\t// Sets the radius of a circle. Units are in meters.\n\tsetRadius: function (radius) {\n\t\tthis._mRadius = radius;\n\t\treturn this.redraw();\n\t},\n\n\t// @method getRadius(): Number\n\t// Returns the current radius of a circle. Units are in meters.\n\tgetRadius: function () {\n\t\treturn this._mRadius;\n\t},\n\n\t// @method getBounds(): LatLngBounds\n\t// Returns the `LatLngBounds` of the path.\n\tgetBounds: function () {\n\t\tvar half = [this._radius, this._radiusY || this._radius];\n\n\t\treturn new L.LatLngBounds(\n\t\t\tthis._map.layerPointToLatLng(this._point.subtract(half)),\n\t\t\tthis._map.layerPointToLatLng(this._point.add(half)));\n\t},\n\n\tsetStyle: L.Path.prototype.setStyle,\n\n\t_project: function () {\n\n\t\tvar lng = this._latlng.lng,\n\t\t lat = this._latlng.lat,\n\t\t map = this._map,\n\t\t crs = map.options.crs;\n\n\t\tif (crs.distance === L.CRS.Earth.distance) {\n\t\t\tvar d = Math.PI / 180,\n\t\t\t latR = (this._mRadius / L.CRS.Earth.R) / d,\n\t\t\t top = map.project([lat + latR, lng]),\n\t\t\t bottom = map.project([lat - latR, lng]),\n\t\t\t p = top.add(bottom).divideBy(2),\n\t\t\t lat2 = map.unproject(p).lat,\n\t\t\t lngR = Math.acos((Math.cos(latR * d) - Math.sin(lat * d) * Math.sin(lat2 * d)) /\n\t\t\t (Math.cos(lat * d) * Math.cos(lat2 * d))) / d;\n\n\t\t\tif (isNaN(lngR) || lngR === 0) {\n\t\t\t\tlngR = latR / Math.cos(Math.PI / 180 * lat); // Fallback for edge case, #2425\n\t\t\t}\n\n\t\t\tthis._point = p.subtract(map.getPixelOrigin());\n\t\t\tthis._radius = isNaN(lngR) ? 0 : Math.max(Math.round(p.x - map.project([lat2, lng - lngR]).x), 1);\n\t\t\tthis._radiusY = Math.max(Math.round(p.y - top.y), 1);\n\n\t\t} else {\n\t\t\tvar latlng2 = crs.unproject(crs.project(this._latlng).subtract([this._mRadius, 0]));\n\n\t\t\tthis._point = map.latLngToLayerPoint(this._latlng);\n\t\t\tthis._radius = this._point.x - map.latLngToLayerPoint(latlng2).x;\n\t\t}\n\n\t\tthis._updateBounds();\n\t}\n});\n\n// @factory L.circle(latlng: LatLng, options?: Circle options)\n// Instantiates a circle object given a geographical point, and an options object\n// which contains the circle radius.\n// @alternative\n// @factory L.circle(latlng: LatLng, radius: Number, options?: Circle options)\n// Obsolete way of instantiating a circle, for compatibility with 0.7.x code.\n// Do not use in new applications or plugins.\nL.circle = function (latlng, options, legacyOptions) {\n\treturn new L.Circle(latlng, options, legacyOptions);\n};\n","/*\n * @class SVG\n * @inherits Renderer\n * @aka L.SVG\n *\n * Allows vector layers to be displayed with [SVG](https://developer.mozilla.org/docs/Web/SVG).\n * Inherits `Renderer`.\n *\n * Due to [technical limitations](http://caniuse.com/#search=svg), SVG is not\n * available in all web browsers, notably Android 2.x and 3.x.\n *\n * Although SVG is not available on IE7 and IE8, these browsers support\n * [VML](https://en.wikipedia.org/wiki/Vector_Markup_Language)\n * (a now deprecated technology), and the SVG renderer will fall back to VML in\n * this case.\n *\n * @example\n *\n * Use SVG by default for all paths in the map:\n *\n * ```js\n * var map = L.map('map', {\n * \trenderer: L.svg()\n * });\n * ```\n *\n * Use a SVG renderer with extra padding for specific vector geometries:\n *\n * ```js\n * var map = L.map('map');\n * var myRenderer = L.svg({ padding: 0.5 });\n * var line = L.polyline( coordinates, { renderer: myRenderer } );\n * var circle = L.circle( center, { renderer: myRenderer } );\n * ```\n */\n\nL.SVG = L.Renderer.extend({\n\n\tgetEvents: function () {\n\t\tvar events = L.Renderer.prototype.getEvents.call(this);\n\t\tevents.zoomstart = this._onZoomStart;\n\t\treturn events;\n\t},\n\n\t_initContainer: function () {\n\t\tthis._container = L.SVG.create('svg');\n\n\t\t// makes it possible to click through svg root; we'll reset it back in individual paths\n\t\tthis._container.setAttribute('pointer-events', 'none');\n\n\t\tthis._rootGroup = L.SVG.create('g');\n\t\tthis._container.appendChild(this._rootGroup);\n\t},\n\n\t_onZoomStart: function () {\n\t\t// Drag-then-pinch interactions might mess up the center and zoom.\n\t\t// In this case, the easiest way to prevent this is re-do the renderer\n\t\t// bounds and padding when the zooming starts.\n\t\tthis._update();\n\t},\n\n\t_update: function () {\n\t\tif (this._map._animatingZoom && this._bounds) { return; }\n\n\t\tL.Renderer.prototype._update.call(this);\n\n\t\tvar b = this._bounds,\n\t\t size = b.getSize(),\n\t\t container = this._container;\n\n\t\t// set size of svg-container if changed\n\t\tif (!this._svgSize || !this._svgSize.equals(size)) {\n\t\t\tthis._svgSize = size;\n\t\t\tcontainer.setAttribute('width', size.x);\n\t\t\tcontainer.setAttribute('height', size.y);\n\t\t}\n\n\t\t// movement: update container viewBox so that we don't have to change coordinates of individual layers\n\t\tL.DomUtil.setPosition(container, b.min);\n\t\tcontainer.setAttribute('viewBox', [b.min.x, b.min.y, size.x, size.y].join(' '));\n\n\t\tthis.fire('update');\n\t},\n\n\t// methods below are called by vector layers implementations\n\n\t_initPath: function (layer) {\n\t\tvar path = layer._path = L.SVG.create('path');\n\n\t\t// @namespace Path\n\t\t// @option className: String = null\n\t\t// Custom class name set on an element. Only for SVG renderer.\n\t\tif (layer.options.className) {\n\t\t\tL.DomUtil.addClass(path, layer.options.className);\n\t\t}\n\n\t\tif (layer.options.interactive) {\n\t\t\tL.DomUtil.addClass(path, 'leaflet-interactive');\n\t\t}\n\n\t\tthis._updateStyle(layer);\n\t\tthis._layers[L.stamp(layer)] = layer;\n\t},\n\n\t_addPath: function (layer) {\n\t\tthis._rootGroup.appendChild(layer._path);\n\t\tlayer.addInteractiveTarget(layer._path);\n\t},\n\n\t_removePath: function (layer) {\n\t\tL.DomUtil.remove(layer._path);\n\t\tlayer.removeInteractiveTarget(layer._path);\n\t\tdelete this._layers[L.stamp(layer)];\n\t},\n\n\t_updatePath: function (layer) {\n\t\tlayer._project();\n\t\tlayer._update();\n\t},\n\n\t_updateStyle: function (layer) {\n\t\tvar path = layer._path,\n\t\t options = layer.options;\n\n\t\tif (!path) { return; }\n\n\t\tif (options.stroke) {\n\t\t\tpath.setAttribute('stroke', options.color);\n\t\t\tpath.setAttribute('stroke-opacity', options.opacity);\n\t\t\tpath.setAttribute('stroke-width', options.weight);\n\t\t\tpath.setAttribute('stroke-linecap', options.lineCap);\n\t\t\tpath.setAttribute('stroke-linejoin', options.lineJoin);\n\n\t\t\tif (options.dashArray) {\n\t\t\t\tpath.setAttribute('stroke-dasharray', options.dashArray);\n\t\t\t} else {\n\t\t\t\tpath.removeAttribute('stroke-dasharray');\n\t\t\t}\n\n\t\t\tif (options.dashOffset) {\n\t\t\t\tpath.setAttribute('stroke-dashoffset', options.dashOffset);\n\t\t\t} else {\n\t\t\t\tpath.removeAttribute('stroke-dashoffset');\n\t\t\t}\n\t\t} else {\n\t\t\tpath.setAttribute('stroke', 'none');\n\t\t}\n\n\t\tif (options.fill) {\n\t\t\tpath.setAttribute('fill', options.fillColor || options.color);\n\t\t\tpath.setAttribute('fill-opacity', options.fillOpacity);\n\t\t\tpath.setAttribute('fill-rule', options.fillRule || 'evenodd');\n\t\t} else {\n\t\t\tpath.setAttribute('fill', 'none');\n\t\t}\n\t},\n\n\t_updatePoly: function (layer, closed) {\n\t\tthis._setPath(layer, L.SVG.pointsToPath(layer._parts, closed));\n\t},\n\n\t_updateCircle: function (layer) {\n\t\tvar p = layer._point,\n\t\t r = layer._radius,\n\t\t r2 = layer._radiusY || r,\n\t\t arc = 'a' + r + ',' + r2 + ' 0 1,0 ';\n\n\t\t// drawing a circle with two half-arcs\n\t\tvar d = layer._empty() ? 'M0 0' :\n\t\t\t\t'M' + (p.x - r) + ',' + p.y +\n\t\t\t\tarc + (r * 2) + ',0 ' +\n\t\t\t\tarc + (-r * 2) + ',0 ';\n\n\t\tthis._setPath(layer, d);\n\t},\n\n\t_setPath: function (layer, path) {\n\t\tlayer._path.setAttribute('d', path);\n\t},\n\n\t// SVG does not have the concept of zIndex so we resort to changing the DOM order of elements\n\t_bringToFront: function (layer) {\n\t\tL.DomUtil.toFront(layer._path);\n\t},\n\n\t_bringToBack: function (layer) {\n\t\tL.DomUtil.toBack(layer._path);\n\t}\n});\n\n\n// @namespace SVG; @section\n// There are several static functions which can be called without instantiating L.SVG:\nL.extend(L.SVG, {\n\t// @function create(name: String): SVGElement\n\t// Returns a instance of [SVGElement](https://developer.mozilla.org/docs/Web/API/SVGElement),\n\t// corresponding to the class name passed. For example, using 'line' will return\n\t// an instance of [SVGLineElement](https://developer.mozilla.org/docs/Web/API/SVGLineElement).\n\tcreate: function (name) {\n\t\treturn document.createElementNS('http://www.w3.org/2000/svg', name);\n\t},\n\n\t// @function pointsToPath(rings: Point[], closed: Boolean): String\n\t// Generates a SVG path string for multiple rings, with each ring turning\n\t// into \"M..L..L..\" instructions\n\tpointsToPath: function (rings, closed) {\n\t\tvar str = '',\n\t\t i, j, len, len2, points, p;\n\n\t\tfor (i = 0, len = rings.length; i < len; i++) {\n\t\t\tpoints = rings[i];\n\n\t\t\tfor (j = 0, len2 = points.length; j < len2; j++) {\n\t\t\t\tp = points[j];\n\t\t\t\tstr += (j ? 'L' : 'M') + p.x + ' ' + p.y;\n\t\t\t}\n\n\t\t\t// closes the ring for polygons; \"x\" is VML syntax\n\t\t\tstr += closed ? (L.Browser.svg ? 'z' : 'x') : '';\n\t\t}\n\n\t\t// SVG complains about empty path strings\n\t\treturn str || 'M0 0';\n\t}\n});\n\n// @namespace Browser; @property svg: Boolean\n// `true` when the browser supports [SVG](https://developer.mozilla.org/docs/Web/SVG).\nL.Browser.svg = !!(document.createElementNS && L.SVG.create('svg').createSVGRect);\n\n\n// @namespace SVG\n// @factory L.svg(options?: Renderer options)\n// Creates a SVG renderer with the given options.\nL.svg = function (options) {\n\treturn L.Browser.svg || L.Browser.vml ? new L.SVG(options) : null;\n};\n","/*\n * Thanks to Dmitry Baranovsky and his Raphael library for inspiration!\n */\n\n/*\n * @class SVG\n *\n * Although SVG is not available on IE7 and IE8, these browsers support [VML](https://en.wikipedia.org/wiki/Vector_Markup_Language), and the SVG renderer will fall back to VML in this case.\n *\n * VML was deprecated in 2012, which means VML functionality exists only for backwards compatibility\n * with old versions of Internet Explorer.\n */\n\n// @namespace Browser; @property vml: Boolean\n// `true` if the browser supports [VML](https://en.wikipedia.org/wiki/Vector_Markup_Language).\nL.Browser.vml = !L.Browser.svg && (function () {\n\ttry {\n\t\tvar div = document.createElement('div');\n\t\tdiv.innerHTML = '';\n\n\t\tvar shape = div.firstChild;\n\t\tshape.style.behavior = 'url(#default#VML)';\n\n\t\treturn shape && (typeof shape.adj === 'object');\n\n\t} catch (e) {\n\t\treturn false;\n\t}\n}());\n\n// redefine some SVG methods to handle VML syntax which is similar but with some differences\nL.SVG.include(!L.Browser.vml ? {} : {\n\n\t_initContainer: function () {\n\t\tthis._container = L.DomUtil.create('div', 'leaflet-vml-container');\n\t},\n\n\t_update: function () {\n\t\tif (this._map._animatingZoom) { return; }\n\t\tL.Renderer.prototype._update.call(this);\n\t\tthis.fire('update');\n\t},\n\n\t_initPath: function (layer) {\n\t\tvar container = layer._container = L.SVG.create('shape');\n\n\t\tL.DomUtil.addClass(container, 'leaflet-vml-shape ' + (this.options.className || ''));\n\n\t\tcontainer.coordsize = '1 1';\n\n\t\tlayer._path = L.SVG.create('path');\n\t\tcontainer.appendChild(layer._path);\n\n\t\tthis._updateStyle(layer);\n\t},\n\n\t_addPath: function (layer) {\n\t\tvar container = layer._container;\n\t\tthis._container.appendChild(container);\n\n\t\tif (layer.options.interactive) {\n\t\t\tlayer.addInteractiveTarget(container);\n\t\t}\n\t},\n\n\t_removePath: function (layer) {\n\t\tvar container = layer._container;\n\t\tL.DomUtil.remove(container);\n\t\tlayer.removeInteractiveTarget(container);\n\t},\n\n\t_updateStyle: function (layer) {\n\t\tvar stroke = layer._stroke,\n\t\t fill = layer._fill,\n\t\t options = layer.options,\n\t\t container = layer._container;\n\n\t\tcontainer.stroked = !!options.stroke;\n\t\tcontainer.filled = !!options.fill;\n\n\t\tif (options.stroke) {\n\t\t\tif (!stroke) {\n\t\t\t\tstroke = layer._stroke = L.SVG.create('stroke');\n\t\t\t}\n\t\t\tcontainer.appendChild(stroke);\n\t\t\tstroke.weight = options.weight + 'px';\n\t\t\tstroke.color = options.color;\n\t\t\tstroke.opacity = options.opacity;\n\n\t\t\tif (options.dashArray) {\n\t\t\t\tstroke.dashStyle = L.Util.isArray(options.dashArray) ?\n\t\t\t\t options.dashArray.join(' ') :\n\t\t\t\t options.dashArray.replace(/( *, *)/g, ' ');\n\t\t\t} else {\n\t\t\t\tstroke.dashStyle = '';\n\t\t\t}\n\t\t\tstroke.endcap = options.lineCap.replace('butt', 'flat');\n\t\t\tstroke.joinstyle = options.lineJoin;\n\n\t\t} else if (stroke) {\n\t\t\tcontainer.removeChild(stroke);\n\t\t\tlayer._stroke = null;\n\t\t}\n\n\t\tif (options.fill) {\n\t\t\tif (!fill) {\n\t\t\t\tfill = layer._fill = L.SVG.create('fill');\n\t\t\t}\n\t\t\tcontainer.appendChild(fill);\n\t\t\tfill.color = options.fillColor || options.color;\n\t\t\tfill.opacity = options.fillOpacity;\n\n\t\t} else if (fill) {\n\t\t\tcontainer.removeChild(fill);\n\t\t\tlayer._fill = null;\n\t\t}\n\t},\n\n\t_updateCircle: function (layer) {\n\t\tvar p = layer._point.round(),\n\t\t r = Math.round(layer._radius),\n\t\t r2 = Math.round(layer._radiusY || r);\n\n\t\tthis._setPath(layer, layer._empty() ? 'M0 0' :\n\t\t\t\t'AL ' + p.x + ',' + p.y + ' ' + r + ',' + r2 + ' 0,' + (65535 * 360));\n\t},\n\n\t_setPath: function (layer, path) {\n\t\tlayer._path.v = path;\n\t},\n\n\t_bringToFront: function (layer) {\n\t\tL.DomUtil.toFront(layer._container);\n\t},\n\n\t_bringToBack: function (layer) {\n\t\tL.DomUtil.toBack(layer._container);\n\t}\n});\n\nif (L.Browser.vml) {\n\tL.SVG.create = (function () {\n\t\ttry {\n\t\t\tdocument.namespaces.add('lvml', 'urn:schemas-microsoft-com:vml');\n\t\t\treturn function (name) {\n\t\t\t\treturn document.createElement('');\n\t\t\t};\n\t\t} catch (e) {\n\t\t\treturn function (name) {\n\t\t\t\treturn document.createElement('<' + name + ' xmlns=\"urn:schemas-microsoft.com:vml\" class=\"lvml\">');\n\t\t\t};\n\t\t}\n\t})();\n}\n","/*\n * @class Canvas\n * @inherits Renderer\n * @aka L.Canvas\n *\n * Allows vector layers to be displayed with [``](https://developer.mozilla.org/docs/Web/API/Canvas_API).\n * Inherits `Renderer`.\n *\n * Due to [technical limitations](http://caniuse.com/#search=canvas), Canvas is not\n * available in all web browsers, notably IE8, and overlapping geometries might\n * not display properly in some edge cases.\n *\n * @example\n *\n * Use Canvas by default for all paths in the map:\n *\n * ```js\n * var map = L.map('map', {\n * \trenderer: L.canvas()\n * });\n * ```\n *\n * Use a Canvas renderer with extra padding for specific vector geometries:\n *\n * ```js\n * var map = L.map('map');\n * var myRenderer = L.canvas({ padding: 0.5 });\n * var line = L.polyline( coordinates, { renderer: myRenderer } );\n * var circle = L.circle( center, { renderer: myRenderer } );\n * ```\n */\n\nL.Canvas = L.Renderer.extend({\n\n\tonAdd: function () {\n\t\tL.Renderer.prototype.onAdd.call(this);\n\n\t\t// Redraw vectors since canvas is cleared upon removal,\n\t\t// in case of removing the renderer itself from the map.\n\t\tthis._draw();\n\t},\n\n\t_initContainer: function () {\n\t\tvar container = this._container = document.createElement('canvas');\n\n\t\tL.DomEvent\n\t\t\t.on(container, 'mousemove', L.Util.throttle(this._onMouseMove, 32, this), this)\n\t\t\t.on(container, 'click dblclick mousedown mouseup contextmenu', this._onClick, this)\n\t\t\t.on(container, 'mouseout', this._handleMouseOut, this);\n\n\t\tthis._ctx = container.getContext('2d');\n\t},\n\n\t_updatePaths: function () {\n\t\tvar layer;\n\t\tthis._redrawBounds = null;\n\t\tfor (var id in this._layers) {\n\t\t\tlayer = this._layers[id];\n\t\t\tlayer._update();\n\t\t}\n\t\tthis._redraw();\n\t},\n\n\t_update: function () {\n\t\tif (this._map._animatingZoom && this._bounds) { return; }\n\n\t\tthis._drawnLayers = {};\n\n\t\tL.Renderer.prototype._update.call(this);\n\n\t\tvar b = this._bounds,\n\t\t container = this._container,\n\t\t size = b.getSize(),\n\t\t m = L.Browser.retina ? 2 : 1;\n\n\t\tL.DomUtil.setPosition(container, b.min);\n\n\t\t// set canvas size (also clearing it); use double size on retina\n\t\tcontainer.width = m * size.x;\n\t\tcontainer.height = m * size.y;\n\t\tcontainer.style.width = size.x + 'px';\n\t\tcontainer.style.height = size.y + 'px';\n\n\t\tif (L.Browser.retina) {\n\t\t\tthis._ctx.scale(2, 2);\n\t\t}\n\n\t\t// translate so we use the same path coordinates after canvas element moves\n\t\tthis._ctx.translate(-b.min.x, -b.min.y);\n\n\t\t// Tell paths to redraw themselves\n\t\tthis.fire('update');\n\t},\n\n\t_initPath: function (layer) {\n\t\tthis._updateDashArray(layer);\n\t\tthis._layers[L.stamp(layer)] = layer;\n\n\t\tvar order = layer._order = {\n\t\t\tlayer: layer,\n\t\t\tprev: this._drawLast,\n\t\t\tnext: null\n\t\t};\n\t\tif (this._drawLast) { this._drawLast.next = order; }\n\t\tthis._drawLast = order;\n\t\tthis._drawFirst = this._drawFirst || this._drawLast;\n\t},\n\n\t_addPath: function (layer) {\n\t\tthis._requestRedraw(layer);\n\t},\n\n\t_removePath: function (layer) {\n\t\tvar order = layer._order;\n\t\tvar next = order.next;\n\t\tvar prev = order.prev;\n\n\t\tif (next) {\n\t\t\tnext.prev = prev;\n\t\t} else {\n\t\t\tthis._drawLast = prev;\n\t\t}\n\t\tif (prev) {\n\t\t\tprev.next = next;\n\t\t} else {\n\t\t\tthis._drawFirst = next;\n\t\t}\n\n\t\tdelete layer._order;\n\n\t\tdelete this._layers[L.stamp(layer)];\n\n\t\tthis._requestRedraw(layer);\n\t},\n\n\t_updatePath: function (layer) {\n\t\t// Redraw the union of the layer's old pixel\n\t\t// bounds and the new pixel bounds.\n\t\tthis._extendRedrawBounds(layer);\n\t\tlayer._project();\n\t\tlayer._update();\n\t\t// The redraw will extend the redraw bounds\n\t\t// with the new pixel bounds.\n\t\tthis._requestRedraw(layer);\n\t},\n\n\t_updateStyle: function (layer) {\n\t\tthis._updateDashArray(layer);\n\t\tthis._requestRedraw(layer);\n\t},\n\n\t_updateDashArray: function (layer) {\n\t\tif (layer.options.dashArray) {\n\t\t\tvar parts = layer.options.dashArray.split(','),\n\t\t\t dashArray = [],\n\t\t\t i;\n\t\t\tfor (i = 0; i < parts.length; i++) {\n\t\t\t\tdashArray.push(Number(parts[i]));\n\t\t\t}\n\t\t\tlayer.options._dashArray = dashArray;\n\t\t}\n\t},\n\n\t_requestRedraw: function (layer) {\n\t\tif (!this._map) { return; }\n\n\t\tthis._extendRedrawBounds(layer);\n\t\tthis._redrawRequest = this._redrawRequest || L.Util.requestAnimFrame(this._redraw, this);\n\t},\n\n\t_extendRedrawBounds: function (layer) {\n\t\tvar padding = (layer.options.weight || 0) + 1;\n\t\tthis._redrawBounds = this._redrawBounds || new L.Bounds();\n\t\tthis._redrawBounds.extend(layer._pxBounds.min.subtract([padding, padding]));\n\t\tthis._redrawBounds.extend(layer._pxBounds.max.add([padding, padding]));\n\t},\n\n\t_redraw: function () {\n\t\tthis._redrawRequest = null;\n\n\t\tthis._clear(); // clear layers in redraw bounds\n\t\tthis._draw(); // draw layers\n\n\t\tthis._redrawBounds = null;\n\t},\n\n\t_clear: function () {\n\t\tvar bounds = this._redrawBounds;\n\t\tif (bounds) {\n\t\t\tvar size = bounds.getSize();\n\t\t\tthis._ctx.clearRect(bounds.min.x, bounds.min.y, size.x, size.y);\n\t\t} else {\n\t\t\tthis._ctx.clearRect(0, 0, this._container.width, this._container.height);\n\t\t}\n\t},\n\n\t_draw: function () {\n\t\tvar layer, bounds = this._redrawBounds;\n\t\tthis._ctx.save();\n\t\tif (bounds) {\n\t\t\tvar size = bounds.getSize();\n\t\t\tthis._ctx.beginPath();\n\t\t\tthis._ctx.rect(bounds.min.x, bounds.min.y, size.x, size.y);\n\t\t\tthis._ctx.clip();\n\t\t}\n\n\t\tthis._drawing = true;\n\n\t\tfor (var order = this._drawFirst; order; order = order.next) {\n\t\t\tlayer = order.layer;\n\t\t\tif (!bounds || (layer._pxBounds && layer._pxBounds.intersects(bounds))) {\n\t\t\t\tlayer._updatePath();\n\t\t\t}\n\t\t}\n\n\t\tthis._drawing = false;\n\n\t\tthis._ctx.restore(); // Restore state before clipping.\n\t},\n\n\t_updatePoly: function (layer, closed) {\n\t\tif (!this._drawing) { return; }\n\n\t\tvar i, j, len2, p,\n\t\t parts = layer._parts,\n\t\t len = parts.length,\n\t\t ctx = this._ctx;\n\n\t\tif (!len) { return; }\n\n\t\tthis._drawnLayers[layer._leaflet_id] = layer;\n\n\t\tctx.beginPath();\n\n\t\tif (ctx.setLineDash) {\n\t\t\tctx.setLineDash(layer.options && layer.options._dashArray || []);\n\t\t}\n\n\t\tfor (i = 0; i < len; i++) {\n\t\t\tfor (j = 0, len2 = parts[i].length; j < len2; j++) {\n\t\t\t\tp = parts[i][j];\n\t\t\t\tctx[j ? 'lineTo' : 'moveTo'](p.x, p.y);\n\t\t\t}\n\t\t\tif (closed) {\n\t\t\t\tctx.closePath();\n\t\t\t}\n\t\t}\n\n\t\tthis._fillStroke(ctx, layer);\n\n\t\t// TODO optimization: 1 fill/stroke for all features with equal style instead of 1 for each feature\n\t},\n\n\t_updateCircle: function (layer) {\n\n\t\tif (!this._drawing || layer._empty()) { return; }\n\n\t\tvar p = layer._point,\n\t\t ctx = this._ctx,\n\t\t r = layer._radius,\n\t\t s = (layer._radiusY || r) / r;\n\n\t\tthis._drawnLayers[layer._leaflet_id] = layer;\n\n\t\tif (s !== 1) {\n\t\t\tctx.save();\n\t\t\tctx.scale(1, s);\n\t\t}\n\n\t\tctx.beginPath();\n\t\tctx.arc(p.x, p.y / s, r, 0, Math.PI * 2, false);\n\n\t\tif (s !== 1) {\n\t\t\tctx.restore();\n\t\t}\n\n\t\tthis._fillStroke(ctx, layer);\n\t},\n\n\t_fillStroke: function (ctx, layer) {\n\t\tvar options = layer.options;\n\n\t\tif (options.fill) {\n\t\t\tctx.globalAlpha = options.fillOpacity;\n\t\t\tctx.fillStyle = options.fillColor || options.color;\n\t\t\tctx.fill(options.fillRule || 'evenodd');\n\t\t}\n\n\t\tif (options.stroke && options.weight !== 0) {\n\t\t\tctx.globalAlpha = options.opacity;\n\t\t\tctx.lineWidth = options.weight;\n\t\t\tctx.strokeStyle = options.color;\n\t\t\tctx.lineCap = options.lineCap;\n\t\t\tctx.lineJoin = options.lineJoin;\n\t\t\tctx.stroke();\n\t\t}\n\t},\n\n\t// Canvas obviously doesn't have mouse events for individual drawn objects,\n\t// so we emulate that by calculating what's under the mouse on mousemove/click manually\n\n\t_onClick: function (e) {\n\t\tvar point = this._map.mouseEventToLayerPoint(e), layer, clickedLayer;\n\n\t\tfor (var order = this._drawFirst; order; order = order.next) {\n\t\t\tlayer = order.layer;\n\t\t\tif (layer.options.interactive && layer._containsPoint(point) && !this._map._draggableMoved(layer)) {\n\t\t\t\tclickedLayer = layer;\n\t\t\t}\n\t\t}\n\t\tif (clickedLayer) {\n\t\t\tL.DomEvent._fakeStop(e);\n\t\t\tthis._fireEvent([clickedLayer], e);\n\t\t}\n\t},\n\n\t_onMouseMove: function (e) {\n\t\tif (!this._map || this._map.dragging.moving() || this._map._animatingZoom) { return; }\n\n\t\tvar point = this._map.mouseEventToLayerPoint(e);\n\t\tthis._handleMouseHover(e, point);\n\t},\n\n\n\t_handleMouseOut: function (e) {\n\t\tvar layer = this._hoveredLayer;\n\t\tif (layer) {\n\t\t\t// if we're leaving the layer, fire mouseout\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-interactive');\n\t\t\tthis._fireEvent([layer], e, 'mouseout');\n\t\t\tthis._hoveredLayer = null;\n\t\t}\n\t},\n\n\t_handleMouseHover: function (e, point) {\n\t\tvar layer, candidateHoveredLayer;\n\n\t\tfor (var order = this._drawFirst; order; order = order.next) {\n\t\t\tlayer = order.layer;\n\t\t\tif (layer.options.interactive && layer._containsPoint(point)) {\n\t\t\t\tcandidateHoveredLayer = layer;\n\t\t\t}\n\t\t}\n\n\t\tif (candidateHoveredLayer !== this._hoveredLayer) {\n\t\t\tthis._handleMouseOut(e);\n\n\t\t\tif (candidateHoveredLayer) {\n\t\t\t\tL.DomUtil.addClass(this._container, 'leaflet-interactive'); // change cursor\n\t\t\t\tthis._fireEvent([candidateHoveredLayer], e, 'mouseover');\n\t\t\t\tthis._hoveredLayer = candidateHoveredLayer;\n\t\t\t}\n\t\t}\n\n\t\tif (this._hoveredLayer) {\n\t\t\tthis._fireEvent([this._hoveredLayer], e);\n\t\t}\n\t},\n\n\t_fireEvent: function (layers, e, type) {\n\t\tthis._map._fireDOMEvent(e, type || e.type, layers);\n\t},\n\n\t_bringToFront: function (layer) {\n\t\tvar order = layer._order;\n\t\tvar next = order.next;\n\t\tvar prev = order.prev;\n\n\t\tif (next) {\n\t\t\tnext.prev = prev;\n\t\t} else {\n\t\t\t// Already last\n\t\t\treturn;\n\t\t}\n\t\tif (prev) {\n\t\t\tprev.next = next;\n\t\t} else if (next) {\n\t\t\t// Update first entry unless this is the\n\t\t\t// signle entry\n\t\t\tthis._drawFirst = next;\n\t\t}\n\n\t\torder.prev = this._drawLast;\n\t\tthis._drawLast.next = order;\n\n\t\torder.next = null;\n\t\tthis._drawLast = order;\n\n\t\tthis._requestRedraw(layer);\n\t},\n\n\t_bringToBack: function (layer) {\n\t\tvar order = layer._order;\n\t\tvar next = order.next;\n\t\tvar prev = order.prev;\n\n\t\tif (prev) {\n\t\t\tprev.next = next;\n\t\t} else {\n\t\t\t// Already first\n\t\t\treturn;\n\t\t}\n\t\tif (next) {\n\t\t\tnext.prev = prev;\n\t\t} else if (prev) {\n\t\t\t// Update last entry unless this is the\n\t\t\t// signle entry\n\t\t\tthis._drawLast = prev;\n\t\t}\n\n\t\torder.prev = null;\n\n\t\torder.next = this._drawFirst;\n\t\tthis._drawFirst.prev = order;\n\t\tthis._drawFirst = order;\n\n\t\tthis._requestRedraw(layer);\n\t}\n});\n\n// @namespace Browser; @property canvas: Boolean\n// `true` when the browser supports [``](https://developer.mozilla.org/docs/Web/API/Canvas_API).\nL.Browser.canvas = (function () {\n\treturn !!document.createElement('canvas').getContext;\n}());\n\n// @namespace Canvas\n// @factory L.canvas(options?: Renderer options)\n// Creates a Canvas renderer with the given options.\nL.canvas = function (options) {\n\treturn L.Browser.canvas ? new L.Canvas(options) : null;\n};\n\nL.Polyline.prototype._containsPoint = function (p, closed) {\n\tvar i, j, k, len, len2, part,\n\t w = this._clickTolerance();\n\n\tif (!this._pxBounds.contains(p)) { return false; }\n\n\t// hit detection for polylines\n\tfor (i = 0, len = this._parts.length; i < len; i++) {\n\t\tpart = this._parts[i];\n\n\t\tfor (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) {\n\t\t\tif (!closed && (j === 0)) { continue; }\n\n\t\t\tif (L.LineUtil.pointToSegmentDistance(p, part[k], part[j]) <= w) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n};\n\nL.Polygon.prototype._containsPoint = function (p) {\n\tvar inside = false,\n\t part, p1, p2, i, j, k, len, len2;\n\n\tif (!this._pxBounds.contains(p)) { return false; }\n\n\t// ray casting algorithm for detecting if point is in polygon\n\tfor (i = 0, len = this._parts.length; i < len; i++) {\n\t\tpart = this._parts[i];\n\n\t\tfor (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) {\n\t\t\tp1 = part[j];\n\t\t\tp2 = part[k];\n\n\t\t\tif (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) {\n\t\t\t\tinside = !inside;\n\t\t\t}\n\t\t}\n\t}\n\n\t// also check if it's on polygon stroke\n\treturn inside || L.Polyline.prototype._containsPoint.call(this, p, true);\n};\n\nL.CircleMarker.prototype._containsPoint = function (p) {\n\treturn p.distanceTo(this._point) <= this._radius + this._clickTolerance();\n};\n","/*\r\n * @class GeoJSON\r\n * @aka L.GeoJSON\r\n * @inherits FeatureGroup\r\n *\r\n * Represents a GeoJSON object or an array of GeoJSON objects. Allows you to parse\r\n * GeoJSON data and display it on the map. Extends `FeatureGroup`.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * L.geoJSON(data, {\r\n * \tstyle: function (feature) {\r\n * \t\treturn {color: feature.properties.color};\r\n * \t}\r\n * }).bindPopup(function (layer) {\r\n * \treturn layer.feature.properties.description;\r\n * }).addTo(map);\r\n * ```\r\n */\r\n\r\nL.GeoJSON = L.FeatureGroup.extend({\r\n\r\n\t/* @section\r\n\t * @aka GeoJSON options\r\n\t *\r\n\t * @option pointToLayer: Function = *\r\n\t * A `Function` defining how GeoJSON points spawn Leaflet layers. It is internally\r\n\t * called when data is added, passing the GeoJSON point feature and its `LatLng`.\r\n\t * The default is to spawn a default `Marker`:\r\n\t * ```js\r\n\t * function(geoJsonPoint, latlng) {\r\n\t * \treturn L.marker(latlng);\r\n\t * }\r\n\t * ```\r\n\t *\r\n\t * @option style: Function = *\r\n\t * A `Function` defining the `Path options` for styling GeoJSON lines and polygons,\r\n\t * called internally when data is added.\r\n\t * The default value is to not override any defaults:\r\n\t * ```js\r\n\t * function (geoJsonFeature) {\r\n\t * \treturn {}\r\n\t * }\r\n\t * ```\r\n\t *\r\n\t * @option onEachFeature: Function = *\r\n\t * A `Function` that will be called once for each created `Feature`, after it has\r\n\t * been created and styled. Useful for attaching events and popups to features.\r\n\t * The default is to do nothing with the newly created layers:\r\n\t * ```js\r\n\t * function (feature, layer) {}\r\n\t * ```\r\n\t *\r\n\t * @option filter: Function = *\r\n\t * A `Function` that will be used to decide whether to include a feature or not.\r\n\t * The default is to include all features:\r\n\t * ```js\r\n\t * function (geoJsonFeature) {\r\n\t * \treturn true;\r\n\t * }\r\n\t * ```\r\n\t * Note: dynamically changing the `filter` option will have effect only on newly\r\n\t * added data. It will _not_ re-evaluate already included features.\r\n\t *\r\n\t * @option coordsToLatLng: Function = *\r\n\t * A `Function` that will be used for converting GeoJSON coordinates to `LatLng`s.\r\n\t * The default is the `coordsToLatLng` static method.\r\n\t */\r\n\r\n\tinitialize: function (geojson, options) {\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tthis._layers = {};\r\n\r\n\t\tif (geojson) {\r\n\t\t\tthis.addData(geojson);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method addData( data ): this\r\n\t// Adds a GeoJSON object to the layer.\r\n\taddData: function (geojson) {\r\n\t\tvar features = L.Util.isArray(geojson) ? geojson : geojson.features,\r\n\t\t i, len, feature;\r\n\r\n\t\tif (features) {\r\n\t\t\tfor (i = 0, len = features.length; i < len; i++) {\r\n\t\t\t\t// only add this if geometry or geometries are set and not null\r\n\t\t\t\tfeature = features[i];\r\n\t\t\t\tif (feature.geometries || feature.geometry || feature.features || feature.coordinates) {\r\n\t\t\t\t\tthis.addData(feature);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn this;\r\n\t\t}\r\n\r\n\t\tvar options = this.options;\r\n\r\n\t\tif (options.filter && !options.filter(geojson)) { return this; }\r\n\r\n\t\tvar layer = L.GeoJSON.geometryToLayer(geojson, options);\r\n\t\tif (!layer) {\r\n\t\t\treturn this;\r\n\t\t}\r\n\t\tlayer.feature = L.GeoJSON.asFeature(geojson);\r\n\r\n\t\tlayer.defaultOptions = layer.options;\r\n\t\tthis.resetStyle(layer);\r\n\r\n\t\tif (options.onEachFeature) {\r\n\t\t\toptions.onEachFeature(geojson, layer);\r\n\t\t}\r\n\r\n\t\treturn this.addLayer(layer);\r\n\t},\r\n\r\n\t// @method resetStyle( layer ): this\r\n\t// Resets the given vector layer's style to the original GeoJSON style, useful for resetting style after hover events.\r\n\tresetStyle: function (layer) {\r\n\t\t// reset any custom styles\r\n\t\tlayer.options = L.Util.extend({}, layer.defaultOptions);\r\n\t\tthis._setLayerStyle(layer, this.options.style);\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method setStyle( style ): this\r\n\t// Changes styles of GeoJSON vector layers with the given style function.\r\n\tsetStyle: function (style) {\r\n\t\treturn this.eachLayer(function (layer) {\r\n\t\t\tthis._setLayerStyle(layer, style);\r\n\t\t}, this);\r\n\t},\r\n\r\n\t_setLayerStyle: function (layer, style) {\r\n\t\tif (typeof style === 'function') {\r\n\t\t\tstyle = style(layer.feature);\r\n\t\t}\r\n\t\tif (layer.setStyle) {\r\n\t\t\tlayer.setStyle(style);\r\n\t\t}\r\n\t}\r\n});\r\n\r\n// @section\r\n// There are several static functions which can be called without instantiating L.GeoJSON:\r\nL.extend(L.GeoJSON, {\r\n\t// @function geometryToLayer(featureData: Object, options?: GeoJSON options): Layer\r\n\t// Creates a `Layer` from a given GeoJSON feature. Can use a custom\r\n\t// [`pointToLayer`](#geojson-pointtolayer) and/or [`coordsToLatLng`](#geojson-coordstolatlng)\r\n\t// functions if provided as options.\r\n\tgeometryToLayer: function (geojson, options) {\r\n\r\n\t\tvar geometry = geojson.type === 'Feature' ? geojson.geometry : geojson,\r\n\t\t coords = geometry ? geometry.coordinates : null,\r\n\t\t layers = [],\r\n\t\t pointToLayer = options && options.pointToLayer,\r\n\t\t coordsToLatLng = options && options.coordsToLatLng || this.coordsToLatLng,\r\n\t\t latlng, latlngs, i, len;\r\n\r\n\t\tif (!coords && !geometry) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tswitch (geometry.type) {\r\n\t\tcase 'Point':\r\n\t\t\tlatlng = coordsToLatLng(coords);\r\n\t\t\treturn pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng);\r\n\r\n\t\tcase 'MultiPoint':\r\n\t\t\tfor (i = 0, len = coords.length; i < len; i++) {\r\n\t\t\t\tlatlng = coordsToLatLng(coords[i]);\r\n\t\t\t\tlayers.push(pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng));\r\n\t\t\t}\r\n\t\t\treturn new L.FeatureGroup(layers);\r\n\r\n\t\tcase 'LineString':\r\n\t\tcase 'MultiLineString':\r\n\t\t\tlatlngs = this.coordsToLatLngs(coords, geometry.type === 'LineString' ? 0 : 1, coordsToLatLng);\r\n\t\t\treturn new L.Polyline(latlngs, options);\r\n\r\n\t\tcase 'Polygon':\r\n\t\tcase 'MultiPolygon':\r\n\t\t\tlatlngs = this.coordsToLatLngs(coords, geometry.type === 'Polygon' ? 1 : 2, coordsToLatLng);\r\n\t\t\treturn new L.Polygon(latlngs, options);\r\n\r\n\t\tcase 'GeometryCollection':\r\n\t\t\tfor (i = 0, len = geometry.geometries.length; i < len; i++) {\r\n\t\t\t\tvar layer = this.geometryToLayer({\r\n\t\t\t\t\tgeometry: geometry.geometries[i],\r\n\t\t\t\t\ttype: 'Feature',\r\n\t\t\t\t\tproperties: geojson.properties\r\n\t\t\t\t}, options);\r\n\r\n\t\t\t\tif (layer) {\r\n\t\t\t\t\tlayers.push(layer);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn new L.FeatureGroup(layers);\r\n\r\n\t\tdefault:\r\n\t\t\tthrow new Error('Invalid GeoJSON object.');\r\n\t\t}\r\n\t},\r\n\r\n\t// @function coordsToLatLng(coords: Array): LatLng\r\n\t// Creates a `LatLng` object from an array of 2 numbers (longitude, latitude)\r\n\t// or 3 numbers (longitude, latitude, altitude) used in GeoJSON for points.\r\n\tcoordsToLatLng: function (coords) {\r\n\t\treturn new L.LatLng(coords[1], coords[0], coords[2]);\r\n\t},\r\n\r\n\t// @function coordsToLatLngs(coords: Array, levelsDeep?: Number, coordsToLatLng?: Function): Array\r\n\t// Creates a multidimensional array of `LatLng`s from a GeoJSON coordinates array.\r\n\t// `levelsDeep` specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default).\r\n\t// Can use a custom [`coordsToLatLng`](#geojson-coordstolatlng) function.\r\n\tcoordsToLatLngs: function (coords, levelsDeep, coordsToLatLng) {\r\n\t\tvar latlngs = [];\r\n\r\n\t\tfor (var i = 0, len = coords.length, latlng; i < len; i++) {\r\n\t\t\tlatlng = levelsDeep ?\r\n\t\t\t this.coordsToLatLngs(coords[i], levelsDeep - 1, coordsToLatLng) :\r\n\t\t\t (coordsToLatLng || this.coordsToLatLng)(coords[i]);\r\n\r\n\t\t\tlatlngs.push(latlng);\r\n\t\t}\r\n\r\n\t\treturn latlngs;\r\n\t},\r\n\r\n\t// @function latLngToCoords(latlng: LatLng): Array\r\n\t// Reverse of [`coordsToLatLng`](#geojson-coordstolatlng)\r\n\tlatLngToCoords: function (latlng) {\r\n\t\treturn latlng.alt !== undefined ?\r\n\t\t\t\t[latlng.lng, latlng.lat, latlng.alt] :\r\n\t\t\t\t[latlng.lng, latlng.lat];\r\n\t},\r\n\r\n\t// @function latLngsToCoords(latlngs: Array, levelsDeep?: Number, closed?: Boolean): Array\r\n\t// Reverse of [`coordsToLatLngs`](#geojson-coordstolatlngs)\r\n\t// `closed` determines whether the first point should be appended to the end of the array to close the feature, only used when `levelsDeep` is 0. False by default.\r\n\tlatLngsToCoords: function (latlngs, levelsDeep, closed) {\r\n\t\tvar coords = [];\r\n\r\n\t\tfor (var i = 0, len = latlngs.length; i < len; i++) {\r\n\t\t\tcoords.push(levelsDeep ?\r\n\t\t\t\tL.GeoJSON.latLngsToCoords(latlngs[i], levelsDeep - 1, closed) :\r\n\t\t\t\tL.GeoJSON.latLngToCoords(latlngs[i]));\r\n\t\t}\r\n\r\n\t\tif (!levelsDeep && closed) {\r\n\t\t\tcoords.push(coords[0]);\r\n\t\t}\r\n\r\n\t\treturn coords;\r\n\t},\r\n\r\n\tgetFeature: function (layer, newGeometry) {\r\n\t\treturn layer.feature ?\r\n\t\t\t\tL.extend({}, layer.feature, {geometry: newGeometry}) :\r\n\t\t\t\tL.GeoJSON.asFeature(newGeometry);\r\n\t},\r\n\r\n\t// @function asFeature(geojson: Object): Object\r\n\t// Normalize GeoJSON geometries/features into GeoJSON features.\r\n\tasFeature: function (geojson) {\r\n\t\tif (geojson.type === 'Feature' || geojson.type === 'FeatureCollection') {\r\n\t\t\treturn geojson;\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\ttype: 'Feature',\r\n\t\t\tproperties: {},\r\n\t\t\tgeometry: geojson\r\n\t\t};\r\n\t}\r\n});\r\n\r\nvar PointToGeoJSON = {\r\n\ttoGeoJSON: function () {\r\n\t\treturn L.GeoJSON.getFeature(this, {\r\n\t\t\ttype: 'Point',\r\n\t\t\tcoordinates: L.GeoJSON.latLngToCoords(this.getLatLng())\r\n\t\t});\r\n\t}\r\n};\r\n\r\n// @namespace Marker\r\n// @method toGeoJSON(): Object\r\n// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the marker (as a GeoJSON `Point` Feature).\r\nL.Marker.include(PointToGeoJSON);\r\n\r\n// @namespace CircleMarker\r\n// @method toGeoJSON(): Object\r\n// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the circle marker (as a GeoJSON `Point` Feature).\r\nL.Circle.include(PointToGeoJSON);\r\nL.CircleMarker.include(PointToGeoJSON);\r\n\r\n\r\n// @namespace Polyline\r\n// @method toGeoJSON(): Object\r\n// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the polyline (as a GeoJSON `LineString` or `MultiLineString` Feature).\r\nL.Polyline.prototype.toGeoJSON = function () {\r\n\tvar multi = !L.Polyline._flat(this._latlngs);\r\n\r\n\tvar coords = L.GeoJSON.latLngsToCoords(this._latlngs, multi ? 1 : 0);\r\n\r\n\treturn L.GeoJSON.getFeature(this, {\r\n\t\ttype: (multi ? 'Multi' : '') + 'LineString',\r\n\t\tcoordinates: coords\r\n\t});\r\n};\r\n\r\n// @namespace Polygon\r\n// @method toGeoJSON(): Object\r\n// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the polygon (as a GeoJSON `Polygon` or `MultiPolygon` Feature).\r\nL.Polygon.prototype.toGeoJSON = function () {\r\n\tvar holes = !L.Polyline._flat(this._latlngs),\r\n\t multi = holes && !L.Polyline._flat(this._latlngs[0]);\r\n\r\n\tvar coords = L.GeoJSON.latLngsToCoords(this._latlngs, multi ? 2 : holes ? 1 : 0, true);\r\n\r\n\tif (!holes) {\r\n\t\tcoords = [coords];\r\n\t}\r\n\r\n\treturn L.GeoJSON.getFeature(this, {\r\n\t\ttype: (multi ? 'Multi' : '') + 'Polygon',\r\n\t\tcoordinates: coords\r\n\t});\r\n};\r\n\r\n\r\n// @namespace LayerGroup\r\nL.LayerGroup.include({\r\n\ttoMultiPoint: function () {\r\n\t\tvar coords = [];\r\n\r\n\t\tthis.eachLayer(function (layer) {\r\n\t\t\tcoords.push(layer.toGeoJSON().geometry.coordinates);\r\n\t\t});\r\n\r\n\t\treturn L.GeoJSON.getFeature(this, {\r\n\t\t\ttype: 'MultiPoint',\r\n\t\t\tcoordinates: coords\r\n\t\t});\r\n\t},\r\n\r\n\t// @method toGeoJSON(): Object\r\n\t// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the layer group (as a GeoJSON `GeometryCollection`).\r\n\ttoGeoJSON: function () {\r\n\r\n\t\tvar type = this.feature && this.feature.geometry && this.feature.geometry.type;\r\n\r\n\t\tif (type === 'MultiPoint') {\r\n\t\t\treturn this.toMultiPoint();\r\n\t\t}\r\n\r\n\t\tvar isGeometryCollection = type === 'GeometryCollection',\r\n\t\t jsons = [];\r\n\r\n\t\tthis.eachLayer(function (layer) {\r\n\t\t\tif (layer.toGeoJSON) {\r\n\t\t\t\tvar json = layer.toGeoJSON();\r\n\t\t\t\tjsons.push(isGeometryCollection ? json.geometry : L.GeoJSON.asFeature(json));\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tif (isGeometryCollection) {\r\n\t\t\treturn L.GeoJSON.getFeature(this, {\r\n\t\t\t\tgeometries: jsons,\r\n\t\t\t\ttype: 'GeometryCollection'\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\ttype: 'FeatureCollection',\r\n\t\t\tfeatures: jsons\r\n\t\t};\r\n\t}\r\n});\r\n\r\n// @namespace GeoJSON\r\n// @factory L.geoJSON(geojson?: Object, options?: GeoJSON options)\r\n// Creates a GeoJSON layer. Optionally accepts an object in\r\n// [GeoJSON format](http://geojson.org/geojson-spec.html) to display on the map\r\n// (you can alternatively add it later with `addData` method) and an `options` object.\r\nL.geoJSON = function (geojson, options) {\r\n\treturn new L.GeoJSON(geojson, options);\r\n};\r\n// Backward compatibility.\r\nL.geoJson = L.geoJSON;\r\n","/*\r\n * @class Draggable\r\n * @aka L.Draggable\r\n * @inherits Evented\r\n *\r\n * A class for making DOM elements draggable (including touch support).\r\n * Used internally for map and marker dragging. Only works for elements\r\n * that were positioned with [`L.DomUtil.setPosition`](#domutil-setposition).\r\n *\r\n * @example\r\n * ```js\r\n * var draggable = new L.Draggable(elementToDrag);\r\n * draggable.enable();\r\n * ```\r\n */\r\n\r\nL.Draggable = L.Evented.extend({\r\n\r\n\toptions: {\r\n\t\t// @option clickTolerance: Number = 3\r\n\t\t// The max number of pixels a user can shift the mouse pointer during a click\r\n\t\t// for it to be considered a valid click (as opposed to a mouse drag).\r\n\t\tclickTolerance: 3\r\n\t},\r\n\r\n\tstatics: {\r\n\t\tSTART: L.Browser.touch ? ['touchstart', 'mousedown'] : ['mousedown'],\r\n\t\tEND: {\r\n\t\t\tmousedown: 'mouseup',\r\n\t\t\ttouchstart: 'touchend',\r\n\t\t\tpointerdown: 'touchend',\r\n\t\t\tMSPointerDown: 'touchend'\r\n\t\t},\r\n\t\tMOVE: {\r\n\t\t\tmousedown: 'mousemove',\r\n\t\t\ttouchstart: 'touchmove',\r\n\t\t\tpointerdown: 'touchmove',\r\n\t\t\tMSPointerDown: 'touchmove'\r\n\t\t}\r\n\t},\r\n\r\n\t// @constructor L.Draggable(el: HTMLElement, dragHandle?: HTMLElement, preventOutline: Boolean)\r\n\t// Creates a `Draggable` object for moving `el` when you start dragging the `dragHandle` element (equals `el` itself by default).\r\n\tinitialize: function (element, dragStartTarget, preventOutline) {\r\n\t\tthis._element = element;\r\n\t\tthis._dragStartTarget = dragStartTarget || element;\r\n\t\tthis._preventOutline = preventOutline;\r\n\t},\r\n\r\n\t// @method enable()\r\n\t// Enables the dragging ability\r\n\tenable: function () {\r\n\t\tif (this._enabled) { return; }\r\n\r\n\t\tL.DomEvent.on(this._dragStartTarget, L.Draggable.START.join(' '), this._onDown, this);\r\n\r\n\t\tthis._enabled = true;\r\n\t},\r\n\r\n\t// @method disable()\r\n\t// Disables the dragging ability\r\n\tdisable: function () {\r\n\t\tif (!this._enabled) { return; }\r\n\r\n\t\t// If we're currently dragging this draggable,\r\n\t\t// disabling it counts as first ending the drag.\r\n\t\tif (L.Draggable._dragging === this) {\r\n\t\t\tthis.finishDrag();\r\n\t\t}\r\n\r\n\t\tL.DomEvent.off(this._dragStartTarget, L.Draggable.START.join(' '), this._onDown, this);\r\n\r\n\t\tthis._enabled = false;\r\n\t\tthis._moved = false;\r\n\t},\r\n\r\n\t_onDown: function (e) {\r\n\t\t// Ignore simulated events, since we handle both touch and\r\n\t\t// mouse explicitly; otherwise we risk getting duplicates of\r\n\t\t// touch events, see #4315.\r\n\t\t// Also ignore the event if disabled; this happens in IE11\r\n\t\t// under some circumstances, see #3666.\r\n\t\tif (e._simulated || !this._enabled) { return; }\r\n\r\n\t\tthis._moved = false;\r\n\r\n\t\tif (L.DomUtil.hasClass(this._element, 'leaflet-zoom-anim')) { return; }\r\n\r\n\t\tif (L.Draggable._dragging || e.shiftKey || ((e.which !== 1) && (e.button !== 1) && !e.touches)) { return; }\r\n\t\tL.Draggable._dragging = this; // Prevent dragging multiple objects at once.\r\n\r\n\t\tif (this._preventOutline) {\r\n\t\t\tL.DomUtil.preventOutline(this._element);\r\n\t\t}\r\n\r\n\t\tL.DomUtil.disableImageDrag();\r\n\t\tL.DomUtil.disableTextSelection();\r\n\r\n\t\tif (this._moving) { return; }\r\n\r\n\t\t// @event down: Event\r\n\t\t// Fired when a drag is about to start.\r\n\t\tthis.fire('down');\r\n\r\n\t\tvar first = e.touches ? e.touches[0] : e;\r\n\r\n\t\tthis._startPoint = new L.Point(first.clientX, first.clientY);\r\n\r\n\t\tL.DomEvent\r\n\t\t\t.on(document, L.Draggable.MOVE[e.type], this._onMove, this)\r\n\t\t\t.on(document, L.Draggable.END[e.type], this._onUp, this);\r\n\t},\r\n\r\n\t_onMove: function (e) {\r\n\t\t// Ignore simulated events, since we handle both touch and\r\n\t\t// mouse explicitly; otherwise we risk getting duplicates of\r\n\t\t// touch events, see #4315.\r\n\t\t// Also ignore the event if disabled; this happens in IE11\r\n\t\t// under some circumstances, see #3666.\r\n\t\tif (e._simulated || !this._enabled) { return; }\r\n\r\n\t\tif (e.touches && e.touches.length > 1) {\r\n\t\t\tthis._moved = true;\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar first = (e.touches && e.touches.length === 1 ? e.touches[0] : e),\r\n\t\t newPoint = new L.Point(first.clientX, first.clientY),\r\n\t\t offset = newPoint.subtract(this._startPoint);\r\n\r\n\t\tif (!offset.x && !offset.y) { return; }\r\n\t\tif (Math.abs(offset.x) + Math.abs(offset.y) < this.options.clickTolerance) { return; }\r\n\r\n\t\tL.DomEvent.preventDefault(e);\r\n\r\n\t\tif (!this._moved) {\r\n\t\t\t// @event dragstart: Event\r\n\t\t\t// Fired when a drag starts\r\n\t\t\tthis.fire('dragstart');\r\n\r\n\t\t\tthis._moved = true;\r\n\t\t\tthis._startPos = L.DomUtil.getPosition(this._element).subtract(offset);\r\n\r\n\t\t\tL.DomUtil.addClass(document.body, 'leaflet-dragging');\r\n\r\n\t\t\tthis._lastTarget = e.target || e.srcElement;\r\n\t\t\t// IE and Edge do not give the element, so fetch it\r\n\t\t\t// if necessary\r\n\t\t\tif ((window.SVGElementInstance) && (this._lastTarget instanceof SVGElementInstance)) {\r\n\t\t\t\tthis._lastTarget = this._lastTarget.correspondingUseElement;\r\n\t\t\t}\r\n\t\t\tL.DomUtil.addClass(this._lastTarget, 'leaflet-drag-target');\r\n\t\t}\r\n\r\n\t\tthis._newPos = this._startPos.add(offset);\r\n\t\tthis._moving = true;\r\n\r\n\t\tL.Util.cancelAnimFrame(this._animRequest);\r\n\t\tthis._lastEvent = e;\r\n\t\tthis._animRequest = L.Util.requestAnimFrame(this._updatePosition, this, true);\r\n\t},\r\n\r\n\t_updatePosition: function () {\r\n\t\tvar e = {originalEvent: this._lastEvent};\r\n\r\n\t\t// @event predrag: Event\r\n\t\t// Fired continuously during dragging *before* each corresponding\r\n\t\t// update of the element's position.\r\n\t\tthis.fire('predrag', e);\r\n\t\tL.DomUtil.setPosition(this._element, this._newPos);\r\n\r\n\t\t// @event drag: Event\r\n\t\t// Fired continuously during dragging.\r\n\t\tthis.fire('drag', e);\r\n\t},\r\n\r\n\t_onUp: function (e) {\r\n\t\t// Ignore simulated events, since we handle both touch and\r\n\t\t// mouse explicitly; otherwise we risk getting duplicates of\r\n\t\t// touch events, see #4315.\r\n\t\t// Also ignore the event if disabled; this happens in IE11\r\n\t\t// under some circumstances, see #3666.\r\n\t\tif (e._simulated || !this._enabled) { return; }\r\n\t\tthis.finishDrag();\r\n\t},\r\n\r\n\tfinishDrag: function () {\r\n\t\tL.DomUtil.removeClass(document.body, 'leaflet-dragging');\r\n\r\n\t\tif (this._lastTarget) {\r\n\t\t\tL.DomUtil.removeClass(this._lastTarget, 'leaflet-drag-target');\r\n\t\t\tthis._lastTarget = null;\r\n\t\t}\r\n\r\n\t\tfor (var i in L.Draggable.MOVE) {\r\n\t\t\tL.DomEvent\r\n\t\t\t\t.off(document, L.Draggable.MOVE[i], this._onMove, this)\r\n\t\t\t\t.off(document, L.Draggable.END[i], this._onUp, this);\r\n\t\t}\r\n\r\n\t\tL.DomUtil.enableImageDrag();\r\n\t\tL.DomUtil.enableTextSelection();\r\n\r\n\t\tif (this._moved && this._moving) {\r\n\t\t\t// ensure drag is not fired after dragend\r\n\t\t\tL.Util.cancelAnimFrame(this._animRequest);\r\n\r\n\t\t\t// @event dragend: DragEndEvent\r\n\t\t\t// Fired when the drag ends.\r\n\t\t\tthis.fire('dragend', {\r\n\t\t\t\tdistance: this._newPos.distanceTo(this._startPos)\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tthis._moving = false;\r\n\t\tL.Draggable._dragging = false;\r\n\t}\r\n\r\n});\r\n","/*\n\tL.Handler is a base class for handler classes that are used internally to inject\n\tinteraction features like dragging to classes like Map and Marker.\n*/\n\n// @class Handler\n// @aka L.Handler\n// Abstract class for map interaction handlers\n\nL.Handler = L.Class.extend({\n\tinitialize: function (map) {\n\t\tthis._map = map;\n\t},\n\n\t// @method enable(): this\n\t// Enables the handler\n\tenable: function () {\n\t\tif (this._enabled) { return this; }\n\n\t\tthis._enabled = true;\n\t\tthis.addHooks();\n\t\treturn this;\n\t},\n\n\t// @method disable(): this\n\t// Disables the handler\n\tdisable: function () {\n\t\tif (!this._enabled) { return this; }\n\n\t\tthis._enabled = false;\n\t\tthis.removeHooks();\n\t\treturn this;\n\t},\n\n\t// @method enabled(): Boolean\n\t// Returns `true` if the handler is enabled\n\tenabled: function () {\n\t\treturn !!this._enabled;\n\t}\n\n\t// @section Extension methods\n\t// Classes inheriting from `Handler` must implement the two following methods:\n\t// @method addHooks()\n\t// Called when the handler is enabled, should add event hooks.\n\t// @method removeHooks()\n\t// Called when the handler is disabled, should remove the event hooks added previously.\n});\n","/*\n * L.Handler.MapDrag is used to make the map draggable (with panning inertia), enabled by default.\n */\n\n// @namespace Map\n// @section Interaction Options\nL.Map.mergeOptions({\n\t// @option dragging: Boolean = true\n\t// Whether the map be draggable with mouse/touch or not.\n\tdragging: true,\n\n\t// @section Panning Inertia Options\n\t// @option inertia: Boolean = *\n\t// If enabled, panning of the map will have an inertia effect where\n\t// the map builds momentum while dragging and continues moving in\n\t// the same direction for some time. Feels especially nice on touch\n\t// devices. Enabled by default unless running on old Android devices.\n\tinertia: !L.Browser.android23,\n\n\t// @option inertiaDeceleration: Number = 3000\n\t// The rate with which the inertial movement slows down, in pixels/second².\n\tinertiaDeceleration: 3400, // px/s^2\n\n\t// @option inertiaMaxSpeed: Number = Infinity\n\t// Max speed of the inertial movement, in pixels/second.\n\tinertiaMaxSpeed: Infinity, // px/s\n\n\t// @option easeLinearity: Number = 0.2\n\teaseLinearity: 0.2,\n\n\t// TODO refactor, move to CRS\n\t// @option worldCopyJump: Boolean = false\n\t// With this option enabled, the map tracks when you pan to another \"copy\"\n\t// of the world and seamlessly jumps to the original one so that all overlays\n\t// like markers and vector layers are still visible.\n\tworldCopyJump: false,\n\n\t// @option maxBoundsViscosity: Number = 0.0\n\t// If `maxBounds` is set, this option will control how solid the bounds\n\t// are when dragging the map around. The default value of `0.0` allows the\n\t// user to drag outside the bounds at normal speed, higher values will\n\t// slow down map dragging outside bounds, and `1.0` makes the bounds fully\n\t// solid, preventing the user from dragging outside the bounds.\n\tmaxBoundsViscosity: 0.0\n});\n\nL.Map.Drag = L.Handler.extend({\n\taddHooks: function () {\n\t\tif (!this._draggable) {\n\t\t\tvar map = this._map;\n\n\t\t\tthis._draggable = new L.Draggable(map._mapPane, map._container);\n\n\t\t\tthis._draggable.on({\n\t\t\t\tdown: this._onDown,\n\t\t\t\tdragstart: this._onDragStart,\n\t\t\t\tdrag: this._onDrag,\n\t\t\t\tdragend: this._onDragEnd\n\t\t\t}, this);\n\n\t\t\tthis._draggable.on('predrag', this._onPreDragLimit, this);\n\t\t\tif (map.options.worldCopyJump) {\n\t\t\t\tthis._draggable.on('predrag', this._onPreDragWrap, this);\n\t\t\t\tmap.on('zoomend', this._onZoomEnd, this);\n\n\t\t\t\tmap.whenReady(this._onZoomEnd, this);\n\t\t\t}\n\t\t}\n\t\tL.DomUtil.addClass(this._map._container, 'leaflet-grab leaflet-touch-drag');\n\t\tthis._draggable.enable();\n\t\tthis._positions = [];\n\t\tthis._times = [];\n\t},\n\n\tremoveHooks: function () {\n\t\tL.DomUtil.removeClass(this._map._container, 'leaflet-grab');\n\t\tL.DomUtil.removeClass(this._map._container, 'leaflet-touch-drag');\n\t\tthis._draggable.disable();\n\t},\n\n\tmoved: function () {\n\t\treturn this._draggable && this._draggable._moved;\n\t},\n\n\tmoving: function () {\n\t\treturn this._draggable && this._draggable._moving;\n\t},\n\n\t_onDown: function () {\n\t\tthis._map._stop();\n\t},\n\n\t_onDragStart: function () {\n\t\tvar map = this._map;\n\n\t\tif (this._map.options.maxBounds && this._map.options.maxBoundsViscosity) {\n\t\t\tvar bounds = L.latLngBounds(this._map.options.maxBounds);\n\n\t\t\tthis._offsetLimit = L.bounds(\n\t\t\t\tthis._map.latLngToContainerPoint(bounds.getNorthWest()).multiplyBy(-1),\n\t\t\t\tthis._map.latLngToContainerPoint(bounds.getSouthEast()).multiplyBy(-1)\n\t\t\t\t\t.add(this._map.getSize()));\n\n\t\t\tthis._viscosity = Math.min(1.0, Math.max(0.0, this._map.options.maxBoundsViscosity));\n\t\t} else {\n\t\t\tthis._offsetLimit = null;\n\t\t}\n\n\t\tmap\n\t\t .fire('movestart')\n\t\t .fire('dragstart');\n\n\t\tif (map.options.inertia) {\n\t\t\tthis._positions = [];\n\t\t\tthis._times = [];\n\t\t}\n\t},\n\n\t_onDrag: function (e) {\n\t\tif (this._map.options.inertia) {\n\t\t\tvar time = this._lastTime = +new Date(),\n\t\t\t pos = this._lastPos = this._draggable._absPos || this._draggable._newPos;\n\n\t\t\tthis._positions.push(pos);\n\t\t\tthis._times.push(time);\n\n\t\t\tif (time - this._times[0] > 50) {\n\t\t\t\tthis._positions.shift();\n\t\t\t\tthis._times.shift();\n\t\t\t}\n\t\t}\n\n\t\tthis._map\n\t\t .fire('move', e)\n\t\t .fire('drag', e);\n\t},\n\n\t_onZoomEnd: function () {\n\t\tvar pxCenter = this._map.getSize().divideBy(2),\n\t\t pxWorldCenter = this._map.latLngToLayerPoint([0, 0]);\n\n\t\tthis._initialWorldOffset = pxWorldCenter.subtract(pxCenter).x;\n\t\tthis._worldWidth = this._map.getPixelWorldBounds().getSize().x;\n\t},\n\n\t_viscousLimit: function (value, threshold) {\n\t\treturn value - (value - threshold) * this._viscosity;\n\t},\n\n\t_onPreDragLimit: function () {\n\t\tif (!this._viscosity || !this._offsetLimit) { return; }\n\n\t\tvar offset = this._draggable._newPos.subtract(this._draggable._startPos);\n\n\t\tvar limit = this._offsetLimit;\n\t\tif (offset.x < limit.min.x) { offset.x = this._viscousLimit(offset.x, limit.min.x); }\n\t\tif (offset.y < limit.min.y) { offset.y = this._viscousLimit(offset.y, limit.min.y); }\n\t\tif (offset.x > limit.max.x) { offset.x = this._viscousLimit(offset.x, limit.max.x); }\n\t\tif (offset.y > limit.max.y) { offset.y = this._viscousLimit(offset.y, limit.max.y); }\n\n\t\tthis._draggable._newPos = this._draggable._startPos.add(offset);\n\t},\n\n\t_onPreDragWrap: function () {\n\t\t// TODO refactor to be able to adjust map pane position after zoom\n\t\tvar worldWidth = this._worldWidth,\n\t\t halfWidth = Math.round(worldWidth / 2),\n\t\t dx = this._initialWorldOffset,\n\t\t x = this._draggable._newPos.x,\n\t\t newX1 = (x - halfWidth + dx) % worldWidth + halfWidth - dx,\n\t\t newX2 = (x + halfWidth + dx) % worldWidth - halfWidth - dx,\n\t\t newX = Math.abs(newX1 + dx) < Math.abs(newX2 + dx) ? newX1 : newX2;\n\n\t\tthis._draggable._absPos = this._draggable._newPos.clone();\n\t\tthis._draggable._newPos.x = newX;\n\t},\n\n\t_onDragEnd: function (e) {\n\t\tvar map = this._map,\n\t\t options = map.options,\n\n\t\t noInertia = !options.inertia || this._times.length < 2;\n\n\t\tmap.fire('dragend', e);\n\n\t\tif (noInertia) {\n\t\t\tmap.fire('moveend');\n\n\t\t} else {\n\n\t\t\tvar direction = this._lastPos.subtract(this._positions[0]),\n\t\t\t duration = (this._lastTime - this._times[0]) / 1000,\n\t\t\t ease = options.easeLinearity,\n\n\t\t\t speedVector = direction.multiplyBy(ease / duration),\n\t\t\t speed = speedVector.distanceTo([0, 0]),\n\n\t\t\t limitedSpeed = Math.min(options.inertiaMaxSpeed, speed),\n\t\t\t limitedSpeedVector = speedVector.multiplyBy(limitedSpeed / speed),\n\n\t\t\t decelerationDuration = limitedSpeed / (options.inertiaDeceleration * ease),\n\t\t\t offset = limitedSpeedVector.multiplyBy(-decelerationDuration / 2).round();\n\n\t\t\tif (!offset.x && !offset.y) {\n\t\t\t\tmap.fire('moveend');\n\n\t\t\t} else {\n\t\t\t\toffset = map._limitOffset(offset, map.options.maxBounds);\n\n\t\t\t\tL.Util.requestAnimFrame(function () {\n\t\t\t\t\tmap.panBy(offset, {\n\t\t\t\t\t\tduration: decelerationDuration,\n\t\t\t\t\t\teaseLinearity: ease,\n\t\t\t\t\t\tnoMoveStart: true,\n\t\t\t\t\t\tanimate: true\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n});\n\n// @section Handlers\n// @property dragging: Handler\n// Map dragging handler (by both mouse and touch).\nL.Map.addInitHook('addHandler', 'dragging', L.Map.Drag);\n","/*\n * L.Handler.DoubleClickZoom is used to handle double-click zoom on the map, enabled by default.\n */\n\n// @namespace Map\n// @section Interaction Options\n\nL.Map.mergeOptions({\n\t// @option doubleClickZoom: Boolean|String = true\n\t// Whether the map can be zoomed in by double clicking on it and\n\t// zoomed out by double clicking while holding shift. If passed\n\t// `'center'`, double-click zoom will zoom to the center of the\n\t// view regardless of where the mouse was.\n\tdoubleClickZoom: true\n});\n\nL.Map.DoubleClickZoom = L.Handler.extend({\n\taddHooks: function () {\n\t\tthis._map.on('dblclick', this._onDoubleClick, this);\n\t},\n\n\tremoveHooks: function () {\n\t\tthis._map.off('dblclick', this._onDoubleClick, this);\n\t},\n\n\t_onDoubleClick: function (e) {\n\t\tvar map = this._map,\n\t\t oldZoom = map.getZoom(),\n\t\t delta = map.options.zoomDelta,\n\t\t zoom = e.originalEvent.shiftKey ? oldZoom - delta : oldZoom + delta;\n\n\t\tif (map.options.doubleClickZoom === 'center') {\n\t\t\tmap.setZoom(zoom);\n\t\t} else {\n\t\t\tmap.setZoomAround(e.containerPoint, zoom);\n\t\t}\n\t}\n});\n\n// @section Handlers\n//\n// Map properties include interaction handlers that allow you to control\n// interaction behavior in runtime, enabling or disabling certain features such\n// as dragging or touch zoom (see `Handler` methods). For example:\n//\n// ```js\n// map.doubleClickZoom.disable();\n// ```\n//\n// @property doubleClickZoom: Handler\n// Double click zoom handler.\nL.Map.addInitHook('addHandler', 'doubleClickZoom', L.Map.DoubleClickZoom);\n","/*\n * L.Handler.ScrollWheelZoom is used by L.Map to enable mouse scroll wheel zoom on the map.\n */\n\n// @namespace Map\n// @section Interaction Options\nL.Map.mergeOptions({\n\t// @section Mousewheel options\n\t// @option scrollWheelZoom: Boolean|String = true\n\t// Whether the map can be zoomed by using the mouse wheel. If passed `'center'`,\n\t// it will zoom to the center of the view regardless of where the mouse was.\n\tscrollWheelZoom: true,\n\n\t// @option wheelDebounceTime: Number = 40\n\t// Limits the rate at which a wheel can fire (in milliseconds). By default\n\t// user can't zoom via wheel more often than once per 40 ms.\n\twheelDebounceTime: 40,\n\n\t// @option wheelPxPerZoomLevel: Number = 60\n\t// How many scroll pixels (as reported by [L.DomEvent.getWheelDelta](#domevent-getwheeldelta))\n\t// mean a change of one full zoom level. Smaller values will make wheel-zooming\n\t// faster (and vice versa).\n\twheelPxPerZoomLevel: 60\n});\n\nL.Map.ScrollWheelZoom = L.Handler.extend({\n\taddHooks: function () {\n\t\tL.DomEvent.on(this._map._container, 'mousewheel', this._onWheelScroll, this);\n\n\t\tthis._delta = 0;\n\t},\n\n\tremoveHooks: function () {\n\t\tL.DomEvent.off(this._map._container, 'mousewheel', this._onWheelScroll, this);\n\t},\n\n\t_onWheelScroll: function (e) {\n\t\tvar delta = L.DomEvent.getWheelDelta(e);\n\n\t\tvar debounce = this._map.options.wheelDebounceTime;\n\n\t\tthis._delta += delta;\n\t\tthis._lastMousePos = this._map.mouseEventToContainerPoint(e);\n\n\t\tif (!this._startTime) {\n\t\t\tthis._startTime = +new Date();\n\t\t}\n\n\t\tvar left = Math.max(debounce - (+new Date() - this._startTime), 0);\n\n\t\tclearTimeout(this._timer);\n\t\tthis._timer = setTimeout(L.bind(this._performZoom, this), left);\n\n\t\tL.DomEvent.stop(e);\n\t},\n\n\t_performZoom: function () {\n\t\tvar map = this._map,\n\t\t zoom = map.getZoom(),\n\t\t snap = this._map.options.zoomSnap || 0;\n\n\t\tmap._stop(); // stop panning and fly animations if any\n\n\t\t// map the delta with a sigmoid function to -4..4 range leaning on -1..1\n\t\tvar d2 = this._delta / (this._map.options.wheelPxPerZoomLevel * 4),\n\t\t d3 = 4 * Math.log(2 / (1 + Math.exp(-Math.abs(d2)))) / Math.LN2,\n\t\t d4 = snap ? Math.ceil(d3 / snap) * snap : d3,\n\t\t delta = map._limitZoom(zoom + (this._delta > 0 ? d4 : -d4)) - zoom;\n\n\t\tthis._delta = 0;\n\t\tthis._startTime = null;\n\n\t\tif (!delta) { return; }\n\n\t\tif (map.options.scrollWheelZoom === 'center') {\n\t\t\tmap.setZoom(zoom + delta);\n\t\t} else {\n\t\t\tmap.setZoomAround(this._lastMousePos, zoom + delta);\n\t\t}\n\t}\n});\n\n// @section Handlers\n// @property scrollWheelZoom: Handler\n// Scroll wheel zoom handler.\nL.Map.addInitHook('addHandler', 'scrollWheelZoom', L.Map.ScrollWheelZoom);\n","/*\r\n * Extends the event handling code with double tap support for mobile browsers.\r\n */\r\n\r\nL.extend(L.DomEvent, {\r\n\r\n\t_touchstart: L.Browser.msPointer ? 'MSPointerDown' : L.Browser.pointer ? 'pointerdown' : 'touchstart',\r\n\t_touchend: L.Browser.msPointer ? 'MSPointerUp' : L.Browser.pointer ? 'pointerup' : 'touchend',\r\n\r\n\t// inspired by Zepto touch code by Thomas Fuchs\r\n\taddDoubleTapListener: function (obj, handler, id) {\r\n\t\tvar last, touch,\r\n\t\t doubleTap = false,\r\n\t\t delay = 250;\r\n\r\n\t\tfunction onTouchStart(e) {\r\n\t\t\tvar count;\r\n\r\n\t\t\tif (L.Browser.pointer) {\r\n\t\t\t\tcount = L.DomEvent._pointersCount;\r\n\t\t\t} else {\r\n\t\t\t\tcount = e.touches.length;\r\n\t\t\t}\r\n\r\n\t\t\tif (count > 1) { return; }\r\n\r\n\t\t\tvar now = Date.now(),\r\n\t\t\t delta = now - (last || now);\r\n\r\n\t\t\ttouch = e.touches ? e.touches[0] : e;\r\n\t\t\tdoubleTap = (delta > 0 && delta <= delay);\r\n\t\t\tlast = now;\r\n\t\t}\r\n\r\n\t\tfunction onTouchEnd() {\r\n\t\t\tif (doubleTap && !touch.cancelBubble) {\r\n\t\t\t\tif (L.Browser.pointer) {\r\n\t\t\t\t\t// work around .type being readonly with MSPointer* events\r\n\t\t\t\t\tvar newTouch = {},\r\n\t\t\t\t\t prop, i;\r\n\r\n\t\t\t\t\tfor (i in touch) {\r\n\t\t\t\t\t\tprop = touch[i];\r\n\t\t\t\t\t\tnewTouch[i] = prop && prop.bind ? prop.bind(touch) : prop;\r\n\t\t\t\t\t}\r\n\t\t\t\t\ttouch = newTouch;\r\n\t\t\t\t}\r\n\t\t\t\ttouch.type = 'dblclick';\r\n\t\t\t\thandler(touch);\r\n\t\t\t\tlast = null;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tvar pre = '_leaflet_',\r\n\t\t touchstart = this._touchstart,\r\n\t\t touchend = this._touchend;\r\n\r\n\t\tobj[pre + touchstart + id] = onTouchStart;\r\n\t\tobj[pre + touchend + id] = onTouchEnd;\r\n\t\tobj[pre + 'dblclick' + id] = handler;\r\n\r\n\t\tobj.addEventListener(touchstart, onTouchStart, false);\r\n\t\tobj.addEventListener(touchend, onTouchEnd, false);\r\n\r\n\t\t// On some platforms (notably, chrome on win10 + touchscreen + mouse),\r\n\t\t// the browser doesn't fire touchend/pointerup events but does fire\r\n\t\t// native dblclicks. See #4127.\r\n\t\tif (!L.Browser.edge) {\r\n\t\t\tobj.addEventListener('dblclick', handler, false);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\tremoveDoubleTapListener: function (obj, id) {\r\n\t\tvar pre = '_leaflet_',\r\n\t\t touchstart = obj[pre + this._touchstart + id],\r\n\t\t touchend = obj[pre + this._touchend + id],\r\n\t\t dblclick = obj[pre + 'dblclick' + id];\r\n\r\n\t\tobj.removeEventListener(this._touchstart, touchstart, false);\r\n\t\tobj.removeEventListener(this._touchend, touchend, false);\r\n\t\tif (!L.Browser.edge) {\r\n\t\t\tobj.removeEventListener('dblclick', dblclick, false);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t}\r\n});\r\n","/*\n * Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices.\n */\n\nL.extend(L.DomEvent, {\n\n\tPOINTER_DOWN: L.Browser.msPointer ? 'MSPointerDown' : 'pointerdown',\n\tPOINTER_MOVE: L.Browser.msPointer ? 'MSPointerMove' : 'pointermove',\n\tPOINTER_UP: L.Browser.msPointer ? 'MSPointerUp' : 'pointerup',\n\tPOINTER_CANCEL: L.Browser.msPointer ? 'MSPointerCancel' : 'pointercancel',\n\tTAG_WHITE_LIST: ['INPUT', 'SELECT', 'OPTION'],\n\n\t_pointers: {},\n\t_pointersCount: 0,\n\n\t// Provides a touch events wrapper for (ms)pointer events.\n\t// ref http://www.w3.org/TR/pointerevents/ https://www.w3.org/Bugs/Public/show_bug.cgi?id=22890\n\n\taddPointerListener: function (obj, type, handler, id) {\n\n\t\tif (type === 'touchstart') {\n\t\t\tthis._addPointerStart(obj, handler, id);\n\n\t\t} else if (type === 'touchmove') {\n\t\t\tthis._addPointerMove(obj, handler, id);\n\n\t\t} else if (type === 'touchend') {\n\t\t\tthis._addPointerEnd(obj, handler, id);\n\t\t}\n\n\t\treturn this;\n\t},\n\n\tremovePointerListener: function (obj, type, id) {\n\t\tvar handler = obj['_leaflet_' + type + id];\n\n\t\tif (type === 'touchstart') {\n\t\t\tobj.removeEventListener(this.POINTER_DOWN, handler, false);\n\n\t\t} else if (type === 'touchmove') {\n\t\t\tobj.removeEventListener(this.POINTER_MOVE, handler, false);\n\n\t\t} else if (type === 'touchend') {\n\t\t\tobj.removeEventListener(this.POINTER_UP, handler, false);\n\t\t\tobj.removeEventListener(this.POINTER_CANCEL, handler, false);\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t_addPointerStart: function (obj, handler, id) {\n\t\tvar onDown = L.bind(function (e) {\n\t\t\tif (e.pointerType !== 'mouse' && e.pointerType !== e.MSPOINTER_TYPE_MOUSE) {\n\t\t\t\t// In IE11, some touch events needs to fire for form controls, or\n\t\t\t\t// the controls will stop working. We keep a whitelist of tag names that\n\t\t\t\t// need these events. For other target tags, we prevent default on the event.\n\t\t\t\tif (this.TAG_WHITE_LIST.indexOf(e.target.tagName) < 0) {\n\t\t\t\t\tL.DomEvent.preventDefault(e);\n\t\t\t\t} else {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._handlePointer(e, handler);\n\t\t}, this);\n\n\t\tobj['_leaflet_touchstart' + id] = onDown;\n\t\tobj.addEventListener(this.POINTER_DOWN, onDown, false);\n\n\t\t// need to keep track of what pointers and how many are active to provide e.touches emulation\n\t\tif (!this._pointerDocListener) {\n\t\t\tvar pointerUp = L.bind(this._globalPointerUp, this);\n\n\t\t\t// we listen documentElement as any drags that end by moving the touch off the screen get fired there\n\t\t\tdocument.documentElement.addEventListener(this.POINTER_DOWN, L.bind(this._globalPointerDown, this), true);\n\t\t\tdocument.documentElement.addEventListener(this.POINTER_MOVE, L.bind(this._globalPointerMove, this), true);\n\t\t\tdocument.documentElement.addEventListener(this.POINTER_UP, pointerUp, true);\n\t\t\tdocument.documentElement.addEventListener(this.POINTER_CANCEL, pointerUp, true);\n\n\t\t\tthis._pointerDocListener = true;\n\t\t}\n\t},\n\n\t_globalPointerDown: function (e) {\n\t\tthis._pointers[e.pointerId] = e;\n\t\tthis._pointersCount++;\n\t},\n\n\t_globalPointerMove: function (e) {\n\t\tif (this._pointers[e.pointerId]) {\n\t\t\tthis._pointers[e.pointerId] = e;\n\t\t}\n\t},\n\n\t_globalPointerUp: function (e) {\n\t\tdelete this._pointers[e.pointerId];\n\t\tthis._pointersCount--;\n\t},\n\n\t_handlePointer: function (e, handler) {\n\t\te.touches = [];\n\t\tfor (var i in this._pointers) {\n\t\t\te.touches.push(this._pointers[i]);\n\t\t}\n\t\te.changedTouches = [e];\n\n\t\thandler(e);\n\t},\n\n\t_addPointerMove: function (obj, handler, id) {\n\t\tvar onMove = L.bind(function (e) {\n\t\t\t// don't fire touch moves when mouse isn't down\n\t\t\tif ((e.pointerType === e.MSPOINTER_TYPE_MOUSE || e.pointerType === 'mouse') && e.buttons === 0) { return; }\n\n\t\t\tthis._handlePointer(e, handler);\n\t\t}, this);\n\n\t\tobj['_leaflet_touchmove' + id] = onMove;\n\t\tobj.addEventListener(this.POINTER_MOVE, onMove, false);\n\t},\n\n\t_addPointerEnd: function (obj, handler, id) {\n\t\tvar onUp = L.bind(function (e) {\n\t\t\tthis._handlePointer(e, handler);\n\t\t}, this);\n\n\t\tobj['_leaflet_touchend' + id] = onUp;\n\t\tobj.addEventListener(this.POINTER_UP, onUp, false);\n\t\tobj.addEventListener(this.POINTER_CANCEL, onUp, false);\n\t}\n});\n","/*\n * L.Handler.TouchZoom is used by L.Map to add pinch zoom on supported mobile browsers.\n */\n\n// @namespace Map\n// @section Interaction Options\nL.Map.mergeOptions({\n\t// @section Touch interaction options\n\t// @option touchZoom: Boolean|String = *\n\t// Whether the map can be zoomed by touch-dragging with two fingers. If\n\t// passed `'center'`, it will zoom to the center of the view regardless of\n\t// where the touch events (fingers) were. Enabled for touch-capable web\n\t// browsers except for old Androids.\n\ttouchZoom: L.Browser.touch && !L.Browser.android23,\n\n\t// @option bounceAtZoomLimits: Boolean = true\n\t// Set it to false if you don't want the map to zoom beyond min/max zoom\n\t// and then bounce back when pinch-zooming.\n\tbounceAtZoomLimits: true\n});\n\nL.Map.TouchZoom = L.Handler.extend({\n\taddHooks: function () {\n\t\tL.DomUtil.addClass(this._map._container, 'leaflet-touch-zoom');\n\t\tL.DomEvent.on(this._map._container, 'touchstart', this._onTouchStart, this);\n\t},\n\n\tremoveHooks: function () {\n\t\tL.DomUtil.removeClass(this._map._container, 'leaflet-touch-zoom');\n\t\tL.DomEvent.off(this._map._container, 'touchstart', this._onTouchStart, this);\n\t},\n\n\t_onTouchStart: function (e) {\n\t\tvar map = this._map;\n\t\tif (!e.touches || e.touches.length !== 2 || map._animatingZoom || this._zooming) { return; }\n\n\t\tvar p1 = map.mouseEventToContainerPoint(e.touches[0]),\n\t\t p2 = map.mouseEventToContainerPoint(e.touches[1]);\n\n\t\tthis._centerPoint = map.getSize()._divideBy(2);\n\t\tthis._startLatLng = map.containerPointToLatLng(this._centerPoint);\n\t\tif (map.options.touchZoom !== 'center') {\n\t\t\tthis._pinchStartLatLng = map.containerPointToLatLng(p1.add(p2)._divideBy(2));\n\t\t}\n\n\t\tthis._startDist = p1.distanceTo(p2);\n\t\tthis._startZoom = map.getZoom();\n\n\t\tthis._moved = false;\n\t\tthis._zooming = true;\n\n\t\tmap._stop();\n\n\t\tL.DomEvent\n\t\t .on(document, 'touchmove', this._onTouchMove, this)\n\t\t .on(document, 'touchend', this._onTouchEnd, this);\n\n\t\tL.DomEvent.preventDefault(e);\n\t},\n\n\t_onTouchMove: function (e) {\n\t\tif (!e.touches || e.touches.length !== 2 || !this._zooming) { return; }\n\n\t\tvar map = this._map,\n\t\t p1 = map.mouseEventToContainerPoint(e.touches[0]),\n\t\t p2 = map.mouseEventToContainerPoint(e.touches[1]),\n\t\t scale = p1.distanceTo(p2) / this._startDist;\n\n\n\t\tthis._zoom = map.getScaleZoom(scale, this._startZoom);\n\n\t\tif (!map.options.bounceAtZoomLimits && (\n\t\t\t(this._zoom < map.getMinZoom() && scale < 1) ||\n\t\t\t(this._zoom > map.getMaxZoom() && scale > 1))) {\n\t\t\tthis._zoom = map._limitZoom(this._zoom);\n\t\t}\n\n\t\tif (map.options.touchZoom === 'center') {\n\t\t\tthis._center = this._startLatLng;\n\t\t\tif (scale === 1) { return; }\n\t\t} else {\n\t\t\t// Get delta from pinch to center, so centerLatLng is delta applied to initial pinchLatLng\n\t\t\tvar delta = p1._add(p2)._divideBy(2)._subtract(this._centerPoint);\n\t\t\tif (scale === 1 && delta.x === 0 && delta.y === 0) { return; }\n\t\t\tthis._center = map.unproject(map.project(this._pinchStartLatLng, this._zoom).subtract(delta), this._zoom);\n\t\t}\n\n\t\tif (!this._moved) {\n\t\t\tmap._moveStart(true);\n\t\t\tthis._moved = true;\n\t\t}\n\n\t\tL.Util.cancelAnimFrame(this._animRequest);\n\n\t\tvar moveFn = L.bind(map._move, map, this._center, this._zoom, {pinch: true, round: false});\n\t\tthis._animRequest = L.Util.requestAnimFrame(moveFn, this, true);\n\n\t\tL.DomEvent.preventDefault(e);\n\t},\n\n\t_onTouchEnd: function () {\n\t\tif (!this._moved || !this._zooming) {\n\t\t\tthis._zooming = false;\n\t\t\treturn;\n\t\t}\n\n\t\tthis._zooming = false;\n\t\tL.Util.cancelAnimFrame(this._animRequest);\n\n\t\tL.DomEvent\n\t\t .off(document, 'touchmove', this._onTouchMove)\n\t\t .off(document, 'touchend', this._onTouchEnd);\n\n\t\t// Pinch updates GridLayers' levels only when zoomSnap is off, so zoomSnap becomes noUpdate.\n\t\tif (this._map.options.zoomAnimation) {\n\t\t\tthis._map._animateZoom(this._center, this._map._limitZoom(this._zoom), true, this._map.options.zoomSnap);\n\t\t} else {\n\t\t\tthis._map._resetView(this._center, this._map._limitZoom(this._zoom));\n\t\t}\n\t}\n});\n\n// @section Handlers\n// @property touchZoom: Handler\n// Touch zoom handler.\nL.Map.addInitHook('addHandler', 'touchZoom', L.Map.TouchZoom);\n","/*\n * L.Map.Tap is used to enable mobile hacks like quick taps and long hold.\n */\n\n// @namespace Map\n// @section Interaction Options\nL.Map.mergeOptions({\n\t// @section Touch interaction options\n\t// @option tap: Boolean = true\n\t// Enables mobile hacks for supporting instant taps (fixing 200ms click\n\t// delay on iOS/Android) and touch holds (fired as `contextmenu` events).\n\ttap: true,\n\n\t// @option tapTolerance: Number = 15\n\t// The max number of pixels a user can shift his finger during touch\n\t// for it to be considered a valid tap.\n\ttapTolerance: 15\n});\n\nL.Map.Tap = L.Handler.extend({\n\taddHooks: function () {\n\t\tL.DomEvent.on(this._map._container, 'touchstart', this._onDown, this);\n\t},\n\n\tremoveHooks: function () {\n\t\tL.DomEvent.off(this._map._container, 'touchstart', this._onDown, this);\n\t},\n\n\t_onDown: function (e) {\n\t\tif (!e.touches) { return; }\n\n\t\tL.DomEvent.preventDefault(e);\n\n\t\tthis._fireClick = true;\n\n\t\t// don't simulate click or track longpress if more than 1 touch\n\t\tif (e.touches.length > 1) {\n\t\t\tthis._fireClick = false;\n\t\t\tclearTimeout(this._holdTimeout);\n\t\t\treturn;\n\t\t}\n\n\t\tvar first = e.touches[0],\n\t\t el = first.target;\n\n\t\tthis._startPos = this._newPos = new L.Point(first.clientX, first.clientY);\n\n\t\t// if touching a link, highlight it\n\t\tif (el.tagName && el.tagName.toLowerCase() === 'a') {\n\t\t\tL.DomUtil.addClass(el, 'leaflet-active');\n\t\t}\n\n\t\t// simulate long hold but setting a timeout\n\t\tthis._holdTimeout = setTimeout(L.bind(function () {\n\t\t\tif (this._isTapValid()) {\n\t\t\t\tthis._fireClick = false;\n\t\t\t\tthis._onUp();\n\t\t\t\tthis._simulateEvent('contextmenu', first);\n\t\t\t}\n\t\t}, this), 1000);\n\n\t\tthis._simulateEvent('mousedown', first);\n\n\t\tL.DomEvent.on(document, {\n\t\t\ttouchmove: this._onMove,\n\t\t\ttouchend: this._onUp\n\t\t}, this);\n\t},\n\n\t_onUp: function (e) {\n\t\tclearTimeout(this._holdTimeout);\n\n\t\tL.DomEvent.off(document, {\n\t\t\ttouchmove: this._onMove,\n\t\t\ttouchend: this._onUp\n\t\t}, this);\n\n\t\tif (this._fireClick && e && e.changedTouches) {\n\n\t\t\tvar first = e.changedTouches[0],\n\t\t\t el = first.target;\n\n\t\t\tif (el && el.tagName && el.tagName.toLowerCase() === 'a') {\n\t\t\t\tL.DomUtil.removeClass(el, 'leaflet-active');\n\t\t\t}\n\n\t\t\tthis._simulateEvent('mouseup', first);\n\n\t\t\t// simulate click if the touch didn't move too much\n\t\t\tif (this._isTapValid()) {\n\t\t\t\tthis._simulateEvent('click', first);\n\t\t\t}\n\t\t}\n\t},\n\n\t_isTapValid: function () {\n\t\treturn this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance;\n\t},\n\n\t_onMove: function (e) {\n\t\tvar first = e.touches[0];\n\t\tthis._newPos = new L.Point(first.clientX, first.clientY);\n\t\tthis._simulateEvent('mousemove', first);\n\t},\n\n\t_simulateEvent: function (type, e) {\n\t\tvar simulatedEvent = document.createEvent('MouseEvents');\n\n\t\tsimulatedEvent._simulated = true;\n\t\te.target._simulatedClick = true;\n\n\t\tsimulatedEvent.initMouseEvent(\n\t\t type, true, true, window, 1,\n\t\t e.screenX, e.screenY,\n\t\t e.clientX, e.clientY,\n\t\t false, false, false, false, 0, null);\n\n\t\te.target.dispatchEvent(simulatedEvent);\n\t}\n});\n\n// @section Handlers\n// @property tap: Handler\n// Mobile touch hacks (quick tap and touch hold) handler.\nif (L.Browser.touch && !L.Browser.pointer) {\n\tL.Map.addInitHook('addHandler', 'tap', L.Map.Tap);\n}\n","/*\n * L.Handler.BoxZoom is used to add shift-drag zoom interaction to the map\n * (zoom to a selected bounding box), enabled by default.\n */\n\n// @namespace Map\n// @section Interaction Options\nL.Map.mergeOptions({\n\t// @option boxZoom: Boolean = true\n\t// Whether the map can be zoomed to a rectangular area specified by\n\t// dragging the mouse while pressing the shift key.\n\tboxZoom: true\n});\n\nL.Map.BoxZoom = L.Handler.extend({\n\tinitialize: function (map) {\n\t\tthis._map = map;\n\t\tthis._container = map._container;\n\t\tthis._pane = map._panes.overlayPane;\n\t},\n\n\taddHooks: function () {\n\t\tL.DomEvent.on(this._container, 'mousedown', this._onMouseDown, this);\n\t},\n\n\tremoveHooks: function () {\n\t\tL.DomEvent.off(this._container, 'mousedown', this._onMouseDown, this);\n\t},\n\n\tmoved: function () {\n\t\treturn this._moved;\n\t},\n\n\t_resetState: function () {\n\t\tthis._moved = false;\n\t},\n\n\t_onMouseDown: function (e) {\n\t\tif (!e.shiftKey || ((e.which !== 1) && (e.button !== 1))) { return false; }\n\n\t\tthis._resetState();\n\n\t\tL.DomUtil.disableTextSelection();\n\t\tL.DomUtil.disableImageDrag();\n\n\t\tthis._startPoint = this._map.mouseEventToContainerPoint(e);\n\n\t\tL.DomEvent.on(document, {\n\t\t\tcontextmenu: L.DomEvent.stop,\n\t\t\tmousemove: this._onMouseMove,\n\t\t\tmouseup: this._onMouseUp,\n\t\t\tkeydown: this._onKeyDown\n\t\t}, this);\n\t},\n\n\t_onMouseMove: function (e) {\n\t\tif (!this._moved) {\n\t\t\tthis._moved = true;\n\n\t\t\tthis._box = L.DomUtil.create('div', 'leaflet-zoom-box', this._container);\n\t\t\tL.DomUtil.addClass(this._container, 'leaflet-crosshair');\n\n\t\t\tthis._map.fire('boxzoomstart');\n\t\t}\n\n\t\tthis._point = this._map.mouseEventToContainerPoint(e);\n\n\t\tvar bounds = new L.Bounds(this._point, this._startPoint),\n\t\t size = bounds.getSize();\n\n\t\tL.DomUtil.setPosition(this._box, bounds.min);\n\n\t\tthis._box.style.width = size.x + 'px';\n\t\tthis._box.style.height = size.y + 'px';\n\t},\n\n\t_finish: function () {\n\t\tif (this._moved) {\n\t\t\tL.DomUtil.remove(this._box);\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-crosshair');\n\t\t}\n\n\t\tL.DomUtil.enableTextSelection();\n\t\tL.DomUtil.enableImageDrag();\n\n\t\tL.DomEvent.off(document, {\n\t\t\tcontextmenu: L.DomEvent.stop,\n\t\t\tmousemove: this._onMouseMove,\n\t\t\tmouseup: this._onMouseUp,\n\t\t\tkeydown: this._onKeyDown\n\t\t}, this);\n\t},\n\n\t_onMouseUp: function (e) {\n\t\tif ((e.which !== 1) && (e.button !== 1)) { return; }\n\n\t\tthis._finish();\n\n\t\tif (!this._moved) { return; }\n\t\t// Postpone to next JS tick so internal click event handling\n\t\t// still see it as \"moved\".\n\t\tsetTimeout(L.bind(this._resetState, this), 0);\n\n\t\tvar bounds = new L.LatLngBounds(\n\t\t this._map.containerPointToLatLng(this._startPoint),\n\t\t this._map.containerPointToLatLng(this._point));\n\n\t\tthis._map\n\t\t\t.fitBounds(bounds)\n\t\t\t.fire('boxzoomend', {boxZoomBounds: bounds});\n\t},\n\n\t_onKeyDown: function (e) {\n\t\tif (e.keyCode === 27) {\n\t\t\tthis._finish();\n\t\t}\n\t}\n});\n\n// @section Handlers\n// @property boxZoom: Handler\n// Box (shift-drag with mouse) zoom handler.\nL.Map.addInitHook('addHandler', 'boxZoom', L.Map.BoxZoom);\n","/*\n * L.Map.Keyboard is handling keyboard interaction with the map, enabled by default.\n */\n\n// @namespace Map\n// @section Keyboard Navigation Options\nL.Map.mergeOptions({\n\t// @option keyboard: Boolean = true\n\t// Makes the map focusable and allows users to navigate the map with keyboard\n\t// arrows and `+`/`-` keys.\n\tkeyboard: true,\n\n\t// @option keyboardPanDelta: Number = 80\n\t// Amount of pixels to pan when pressing an arrow key.\n\tkeyboardPanDelta: 80\n});\n\nL.Map.Keyboard = L.Handler.extend({\n\n\tkeyCodes: {\n\t\tleft: [37],\n\t\tright: [39],\n\t\tdown: [40],\n\t\tup: [38],\n\t\tzoomIn: [187, 107, 61, 171],\n\t\tzoomOut: [189, 109, 54, 173]\n\t},\n\n\tinitialize: function (map) {\n\t\tthis._map = map;\n\n\t\tthis._setPanDelta(map.options.keyboardPanDelta);\n\t\tthis._setZoomDelta(map.options.zoomDelta);\n\t},\n\n\taddHooks: function () {\n\t\tvar container = this._map._container;\n\n\t\t// make the container focusable by tabbing\n\t\tif (container.tabIndex <= 0) {\n\t\t\tcontainer.tabIndex = '0';\n\t\t}\n\n\t\tL.DomEvent.on(container, {\n\t\t\tfocus: this._onFocus,\n\t\t\tblur: this._onBlur,\n\t\t\tmousedown: this._onMouseDown\n\t\t}, this);\n\n\t\tthis._map.on({\n\t\t\tfocus: this._addHooks,\n\t\t\tblur: this._removeHooks\n\t\t}, this);\n\t},\n\n\tremoveHooks: function () {\n\t\tthis._removeHooks();\n\n\t\tL.DomEvent.off(this._map._container, {\n\t\t\tfocus: this._onFocus,\n\t\t\tblur: this._onBlur,\n\t\t\tmousedown: this._onMouseDown\n\t\t}, this);\n\n\t\tthis._map.off({\n\t\t\tfocus: this._addHooks,\n\t\t\tblur: this._removeHooks\n\t\t}, this);\n\t},\n\n\t_onMouseDown: function () {\n\t\tif (this._focused) { return; }\n\n\t\tvar body = document.body,\n\t\t docEl = document.documentElement,\n\t\t top = body.scrollTop || docEl.scrollTop,\n\t\t left = body.scrollLeft || docEl.scrollLeft;\n\n\t\tthis._map._container.focus();\n\n\t\twindow.scrollTo(left, top);\n\t},\n\n\t_onFocus: function () {\n\t\tthis._focused = true;\n\t\tthis._map.fire('focus');\n\t},\n\n\t_onBlur: function () {\n\t\tthis._focused = false;\n\t\tthis._map.fire('blur');\n\t},\n\n\t_setPanDelta: function (panDelta) {\n\t\tvar keys = this._panKeys = {},\n\t\t codes = this.keyCodes,\n\t\t i, len;\n\n\t\tfor (i = 0, len = codes.left.length; i < len; i++) {\n\t\t\tkeys[codes.left[i]] = [-1 * panDelta, 0];\n\t\t}\n\t\tfor (i = 0, len = codes.right.length; i < len; i++) {\n\t\t\tkeys[codes.right[i]] = [panDelta, 0];\n\t\t}\n\t\tfor (i = 0, len = codes.down.length; i < len; i++) {\n\t\t\tkeys[codes.down[i]] = [0, panDelta];\n\t\t}\n\t\tfor (i = 0, len = codes.up.length; i < len; i++) {\n\t\t\tkeys[codes.up[i]] = [0, -1 * panDelta];\n\t\t}\n\t},\n\n\t_setZoomDelta: function (zoomDelta) {\n\t\tvar keys = this._zoomKeys = {},\n\t\t codes = this.keyCodes,\n\t\t i, len;\n\n\t\tfor (i = 0, len = codes.zoomIn.length; i < len; i++) {\n\t\t\tkeys[codes.zoomIn[i]] = zoomDelta;\n\t\t}\n\t\tfor (i = 0, len = codes.zoomOut.length; i < len; i++) {\n\t\t\tkeys[codes.zoomOut[i]] = -zoomDelta;\n\t\t}\n\t},\n\n\t_addHooks: function () {\n\t\tL.DomEvent.on(document, 'keydown', this._onKeyDown, this);\n\t},\n\n\t_removeHooks: function () {\n\t\tL.DomEvent.off(document, 'keydown', this._onKeyDown, this);\n\t},\n\n\t_onKeyDown: function (e) {\n\t\tif (e.altKey || e.ctrlKey || e.metaKey) { return; }\n\n\t\tvar key = e.keyCode,\n\t\t map = this._map,\n\t\t offset;\n\n\t\tif (key in this._panKeys) {\n\n\t\t\tif (map._panAnim && map._panAnim._inProgress) { return; }\n\n\t\t\toffset = this._panKeys[key];\n\t\t\tif (e.shiftKey) {\n\t\t\t\toffset = L.point(offset).multiplyBy(3);\n\t\t\t}\n\n\t\t\tmap.panBy(offset);\n\n\t\t\tif (map.options.maxBounds) {\n\t\t\t\tmap.panInsideBounds(map.options.maxBounds);\n\t\t\t}\n\n\t\t} else if (key in this._zoomKeys) {\n\t\t\tmap.setZoom(map.getZoom() + (e.shiftKey ? 3 : 1) * this._zoomKeys[key]);\n\n\t\t} else if (key === 27) {\n\t\t\tmap.closePopup();\n\n\t\t} else {\n\t\t\treturn;\n\t\t}\n\n\t\tL.DomEvent.stop(e);\n\t}\n});\n\n// @section Handlers\n// @section Handlers\n// @property keyboard: Handler\n// Keyboard navigation handler.\nL.Map.addInitHook('addHandler', 'keyboard', L.Map.Keyboard);\n","/*\n * L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable.\n */\n\n\n/* @namespace Marker\n * @section Interaction handlers\n *\n * Interaction handlers are properties of a marker instance that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging (see `Handler` methods). Example:\n *\n * ```js\n * marker.dragging.disable();\n * ```\n *\n * @property dragging: Handler\n * Marker dragging handler (by both mouse and touch).\n */\n\nL.Handler.MarkerDrag = L.Handler.extend({\n\tinitialize: function (marker) {\n\t\tthis._marker = marker;\n\t},\n\n\taddHooks: function () {\n\t\tvar icon = this._marker._icon;\n\n\t\tif (!this._draggable) {\n\t\t\tthis._draggable = new L.Draggable(icon, icon, true);\n\t\t}\n\n\t\tthis._draggable.on({\n\t\t\tdragstart: this._onDragStart,\n\t\t\tdrag: this._onDrag,\n\t\t\tdragend: this._onDragEnd\n\t\t}, this).enable();\n\n\t\tL.DomUtil.addClass(icon, 'leaflet-marker-draggable');\n\t},\n\n\tremoveHooks: function () {\n\t\tthis._draggable.off({\n\t\t\tdragstart: this._onDragStart,\n\t\t\tdrag: this._onDrag,\n\t\t\tdragend: this._onDragEnd\n\t\t}, this).disable();\n\n\t\tif (this._marker._icon) {\n\t\t\tL.DomUtil.removeClass(this._marker._icon, 'leaflet-marker-draggable');\n\t\t}\n\t},\n\n\tmoved: function () {\n\t\treturn this._draggable && this._draggable._moved;\n\t},\n\n\t_onDragStart: function () {\n\t\t// @section Dragging events\n\t\t// @event dragstart: Event\n\t\t// Fired when the user starts dragging the marker.\n\n\t\t// @event movestart: Event\n\t\t// Fired when the marker starts moving (because of dragging).\n\n\t\tthis._oldLatLng = this._marker.getLatLng();\n\t\tthis._marker\n\t\t .closePopup()\n\t\t .fire('movestart')\n\t\t .fire('dragstart');\n\t},\n\n\t_onDrag: function (e) {\n\t\tvar marker = this._marker,\n\t\t shadow = marker._shadow,\n\t\t iconPos = L.DomUtil.getPosition(marker._icon),\n\t\t latlng = marker._map.layerPointToLatLng(iconPos);\n\n\t\t// update shadow position\n\t\tif (shadow) {\n\t\t\tL.DomUtil.setPosition(shadow, iconPos);\n\t\t}\n\n\t\tmarker._latlng = latlng;\n\t\te.latlng = latlng;\n\t\te.oldLatLng = this._oldLatLng;\n\n\t\t// @event drag: Event\n\t\t// Fired repeatedly while the user drags the marker.\n\t\tmarker\n\t\t .fire('move', e)\n\t\t .fire('drag', e);\n\t},\n\n\t_onDragEnd: function (e) {\n\t\t// @event dragend: DragEndEvent\n\t\t// Fired when the user stops dragging the marker.\n\n\t\t// @event moveend: Event\n\t\t// Fired when the marker stops moving (because of dragging).\n\t\tdelete this._oldLatLng;\n\t\tthis._marker\n\t\t .fire('moveend')\n\t\t .fire('dragend', e);\n\t}\n});\n","/*\r\n * @class Control\r\n * @aka L.Control\r\n * @inherits Class\r\n *\r\n * L.Control is a base class for implementing map controls. Handles positioning.\r\n * All other controls extend from this class.\r\n */\r\n\r\nL.Control = L.Class.extend({\r\n\t// @section\r\n\t// @aka Control options\r\n\toptions: {\r\n\t\t// @option position: String = 'topright'\r\n\t\t// The position of the control (one of the map corners). Possible values are `'topleft'`,\r\n\t\t// `'topright'`, `'bottomleft'` or `'bottomright'`\r\n\t\tposition: 'topright'\r\n\t},\r\n\r\n\tinitialize: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\t},\r\n\r\n\t/* @section\r\n\t * Classes extending L.Control will inherit the following methods:\r\n\t *\r\n\t * @method getPosition: string\r\n\t * Returns the position of the control.\r\n\t */\r\n\tgetPosition: function () {\r\n\t\treturn this.options.position;\r\n\t},\r\n\r\n\t// @method setPosition(position: string): this\r\n\t// Sets the position of the control.\r\n\tsetPosition: function (position) {\r\n\t\tvar map = this._map;\r\n\r\n\t\tif (map) {\r\n\t\t\tmap.removeControl(this);\r\n\t\t}\r\n\r\n\t\tthis.options.position = position;\r\n\r\n\t\tif (map) {\r\n\t\t\tmap.addControl(this);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method getContainer: HTMLElement\r\n\t// Returns the HTMLElement that contains the control.\r\n\tgetContainer: function () {\r\n\t\treturn this._container;\r\n\t},\r\n\r\n\t// @method addTo(map: Map): this\r\n\t// Adds the control to the given map.\r\n\taddTo: function (map) {\r\n\t\tthis.remove();\r\n\t\tthis._map = map;\r\n\r\n\t\tvar container = this._container = this.onAdd(map),\r\n\t\t pos = this.getPosition(),\r\n\t\t corner = map._controlCorners[pos];\r\n\r\n\t\tL.DomUtil.addClass(container, 'leaflet-control');\r\n\r\n\t\tif (pos.indexOf('bottom') !== -1) {\r\n\t\t\tcorner.insertBefore(container, corner.firstChild);\r\n\t\t} else {\r\n\t\t\tcorner.appendChild(container);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method remove: this\r\n\t// Removes the control from the map it is currently active on.\r\n\tremove: function () {\r\n\t\tif (!this._map) {\r\n\t\t\treturn this;\r\n\t\t}\r\n\r\n\t\tL.DomUtil.remove(this._container);\r\n\r\n\t\tif (this.onRemove) {\r\n\t\t\tthis.onRemove(this._map);\r\n\t\t}\r\n\r\n\t\tthis._map = null;\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_refocusOnMap: function (e) {\r\n\t\t// if map exists and event is not a keyboard event\r\n\t\tif (this._map && e && e.screenX > 0 && e.screenY > 0) {\r\n\t\t\tthis._map.getContainer().focus();\r\n\t\t}\r\n\t}\r\n});\r\n\r\nL.control = function (options) {\r\n\treturn new L.Control(options);\r\n};\r\n\r\n/* @section Extension methods\r\n * @uninheritable\r\n *\r\n * Every control should extend from `L.Control` and (re-)implement the following methods.\r\n *\r\n * @method onAdd(map: Map): HTMLElement\r\n * Should return the container DOM element for the control and add listeners on relevant map events. Called on [`control.addTo(map)`](#control-addTo).\r\n *\r\n * @method onRemove(map: Map)\r\n * Optional method. Should contain all clean up code that removes the listeners previously added in [`onAdd`](#control-onadd). Called on [`control.remove()`](#control-remove).\r\n */\r\n\r\n/* @namespace Map\r\n * @section Methods for Layers and Controls\r\n */\r\nL.Map.include({\r\n\t// @method addControl(control: Control): this\r\n\t// Adds the given control to the map\r\n\taddControl: function (control) {\r\n\t\tcontrol.addTo(this);\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method removeControl(control: Control): this\r\n\t// Removes the given control from the map\r\n\tremoveControl: function (control) {\r\n\t\tcontrol.remove();\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_initControlPos: function () {\r\n\t\tvar corners = this._controlCorners = {},\r\n\t\t l = 'leaflet-',\r\n\t\t container = this._controlContainer =\r\n\t\t L.DomUtil.create('div', l + 'control-container', this._container);\r\n\r\n\t\tfunction createCorner(vSide, hSide) {\r\n\t\t\tvar className = l + vSide + ' ' + l + hSide;\r\n\r\n\t\t\tcorners[vSide + hSide] = L.DomUtil.create('div', className, container);\r\n\t\t}\r\n\r\n\t\tcreateCorner('top', 'left');\r\n\t\tcreateCorner('top', 'right');\r\n\t\tcreateCorner('bottom', 'left');\r\n\t\tcreateCorner('bottom', 'right');\r\n\t},\r\n\r\n\t_clearControlPos: function () {\r\n\t\tL.DomUtil.remove(this._controlContainer);\r\n\t}\r\n});\r\n","/*\r\n * @class Control.Zoom\r\n * @aka L.Control.Zoom\r\n * @inherits Control\r\n *\r\n * A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its [`zoomControl` option](#map-zoomcontrol) to `false`. Extends `Control`.\r\n */\r\n\r\nL.Control.Zoom = L.Control.extend({\r\n\t// @section\r\n\t// @aka Control.Zoom options\r\n\toptions: {\r\n\t\tposition: 'topleft',\r\n\r\n\t\t// @option zoomInText: String = '+'\r\n\t\t// The text set on the 'zoom in' button.\r\n\t\tzoomInText: '+',\r\n\r\n\t\t// @option zoomInTitle: String = 'Zoom in'\r\n\t\t// The title set on the 'zoom in' button.\r\n\t\tzoomInTitle: 'Zoom in',\r\n\r\n\t\t// @option zoomOutText: String = '-'\r\n\t\t// The text set on the 'zoom out' button.\r\n\t\tzoomOutText: '-',\r\n\r\n\t\t// @option zoomOutTitle: String = 'Zoom out'\r\n\t\t// The title set on the 'zoom out' button.\r\n\t\tzoomOutTitle: 'Zoom out'\r\n\t},\r\n\r\n\tonAdd: function (map) {\r\n\t\tvar zoomName = 'leaflet-control-zoom',\r\n\t\t container = L.DomUtil.create('div', zoomName + ' leaflet-bar'),\r\n\t\t options = this.options;\r\n\r\n\t\tthis._zoomInButton = this._createButton(options.zoomInText, options.zoomInTitle,\r\n\t\t zoomName + '-in', container, this._zoomIn);\r\n\t\tthis._zoomOutButton = this._createButton(options.zoomOutText, options.zoomOutTitle,\r\n\t\t zoomName + '-out', container, this._zoomOut);\r\n\r\n\t\tthis._updateDisabled();\r\n\t\tmap.on('zoomend zoomlevelschange', this._updateDisabled, this);\r\n\r\n\t\treturn container;\r\n\t},\r\n\r\n\tonRemove: function (map) {\r\n\t\tmap.off('zoomend zoomlevelschange', this._updateDisabled, this);\r\n\t},\r\n\r\n\tdisable: function () {\r\n\t\tthis._disabled = true;\r\n\t\tthis._updateDisabled();\r\n\t\treturn this;\r\n\t},\r\n\r\n\tenable: function () {\r\n\t\tthis._disabled = false;\r\n\t\tthis._updateDisabled();\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_zoomIn: function (e) {\r\n\t\tif (!this._disabled && this._map._zoom < this._map.getMaxZoom()) {\r\n\t\t\tthis._map.zoomIn(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));\r\n\t\t}\r\n\t},\r\n\r\n\t_zoomOut: function (e) {\r\n\t\tif (!this._disabled && this._map._zoom > this._map.getMinZoom()) {\r\n\t\t\tthis._map.zoomOut(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));\r\n\t\t}\r\n\t},\r\n\r\n\t_createButton: function (html, title, className, container, fn) {\r\n\t\tvar link = L.DomUtil.create('a', className, container);\r\n\t\tlink.innerHTML = html;\r\n\t\tlink.href = '#';\r\n\t\tlink.title = title;\r\n\r\n\t\t/*\r\n\t\t * Will force screen readers like VoiceOver to read this as \"Zoom in - button\"\r\n\t\t */\r\n\t\tlink.setAttribute('role', 'button');\r\n\t\tlink.setAttribute('aria-label', title);\r\n\r\n\t\tL.DomEvent\r\n\t\t .on(link, 'mousedown dblclick', L.DomEvent.stopPropagation)\r\n\t\t .on(link, 'click', L.DomEvent.stop)\r\n\t\t .on(link, 'click', fn, this)\r\n\t\t .on(link, 'click', this._refocusOnMap, this);\r\n\r\n\t\treturn link;\r\n\t},\r\n\r\n\t_updateDisabled: function () {\r\n\t\tvar map = this._map,\r\n\t\t className = 'leaflet-disabled';\r\n\r\n\t\tL.DomUtil.removeClass(this._zoomInButton, className);\r\n\t\tL.DomUtil.removeClass(this._zoomOutButton, className);\r\n\r\n\t\tif (this._disabled || map._zoom === map.getMinZoom()) {\r\n\t\t\tL.DomUtil.addClass(this._zoomOutButton, className);\r\n\t\t}\r\n\t\tif (this._disabled || map._zoom === map.getMaxZoom()) {\r\n\t\t\tL.DomUtil.addClass(this._zoomInButton, className);\r\n\t\t}\r\n\t}\r\n});\r\n\r\n// @namespace Map\r\n// @section Control options\r\n// @option zoomControl: Boolean = true\r\n// Whether a [zoom control](#control-zoom) is added to the map by default.\r\nL.Map.mergeOptions({\r\n\tzoomControl: true\r\n});\r\n\r\nL.Map.addInitHook(function () {\r\n\tif (this.options.zoomControl) {\r\n\t\tthis.zoomControl = new L.Control.Zoom();\r\n\t\tthis.addControl(this.zoomControl);\r\n\t}\r\n});\r\n\r\n// @namespace Control.Zoom\r\n// @factory L.control.zoom(options: Control.Zoom options)\r\n// Creates a zoom control\r\nL.control.zoom = function (options) {\r\n\treturn new L.Control.Zoom(options);\r\n};\r\n","/*\r\n * @class Control.Attribution\r\n * @aka L.Control.Attribution\r\n * @inherits Control\r\n *\r\n * The attribution control allows you to display attribution data in a small text box on a map. It is put on the map by default unless you set its [`attributionControl` option](#map-attributioncontrol) to `false`, and it fetches attribution texts from layers with the [`getAttribution` method](#layer-getattribution) automatically. Extends Control.\r\n */\r\n\r\nL.Control.Attribution = L.Control.extend({\r\n\t// @section\r\n\t// @aka Control.Attribution options\r\n\toptions: {\r\n\t\tposition: 'bottomright',\r\n\r\n\t\t// @option prefix: String = 'Leaflet'\r\n\t\t// The HTML text shown before the attributions. Pass `false` to disable.\r\n\t\tprefix: 'Leaflet'\r\n\t},\r\n\r\n\tinitialize: function (options) {\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tthis._attributions = {};\r\n\t},\r\n\r\n\tonAdd: function (map) {\r\n\t\tmap.attributionControl = this;\r\n\t\tthis._container = L.DomUtil.create('div', 'leaflet-control-attribution');\r\n\t\tif (L.DomEvent) {\r\n\t\t\tL.DomEvent.disableClickPropagation(this._container);\r\n\t\t}\r\n\r\n\t\t// TODO ugly, refactor\r\n\t\tfor (var i in map._layers) {\r\n\t\t\tif (map._layers[i].getAttribution) {\r\n\t\t\t\tthis.addAttribution(map._layers[i].getAttribution());\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis._update();\r\n\r\n\t\treturn this._container;\r\n\t},\r\n\r\n\t// @method setPrefix(prefix: String): this\r\n\t// Sets the text before the attributions.\r\n\tsetPrefix: function (prefix) {\r\n\t\tthis.options.prefix = prefix;\r\n\t\tthis._update();\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method addAttribution(text: String): this\r\n\t// Adds an attribution text (e.g. `'Vector data © Mapbox'`).\r\n\taddAttribution: function (text) {\r\n\t\tif (!text) { return this; }\r\n\r\n\t\tif (!this._attributions[text]) {\r\n\t\t\tthis._attributions[text] = 0;\r\n\t\t}\r\n\t\tthis._attributions[text]++;\r\n\r\n\t\tthis._update();\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method removeAttribution(text: String): this\r\n\t// Removes an attribution text.\r\n\tremoveAttribution: function (text) {\r\n\t\tif (!text) { return this; }\r\n\r\n\t\tif (this._attributions[text]) {\r\n\t\t\tthis._attributions[text]--;\r\n\t\t\tthis._update();\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_update: function () {\r\n\t\tif (!this._map) { return; }\r\n\r\n\t\tvar attribs = [];\r\n\r\n\t\tfor (var i in this._attributions) {\r\n\t\t\tif (this._attributions[i]) {\r\n\t\t\t\tattribs.push(i);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tvar prefixAndAttribs = [];\r\n\r\n\t\tif (this.options.prefix) {\r\n\t\t\tprefixAndAttribs.push(this.options.prefix);\r\n\t\t}\r\n\t\tif (attribs.length) {\r\n\t\t\tprefixAndAttribs.push(attribs.join(', '));\r\n\t\t}\r\n\r\n\t\tthis._container.innerHTML = prefixAndAttribs.join(' | ');\r\n\t}\r\n});\r\n\r\n// @namespace Map\r\n// @section Control options\r\n// @option attributionControl: Boolean = true\r\n// Whether a [attribution control](#control-attribution) is added to the map by default.\r\nL.Map.mergeOptions({\r\n\tattributionControl: true\r\n});\r\n\r\nL.Map.addInitHook(function () {\r\n\tif (this.options.attributionControl) {\r\n\t\tnew L.Control.Attribution().addTo(this);\r\n\t}\r\n});\r\n\r\n// @namespace Control.Attribution\r\n// @factory L.control.attribution(options: Control.Attribution options)\r\n// Creates an attribution control.\r\nL.control.attribution = function (options) {\r\n\treturn new L.Control.Attribution(options);\r\n};\r\n","/*\n * @class Control.Scale\n * @aka L.Control.Scale\n * @inherits Control\n *\n * A simple scale control that shows the scale of the current center of screen in metric (m/km) and imperial (mi/ft) systems. Extends `Control`.\n *\n * @example\n *\n * ```js\n * L.control.scale().addTo(map);\n * ```\n */\n\nL.Control.Scale = L.Control.extend({\n\t// @section\n\t// @aka Control.Scale options\n\toptions: {\n\t\tposition: 'bottomleft',\n\n\t\t// @option maxWidth: Number = 100\n\t\t// Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500).\n\t\tmaxWidth: 100,\n\n\t\t// @option metric: Boolean = True\n\t\t// Whether to show the metric scale line (m/km).\n\t\tmetric: true,\n\n\t\t// @option imperial: Boolean = True\n\t\t// Whether to show the imperial scale line (mi/ft).\n\t\timperial: true\n\n\t\t// @option updateWhenIdle: Boolean = false\n\t\t// If `true`, the control is updated on [`moveend`](#map-moveend), otherwise it's always up-to-date (updated on [`move`](#map-move)).\n\t},\n\n\tonAdd: function (map) {\n\t\tvar className = 'leaflet-control-scale',\n\t\t container = L.DomUtil.create('div', className),\n\t\t options = this.options;\n\n\t\tthis._addScales(options, className + '-line', container);\n\n\t\tmap.on(options.updateWhenIdle ? 'moveend' : 'move', this._update, this);\n\t\tmap.whenReady(this._update, this);\n\n\t\treturn container;\n\t},\n\n\tonRemove: function (map) {\n\t\tmap.off(this.options.updateWhenIdle ? 'moveend' : 'move', this._update, this);\n\t},\n\n\t_addScales: function (options, className, container) {\n\t\tif (options.metric) {\n\t\t\tthis._mScale = L.DomUtil.create('div', className, container);\n\t\t}\n\t\tif (options.imperial) {\n\t\t\tthis._iScale = L.DomUtil.create('div', className, container);\n\t\t}\n\t},\n\n\t_update: function () {\n\t\tvar map = this._map,\n\t\t y = map.getSize().y / 2;\n\n\t\tvar maxMeters = map.distance(\n\t\t\t\tmap.containerPointToLatLng([0, y]),\n\t\t\t\tmap.containerPointToLatLng([this.options.maxWidth, y]));\n\n\t\tthis._updateScales(maxMeters);\n\t},\n\n\t_updateScales: function (maxMeters) {\n\t\tif (this.options.metric && maxMeters) {\n\t\t\tthis._updateMetric(maxMeters);\n\t\t}\n\t\tif (this.options.imperial && maxMeters) {\n\t\t\tthis._updateImperial(maxMeters);\n\t\t}\n\t},\n\n\t_updateMetric: function (maxMeters) {\n\t\tvar meters = this._getRoundNum(maxMeters),\n\t\t label = meters < 1000 ? meters + ' m' : (meters / 1000) + ' km';\n\n\t\tthis._updateScale(this._mScale, label, meters / maxMeters);\n\t},\n\n\t_updateImperial: function (maxMeters) {\n\t\tvar maxFeet = maxMeters * 3.2808399,\n\t\t maxMiles, miles, feet;\n\n\t\tif (maxFeet > 5280) {\n\t\t\tmaxMiles = maxFeet / 5280;\n\t\t\tmiles = this._getRoundNum(maxMiles);\n\t\t\tthis._updateScale(this._iScale, miles + ' mi', miles / maxMiles);\n\n\t\t} else {\n\t\t\tfeet = this._getRoundNum(maxFeet);\n\t\t\tthis._updateScale(this._iScale, feet + ' ft', feet / maxFeet);\n\t\t}\n\t},\n\n\t_updateScale: function (scale, text, ratio) {\n\t\tscale.style.width = Math.round(this.options.maxWidth * ratio) + 'px';\n\t\tscale.innerHTML = text;\n\t},\n\n\t_getRoundNum: function (num) {\n\t\tvar pow10 = Math.pow(10, (Math.floor(num) + '').length - 1),\n\t\t d = num / pow10;\n\n\t\td = d >= 10 ? 10 :\n\t\t d >= 5 ? 5 :\n\t\t d >= 3 ? 3 :\n\t\t d >= 2 ? 2 : 1;\n\n\t\treturn pow10 * d;\n\t}\n});\n\n\n// @factory L.control.scale(options?: Control.Scale options)\n// Creates an scale control with the given options.\nL.control.scale = function (options) {\n\treturn new L.Control.Scale(options);\n};\n","/*\r\n * @class Control.Layers\r\n * @aka L.Control.Layers\r\n * @inherits Control\r\n *\r\n * The layers control gives users the ability to switch between different base layers and switch overlays on/off (check out the [detailed example](http://leafletjs.com/examples/layers-control.html)). Extends `Control`.\r\n *\r\n * @example\r\n *\r\n * ```js\r\n * var baseLayers = {\r\n * \t\"Mapbox\": mapbox,\r\n * \t\"OpenStreetMap\": osm\r\n * };\r\n *\r\n * var overlays = {\r\n * \t\"Marker\": marker,\r\n * \t\"Roads\": roadsLayer\r\n * };\r\n *\r\n * L.control.layers(baseLayers, overlays).addTo(map);\r\n * ```\r\n *\r\n * The `baseLayers` and `overlays` parameters are object literals with layer names as keys and `Layer` objects as values:\r\n *\r\n * ```js\r\n * {\r\n * \"\": layer1,\r\n * \"\": layer2\r\n * }\r\n * ```\r\n *\r\n * The layer names can contain HTML, which allows you to add additional styling to the items:\r\n *\r\n * ```js\r\n * {\" My Layer\": myLayer}\r\n * ```\r\n */\r\n\r\n\r\nL.Control.Layers = L.Control.extend({\r\n\t// @section\r\n\t// @aka Control.Layers options\r\n\toptions: {\r\n\t\t// @option collapsed: Boolean = true\r\n\t\t// If `true`, the control will be collapsed into an icon and expanded on mouse hover or touch.\r\n\t\tcollapsed: true,\r\n\t\tposition: 'topright',\r\n\r\n\t\t// @option autoZIndex: Boolean = true\r\n\t\t// If `true`, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off.\r\n\t\tautoZIndex: true,\r\n\r\n\t\t// @option hideSingleBase: Boolean = false\r\n\t\t// If `true`, the base layers in the control will be hidden when there is only one.\r\n\t\thideSingleBase: false,\r\n\r\n\t\t// @option sortLayers: Boolean = false\r\n\t\t// Whether to sort the layers. When `false`, layers will keep the order\r\n\t\t// in which they were added to the control.\r\n\t\tsortLayers: false,\r\n\r\n\t\t// @option sortFunction: Function = *\r\n\t\t// A [compare function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)\r\n\t\t// that will be used for sorting the layers, when `sortLayers` is `true`.\r\n\t\t// The function receives both the `L.Layer` instances and their names, as in\r\n\t\t// `sortFunction(layerA, layerB, nameA, nameB)`.\r\n\t\t// By default, it sorts layers alphabetically by their name.\r\n\t\tsortFunction: function (layerA, layerB, nameA, nameB) {\r\n\t\t\treturn nameA < nameB ? -1 : (nameB < nameA ? 1 : 0);\r\n\t\t}\r\n\t},\r\n\r\n\tinitialize: function (baseLayers, overlays, options) {\r\n\t\tL.setOptions(this, options);\r\n\r\n\t\tthis._layers = [];\r\n\t\tthis._lastZIndex = 0;\r\n\t\tthis._handlingClick = false;\r\n\r\n\t\tfor (var i in baseLayers) {\r\n\t\t\tthis._addLayer(baseLayers[i], i);\r\n\t\t}\r\n\r\n\t\tfor (i in overlays) {\r\n\t\t\tthis._addLayer(overlays[i], i, true);\r\n\t\t}\r\n\t},\r\n\r\n\tonAdd: function (map) {\r\n\t\tthis._initLayout();\r\n\t\tthis._update();\r\n\r\n\t\tthis._map = map;\r\n\t\tmap.on('zoomend', this._checkDisabledLayers, this);\r\n\r\n\t\treturn this._container;\r\n\t},\r\n\r\n\tonRemove: function () {\r\n\t\tthis._map.off('zoomend', this._checkDisabledLayers, this);\r\n\r\n\t\tfor (var i = 0; i < this._layers.length; i++) {\r\n\t\t\tthis._layers[i].layer.off('add remove', this._onLayerChange, this);\r\n\t\t}\r\n\t},\r\n\r\n\t// @method addBaseLayer(layer: Layer, name: String): this\r\n\t// Adds a base layer (radio button entry) with the given name to the control.\r\n\taddBaseLayer: function (layer, name) {\r\n\t\tthis._addLayer(layer, name);\r\n\t\treturn (this._map) ? this._update() : this;\r\n\t},\r\n\r\n\t// @method addOverlay(layer: Layer, name: String): this\r\n\t// Adds an overlay (checkbox entry) with the given name to the control.\r\n\taddOverlay: function (layer, name) {\r\n\t\tthis._addLayer(layer, name, true);\r\n\t\treturn (this._map) ? this._update() : this;\r\n\t},\r\n\r\n\t// @method removeLayer(layer: Layer): this\r\n\t// Remove the given layer from the control.\r\n\tremoveLayer: function (layer) {\r\n\t\tlayer.off('add remove', this._onLayerChange, this);\r\n\r\n\t\tvar obj = this._getLayer(L.stamp(layer));\r\n\t\tif (obj) {\r\n\t\t\tthis._layers.splice(this._layers.indexOf(obj), 1);\r\n\t\t}\r\n\t\treturn (this._map) ? this._update() : this;\r\n\t},\r\n\r\n\t// @method expand(): this\r\n\t// Expand the control container if collapsed.\r\n\texpand: function () {\r\n\t\tL.DomUtil.addClass(this._container, 'leaflet-control-layers-expanded');\r\n\t\tthis._form.style.height = null;\r\n\t\tvar acceptableHeight = this._map.getSize().y - (this._container.offsetTop + 50);\r\n\t\tif (acceptableHeight < this._form.clientHeight) {\r\n\t\t\tL.DomUtil.addClass(this._form, 'leaflet-control-layers-scrollbar');\r\n\t\t\tthis._form.style.height = acceptableHeight + 'px';\r\n\t\t} else {\r\n\t\t\tL.DomUtil.removeClass(this._form, 'leaflet-control-layers-scrollbar');\r\n\t\t}\r\n\t\tthis._checkDisabledLayers();\r\n\t\treturn this;\r\n\t},\r\n\r\n\t// @method collapse(): this\r\n\t// Collapse the control container if expanded.\r\n\tcollapse: function () {\r\n\t\tL.DomUtil.removeClass(this._container, 'leaflet-control-layers-expanded');\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_initLayout: function () {\r\n\t\tvar className = 'leaflet-control-layers',\r\n\t\t container = this._container = L.DomUtil.create('div', className);\r\n\r\n\t\t// makes this work on IE touch devices by stopping it from firing a mouseout event when the touch is released\r\n\t\tcontainer.setAttribute('aria-haspopup', true);\r\n\r\n\t\tL.DomEvent.disableClickPropagation(container);\r\n\t\tif (!L.Browser.touch) {\r\n\t\t\tL.DomEvent.disableScrollPropagation(container);\r\n\t\t}\r\n\r\n\t\tvar form = this._form = L.DomUtil.create('form', className + '-list');\r\n\r\n\t\tif (!L.Browser.android) {\r\n\t\t\tL.DomEvent.on(container, {\r\n\t\t\t\tmouseenter: this.expand,\r\n\t\t\t\tmouseleave: this.collapse\r\n\t\t\t}, this);\r\n\t\t}\r\n\r\n\t\tvar link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container);\r\n\t\tlink.href = '#';\r\n\t\tlink.title = 'Layers';\r\n\r\n\t\tif (L.Browser.touch) {\r\n\t\t\tL.DomEvent\r\n\t\t\t .on(link, 'click', L.DomEvent.stop)\r\n\t\t\t .on(link, 'click', this.expand, this);\r\n\t\t} else {\r\n\t\t\tL.DomEvent.on(link, 'focus', this.expand, this);\r\n\t\t}\r\n\r\n\t\t// work around for Firefox Android issue https://github.com/Leaflet/Leaflet/issues/2033\r\n\t\tL.DomEvent.on(form, 'click', function () {\r\n\t\t\tsetTimeout(L.bind(this._onInputClick, this), 0);\r\n\t\t}, this);\r\n\r\n\t\tthis._map.on('click', this.collapse, this);\r\n\t\t// TODO keyboard accessibility\r\n\r\n\t\tif (!this.options.collapsed) {\r\n\t\t\tthis.expand();\r\n\t\t}\r\n\r\n\t\tthis._baseLayersList = L.DomUtil.create('div', className + '-base', form);\r\n\t\tthis._separator = L.DomUtil.create('div', className + '-separator', form);\r\n\t\tthis._overlaysList = L.DomUtil.create('div', className + '-overlays', form);\r\n\r\n\t\tcontainer.appendChild(form);\r\n\t},\r\n\r\n\t_getLayer: function (id) {\r\n\t\tfor (var i = 0; i < this._layers.length; i++) {\r\n\r\n\t\t\tif (this._layers[i] && L.stamp(this._layers[i].layer) === id) {\r\n\t\t\t\treturn this._layers[i];\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t_addLayer: function (layer, name, overlay) {\r\n\t\tlayer.on('add remove', this._onLayerChange, this);\r\n\r\n\t\tthis._layers.push({\r\n\t\t\tlayer: layer,\r\n\t\t\tname: name,\r\n\t\t\toverlay: overlay\r\n\t\t});\r\n\r\n\t\tif (this.options.sortLayers) {\r\n\t\t\tthis._layers.sort(L.bind(function (a, b) {\r\n\t\t\t\treturn this.options.sortFunction(a.layer, b.layer, a.name, b.name);\r\n\t\t\t}, this));\r\n\t\t}\r\n\r\n\t\tif (this.options.autoZIndex && layer.setZIndex) {\r\n\t\t\tthis._lastZIndex++;\r\n\t\t\tlayer.setZIndex(this._lastZIndex);\r\n\t\t}\r\n\t},\r\n\r\n\t_update: function () {\r\n\t\tif (!this._container) { return this; }\r\n\r\n\t\tL.DomUtil.empty(this._baseLayersList);\r\n\t\tL.DomUtil.empty(this._overlaysList);\r\n\r\n\t\tvar baseLayersPresent, overlaysPresent, i, obj, baseLayersCount = 0;\r\n\r\n\t\tfor (i = 0; i < this._layers.length; i++) {\r\n\t\t\tobj = this._layers[i];\r\n\t\t\tthis._addItem(obj);\r\n\t\t\toverlaysPresent = overlaysPresent || obj.overlay;\r\n\t\t\tbaseLayersPresent = baseLayersPresent || !obj.overlay;\r\n\t\t\tbaseLayersCount += !obj.overlay ? 1 : 0;\r\n\t\t}\r\n\r\n\t\t// Hide base layers section if there's only one layer.\r\n\t\tif (this.options.hideSingleBase) {\r\n\t\t\tbaseLayersPresent = baseLayersPresent && baseLayersCount > 1;\r\n\t\t\tthis._baseLayersList.style.display = baseLayersPresent ? '' : 'none';\r\n\t\t}\r\n\r\n\t\tthis._separator.style.display = overlaysPresent && baseLayersPresent ? '' : 'none';\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t_onLayerChange: function (e) {\r\n\t\tif (!this._handlingClick) {\r\n\t\t\tthis._update();\r\n\t\t}\r\n\r\n\t\tvar obj = this._getLayer(L.stamp(e.target));\r\n\r\n\t\t// @namespace Map\r\n\t\t// @section Layer events\r\n\t\t// @event baselayerchange: LayersControlEvent\r\n\t\t// Fired when the base layer is changed through the [layer control](#control-layers).\r\n\t\t// @event overlayadd: LayersControlEvent\r\n\t\t// Fired when an overlay is selected through the [layer control](#control-layers).\r\n\t\t// @event overlayremove: LayersControlEvent\r\n\t\t// Fired when an overlay is deselected through the [layer control](#control-layers).\r\n\t\t// @namespace Control.Layers\r\n\t\tvar type = obj.overlay ?\r\n\t\t\t(e.type === 'add' ? 'overlayadd' : 'overlayremove') :\r\n\t\t\t(e.type === 'add' ? 'baselayerchange' : null);\r\n\r\n\t\tif (type) {\r\n\t\t\tthis._map.fire(type, obj);\r\n\t\t}\r\n\t},\r\n\r\n\t// IE7 bugs out if you create a radio dynamically, so you have to do it this hacky way (see http://bit.ly/PqYLBe)\r\n\t_createRadioElement: function (name, checked) {\r\n\r\n\t\tvar radioHtml = '';\r\n\r\n\t\tvar radioFragment = document.createElement('div');\r\n\t\tradioFragment.innerHTML = radioHtml;\r\n\r\n\t\treturn radioFragment.firstChild;\r\n\t},\r\n\r\n\t_addItem: function (obj) {\r\n\t\tvar label = document.createElement('label'),\r\n\t\t checked = this._map.hasLayer(obj.layer),\r\n\t\t input;\r\n\r\n\t\tif (obj.overlay) {\r\n\t\t\tinput = document.createElement('input');\r\n\t\t\tinput.type = 'checkbox';\r\n\t\t\tinput.className = 'leaflet-control-layers-selector';\r\n\t\t\tinput.defaultChecked = checked;\r\n\t\t} else {\r\n\t\t\tinput = this._createRadioElement('leaflet-base-layers', checked);\r\n\t\t}\r\n\r\n\t\tinput.layerId = L.stamp(obj.layer);\r\n\r\n\t\tL.DomEvent.on(input, 'click', this._onInputClick, this);\r\n\r\n\t\tvar name = document.createElement('span');\r\n\t\tname.innerHTML = ' ' + obj.name;\r\n\r\n\t\t// Helps from preventing layer control flicker when checkboxes are disabled\r\n\t\t// https://github.com/Leaflet/Leaflet/issues/2771\r\n\t\tvar holder = document.createElement('div');\r\n\r\n\t\tlabel.appendChild(holder);\r\n\t\tholder.appendChild(input);\r\n\t\tholder.appendChild(name);\r\n\r\n\t\tvar container = obj.overlay ? this._overlaysList : this._baseLayersList;\r\n\t\tcontainer.appendChild(label);\r\n\r\n\t\tthis._checkDisabledLayers();\r\n\t\treturn label;\r\n\t},\r\n\r\n\t_onInputClick: function () {\r\n\t\tvar inputs = this._form.getElementsByTagName('input'),\r\n\t\t input, layer, hasLayer;\r\n\t\tvar addedLayers = [],\r\n\t\t removedLayers = [];\r\n\r\n\t\tthis._handlingClick = true;\r\n\r\n\t\tfor (var i = inputs.length - 1; i >= 0; i--) {\r\n\t\t\tinput = inputs[i];\r\n\t\t\tlayer = this._getLayer(input.layerId).layer;\r\n\t\t\thasLayer = this._map.hasLayer(layer);\r\n\r\n\t\t\tif (input.checked && !hasLayer) {\r\n\t\t\t\taddedLayers.push(layer);\r\n\r\n\t\t\t} else if (!input.checked && hasLayer) {\r\n\t\t\t\tremovedLayers.push(layer);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Bugfix issue 2318: Should remove all old layers before readding new ones\r\n\t\tfor (i = 0; i < removedLayers.length; i++) {\r\n\t\t\tthis._map.removeLayer(removedLayers[i]);\r\n\t\t}\r\n\t\tfor (i = 0; i < addedLayers.length; i++) {\r\n\t\t\tthis._map.addLayer(addedLayers[i]);\r\n\t\t}\r\n\r\n\t\tthis._handlingClick = false;\r\n\r\n\t\tthis._refocusOnMap();\r\n\t},\r\n\r\n\t_checkDisabledLayers: function () {\r\n\t\tvar inputs = this._form.getElementsByTagName('input'),\r\n\t\t input,\r\n\t\t layer,\r\n\t\t zoom = this._map.getZoom();\r\n\r\n\t\tfor (var i = inputs.length - 1; i >= 0; i--) {\r\n\t\t\tinput = inputs[i];\r\n\t\t\tlayer = this._getLayer(input.layerId).layer;\r\n\t\t\tinput.disabled = (layer.options.minZoom !== undefined && zoom < layer.options.minZoom) ||\r\n\t\t\t (layer.options.maxZoom !== undefined && zoom > layer.options.maxZoom);\r\n\r\n\t\t}\r\n\t},\r\n\r\n\t_expand: function () {\r\n\t\t// Backward compatibility, remove me in 1.1.\r\n\t\treturn this.expand();\r\n\t},\r\n\r\n\t_collapse: function () {\r\n\t\t// Backward compatibility, remove me in 1.1.\r\n\t\treturn this.collapse();\r\n\t}\r\n\r\n});\r\n\r\n\r\n// @factory L.control.layers(baselayers?: Object, overlays?: Object, options?: Control.Layers options)\r\n// Creates an attribution control with the given layers. Base layers will be switched with radio buttons, while overlays will be switched with checkboxes. Note that all base layers should be passed in the base layers object, but only one should be added to the map during map instantiation.\r\nL.control.layers = function (baseLayers, overlays, options) {\r\n\treturn new L.Control.Layers(baseLayers, overlays, options);\r\n};\r\n"]} \ No newline at end of file diff --git a/www7/sites/all/libraries/leaflet/leaflet.css b/www7/sites/all/libraries/leaflet/leaflet.css index ac0cd174d..0d9ccfd8e 100644 --- a/www7/sites/all/libraries/leaflet/leaflet.css +++ b/www7/sites/all/libraries/leaflet/leaflet.css @@ -1,16 +1,12 @@ /* required styles */ -.leaflet-map-pane, +.leaflet-pane, .leaflet-tile, .leaflet-marker-icon, .leaflet-marker-shadow, -.leaflet-tile-pane, .leaflet-tile-container, -.leaflet-overlay-pane, -.leaflet-shadow-pane, -.leaflet-marker-pane, -.leaflet-popup-pane, -.leaflet-overlay-pane svg, +.leaflet-pane > svg, +.leaflet-pane > canvas, .leaflet-zoom-box, .leaflet-image-layer, .leaflet-layer { @@ -20,7 +16,6 @@ } .leaflet-container { overflow: hidden; - -ms-touch-action: none; } .leaflet-tile, .leaflet-marker-icon, @@ -28,20 +23,43 @@ -webkit-user-select: none; -moz-user-select: none; user-select: none; - -webkit-user-drag: none; + -webkit-user-drag: none; + } +/* Safari renders non-retina tile on retina better with this, but Chrome is worse */ +.leaflet-safari .leaflet-tile { + image-rendering: -webkit-optimize-contrast; + } +/* hack that prevents hw layers "stretching" when loading new tiles */ +.leaflet-safari .leaflet-tile-container { + width: 1600px; + height: 1600px; + -webkit-transform-origin: 0 0; } .leaflet-marker-icon, .leaflet-marker-shadow { display: block; } -/* map is broken in FF if you have max-width: 100% on tiles */ -.leaflet-container img { +/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */ +/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */ +.leaflet-container .leaflet-overlay-pane svg, +.leaflet-container .leaflet-marker-pane img, +.leaflet-container .leaflet-shadow-pane img, +.leaflet-container .leaflet-tile-pane img, +.leaflet-container img.leaflet-image-layer { max-width: none !important; } -/* stupid Android 2 doesn't understand "max-width: none" properly */ -.leaflet-container img.leaflet-image-layer { - max-width: 15000px !important; + +.leaflet-container.leaflet-touch-zoom { + -ms-touch-action: pan-x pan-y; + touch-action: pan-x pan-y; + } +.leaflet-container.leaflet-touch-drag { + -ms-touch-action: pinch-zoom; } +.leaflet-container.leaflet-touch-drag.leaflet-touch-drag { + -ms-touch-action: none; + touch-action: none; +} .leaflet-tile { filter: inherit; visibility: hidden; @@ -52,18 +70,26 @@ .leaflet-zoom-box { width: 0; height: 0; + -moz-box-sizing: border-box; + box-sizing: border-box; + z-index: 800; } /* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */ .leaflet-overlay-pane svg { -moz-user-select: none; } -.leaflet-tile-pane { z-index: 2; } -.leaflet-objects-pane { z-index: 3; } -.leaflet-overlay-pane { z-index: 4; } -.leaflet-shadow-pane { z-index: 5; } -.leaflet-marker-pane { z-index: 6; } -.leaflet-popup-pane { z-index: 7; } +.leaflet-pane { z-index: 400; } + +.leaflet-tile-pane { z-index: 200; } +.leaflet-overlay-pane { z-index: 400; } +.leaflet-shadow-pane { z-index: 500; } +.leaflet-marker-pane { z-index: 600; } +.leaflet-tooltip-pane { z-index: 650; } +.leaflet-popup-pane { z-index: 700; } + +.leaflet-map-pane canvas { z-index: 100; } +.leaflet-map-pane svg { z-index: 200; } .leaflet-vml-shape { width: 1px; @@ -80,7 +106,8 @@ .leaflet-control { position: relative; - z-index: 7; + z-index: 800; + pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */ pointer-events: auto; } .leaflet-top, @@ -124,7 +151,9 @@ /* zoom and fade animations */ -.leaflet-fade-anim .leaflet-tile, +.leaflet-fade-anim .leaflet-tile { + will-change: opacity; + } .leaflet-fade-anim .leaflet-popup { opacity: 0; -webkit-transition: opacity 0.2s linear; @@ -132,11 +161,17 @@ -o-transition: opacity 0.2s linear; transition: opacity 0.2s linear; } -.leaflet-fade-anim .leaflet-tile-loaded, .leaflet-fade-anim .leaflet-map-pane .leaflet-popup { opacity: 1; } - +.leaflet-zoom-animated { + -webkit-transform-origin: 0 0; + -ms-transform-origin: 0 0; + transform-origin: 0 0; + } +.leaflet-zoom-anim .leaflet-zoom-animated { + will-change: transform; + } .leaflet-zoom-anim .leaflet-zoom-animated { -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1); -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); @@ -144,8 +179,7 @@ transition: transform 0.25s cubic-bezier(0,0,0.25,1); } .leaflet-zoom-anim .leaflet-tile, -.leaflet-pan-anim .leaflet-tile, -.leaflet-touching .leaflet-zoom-animated { +.leaflet-pan-anim .leaflet-tile { -webkit-transition: none; -moz-transition: none; -o-transition: none; @@ -159,24 +193,44 @@ /* cursors */ -.leaflet-clickable { +.leaflet-interactive { cursor: pointer; } -.leaflet-container { +.leaflet-grab { cursor: -webkit-grab; cursor: -moz-grab; } +.leaflet-crosshair, +.leaflet-crosshair .leaflet-interactive { + cursor: crosshair; + } .leaflet-popup-pane, .leaflet-control { cursor: auto; } -.leaflet-dragging .leaflet-container, -.leaflet-dragging .leaflet-clickable { +.leaflet-dragging .leaflet-grab, +.leaflet-dragging .leaflet-grab .leaflet-interactive, +.leaflet-dragging .leaflet-marker-draggable { cursor: move; cursor: -webkit-grabbing; cursor: -moz-grabbing; } +/* marker & overlays interactivity */ +.leaflet-marker-icon, +.leaflet-marker-shadow, +.leaflet-image-layer, +.leaflet-pane > svg path, +.leaflet-tile-container { + pointer-events: none; + } + +.leaflet-marker-icon.leaflet-interactive, +.leaflet-image-layer.leaflet-interactive, +.leaflet-pane > svg path.leaflet-interactive { + pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */ + pointer-events: auto; + } /* visual tweaks */ @@ -303,6 +357,10 @@ color: #333; background: #fff; } +.leaflet-control-layers-scrollbar { + overflow-y: scroll; + padding-right: 5px; + } .leaflet-control-layers-selector { margin-top: 2px; position: relative; @@ -317,6 +375,11 @@ margin: 5px -10px 5px -6px; } +/* Default icon URLs */ +.leaflet-default-icon-path { + background-image: url(images/marker-icon.png); + } + /* attribution and scale controls */ @@ -354,8 +417,8 @@ font-size: 11px; white-space: nowrap; overflow: hidden; - -moz-box-sizing: content-box; - box-sizing: content-box; + -moz-box-sizing: border-box; + box-sizing: border-box; background: #fff; background: rgba(255, 255, 255, 0.5); @@ -386,6 +449,7 @@ .leaflet-popup { position: absolute; text-align: center; + margin-bottom: 20px; } .leaflet-popup-content-wrapper { padding: 1px; @@ -400,11 +464,13 @@ margin: 18px 0; } .leaflet-popup-tip-container { - margin: 0 auto; width: 40px; height: 20px; - position: relative; + position: absolute; + left: 50%; + margin-left: -20px; overflow: hidden; + pointer-events: none; } .leaflet-popup-tip { width: 17px; @@ -422,7 +488,7 @@ .leaflet-popup-content-wrapper, .leaflet-popup-tip { background: white; - + color: #333; box-shadow: 0 3px 14px rgba(0,0,0,0.4); } .leaflet-container a.leaflet-popup-close-button { @@ -430,6 +496,7 @@ top: 0; right: 0; padding: 4px 4px 0 0; + border: none; text-align: center; width: 18px; height: 14px; @@ -476,3 +543,82 @@ background: #fff; border: 1px solid #666; } + + +/* Tooltip */ +/* Base styles for the element that has a tooltip */ +.leaflet-tooltip { + position: absolute; + padding: 6px; + background-color: #fff; + border: 1px solid #fff; + border-radius: 3px; + color: #222; + white-space: nowrap; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + pointer-events: none; + box-shadow: 0 1px 3px rgba(0,0,0,0.4); + } +.leaflet-tooltip.leaflet-clickable { + cursor: pointer; + pointer-events: auto; + } +.leaflet-tooltip-top:before, +.leaflet-tooltip-bottom:before, +.leaflet-tooltip-left:before, +.leaflet-tooltip-right:before { + position: absolute; + pointer-events: none; + border: 6px solid transparent; + background: transparent; + content: ""; + } + +/* Directions */ + +.leaflet-tooltip-bottom { + margin-top: 6px; +} +.leaflet-tooltip-top { + margin-top: -6px; +} +.leaflet-tooltip-bottom:before, +.leaflet-tooltip-top:before { + left: 50%; + margin-left: -6px; + } +.leaflet-tooltip-top:before { + bottom: 0; + margin-bottom: -12px; + border-top-color: #fff; + } +.leaflet-tooltip-bottom:before { + top: 0; + margin-top: -12px; + margin-left: -6px; + border-bottom-color: #fff; + } +.leaflet-tooltip-left { + margin-left: -6px; +} +.leaflet-tooltip-right { + margin-left: 6px; +} +.leaflet-tooltip-left:before, +.leaflet-tooltip-right:before { + top: 50%; + margin-top: -6px; + } +.leaflet-tooltip-left:before { + right: 0; + margin-right: -12px; + border-left-color: #fff; + } +.leaflet-tooltip-right:before { + left: 0; + margin-left: -12px; + border-right-color: #fff; + } diff --git a/www7/sites/all/libraries/leaflet/leaflet.js b/www7/sites/all/libraries/leaflet/leaflet.js new file mode 100644 index 000000000..7df6cac82 --- /dev/null +++ b/www7/sites/all/libraries/leaflet/leaflet.js @@ -0,0 +1,9 @@ +/* + Leaflet 1.0.2+4bbb16c, a JS library for interactive maps. http://leafletjs.com + (c) 2010-2016 Vladimir Agafonkin, (c) 2010-2011 CloudMade +*/ +!function(t,e,i){function n(){var e=t.L;o.noConflict=function(){return t.L=e,this},t.L=o}var o={version:"1.0.2+4bbb16c"};"object"==typeof module&&"object"==typeof module.exports?module.exports=o:"function"==typeof define&&define.amd&&define(o),"undefined"!=typeof t&&n(),o.Util={extend:function(t){var e,i,n,o;for(i=1,n=arguments.length;i1}}(),o.Point=function(t,e,i){this.x=i?Math.round(t):t,this.y=i?Math.round(e):e},o.Point.prototype={clone:function(){return new o.Point(this.x,this.y)},add:function(t){return this.clone()._add(o.point(t))},_add:function(t){return this.x+=t.x,this.y+=t.y,this},subtract:function(t){return this.clone()._subtract(o.point(t))},_subtract:function(t){return this.x-=t.x,this.y-=t.y,this},divideBy:function(t){return this.clone()._divideBy(t)},_divideBy:function(t){return this.x/=t,this.y/=t,this},multiplyBy:function(t){return this.clone()._multiplyBy(t)},_multiplyBy:function(t){return this.x*=t,this.y*=t,this},scaleBy:function(t){return new o.Point(this.x*t.x,this.y*t.y)},unscaleBy:function(t){return new o.Point(this.x/t.x,this.y/t.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},distanceTo:function(t){t=o.point(t);var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},equals:function(t){return t=o.point(t),t.x===this.x&&t.y===this.y},contains:function(t){return t=o.point(t),Math.abs(t.x)<=Math.abs(this.x)&&Math.abs(t.y)<=Math.abs(this.y)},toString:function(){return"Point("+o.Util.formatNum(this.x)+", "+o.Util.formatNum(this.y)+")"}},o.point=function(t,e,n){return t instanceof o.Point?t:o.Util.isArray(t)?new o.Point(t[0],t[1]):t===i||null===t?t:"object"==typeof t&&"x"in t&&"y"in t?new o.Point(t.x,t.y):new o.Point(t,e,n)},o.Bounds=function(t,e){if(t)for(var i=e?[t,e]:t,n=0,o=i.length;n=this.min.x&&i.x<=this.max.x&&e.y>=this.min.y&&i.y<=this.max.y},intersects:function(t){t=o.bounds(t);var e=this.min,i=this.max,n=t.min,s=t.max,r=s.x>=e.x&&n.x<=i.x,a=s.y>=e.y&&n.y<=i.y;return r&&a},overlaps:function(t){t=o.bounds(t);var e=this.min,i=this.max,n=t.min,s=t.max,r=s.x>e.x&&n.xe.y&&n.y0&&new RegExp("(^|\\s)"+e+"(\\s|$)").test(n)},addClass:function(t,e){if(t.classList!==i)for(var n=o.Util.splitWords(e),s=0,r=n.length;s=n.lat&&i.lat<=s.lat&&e.lng>=n.lng&&i.lng<=s.lng},intersects:function(t){t=o.latLngBounds(t);var e=this._southWest,i=this._northEast,n=t.getSouthWest(),s=t.getNorthEast(),r=s.lat>=e.lat&&n.lat<=i.lat,a=s.lng>=e.lng&&n.lng<=i.lng;return r&&a},overlaps:function(t){t=o.latLngBounds(t);var e=this._southWest,i=this._northEast,n=t.getSouthWest(),s=t.getNorthEast(),r=s.lat>e.lat&&n.late.lng&&n.lngthis.options.maxZoom?this.setZoom(t):this},panInsideBounds:function(t,e){this._enforcingBounds=!0;var i=this.getCenter(),n=this._limitCenter(i,this._zoom,o.latLngBounds(t));return i.equals(n)||this.panTo(n,e),this._enforcingBounds=!1,this},invalidateSize:function(t){if(!this._loaded)return this;t=o.extend({animate:!1,pan:!0},t===!0?{animate:!0}:t);var e=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var i=this.getSize(),n=e.divideBy(2).round(),s=i.divideBy(2).round(),r=n.subtract(s);return r.x||r.y?(t.animate&&t.pan?this.panBy(r):(t.pan&&this._rawPanBy(r),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(o.bind(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:e,newSize:i})):this},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(t){if(t=this._locateOptions=o.extend({timeout:1e4,watch:!1},t),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var e=o.bind(this._handleGeolocationResponse,this),i=o.bind(this._handleGeolocationError,this);return t.watch?this._locationWatchId=navigator.geolocation.watchPosition(e,i,t):navigator.geolocation.getCurrentPosition(e,i,t),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(t){var e=t.code,i=t.message||(1===e?"permission denied":2===e?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:e,message:"Geolocation error: "+i+"."})},_handleGeolocationResponse:function(t){var e=t.coords.latitude,i=t.coords.longitude,n=new o.LatLng(e,i),s=n.toBounds(t.coords.accuracy),r=this._locateOptions;if(r.setView){var a=this.getBoundsZoom(s);this.setView(n,r.maxZoom?Math.min(a,r.maxZoom):a)}var h={latlng:n,bounds:s,timestamp:t.timestamp};for(var l in t.coords)"number"==typeof t.coords[l]&&(h[l]=t.coords[l]);this.fire("locationfound",h)},addHandler:function(t,e){if(!e)return this;var i=this[t]=new e(this);return this._handlers.push(i),this.options[t]&&i.enable(),this},remove:function(){if(this._initEvents(!0),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch(t){this._container._leaflet_id=i,this._containerId=i}o.DomUtil.remove(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._clearHandlers(),this._loaded&&this.fire("unload");for(var t in this._layers)this._layers[t].remove();return this},createPane:function(t,e){var i="leaflet-pane"+(t?" leaflet-"+t.replace("Pane","")+"-pane":""),n=o.DomUtil.create("div",i,e||this._mapPane);return t&&(this._panes[t]=n),n},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter:this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds(),e=this.unproject(t.getBottomLeft()),i=this.unproject(t.getTopRight());return new o.LatLngBounds(e,i)},getMinZoom:function(){return this.options.minZoom===i?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===i?this._layersMaxZoom===i?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(t,e,i){t=o.latLngBounds(t),i=o.point(i||[0,0]);var n=this.getZoom()||0,s=this.getMinZoom(),r=this.getMaxZoom(),a=t.getNorthWest(),h=t.getSouthEast(),l=this.getSize().subtract(i),u=this.project(h,n).subtract(this.project(a,n)),c=o.Browser.any3d?this.options.zoomSnap:1,d=Math.min(l.x/u.x,l.y/u.y);return n=this.getScaleZoom(d,n),c&&(n=Math.round(n/(c/100))*(c/100),n=e?Math.ceil(n/c)*c:Math.floor(n/c)*c),Math.max(s,Math.min(r,n))},getSize:function(){return this._size&&!this._sizeChanged||(this._size=new o.Point(this._container.clientWidth,this._container.clientHeight),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(t,e){var i=this._getTopLeftPoint(t,e);return new o.Bounds(i,i.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(t){return this.options.crs.getProjectedBounds(t===i?this.getZoom():t)},getPane:function(t){return"string"==typeof t?this._panes[t]:t},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(t,e){var n=this.options.crs;return e=e===i?this._zoom:e,n.scale(t)/n.scale(e)},getScaleZoom:function(t,e){var n=this.options.crs;e=e===i?this._zoom:e;var o=n.zoom(t*n.scale(e));return isNaN(o)?1/0:o},project:function(t,e){return e=e===i?this._zoom:e,this.options.crs.latLngToPoint(o.latLng(t),e)},unproject:function(t,e){return e=e===i?this._zoom:e,this.options.crs.pointToLatLng(o.point(t),e)},layerPointToLatLng:function(t){var e=o.point(t).add(this.getPixelOrigin());return this.unproject(e)},latLngToLayerPoint:function(t){var e=this.project(o.latLng(t))._round();return e._subtract(this.getPixelOrigin())},wrapLatLng:function(t){return this.options.crs.wrapLatLng(o.latLng(t))},distance:function(t,e){return this.options.crs.distance(o.latLng(t),o.latLng(e))},containerPointToLayerPoint:function(t){return o.point(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return o.point(t).add(this._getMapPanePos())},containerPointToLatLng:function(t){var e=this.containerPointToLayerPoint(o.point(t));return this.layerPointToLatLng(e)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(o.latLng(t)))},mouseEventToContainerPoint:function(t){return o.DomEvent.getMousePosition(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(t){var e=this._container=o.DomUtil.get(t);if(!e)throw new Error("Map container not found.");if(e._leaflet_id)throw new Error("Map container is already initialized.");o.DomEvent.addListener(e,"scroll",this._onScroll,this),this._containerId=o.Util.stamp(e)},_initLayout:function(){var t=this._container;this._fadeAnimated=this.options.fadeAnimation&&o.Browser.any3d,o.DomUtil.addClass(t,"leaflet-container"+(o.Browser.touch?" leaflet-touch":"")+(o.Browser.retina?" leaflet-retina":"")+(o.Browser.ielt9?" leaflet-oldie":"")+(o.Browser.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var e=o.DomUtil.getStyle(t,"position");"absolute"!==e&&"relative"!==e&&"fixed"!==e&&(t.style.position="relative"),this._initPanes(), +this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),o.DomUtil.setPosition(this._mapPane,new o.Point(0,0)),this.createPane("tilePane"),this.createPane("shadowPane"),this.createPane("overlayPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(o.DomUtil.addClass(t.markerPane,"leaflet-zoom-hide"),o.DomUtil.addClass(t.shadowPane,"leaflet-zoom-hide"))},_resetView:function(t,e){o.DomUtil.setPosition(this._mapPane,new o.Point(0,0));var i=!this._loaded;this._loaded=!0,e=this._limitZoom(e),this.fire("viewprereset");var n=this._zoom!==e;this._moveStart(n)._move(t,e)._moveEnd(n),this.fire("viewreset"),i&&this.fire("load")},_moveStart:function(t){return t&&this.fire("zoomstart"),this.fire("movestart")},_move:function(t,e,n){e===i&&(e=this._zoom);var o=this._zoom!==e;return this._zoom=e,this._lastCenter=t,this._pixelOrigin=this._getNewPixelOrigin(t),(o||n&&n.pinch)&&this.fire("zoom",n),this.fire("move",n)},_moveEnd:function(t){return t&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return o.Util.cancelAnimFrame(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(t){o.DomUtil.setPosition(this._mapPane,this._getMapPanePos().subtract(t))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(e){if(o.DomEvent){this._targets={},this._targets[o.stamp(this._container)]=this;var i=e?"off":"on";o.DomEvent[i](this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress",this._handleDOMEvent,this),this.options.trackResize&&o.DomEvent[i](t,"resize",this._onResize,this),o.Browser.any3d&&this.options.transform3DLimit&&this[i]("moveend",this._onMoveEnd)}},_onResize:function(){o.Util.cancelAnimFrame(this._resizeRequest),this._resizeRequest=o.Util.requestAnimFrame(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var t=this._getMapPanePos();Math.max(Math.abs(t.x),Math.abs(t.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(t,e){for(var i,n=[],s="mouseout"===e||"mouseover"===e,r=t.target||t.srcElement,a=!1;r;){if(i=this._targets[o.stamp(r)],i&&("click"===e||"preclick"===e)&&!t._simulated&&this._draggableMoved(i)){a=!0;break}if(i&&i.listens(e,!0)){if(s&&!o.DomEvent._isExternalTarget(r,t))break;if(n.push(i),s)break}if(r===this._container)break;r=r.parentNode}return n.length||a||s||!o.DomEvent._isExternalTarget(r,t)||(n=[this]),n},_handleDOMEvent:function(t){if(this._loaded&&!o.DomEvent._skipped(t)){var e="keypress"===t.type&&13===t.keyCode?"click":t.type;"mousedown"===e&&o.DomUtil.preventOutline(t.target||t.srcElement),this._fireDOMEvent(t,e)}},_fireDOMEvent:function(t,e,i){if("click"===t.type){var n=o.Util.extend({},t);n.type="preclick",this._fireDOMEvent(n,n.type,i)}if(!t._stopped&&(i=(i||[]).concat(this._findEventTargets(t,e)),i.length)){var s=i[0];"contextmenu"===e&&s.listens(e,!0)&&o.DomEvent.preventDefault(t);var r={originalEvent:t};if("keypress"!==t.type){var a=s instanceof o.Marker;r.containerPoint=a?this.latLngToContainerPoint(s.getLatLng()):this.mouseEventToContainerPoint(t),r.layerPoint=this.containerPointToLayerPoint(r.containerPoint),r.latlng=a?s.getLatLng():this.layerPointToLatLng(r.layerPoint)}for(var h=0;h0?Math.round(t-e)/2:Math.max(0,Math.ceil(t))-Math.max(0,Math.floor(e))},_limitZoom:function(t){var e=this.getMinZoom(),i=this.getMaxZoom(),n=o.Browser.any3d?this.options.zoomSnap:1;return n&&(t=Math.round(t/n)*n),Math.max(e,Math.min(i,t))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){o.DomUtil.removeClass(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(t,e){var i=this._getCenterOffset(t)._floor();return!((e&&e.animate)!==!0&&!this.getSize().contains(i))&&(this.panBy(i,e),!0)},_createAnimProxy:function(){var t=this._proxy=o.DomUtil.create("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(t),this.on("zoomanim",function(e){var i=o.DomUtil.TRANSFORM,n=t.style[i];o.DomUtil.setTransform(t,this.project(e.center,e.zoom),this.getZoomScale(e.zoom,1)),n===t.style[i]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",function(){var e=this.getCenter(),i=this.getZoom();o.DomUtil.setTransform(t,this.project(e,i),this.getZoomScale(i,1))},this)},_catchTransitionEnd:function(t){this._animatingZoom&&t.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(t,e,i){if(this._animatingZoom)return!0;if(i=i||{},!this._zoomAnimated||i.animate===!1||this._nothingToAnimate()||Math.abs(e-this._zoom)>this.options.zoomAnimationThreshold)return!1;var n=this.getZoomScale(e),s=this._getCenterOffset(t)._divideBy(1-1/n);return!(i.animate!==!0&&!this.getSize().contains(s))&&(o.Util.requestAnimFrame(function(){this._moveStart(!0)._animateZoom(t,e,!0)},this),!0)},_animateZoom:function(t,e,i,n){i&&(this._animatingZoom=!0,this._animateToCenter=t,this._animateToZoom=e,o.DomUtil.addClass(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:t,zoom:e,noUpdate:n}),setTimeout(o.bind(this._onZoomTransitionEnd,this),250)},_onZoomTransitionEnd:function(){this._animatingZoom&&(o.DomUtil.removeClass(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom),o.Util.requestAnimFrame(function(){this._moveEnd(!0)},this))}}),o.map=function(t,e){return new o.Map(t,e)},o.Layer=o.Evented.extend({options:{pane:"overlayPane",nonBubblingEvents:[],attribution:null},addTo:function(t){return t.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(t){return t&&t.removeLayer(this),this},getPane:function(t){return this._map.getPane(t?this.options[t]||t:this.options.pane)},addInteractiveTarget:function(t){return this._map._targets[o.stamp(t)]=this,this},removeInteractiveTarget:function(t){return delete this._map._targets[o.stamp(t)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(t){var e=t.target;if(e.hasLayer(this)){if(this._map=e,this._zoomAnimated=e._zoomAnimated,this.getEvents){var i=this.getEvents();e.on(i,this),this.once("remove",function(){e.off(i,this)},this)}this.onAdd(e),this.getAttribution&&this._map.attributionControl&&this._map.attributionControl.addAttribution(this.getAttribution()),this.fire("add"),e.fire("layeradd",{layer:this})}}}),o.Map.include({addLayer:function(t){var e=o.stamp(t);return this._layers[e]?this:(this._layers[e]=t,t._mapToAdd=this,t.beforeAdd&&t.beforeAdd(this),this.whenReady(t._layerAdd,t),this)},removeLayer:function(t){var e=o.stamp(t);return this._layers[e]?(this._loaded&&t.onRemove(this),t.getAttribution&&this.attributionControl&&this.attributionControl.removeAttribution(t.getAttribution()),delete this._layers[e],this._loaded&&(this.fire("layerremove",{layer:t}),t.fire("remove")),t._map=t._mapToAdd=null,this):this},hasLayer:function(t){return!!t&&o.stamp(t)in this._layers},eachLayer:function(t,e){for(var i in this._layers)t.call(e,this._layers[i]);return this},_addLayers:function(t){t=t?o.Util.isArray(t)?t:[t]:[];for(var e=0,i=t.length;ethis._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===i&&this._layersMinZoom&&this.getZoom()100&&n<500||t.target._simulatedClick&&!t._simulated?void o.DomEvent.stop(t):(o.DomEvent._lastClick=i,void e(t))}},o.DomEvent.addListener=o.DomEvent.on,o.DomEvent.removeListener=o.DomEvent.off,o.PosAnimation=o.Evented.extend({run:function(t,e,i,n){this.stop(),this._el=t,this._inProgress=!0,this._duration=i||.25,this._easeOutPower=1/Math.max(n||.5,.2),this._startPos=o.DomUtil.getPosition(t),this._offset=e.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=o.Util.requestAnimFrame(this._animate,this),this._step()},_step:function(t){var e=+new Date-this._startTime,i=1e3*this._duration;e1e-7;l++)e=r*Math.sin(h),e=Math.pow((1-e)/(1+e),r/2),u=Math.PI/2-2*Math.atan(a*e)-h,h+=u;return new o.LatLng(h*i,t.x*i/n)}},o.CRS.EPSG3395=o.extend({},o.CRS.Earth,{code:"EPSG:3395",projection:o.Projection.Mercator,transformation:function(){var t=.5/(Math.PI*o.Projection.Mercator.R);return new o.Transformation(t,.5,-t,.5)}()}),o.GridLayer=o.Layer.extend({options:{tileSize:256,opacity:1,updateWhenIdle:o.Browser.mobile,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:i,noWrap:!1,pane:"tilePane",className:"",keepBuffer:2},initialize:function(t){o.setOptions(this,t)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView(),this._update()},beforeAdd:function(t){t._addZoomLimit(this)},onRemove:function(t){this._removeAllTiles(),o.DomUtil.remove(this._container),t._removeZoomLimit(this),this._container=null,this._tileZoom=null},bringToFront:function(){return this._map&&(o.DomUtil.toFront(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(o.DomUtil.toBack(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(t){return this.options.opacity=t,this._updateOpacity(),this},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){return this._map&&(this._removeAllTiles(),this._update()),this},getEvents:function(){var t={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||(this._onMove=o.Util.throttle(this._onMoveEnd,this.options.updateInterval,this)),t.move=this._onMove),this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},createTile:function(){return e.createElement("div")},getTileSize:function(){var t=this.options.tileSize;return t instanceof o.Point?t:new o.Point(t,t)},_updateZIndex:function(){this._container&&this.options.zIndex!==i&&null!==this.options.zIndex&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(t){for(var e,i=this.getPane().children,n=-t(-(1/0),1/0),o=0,s=i.length;othis.options.maxZoom||in&&this._retainParent(s,r,a,n))},_retainChildren:function(t,e,i,n){for(var s=2*t;s<2*t+2;s++)for(var r=2*e;r<2*e+2;r++){var a=new o.Point(s,r);a.z=i+1;var h=this._tileCoordsToKey(a),l=this._tiles[h];l&&l.active?l.retain=!0:(l&&l.loaded&&(l.retain=!0),i+1this.options.maxZoom||this.options.minZoom!==i&&s1)return void this._setView(t,s);for(var m=a.min.y;m<=a.max.y;m++)for(var p=a.min.x;p<=a.max.x;p++){var f=new o.Point(p,m);if(f.z=this._tileZoom,this._isValidTile(f)){var g=this._tiles[this._tileCoordsToKey(f)];g?g.current=!0:l.push(f)}}if(l.sort(function(t,e){return t.distanceTo(h)-e.distanceTo(h)}),0!==l.length){this._loading||(this._loading=!0,this.fire("loading"));var v=e.createDocumentFragment();for(p=0;pi.max.x)||!e.wrapLat&&(t.yi.max.y))return!1}if(!this.options.bounds)return!0;var n=this._tileCoordsToBounds(t);return o.latLngBounds(this.options.bounds).overlaps(n)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToBounds:function(t){var e=this._map,i=this.getTileSize(),n=t.scaleBy(i),s=n.add(i),r=e.unproject(n,t.z),a=e.unproject(s,t.z);return this.options.noWrap||(r=e.wrapLatLng(r),a=e.wrapLatLng(a)),new o.LatLngBounds(r,a)},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var e=t.split(":"),i=new o.Point(+e[0],+e[1]);return i.z=+e[2],i},_removeTile:function(t){var e=this._tiles[t];e&&(o.DomUtil.remove(e.el),delete this._tiles[t],this.fire("tileunload",{tile:e.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){o.DomUtil.addClass(t,"leaflet-tile");var e=this.getTileSize();t.style.width=e.x+"px",t.style.height=e.y+"px",t.onselectstart=o.Util.falseFn,t.onmousemove=o.Util.falseFn,o.Browser.ielt9&&this.options.opacity<1&&o.DomUtil.setOpacity(t,this.options.opacity),o.Browser.android&&!o.Browser.android23&&(t.style.WebkitBackfaceVisibility="hidden")},_addTile:function(t,e){var i=this._getTilePos(t),n=this._tileCoordsToKey(t),s=this.createTile(this._wrapCoords(t),o.bind(this._tileReady,this,t));this._initTile(s),this.createTile.length<2&&o.Util.requestAnimFrame(o.bind(this._tileReady,this,t,null,s)),o.DomUtil.setPosition(s,i),this._tiles[n]={el:s,coords:t,current:!0},e.appendChild(s),this.fire("tileloadstart",{tile:s,coords:t})},_tileReady:function(t,e,i){if(this._map){e&&this.fire("tileerror",{error:e,tile:i,coords:t});var n=this._tileCoordsToKey(t);i=this._tiles[n],i&&(i.loaded=+new Date,this._map._fadeAnimated?(o.DomUtil.setOpacity(i.el,0),o.Util.cancelAnimFrame(this._fadeFrame),this._fadeFrame=o.Util.requestAnimFrame(this._updateOpacity,this)):(i.active=!0,this._pruneTiles()),e||(o.DomUtil.addClass(i.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:i.el,coords:t})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),o.Browser.ielt9||!this._map._fadeAnimated?o.Util.requestAnimFrame(this._pruneTiles,this):setTimeout(o.bind(this._pruneTiles,this),250)))}},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(t){var e=new o.Point(this._wrapX?o.Util.wrapNum(t.x,this._wrapX):t.x,this._wrapY?o.Util.wrapNum(t.y,this._wrapY):t.y);return e.z=t.z,e},_pxBoundsToTileRange:function(t){var e=this.getTileSize();return new o.Bounds(t.min.unscaleBy(e).floor(),t.max.unscaleBy(e).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}}),o.gridLayer=function(t){return new o.GridLayer(t)},o.TileLayer=o.GridLayer.extend({options:{minZoom:0,maxZoom:18,maxNativeZoom:null,minNativeZoom:null,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1},initialize:function(t,e){this._url=t,e=o.setOptions(this,e),e.detectRetina&&o.Browser.retina&&e.maxZoom>0&&(e.tileSize=Math.floor(e.tileSize/2),e.zoomReverse?(e.zoomOffset--,e.minZoom++):(e.zoomOffset++,e.maxZoom--),e.minZoom=Math.max(0,e.minZoom)),"string"==typeof e.subdomains&&(e.subdomains=e.subdomains.split("")),o.Browser.android||this.on("tileunload",this._onTileRemove)},setUrl:function(t,e){return this._url=t,e||this.redraw(),this},createTile:function(t,i){var n=e.createElement("img");return o.DomEvent.on(n,"load",o.bind(this._tileOnLoad,this,i,n)),o.DomEvent.on(n,"error",o.bind(this._tileOnError,this,i,n)),this.options.crossOrigin&&(n.crossOrigin=""),n.alt="",n.setAttribute("role","presentation"),n.src=this.getTileUrl(t),n},getTileUrl:function(t){var e={r:o.Browser.retina?"@2x":"",s:this._getSubdomain(t),x:t.x,y:t.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var i=this._globalTileRange.max.y-t.y;this.options.tms&&(e.y=i),e["-y"]=i}return o.Util.template(this._url,o.extend(e,this.options))},_tileOnLoad:function(t,e){o.Browser.ielt9?setTimeout(o.bind(t,this,null,e),0):t(null,e)},_tileOnError:function(t,e,i){var n=this.options.errorTileUrl;n&&(e.src=n),t(i,e)},getTileSize:function(){var t=this._map,e=o.GridLayer.prototype.getTileSize.call(this),i=this._tileZoom+this.options.zoomOffset,n=this.options.minNativeZoom,s=this.options.maxNativeZoom;return null!==n&&is?e.divideBy(t.getZoomScale(s,i)).round():e},_onTileRemove:function(t){t.tile.onload=null},_getZoomForUrl:function(){var t=this._tileZoom,e=this.options.maxZoom,i=this.options.zoomReverse,n=this.options.zoomOffset,o=this.options.minNativeZoom,s=this.options.maxNativeZoom;return i&&(t=e-t),t+=n,null!==o&&ts?s:t},_getSubdomain:function(t){var e=Math.abs(t.x+t.y)%this.options.subdomains.length;return this.options.subdomains[e]},_abortLoading:function(){var t,e;for(t in this._tiles)this._tiles[t].coords.z!==this._tileZoom&&(e=this._tiles[t].el,e.onload=o.Util.falseFn,e.onerror=o.Util.falseFn,e.complete||(e.src=o.Util.emptyImageUrl,o.DomUtil.remove(e)))}}),o.tileLayer=function(t,e){return new o.TileLayer(t,e)},o.TileLayer.WMS=o.TileLayer.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(t,e){this._url=t;var i=o.extend({},this.defaultWmsParams);for(var n in e)n in this.options||(i[n]=e[n]);e=o.setOptions(this,e),i.width=i.height=e.tileSize*(e.detectRetina&&o.Browser.retina?2:1),this.wmsParams=i},onAdd:function(t){this._crs=this.options.crs||t.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var e=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[e]=this._crs.code,o.TileLayer.prototype.onAdd.call(this,t)},getTileUrl:function(t){var e=this._tileCoordsToBounds(t),i=this._crs.project(e.getNorthWest()),n=this._crs.project(e.getSouthEast()),s=(this._wmsVersion>=1.3&&this._crs===o.CRS.EPSG4326?[n.y,i.x,i.y,n.x]:[i.x,n.y,n.x,i.y]).join(","),r=o.TileLayer.prototype.getTileUrl.call(this,t);return r+o.Util.getParamString(this.wmsParams,r,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+s},setParams:function(t,e){return o.extend(this.wmsParams,t),e||this.redraw(),this}}),o.tileLayer.wms=function(t,e){return new o.TileLayer.WMS(t,e)},o.ImageOverlay=o.Layer.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1},initialize:function(t,e,i){this._url=t,this._bounds=o.latLngBounds(e),o.setOptions(this,i)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(o.DomUtil.addClass(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){o.DomUtil.remove(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(t){return this.options.opacity=t,this._image&&this._updateOpacity(),this},setStyle:function(t){return t.opacity&&this.setOpacity(t.opacity),this},bringToFront:function(){return this._map&&o.DomUtil.toFront(this._image),this},bringToBack:function(){return this._map&&o.DomUtil.toBack(this._image),this},setUrl:function(t){return this._url=t,this._image&&(this._image.src=t),this},setBounds:function(t){return this._bounds=t,this._map&&this._reset(),this},getEvents:function(){var t={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var t=this._image=o.DomUtil.create("img","leaflet-image-layer "+(this._zoomAnimated?"leaflet-zoom-animated":""));t.onselectstart=o.Util.falseFn,t.onmousemove=o.Util.falseFn,t.onload=o.bind(this.fire,this,"load"),this.options.crossOrigin&&(t.crossOrigin=""),t.src=this._url,t.alt=this.options.alt},_animateZoom:function(t){var e=this._map.getZoomScale(t.zoom),i=this._map._latLngBoundsToNewLayerBounds(this._bounds,t.zoom,t.center).min;o.DomUtil.setTransform(this._image,i,e)},_reset:function(){var t=this._image,e=new o.Bounds(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),i=e.getSize();o.DomUtil.setPosition(t,e.min),t.style.width=i.x+"px",t.style.height=i.y+"px"},_updateOpacity:function(){ +o.DomUtil.setOpacity(this._image,this.options.opacity)}}),o.imageOverlay=function(t,e,i){return new o.ImageOverlay(t,e,i)},o.Icon=o.Class.extend({initialize:function(t){o.setOptions(this,t)},createIcon:function(t){return this._createIcon("icon",t)},createShadow:function(t){return this._createIcon("shadow",t)},_createIcon:function(t,e){var i=this._getIconUrl(t);if(!i){if("icon"===t)throw new Error("iconUrl not set in Icon options (see the docs).");return null}var n=this._createImg(i,e&&"IMG"===e.tagName?e:null);return this._setIconStyles(n,t),n},_setIconStyles:function(t,e){var i=this.options,n=i[e+"Size"];"number"==typeof n&&(n=[n,n]);var s=o.point(n),r=o.point("shadow"===e&&i.shadowAnchor||i.iconAnchor||s&&s.divideBy(2,!0));t.className="leaflet-marker-"+e+" "+(i.className||""),r&&(t.style.marginLeft=-r.x+"px",t.style.marginTop=-r.y+"px"),s&&(t.style.width=s.x+"px",t.style.height=s.y+"px")},_createImg:function(t,i){return i=i||e.createElement("img"),i.src=t,i},_getIconUrl:function(t){return o.Browser.retina&&this.options[t+"RetinaUrl"]||this.options[t+"Url"]}}),o.icon=function(t){return new o.Icon(t)},o.Icon.Default=o.Icon.extend({options:{iconUrl:"marker-icon.png",iconRetinaUrl:"marker-icon-2x.png",shadowUrl:"marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]},_getIconUrl:function(t){return o.Icon.Default.imagePath||(o.Icon.Default.imagePath=this._detectIconPath()),(this.options.imagePath||o.Icon.Default.imagePath)+o.Icon.prototype._getIconUrl.call(this,t)},_detectIconPath:function(){var t=o.DomUtil.create("div","leaflet-default-icon-path",e.body),i=o.DomUtil.getStyle(t,"background-image")||o.DomUtil.getStyle(t,"backgroundImage");return e.body.removeChild(t),0===i.indexOf("url")?i.replace(/^url\([\"\']?/,"").replace(/marker-icon\.png[\"\']?\)$/,""):""}}),o.Marker=o.Layer.extend({options:{icon:new o.Icon.Default,interactive:!0,draggable:!1,keyboard:!0,title:"",alt:"",zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:"markerPane",nonBubblingEvents:["click","dblclick","mouseover","mouseout","contextmenu"]},initialize:function(t,e){o.setOptions(this,e),this._latlng=o.latLng(t)},onAdd:function(t){this._zoomAnimated=this._zoomAnimated&&t.options.markerZoomAnimation,this._zoomAnimated&&t.on("zoomanim",this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(t){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),this._zoomAnimated&&t.off("zoomanim",this._animateZoom,this),this._removeIcon(),this._removeShadow()},getEvents:function(){return{zoom:this.update,viewreset:this.update}},getLatLng:function(){return this._latlng},setLatLng:function(t){var e=this._latlng;return this._latlng=o.latLng(t),this.update(),this.fire("move",{oldLatLng:e,latlng:this._latlng})},setZIndexOffset:function(t){return this.options.zIndexOffset=t,this.update()},setIcon:function(t){return this.options.icon=t,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this},getElement:function(){return this._icon},update:function(){if(this._icon){var t=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(t)}return this},_initIcon:function(){var t=this.options,e="leaflet-zoom-"+(this._zoomAnimated?"animated":"hide"),i=t.icon.createIcon(this._icon),n=!1;i!==this._icon&&(this._icon&&this._removeIcon(),n=!0,t.title&&(i.title=t.title),t.alt&&(i.alt=t.alt)),o.DomUtil.addClass(i,e),t.keyboard&&(i.tabIndex="0"),this._icon=i,t.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex});var s=t.icon.createShadow(this._shadow),r=!1;s!==this._shadow&&(this._removeShadow(),r=!0),s&&o.DomUtil.addClass(s,e),this._shadow=s,t.opacity<1&&this._updateOpacity(),n&&this.getPane().appendChild(this._icon),this._initInteraction(),s&&r&&this.getPane("shadowPane").appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),o.DomUtil.remove(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&o.DomUtil.remove(this._shadow),this._shadow=null},_setPos:function(t){o.DomUtil.setPosition(this._icon,t),this._shadow&&o.DomUtil.setPosition(this._shadow,t),this._zIndex=t.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(t){this._icon.style.zIndex=this._zIndex+t},_animateZoom:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center).round();this._setPos(e)},_initInteraction:function(){if(this.options.interactive&&(o.DomUtil.addClass(this._icon,"leaflet-interactive"),this.addInteractiveTarget(this._icon),o.Handler.MarkerDrag)){var t=this.options.draggable;this.dragging&&(t=this.dragging.enabled(),this.dragging.disable()),this.dragging=new o.Handler.MarkerDrag(this),t&&this.dragging.enable()}},setOpacity:function(t){return this.options.opacity=t,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var t=this.options.opacity;o.DomUtil.setOpacity(this._icon,t),this._shadow&&o.DomUtil.setOpacity(this._shadow,t)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor||[0,0]},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor||[0,0]}}),o.marker=function(t,e){return new o.Marker(t,e)},o.DivIcon=o.Icon.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:"leaflet-div-icon"},createIcon:function(t){var i=t&&"DIV"===t.tagName?t:e.createElement("div"),n=this.options;if(i.innerHTML=n.html!==!1?n.html:"",n.bgPos){var s=o.point(n.bgPos);i.style.backgroundPosition=-s.x+"px "+-s.y+"px"}return this._setIconStyles(i,"icon"),i},createShadow:function(){return null}}),o.divIcon=function(t){return new o.DivIcon(t)},o.DivOverlay=o.Layer.extend({options:{offset:[0,7],className:"",pane:"popupPane"},initialize:function(t,e){o.setOptions(this,t),this._source=e},onAdd:function(t){this._zoomAnimated=t._zoomAnimated,this._container||this._initLayout(),t._fadeAnimated&&o.DomUtil.setOpacity(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),t._fadeAnimated&&o.DomUtil.setOpacity(this._container,1),this.bringToFront()},onRemove:function(t){t._fadeAnimated?(o.DomUtil.setOpacity(this._container,0),this._removeTimeout=setTimeout(o.bind(o.DomUtil.remove,o.DomUtil,this._container),200)):o.DomUtil.remove(this._container)},getLatLng:function(){return this._latlng},setLatLng:function(t){return this._latlng=o.latLng(t),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(t){return this._content=t,this.update(),this},getElement:function(){return this._container},update:function(){this._map&&(this._container.style.visibility="hidden",this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility="",this._adjustPan())},getEvents:function(){var t={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&o.DomUtil.toFront(this._container),this},bringToBack:function(){return this._map&&o.DomUtil.toBack(this._container),this},_updateContent:function(){if(this._content){var t=this._contentNode,e="function"==typeof this._content?this._content(this._source||this):this._content;if("string"==typeof e)t.innerHTML=e;else{for(;t.hasChildNodes();)t.removeChild(t.firstChild);t.appendChild(e)}this.fire("contentupdate")}},_updatePosition:function(){if(this._map){var t=this._map.latLngToLayerPoint(this._latlng),e=o.point(this.options.offset),i=this._getAnchor();this._zoomAnimated?o.DomUtil.setPosition(this._container,t.add(i)):e=e.add(t).add(i);var n=this._containerBottom=-e.y,s=this._containerLeft=-Math.round(this._containerWidth/2)+e.x;this._container.style.bottom=n+"px",this._container.style.left=s+"px"}},_getAnchor:function(){return[0,0]}}),o.Popup=o.DivOverlay.extend({options:{maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,className:""},openOn:function(t){return t.openPopup(this),this},onAdd:function(t){o.DivOverlay.prototype.onAdd.call(this,t),t.fire("popupopen",{popup:this}),this._source&&(this._source.fire("popupopen",{popup:this},!0),this._source instanceof o.Path||this._source.on("preclick",o.DomEvent.stopPropagation))},onRemove:function(t){o.DivOverlay.prototype.onRemove.call(this,t),t.fire("popupclose",{popup:this}),this._source&&(this._source.fire("popupclose",{popup:this},!0),this._source instanceof o.Path||this._source.off("preclick",o.DomEvent.stopPropagation))},getEvents:function(){var t=o.DivOverlay.prototype.getEvents.call(this);return("closeOnClick"in this.options?this.options.closeOnClick:this._map.options.closePopupOnClick)&&(t.preclick=this._close),this.options.keepInView&&(t.moveend=this._adjustPan),t},_close:function(){this._map&&this._map.closePopup(this)},_initLayout:function(){var t="leaflet-popup",e=this._container=o.DomUtil.create("div",t+" "+(this.options.className||"")+" leaflet-zoom-animated");if(this.options.closeButton){var i=this._closeButton=o.DomUtil.create("a",t+"-close-button",e);i.href="#close",i.innerHTML="×",o.DomEvent.on(i,"click",this._onCloseButtonClick,this)}var n=this._wrapper=o.DomUtil.create("div",t+"-content-wrapper",e);this._contentNode=o.DomUtil.create("div",t+"-content",n),o.DomEvent.disableClickPropagation(n).disableScrollPropagation(this._contentNode).on(n,"contextmenu",o.DomEvent.stopPropagation),this._tipContainer=o.DomUtil.create("div",t+"-tip-container",e),this._tip=o.DomUtil.create("div",t+"-tip",this._tipContainer)},_updateLayout:function(){var t=this._contentNode,e=t.style;e.width="",e.whiteSpace="nowrap";var i=t.offsetWidth;i=Math.min(i,this.options.maxWidth),i=Math.max(i,this.options.minWidth),e.width=i+1+"px",e.whiteSpace="",e.height="";var n=t.offsetHeight,s=this.options.maxHeight,r="leaflet-popup-scrolled";s&&n>s?(e.height=s+"px",o.DomUtil.addClass(t,r)):o.DomUtil.removeClass(t,r),this._containerWidth=this._container.offsetWidth},_animateZoom:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center),i=this._getAnchor();o.DomUtil.setPosition(this._container,e.add(i))},_adjustPan:function(){if(!(!this.options.autoPan||this._map._panAnim&&this._map._panAnim._inProgress)){var t=this._map,e=parseInt(o.DomUtil.getStyle(this._container,"marginBottom"),10)||0,i=this._container.offsetHeight+e,n=this._containerWidth,s=new o.Point(this._containerLeft,-i-this._containerBottom);s._add(o.DomUtil.getPosition(this._container));var r=t.layerPointToContainerPoint(s),a=o.point(this.options.autoPanPadding),h=o.point(this.options.autoPanPaddingTopLeft||a),l=o.point(this.options.autoPanPaddingBottomRight||a),u=t.getSize(),c=0,d=0;r.x+n+l.x>u.x&&(c=r.x+n-u.x+l.x),r.x-c-h.x<0&&(c=r.x-h.x),r.y+i+l.y>u.y&&(d=r.y+i-u.y+l.y),r.y-d-h.y<0&&(d=r.y-h.y),(c||d)&&t.fire("autopanstart").panBy([c,d])}},_onCloseButtonClick:function(t){this._close(),o.DomEvent.stop(t)},_getAnchor:function(){return o.point(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),o.popup=function(t,e){return new o.Popup(t,e)},o.Map.mergeOptions({closePopupOnClick:!0}),o.Map.include({openPopup:function(t,e,i){return t instanceof o.Popup||(t=new o.Popup(i).setContent(t)),e&&t.setLatLng(e),this.hasLayer(t)?this:(this._popup&&this._popup.options.autoClose&&this.closePopup(),this._popup=t,this.addLayer(t))},closePopup:function(t){return t&&t!==this._popup||(t=this._popup,this._popup=null),t&&this.removeLayer(t),this}}),o.Layer.include({bindPopup:function(t,e){return t instanceof o.Popup?(o.setOptions(t,e),this._popup=t,t._source=this):(this._popup&&!e||(this._popup=new o.Popup(e,this)),this._popup.setContent(t)),this._popupHandlersAdded||(this.on({click:this._openPopup,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(t,e){if(t instanceof o.Layer||(e=t,t=this),t instanceof o.FeatureGroup)for(var i in this._layers){t=this._layers[i];break}return e||(e=t.getCenter?t.getCenter():t.getLatLng()),this._popup&&this._map&&(this._popup._source=t,this._popup.update(),this._map.openPopup(this._popup,e)),this},closePopup:function(){return this._popup&&this._popup._close(),this},togglePopup:function(t){return this._popup&&(this._popup._map?this.closePopup():this.openPopup(t)),this},isPopupOpen:function(){return this._popup.isOpen()},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(t){var e=t.layer||t.target;if(this._popup&&this._map)return o.DomEvent.stop(t),e instanceof o.Path?void this.openPopup(t.layer||t.target,t.latlng):void(this._map.hasLayer(this._popup)&&this._popup._source===e?this.closePopup():this.openPopup(e,t.latlng))},_movePopup:function(t){this._popup.setLatLng(t.latlng)}}),o.Tooltip=o.DivOverlay.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,interactive:!1,opacity:.9},onAdd:function(t){o.DivOverlay.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&this._source.fire("tooltipopen",{tooltip:this},!0)},onRemove:function(t){o.DivOverlay.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&this._source.fire("tooltipclose",{tooltip:this},!0)},getEvents:function(){var t=o.DivOverlay.prototype.getEvents.call(this);return o.Browser.touch&&!this.options.permanent&&(t.preclick=this._close),t},_close:function(){this._map&&this._map.closeTooltip(this)},_initLayout:function(){var t="leaflet-tooltip",e=t+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=o.DomUtil.create("div",e)},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var e=this._map,i=this._container,n=e.latLngToContainerPoint(e.getCenter()),s=e.layerPointToContainerPoint(t),r=this.options.direction,a=i.offsetWidth,h=i.offsetHeight,l=o.point(this.options.offset),u=this._getAnchor();"top"===r?t=t.add(o.point(-a/2+l.x,-h+l.y+u.y,!0)):"bottom"===r?t=t.subtract(o.point(a/2-l.x,-l.y,!0)):"center"===r?t=t.subtract(o.point(a/2+l.x,h/2-u.y+l.y,!0)):"right"===r||"auto"===r&&s.xh&&(s=r,h=a);h>i&&(e[s]=1,this._simplifyDPStep(t,e,i,n,s),this._simplifyDPStep(t,e,i,s,o))},_reducePoints:function(t,e){for(var i=[t[0]],n=1,o=0,s=t.length;ne&&(i.push(t[n]),o=n);return oe.max.x&&(i|=2),t.ye.max.y&&(i|=8),i},_sqDist:function(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n},_sqClosestPointOnSegment:function(t,e,i,n){var s,r=e.x,a=e.y,h=i.x-r,l=i.y-a,u=h*h+l*l;return u>0&&(s=((t.x-r)*h+(t.y-a)*l)/u,s>1?(r=i.x,a=i.y):s>0&&(r+=h*s,a+=l*s)),h=t.x-r,l=t.y-a,n?h*h+l*l:new o.Point(r,a)}},o.Polyline=o.Path.extend({options:{smoothFactor:1,noClip:!1},initialize:function(t,e){o.setOptions(this,e),this._setLatLngs(t)},getLatLngs:function(){return this._latlngs},setLatLngs:function(t){return this._setLatLngs(t),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(t){for(var e,i,n=1/0,s=null,r=o.LineUtil._sqClosestPointOnSegment,a=0,h=this._parts.length;ae)return r=(n-e)/i,this._map.layerPointToLatLng([s.x-r*(s.x-o.x),s.y-r*(s.y-o.y)])},getBounds:function(){return this._bounds},addLatLng:function(t,e){return e=e||this._defaultShape(),t=o.latLng(t),e.push(t),this._bounds.extend(t),this.redraw()},_setLatLngs:function(t){this._bounds=new o.LatLngBounds,this._latlngs=this._convertLatLngs(t)},_defaultShape:function(){return o.Polyline._flat(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(t){for(var e=[],i=o.Polyline._flat(t),n=0,s=t.length;n=2&&e[0]instanceof o.LatLng&&e[0].equals(e[i-1])&&e.pop(),e},_setLatLngs:function(t){o.Polyline.prototype._setLatLngs.call(this,t),o.Polyline._flat(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return o.Polyline._flat(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var t=this._renderer._bounds,e=this.options.weight,i=new o.Point(e,e);if(t=new o.Bounds(t.min.subtract(i),t.max.add(i)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(t)){if(this.options.noClip)return void(this._parts=this._rings);for(var n,s=0,r=this._rings.length;s';var i=t.firstChild;return i.style.behavior="url(#default#VML)",i&&"object"==typeof i.adj}catch(t){return!1}}(),o.SVG.include(o.Browser.vml?{_initContainer:function(){this._container=o.DomUtil.create("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(o.Renderer.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var e=t._container=o.SVG.create("shape");o.DomUtil.addClass(e,"leaflet-vml-shape "+(this.options.className||"")),e.coordsize="1 1",t._path=o.SVG.create("path"),e.appendChild(t._path),this._updateStyle(t)},_addPath:function(t){var e=t._container;this._container.appendChild(e),t.options.interactive&&t.addInteractiveTarget(e)},_removePath:function(t){var e=t._container;o.DomUtil.remove(e),t.removeInteractiveTarget(e)},_updateStyle:function(t){var e=t._stroke,i=t._fill,n=t.options,s=t._container;s.stroked=!!n.stroke,s.filled=!!n.fill,n.stroke?(e||(e=t._stroke=o.SVG.create("stroke")),s.appendChild(e),e.weight=n.weight+"px",e.color=n.color,e.opacity=n.opacity,n.dashArray?e.dashStyle=o.Util.isArray(n.dashArray)?n.dashArray.join(" "):n.dashArray.replace(/( *, *)/g," "):e.dashStyle="",e.endcap=n.lineCap.replace("butt","flat"),e.joinstyle=n.lineJoin):e&&(s.removeChild(e),t._stroke=null),n.fill?(i||(i=t._fill=o.SVG.create("fill")),s.appendChild(i),i.color=n.fillColor||n.color,i.opacity=n.fillOpacity):i&&(s.removeChild(i),t._fill=null)},_updateCircle:function(t){var e=t._point.round(),i=Math.round(t._radius),n=Math.round(t._radiusY||i);this._setPath(t,t._empty()?"M0 0":"AL "+e.x+","+e.y+" "+i+","+n+" 0,23592600")},_setPath:function(t,e){t._path.v=e},_bringToFront:function(t){o.DomUtil.toFront(t._container)},_bringToBack:function(t){o.DomUtil.toBack(t._container)}}:{}),o.Browser.vml&&(o.SVG.create=function(){try{return e.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(t){return e.createElement("')}}catch(t){return function(t){return e.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}()),o.Canvas=o.Renderer.extend({onAdd:function(){o.Renderer.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var t=this._container=e.createElement("canvas");o.DomEvent.on(t,"mousemove",o.Util.throttle(this._onMouseMove,32,this),this).on(t,"click dblclick mousedown mouseup contextmenu",this._onClick,this).on(t,"mouseout",this._handleMouseOut,this),this._ctx=t.getContext("2d")},_updatePaths:function(){var t;this._redrawBounds=null;for(var e in this._layers)t=this._layers[e],t._update();this._redraw()},_update:function(){if(!this._map._animatingZoom||!this._bounds){this._drawnLayers={},o.Renderer.prototype._update.call(this);var t=this._bounds,e=this._container,i=t.getSize(),n=o.Browser.retina?2:1;o.DomUtil.setPosition(e,t.min),e.width=n*i.x,e.height=n*i.y,e.style.width=i.x+"px",e.style.height=i.y+"px",o.Browser.retina&&this._ctx.scale(2,2),this._ctx.translate(-t.min.x,-t.min.y),this.fire("update")}},_initPath:function(t){this._updateDashArray(t),this._layers[o.stamp(t)]=t;var e=t._order={layer:t,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=e),this._drawLast=e,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(t){this._requestRedraw(t)},_removePath:function(t){var e=t._order,i=e.next,n=e.prev;i?i.prev=n:this._drawLast=n,n?n.next=i:this._drawFirst=i,delete t._order,delete this._layers[o.stamp(t)],this._requestRedraw(t)},_updatePath:function(t){this._extendRedrawBounds(t),t._project(),t._update(),this._requestRedraw(t)},_updateStyle:function(t){this._updateDashArray(t),this._requestRedraw(t)},_updateDashArray:function(t){if(t.options.dashArray){var e,i=t.options.dashArray.split(","),n=[];for(e=0;et.y!=n.y>t.y&&t.x<(n.x-i.x)*(t.y-i.y)/(n.y-i.y)+i.x&&(u=!u);return u||o.Polyline.prototype._containsPoint.call(this,t,!0)},o.CircleMarker.prototype._containsPoint=function(t){return t.distanceTo(this._point)<=this._radius+this._clickTolerance()},o.GeoJSON=o.FeatureGroup.extend({initialize:function(t,e){o.setOptions(this,e),this._layers={},t&&this.addData(t)},addData:function(t){var e,i,n,s=o.Util.isArray(t)?t:t.features;if(s){for(e=0,i=s.length;e1)return void(this._moved=!0);var n=i.touches&&1===i.touches.length?i.touches[0]:i,s=new o.Point(n.clientX,n.clientY),r=s.subtract(this._startPoint);(r.x||r.y)&&(Math.abs(r.x)+Math.abs(r.y)50&&(this._positions.shift(),this._times.shift())}this._map.fire("move",t).fire("drag",t)},_onZoomEnd:function(){var t=this._map.getSize().divideBy(2),e=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=e.subtract(t).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(t,e){return t-(t-e)*this._viscosity},_onPreDragLimit:function(){if(this._viscosity&&this._offsetLimit){var t=this._draggable._newPos.subtract(this._draggable._startPos),e=this._offsetLimit;t.xe.max.x&&(t.x=this._viscousLimit(t.x,e.max.x)),t.y>e.max.y&&(t.y=this._viscousLimit(t.y,e.max.y)),this._draggable._newPos=this._draggable._startPos.add(t)}},_onPreDragWrap:function(){var t=this._worldWidth,e=Math.round(t/2),i=this._initialWorldOffset,n=this._draggable._newPos.x,o=(n-e+i)%t+e-i,s=(n+e+i)%t-e-i,r=Math.abs(o+i)0?s:-s))-e;this._delta=0,this._startTime=null,r&&("center"===t.options.scrollWheelZoom?t.setZoom(e+r):t.setZoomAround(this._lastMousePos,e+r))}}),o.Map.addInitHook("addHandler","scrollWheelZoom",o.Map.ScrollWheelZoom),o.extend(o.DomEvent,{_touchstart:o.Browser.msPointer?"MSPointerDown":o.Browser.pointer?"pointerdown":"touchstart",_touchend:o.Browser.msPointer?"MSPointerUp":o.Browser.pointer?"pointerup":"touchend",addDoubleTapListener:function(t,e,i){function n(t){var e;if(e=o.Browser.pointer?o.DomEvent._pointersCount:t.touches.length,!(e>1)){var i=Date.now(),n=i-(r||i);a=t.touches?t.touches[0]:t,h=n>0&&n<=l,r=i}}function s(){if(h&&!a.cancelBubble){if(o.Browser.pointer){var t,i,n={};for(i in a)t=a[i],n[i]=t&&t.bind?t.bind(a):t;a=n}a.type="dblclick",e(a),r=null}}var r,a,h=!1,l=250,u="_leaflet_",c=this._touchstart,d=this._touchend;return t[u+c+i]=n,t[u+d+i]=s,t[u+"dblclick"+i]=e,t.addEventListener(c,n,!1),t.addEventListener(d,s,!1),o.Browser.edge||t.addEventListener("dblclick",e,!1),this},removeDoubleTapListener:function(t,e){var i="_leaflet_",n=t[i+this._touchstart+e],s=t[i+this._touchend+e],r=t[i+"dblclick"+e];return t.removeEventListener(this._touchstart,n,!1),t.removeEventListener(this._touchend,s,!1),o.Browser.edge||t.removeEventListener("dblclick",r,!1),this}}),o.extend(o.DomEvent,{POINTER_DOWN:o.Browser.msPointer?"MSPointerDown":"pointerdown",POINTER_MOVE:o.Browser.msPointer?"MSPointerMove":"pointermove",POINTER_UP:o.Browser.msPointer?"MSPointerUp":"pointerup",POINTER_CANCEL:o.Browser.msPointer?"MSPointerCancel":"pointercancel",TAG_WHITE_LIST:["INPUT","SELECT","OPTION"],_pointers:{},_pointersCount:0,addPointerListener:function(t,e,i,n){return"touchstart"===e?this._addPointerStart(t,i,n):"touchmove"===e?this._addPointerMove(t,i,n):"touchend"===e&&this._addPointerEnd(t,i,n),this},removePointerListener:function(t,e,i){var n=t["_leaflet_"+e+i];return"touchstart"===e?t.removeEventListener(this.POINTER_DOWN,n,!1):"touchmove"===e?t.removeEventListener(this.POINTER_MOVE,n,!1):"touchend"===e&&(t.removeEventListener(this.POINTER_UP,n,!1),t.removeEventListener(this.POINTER_CANCEL,n,!1)),this},_addPointerStart:function(t,i,n){var s=o.bind(function(t){if("mouse"!==t.pointerType&&t.pointerType!==t.MSPOINTER_TYPE_MOUSE){if(!(this.TAG_WHITE_LIST.indexOf(t.target.tagName)<0))return;o.DomEvent.preventDefault(t)}this._handlePointer(t,i)},this);if(t["_leaflet_touchstart"+n]=s,t.addEventListener(this.POINTER_DOWN,s,!1),!this._pointerDocListener){var r=o.bind(this._globalPointerUp,this);e.documentElement.addEventListener(this.POINTER_DOWN,o.bind(this._globalPointerDown,this),!0),e.documentElement.addEventListener(this.POINTER_MOVE,o.bind(this._globalPointerMove,this),!0),e.documentElement.addEventListener(this.POINTER_UP,r,!0),e.documentElement.addEventListener(this.POINTER_CANCEL,r,!0),this._pointerDocListener=!0}},_globalPointerDown:function(t){this._pointers[t.pointerId]=t,this._pointersCount++},_globalPointerMove:function(t){this._pointers[t.pointerId]&&(this._pointers[t.pointerId]=t)},_globalPointerUp:function(t){delete this._pointers[t.pointerId],this._pointersCount--},_handlePointer:function(t,e){t.touches=[];for(var i in this._pointers)t.touches.push(this._pointers[i]);t.changedTouches=[t],e(t)},_addPointerMove:function(t,e,i){var n=o.bind(function(t){(t.pointerType!==t.MSPOINTER_TYPE_MOUSE&&"mouse"!==t.pointerType||0!==t.buttons)&&this._handlePointer(t,e)},this);t["_leaflet_touchmove"+i]=n,t.addEventListener(this.POINTER_MOVE,n,!1)},_addPointerEnd:function(t,e,i){var n=o.bind(function(t){this._handlePointer(t,e)},this);t["_leaflet_touchend"+i]=n,t.addEventListener(this.POINTER_UP,n,!1),t.addEventListener(this.POINTER_CANCEL,n,!1)}}),o.Map.mergeOptions({touchZoom:o.Browser.touch&&!o.Browser.android23,bounceAtZoomLimits:!0}),o.Map.TouchZoom=o.Handler.extend({addHooks:function(){o.DomUtil.addClass(this._map._container,"leaflet-touch-zoom"),o.DomEvent.on(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){o.DomUtil.removeClass(this._map._container,"leaflet-touch-zoom"),o.DomEvent.off(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(t){var i=this._map;if(t.touches&&2===t.touches.length&&!i._animatingZoom&&!this._zooming){var n=i.mouseEventToContainerPoint(t.touches[0]),s=i.mouseEventToContainerPoint(t.touches[1]);this._centerPoint=i.getSize()._divideBy(2),this._startLatLng=i.containerPointToLatLng(this._centerPoint),"center"!==i.options.touchZoom&&(this._pinchStartLatLng=i.containerPointToLatLng(n.add(s)._divideBy(2))),this._startDist=n.distanceTo(s),this._startZoom=i.getZoom(),this._moved=!1,this._zooming=!0,i._stop(),o.DomEvent.on(e,"touchmove",this._onTouchMove,this).on(e,"touchend",this._onTouchEnd,this),o.DomEvent.preventDefault(t)}},_onTouchMove:function(t){if(t.touches&&2===t.touches.length&&this._zooming){var e=this._map,i=e.mouseEventToContainerPoint(t.touches[0]),n=e.mouseEventToContainerPoint(t.touches[1]),s=i.distanceTo(n)/this._startDist;if(this._zoom=e.getScaleZoom(s,this._startZoom),!e.options.bounceAtZoomLimits&&(this._zoome.getMaxZoom()&&s>1)&&(this._zoom=e._limitZoom(this._zoom)),"center"===e.options.touchZoom){if(this._center=this._startLatLng,1===s)return}else{var r=i._add(n)._divideBy(2)._subtract(this._centerPoint);if(1===s&&0===r.x&&0===r.y)return;this._center=e.unproject(e.project(this._pinchStartLatLng,this._zoom).subtract(r),this._zoom)}this._moved||(e._moveStart(!0),this._moved=!0),o.Util.cancelAnimFrame(this._animRequest);var a=o.bind(e._move,e,this._center,this._zoom,{pinch:!0,round:!1});this._animRequest=o.Util.requestAnimFrame(a,this,!0),o.DomEvent.preventDefault(t)}},_onTouchEnd:function(){return this._moved&&this._zooming?(this._zooming=!1,o.Util.cancelAnimFrame(this._animRequest),o.DomEvent.off(e,"touchmove",this._onTouchMove).off(e,"touchend",this._onTouchEnd),void(this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom)))):void(this._zooming=!1)}}),o.Map.addInitHook("addHandler","touchZoom",o.Map.TouchZoom),o.Map.mergeOptions({tap:!0,tapTolerance:15}),o.Map.Tap=o.Handler.extend({addHooks:function(){o.DomEvent.on(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){o.DomEvent.off(this._map._container,"touchstart",this._onDown,this)},_onDown:function(t){if(t.touches){if(o.DomEvent.preventDefault(t),this._fireClick=!0,t.touches.length>1)return this._fireClick=!1,void clearTimeout(this._holdTimeout);var i=t.touches[0],n=i.target;this._startPos=this._newPos=new o.Point(i.clientX,i.clientY),n.tagName&&"a"===n.tagName.toLowerCase()&&o.DomUtil.addClass(n,"leaflet-active"),this._holdTimeout=setTimeout(o.bind(function(){this._isTapValid()&&(this._fireClick=!1,this._onUp(),this._simulateEvent("contextmenu",i))},this),1e3),this._simulateEvent("mousedown",i),o.DomEvent.on(e,{touchmove:this._onMove,touchend:this._onUp},this)}},_onUp:function(t){if(clearTimeout(this._holdTimeout),o.DomEvent.off(e,{touchmove:this._onMove,touchend:this._onUp},this),this._fireClick&&t&&t.changedTouches){var i=t.changedTouches[0],n=i.target;n&&n.tagName&&"a"===n.tagName.toLowerCase()&&o.DomUtil.removeClass(n,"leaflet-active"),this._simulateEvent("mouseup",i),this._isTapValid()&&this._simulateEvent("click",i)}},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_onMove:function(t){var e=t.touches[0];this._newPos=new o.Point(e.clientX,e.clientY),this._simulateEvent("mousemove",e)},_simulateEvent:function(i,n){var o=e.createEvent("MouseEvents");o._simulated=!0,n.target._simulatedClick=!0,o.initMouseEvent(i,!0,!0,t,1,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),n.target.dispatchEvent(o)}}),o.Browser.touch&&!o.Browser.pointer&&o.Map.addInitHook("addHandler","tap",o.Map.Tap),o.Map.mergeOptions({boxZoom:!0}),o.Map.BoxZoom=o.Handler.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane},addHooks:function(){o.DomEvent.on(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){o.DomEvent.off(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_resetState:function(){ +this._moved=!1},_onMouseDown:function(t){return!(!t.shiftKey||1!==t.which&&1!==t.button)&&(this._resetState(),o.DomUtil.disableTextSelection(),o.DomUtil.disableImageDrag(),this._startPoint=this._map.mouseEventToContainerPoint(t),void o.DomEvent.on(e,{contextmenu:o.DomEvent.stop,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this))},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=o.DomUtil.create("div","leaflet-zoom-box",this._container),o.DomUtil.addClass(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var e=new o.Bounds(this._point,this._startPoint),i=e.getSize();o.DomUtil.setPosition(this._box,e.min),this._box.style.width=i.x+"px",this._box.style.height=i.y+"px"},_finish:function(){this._moved&&(o.DomUtil.remove(this._box),o.DomUtil.removeClass(this._container,"leaflet-crosshair")),o.DomUtil.enableTextSelection(),o.DomUtil.enableImageDrag(),o.DomEvent.off(e,{contextmenu:o.DomEvent.stop,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){if((1===t.which||1===t.button)&&(this._finish(),this._moved)){setTimeout(o.bind(this._resetState,this),0);var e=new o.LatLngBounds(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(e).fire("boxzoomend",{boxZoomBounds:e})}},_onKeyDown:function(t){27===t.keyCode&&this._finish()}}),o.Map.addInitHook("addHandler","boxZoom",o.Map.BoxZoom),o.Map.mergeOptions({keyboard:!0,keyboardPanDelta:80}),o.Map.Keyboard=o.Handler.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(t){this._map=t,this._setPanDelta(t.options.keyboardPanDelta),this._setZoomDelta(t.options.zoomDelta)},addHooks:function(){var t=this._map._container;t.tabIndex<=0&&(t.tabIndex="0"),o.DomEvent.on(t,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),o.DomEvent.off(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){if(!this._focused){var i=e.body,n=e.documentElement,o=i.scrollTop||n.scrollTop,s=i.scrollLeft||n.scrollLeft;this._map._container.focus(),t.scrollTo(s,o)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanDelta:function(t){var e,i,n=this._panKeys={},o=this.keyCodes;for(e=0,i=o.left.length;e0&&t.screenY>0&&this._map.getContainer().focus()}}),o.control=function(t){return new o.Control(t)},o.Map.include({addControl:function(t){return t.addTo(this),this},removeControl:function(t){return t.remove(),this},_initControlPos:function(){function t(t,s){var r=i+t+" "+i+s;e[t+s]=o.DomUtil.create("div",r,n)}var e=this._controlCorners={},i="leaflet-",n=this._controlContainer=o.DomUtil.create("div",i+"control-container",this._container);t("top","left"),t("top","right"),t("bottom","left"),t("bottom","right")},_clearControlPos:function(){o.DomUtil.remove(this._controlContainer)}}),o.Control.Zoom=o.Control.extend({options:{position:"topleft",zoomInText:"+",zoomInTitle:"Zoom in",zoomOutText:"-",zoomOutTitle:"Zoom out"},onAdd:function(t){var e="leaflet-control-zoom",i=o.DomUtil.create("div",e+" leaflet-bar"),n=this.options;return this._zoomInButton=this._createButton(n.zoomInText,n.zoomInTitle,e+"-in",i,this._zoomIn),this._zoomOutButton=this._createButton(n.zoomOutText,n.zoomOutTitle,e+"-out",i,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),i},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(t){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(t,e,i,n,s){var r=o.DomUtil.create("a",i,n);return r.innerHTML=t,r.href="#",r.title=e,r.setAttribute("role","button"),r.setAttribute("aria-label",e),o.DomEvent.on(r,"mousedown dblclick",o.DomEvent.stopPropagation).on(r,"click",o.DomEvent.stop).on(r,"click",s,this).on(r,"click",this._refocusOnMap,this),r},_updateDisabled:function(){var t=this._map,e="leaflet-disabled";o.DomUtil.removeClass(this._zoomInButton,e),o.DomUtil.removeClass(this._zoomOutButton,e),(this._disabled||t._zoom===t.getMinZoom())&&o.DomUtil.addClass(this._zoomOutButton,e),(this._disabled||t._zoom===t.getMaxZoom())&&o.DomUtil.addClass(this._zoomInButton,e)}}),o.Map.mergeOptions({zoomControl:!0}),o.Map.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new o.Control.Zoom,this.addControl(this.zoomControl))}),o.control.zoom=function(t){return new o.Control.Zoom(t)},o.Control.Attribution=o.Control.extend({options:{position:"bottomright",prefix:'Leaflet'},initialize:function(t){o.setOptions(this,t),this._attributions={}},onAdd:function(t){t.attributionControl=this,this._container=o.DomUtil.create("div","leaflet-control-attribution"),o.DomEvent&&o.DomEvent.disableClickPropagation(this._container);for(var e in t._layers)t._layers[e].getAttribution&&this.addAttribution(t._layers[e].getAttribution());return this._update(),this._container},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t?(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update(),this):this},removeAttribution:function(t){return t?(this._attributions[t]&&(this._attributions[t]--,this._update()),this):this},_update:function(){if(this._map){var t=[];for(var e in this._attributions)this._attributions[e]&&t.push(e);var i=[];this.options.prefix&&i.push(this.options.prefix),t.length&&i.push(t.join(", ")),this._container.innerHTML=i.join(" | ")}}}),o.Map.mergeOptions({attributionControl:!0}),o.Map.addInitHook(function(){this.options.attributionControl&&(new o.Control.Attribution).addTo(this)}),o.control.attribution=function(t){return new o.Control.Attribution(t)},o.Control.Scale=o.Control.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(t){var e="leaflet-control-scale",i=o.DomUtil.create("div",e),n=this.options;return this._addScales(n,e+"-line",i),t.on(n.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),i},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,e,i){t.metric&&(this._mScale=o.DomUtil.create("div",e,i)),t.imperial&&(this._iScale=o.DomUtil.create("div",e,i))},_update:function(){var t=this._map,e=t.getSize().y/2,i=t.distance(t.containerPointToLatLng([0,e]),t.containerPointToLatLng([this.options.maxWidth,e]));this._updateScales(i)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(t){var e=this._getRoundNum(t),i=e<1e3?e+" m":e/1e3+" km";this._updateScale(this._mScale,i,e/t)},_updateImperial:function(t){var e,i,n,o=3.2808399*t;o>5280?(e=o/5280,i=this._getRoundNum(e),this._updateScale(this._iScale,i+" mi",i/e)):(n=this._getRoundNum(o),this._updateScale(this._iScale,n+" ft",n/o))},_updateScale:function(t,e,i){t.style.width=Math.round(this.options.maxWidth*i)+"px",t.innerHTML=e},_getRoundNum:function(t){var e=Math.pow(10,(Math.floor(t)+"").length-1),i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:1,e*i}}),o.control.scale=function(t){return new o.Control.Scale(t)},o.Control.Layers=o.Control.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(t,e,i,n){return i1,this._baseLayersList.style.display=t?"":"none"),this._separator.style.display=e&&t?"":"none",this},_onLayerChange:function(t){this._handlingClick||this._update();var e=this._getLayer(o.stamp(t.target)),i=e.overlay?"add"===t.type?"overlayadd":"overlayremove":"add"===t.type?"baselayerchange":null;i&&this._map.fire(i,e)},_createRadioElement:function(t,i){var n='",o=e.createElement("div");return o.innerHTML=n,o.firstChild},_addItem:function(t){var i,n=e.createElement("label"),s=this._map.hasLayer(t.layer);t.overlay?(i=e.createElement("input"),i.type="checkbox",i.className="leaflet-control-layers-selector",i.defaultChecked=s):i=this._createRadioElement("leaflet-base-layers",s),i.layerId=o.stamp(t.layer),o.DomEvent.on(i,"click",this._onInputClick,this);var r=e.createElement("span");r.innerHTML=" "+t.name;var a=e.createElement("div");n.appendChild(a),a.appendChild(i),a.appendChild(r);var h=t.overlay?this._overlaysList:this._baseLayersList;return h.appendChild(n),this._checkDisabledLayers(),n},_onInputClick:function(){var t,e,i,n=this._form.getElementsByTagName("input"),o=[],s=[];this._handlingClick=!0;for(var r=n.length-1;r>=0;r--)t=n[r],e=this._getLayer(t.layerId).layer,i=this._map.hasLayer(e),t.checked&&!i?o.push(e):!t.checked&&i&&s.push(e);for(r=0;r=0;s--)t=n[s],e=this._getLayer(t.layerId).layer,t.disabled=e.options.minZoom!==i&&oe.options.maxZoom},_expand:function(){return this.expand()},_collapse:function(){return this.collapse()}}),o.control.layers=function(t,e,i){return new o.Control.Layers(t,e,i)}}(window,document); \ No newline at end of file