Update wmts-hidpi, add nicer-api-docs
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
// Copyright 2007 The Closure Library Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Useful callback functions for the DOM matcher.
|
||||
*
|
||||
* @author robbyw@google.com (Robby Walker)
|
||||
*/
|
||||
|
||||
goog.provide('goog.dom.pattern.callback');
|
||||
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.dom.TagWalkType');
|
||||
goog.require('goog.iter');
|
||||
|
||||
|
||||
/**
|
||||
* Callback function for use in {@link goog.dom.pattern.Matcher.addPattern}
|
||||
* that removes the matched node from the tree. Should be used in conjunciton
|
||||
* with a {@link goog.dom.pattern.StartTag} pattern.
|
||||
*
|
||||
* @param {Node} node The node matched by the pattern.
|
||||
* @param {goog.dom.TagIterator} position The position where the match
|
||||
* finished.
|
||||
* @return {boolean} Returns true to indicate tree changes were made.
|
||||
*/
|
||||
goog.dom.pattern.callback.removeNode = function(node, position) {
|
||||
// Find out which position would be next.
|
||||
position.setPosition(node, goog.dom.TagWalkType.END_TAG);
|
||||
|
||||
goog.iter.nextOrValue(position, null);
|
||||
|
||||
// Remove the node.
|
||||
goog.dom.removeNode(node);
|
||||
|
||||
// Correct for the depth change.
|
||||
position.depth -= 1;
|
||||
|
||||
// Indicate that we made position/tree changes.
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Callback function for use in {@link goog.dom.pattern.Matcher.addPattern}
|
||||
* that removes the matched node from the tree and replaces it with its
|
||||
* children. Should be used in conjunction with a
|
||||
* {@link goog.dom.pattern.StartTag} pattern.
|
||||
*
|
||||
* @param {Element} node The node matched by the pattern.
|
||||
* @param {goog.dom.TagIterator} position The position where the match
|
||||
* finished.
|
||||
* @return {boolean} Returns true to indicate tree changes were made.
|
||||
*/
|
||||
goog.dom.pattern.callback.flattenElement = function(node, position) {
|
||||
// Find out which position would be next.
|
||||
position.setPosition(node, node.firstChild ?
|
||||
goog.dom.TagWalkType.START_TAG :
|
||||
goog.dom.TagWalkType.END_TAG);
|
||||
|
||||
goog.iter.nextOrValue(position, null);
|
||||
|
||||
// Flatten the node.
|
||||
goog.dom.flattenElement(node);
|
||||
|
||||
// Correct for the depth change.
|
||||
position.depth -= 1;
|
||||
|
||||
// Indicate that we made position/tree changes.
|
||||
return true;
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
// Copyright 2007 The Closure Library Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Callback object that counts matches.
|
||||
*
|
||||
* @author robbyw@google.com (Robby Walker)
|
||||
*/
|
||||
|
||||
goog.provide('goog.dom.pattern.callback.Counter');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Callback class for counting matches.
|
||||
* @constructor
|
||||
*/
|
||||
goog.dom.pattern.callback.Counter = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The count of objects matched so far.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
goog.dom.pattern.callback.Counter.prototype.count = 0;
|
||||
|
||||
|
||||
/**
|
||||
* The callback function. Suitable as a callback for
|
||||
* {@link goog.dom.pattern.Matcher}.
|
||||
* @type {Function}
|
||||
* @private
|
||||
*/
|
||||
goog.dom.pattern.callback.Counter.prototype.callback_ = null;
|
||||
|
||||
|
||||
/**
|
||||
* Get a bound callback function that is suitable as a callback for
|
||||
* {@link goog.dom.pattern.Matcher}.
|
||||
*
|
||||
* @return {Function} A callback function.
|
||||
*/
|
||||
goog.dom.pattern.callback.Counter.prototype.getCallback = function() {
|
||||
if (!this.callback_) {
|
||||
this.callback_ = goog.bind(function() {
|
||||
this.count++;
|
||||
return false;
|
||||
}, this);
|
||||
}
|
||||
return this.callback_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Reset the counter.
|
||||
*/
|
||||
goog.dom.pattern.callback.Counter.prototype.reset = function() {
|
||||
this.count = 0;
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
// Copyright 2007 The Closure Library Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* @fileoverview Callback object that tests if a pattern matches at least once.
|
||||
*
|
||||
* @author robbyw@google.com (Robby Walker)
|
||||
*/
|
||||
|
||||
goog.provide('goog.dom.pattern.callback.Test');
|
||||
|
||||
goog.require('goog.iter.StopIteration');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Callback class for testing for at least one match.
|
||||
* @constructor
|
||||
*/
|
||||
goog.dom.pattern.callback.Test = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Whether or not the pattern matched.
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
goog.dom.pattern.callback.Test.prototype.matched = false;
|
||||
|
||||
|
||||
/**
|
||||
* The callback function. Suitable as a callback for
|
||||
* {@link goog.dom.pattern.Matcher}.
|
||||
* @type {Function}
|
||||
* @private
|
||||
*/
|
||||
goog.dom.pattern.callback.Test.prototype.callback_ = null;
|
||||
|
||||
|
||||
/**
|
||||
* Get a bound callback function that is suitable as a callback for
|
||||
* {@link goog.dom.pattern.Matcher}.
|
||||
*
|
||||
* @return {Function} A callback function.
|
||||
*/
|
||||
goog.dom.pattern.callback.Test.prototype.getCallback = function() {
|
||||
if (!this.callback_) {
|
||||
this.callback_ = goog.bind(function(node, position) {
|
||||
// Mark our match.
|
||||
this.matched = true;
|
||||
|
||||
// Stop searching.
|
||||
throw goog.iter.StopIteration;
|
||||
}, this);
|
||||
}
|
||||
return this.callback_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Reset the counter.
|
||||
*/
|
||||
goog.dom.pattern.callback.Test.prototype.reset = function() {
|
||||
this.matched = false;
|
||||
};
|
||||
Reference in New Issue
Block a user