Adding float-no-zero branch hosted build
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
// Copyright 2012 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 Bidi utility functions.
|
||||
*
|
||||
*/
|
||||
|
||||
goog.provide('goog.style.bidi');
|
||||
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.style');
|
||||
goog.require('goog.userAgent');
|
||||
|
||||
|
||||
/**
|
||||
* Returns the normalized scrollLeft position for a scrolled element.
|
||||
* @param {Element} element The scrolled element.
|
||||
* @return {number} The number of pixels the element is scrolled. 0 indicates
|
||||
* that the element is not scrolled at all (which, in general, is the
|
||||
* left-most position in ltr and the right-most position in rtl).
|
||||
*/
|
||||
goog.style.bidi.getScrollLeft = function(element) {
|
||||
var isRtl = goog.style.isRightToLeft(element);
|
||||
if (isRtl && goog.userAgent.GECKO) {
|
||||
// ScrollLeft starts at 0 and then goes negative as the element is scrolled
|
||||
// towards the left.
|
||||
return -element.scrollLeft;
|
||||
} else if (isRtl &&
|
||||
!(goog.userAgent.IE && goog.userAgent.isVersionOrHigher('8'))) {
|
||||
// ScrollLeft starts at the maximum positive value and decreases towards
|
||||
// 0 as the element is scrolled towards the left. However, for overflow
|
||||
// visible, there is no scrollLeft and the value always stays correctly at 0
|
||||
var overflowX = goog.style.getComputedOverflowX(element);
|
||||
if (overflowX == 'visible') {
|
||||
return element.scrollLeft;
|
||||
} else {
|
||||
return element.scrollWidth - element.clientWidth - element.scrollLeft;
|
||||
}
|
||||
}
|
||||
// ScrollLeft behavior is identical in rtl and ltr, it starts at 0 and
|
||||
// increases as the element is scrolled away from the start.
|
||||
return element.scrollLeft;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the "offsetStart" of an element, analagous to offsetLeft but
|
||||
* normalized for right-to-left environments and various browser
|
||||
* inconsistencies. This value returned can always be passed to setScrollOffset
|
||||
* to scroll to an element's left edge in a left-to-right offsetParent or
|
||||
* right edge in a right-to-left offsetParent.
|
||||
*
|
||||
* For example, here offsetStart is 10px in an LTR environment and 5px in RTL:
|
||||
*
|
||||
* <pre>
|
||||
* | xxxxxxxxxx |
|
||||
* ^^^^^^^^^^ ^^^^ ^^^^^
|
||||
* 10px elem 5px
|
||||
* </pre>
|
||||
*
|
||||
* If an element is positioned before the start of its offsetParent, the
|
||||
* startOffset may be negative. This can be used with setScrollOffset to
|
||||
* reliably scroll to an element:
|
||||
*
|
||||
* <pre>
|
||||
* var scrollOffset = goog.style.bidi.getOffsetStart(element);
|
||||
* goog.style.bidi.setScrollOffset(element.offsetParent, scrollOffset);
|
||||
* </pre>
|
||||
*
|
||||
* @see setScrollOffset
|
||||
*
|
||||
* @param {Element} element The element for which we need to determine the
|
||||
* offsetStart position.
|
||||
* @return {number} The offsetStart for that element.
|
||||
*/
|
||||
goog.style.bidi.getOffsetStart = function(element) {
|
||||
var offsetLeftForReal = element.offsetLeft;
|
||||
|
||||
// The element might not have an offsetParent.
|
||||
// For example, the node might not be attached to the DOM tree,
|
||||
// and position:fixed children do not have an offset parent.
|
||||
// Just try to do the best we can with what we have.
|
||||
var bestParent = element.offsetParent;
|
||||
|
||||
if (!bestParent && goog.style.getComputedPosition(element) == 'fixed') {
|
||||
bestParent = goog.dom.getOwnerDocument(element).documentElement;
|
||||
}
|
||||
|
||||
// Just give up in this case.
|
||||
if (!bestParent) {
|
||||
return offsetLeftForReal;
|
||||
}
|
||||
|
||||
if (goog.userAgent.GECKO) {
|
||||
// When calculating an element's offsetLeft, Firefox erroneously subtracts
|
||||
// the border width from the actual distance. So we need to add it back.
|
||||
var borderWidths = goog.style.getBorderBox(bestParent);
|
||||
offsetLeftForReal += borderWidths.left;
|
||||
} else if (goog.userAgent.isDocumentModeOrHigher(8)) {
|
||||
// When calculating an element's offsetLeft, IE8-Standards Mode erroneously
|
||||
// adds the border width to the actual distance. So we need to subtract it.
|
||||
var borderWidths = goog.style.getBorderBox(bestParent);
|
||||
offsetLeftForReal -= borderWidths.left;
|
||||
}
|
||||
|
||||
if (goog.style.isRightToLeft(bestParent)) {
|
||||
// Right edge of the element relative to the left edge of its parent.
|
||||
var elementRightOffset = offsetLeftForReal + element.offsetWidth;
|
||||
|
||||
// Distance from the parent's right edge to the element's right edge.
|
||||
return bestParent.clientWidth - elementRightOffset;
|
||||
}
|
||||
|
||||
return offsetLeftForReal;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Sets the element's scrollLeft attribute so it is correctly scrolled by
|
||||
* offsetStart pixels. This takes into account whether the element is RTL and
|
||||
* the nuances of different browsers. To scroll to the "beginning" of an
|
||||
* element use getOffsetStart to obtain the element's offsetStart value and then
|
||||
* pass the value to setScrollOffset.
|
||||
* @see getOffsetStart
|
||||
* @param {Element} element The element to set scrollLeft on.
|
||||
* @param {number} offsetStart The number of pixels to scroll the element.
|
||||
* If this value is < 0, 0 is used.
|
||||
*/
|
||||
goog.style.bidi.setScrollOffset = function(element, offsetStart) {
|
||||
offsetStart = Math.max(offsetStart, 0);
|
||||
// In LTR and in "mirrored" browser RTL (such as IE), we set scrollLeft to
|
||||
// the number of pixels to scroll.
|
||||
// Otherwise, in RTL, we need to account for different browser behavior.
|
||||
if (!goog.style.isRightToLeft(element)) {
|
||||
element.scrollLeft = offsetStart;
|
||||
} else if (goog.userAgent.GECKO) {
|
||||
// Negative scroll-left positions in RTL.
|
||||
element.scrollLeft = -offsetStart;
|
||||
} else if (!(goog.userAgent.IE && goog.userAgent.isVersionOrHigher('8'))) {
|
||||
// Take the current scrollLeft value and move to the right by the
|
||||
// offsetStart to get to the left edge of the element, and then by
|
||||
// the clientWidth of the element to get to the right edge.
|
||||
element.scrollLeft =
|
||||
element.scrollWidth - offsetStart - element.clientWidth;
|
||||
} else {
|
||||
element.scrollLeft = offsetStart;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Sets the element's left style attribute in LTR or right style attribute in
|
||||
* RTL. Also clears the left attribute in RTL and the right attribute in LTR.
|
||||
* @param {Element} elem The element to position.
|
||||
* @param {number} left The left position in LTR; will be set as right in RTL.
|
||||
* @param {?number} top The top position. If null only the left/right is set.
|
||||
* @param {boolean} isRtl Whether we are in RTL mode.
|
||||
*/
|
||||
goog.style.bidi.setPosition = function(elem, left, top, isRtl) {
|
||||
if (!goog.isNull(top)) {
|
||||
elem.style.top = top + 'px';
|
||||
}
|
||||
if (isRtl) {
|
||||
elem.style.right = left + 'px';
|
||||
elem.style.left = '';
|
||||
} else {
|
||||
elem.style.left = left + 'px';
|
||||
elem.style.right = '';
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,115 @@
|
||||
// Copyright 2005 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 Functions to create special cursor styles, like "draggable"
|
||||
* (open hand) or "dragging" (closed hand).
|
||||
*
|
||||
*/
|
||||
|
||||
goog.provide('goog.style.cursor');
|
||||
|
||||
goog.require('goog.userAgent');
|
||||
|
||||
|
||||
/**
|
||||
* The file name for the open-hand (draggable) cursor.
|
||||
* @type {string}
|
||||
*/
|
||||
goog.style.cursor.OPENHAND_FILE = 'openhand.cur';
|
||||
|
||||
|
||||
/**
|
||||
* The file name for the close-hand (dragging) cursor.
|
||||
* @type {string}
|
||||
*/
|
||||
goog.style.cursor.CLOSEDHAND_FILE = 'closedhand.cur';
|
||||
|
||||
|
||||
/**
|
||||
* Create the style for the draggable cursor based on browser and OS.
|
||||
* The value can be extended to be '!important' if needed.
|
||||
*
|
||||
* @param {string} absoluteDotCurFilePath The absolute base path of
|
||||
* 'openhand.cur' file to be used if the browser supports it.
|
||||
* @param {boolean=} opt_obsolete Just for compiler backward compatibility.
|
||||
* @return {string} The "draggable" mouse cursor style value.
|
||||
*/
|
||||
goog.style.cursor.getDraggableCursorStyle = function(
|
||||
absoluteDotCurFilePath, opt_obsolete) {
|
||||
return goog.style.cursor.getCursorStyle_(
|
||||
'-moz-grab',
|
||||
absoluteDotCurFilePath + goog.style.cursor.OPENHAND_FILE,
|
||||
'default');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create the style for the dragging cursor based on browser and OS.
|
||||
* The value can be extended to be '!important' if needed.
|
||||
*
|
||||
* @param {string} absoluteDotCurFilePath The absolute base path of
|
||||
* 'closedhand.cur' file to be used if the browser supports it.
|
||||
* @param {boolean=} opt_obsolete Just for compiler backward compatibility.
|
||||
* @return {string} The "dragging" mouse cursor style value.
|
||||
*/
|
||||
goog.style.cursor.getDraggingCursorStyle = function(
|
||||
absoluteDotCurFilePath, opt_obsolete) {
|
||||
return goog.style.cursor.getCursorStyle_(
|
||||
'-moz-grabbing',
|
||||
absoluteDotCurFilePath + goog.style.cursor.CLOSEDHAND_FILE,
|
||||
'move');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create the style for the cursor based on browser and OS.
|
||||
*
|
||||
* @param {string} geckoNonWinBuiltInStyleValue The Gecko on non-Windows OS,
|
||||
* built in cursor style.
|
||||
* @param {string} absoluteDotCurFilePath The .cur file absolute file to be
|
||||
* used if the browser supports it.
|
||||
* @param {string} defaultStyle The default fallback cursor style.
|
||||
* @return {string} The computed mouse cursor style value.
|
||||
* @private
|
||||
*/
|
||||
goog.style.cursor.getCursorStyle_ = function(geckoNonWinBuiltInStyleValue,
|
||||
absoluteDotCurFilePath, defaultStyle) {
|
||||
// Use built in cursors for Gecko on non Windows OS.
|
||||
// We prefer our custom cursor, but Firefox Mac and Firefox Linux
|
||||
// cannot do custom cursors. They do have a built-in hand, so use it:
|
||||
if (goog.userAgent.GECKO && !goog.userAgent.WINDOWS) {
|
||||
return geckoNonWinBuiltInStyleValue;
|
||||
}
|
||||
|
||||
// Use the custom cursor file.
|
||||
var cursorStyleValue = 'url("' + absoluteDotCurFilePath + '")';
|
||||
// Change hot-spot for Safari.
|
||||
if (goog.userAgent.WEBKIT) {
|
||||
// Safari seems to ignore the hotspot specified in the .cur file (it uses
|
||||
// 0,0 instead). This causes the cursor to jump as it transitions between
|
||||
// openhand and pointer which is especially annoying when trying to hover
|
||||
// over the route for draggable routes. We specify the hotspot here as 7,5
|
||||
// in the css - unfortunately ie6 can't understand this and falls back to
|
||||
// the builtin cursors so we just do this for safari (but ie DOES correctly
|
||||
// use the hotspot specified in the file so this is ok). The appropriate
|
||||
// coordinates were determined by looking at a hex dump and the format
|
||||
// description from wikipedia.
|
||||
cursorStyleValue += ' 7 5';
|
||||
}
|
||||
// Add default cursor fallback.
|
||||
cursorStyleValue += ', ' + defaultStyle;
|
||||
return cursorStyleValue;
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,78 @@
|
||||
// Copyright 2011 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 Shared unit tests for scrollbar measurement.
|
||||
*
|
||||
* @author flan@google.com (Ian Flanigan)
|
||||
*/
|
||||
|
||||
goog.provide('goog.styleScrollbarTester');
|
||||
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.style');
|
||||
goog.require('goog.testing.asserts');
|
||||
goog.setTestOnly('goog.styleScrollbarTester');
|
||||
|
||||
|
||||
/**
|
||||
* Tests the scrollbar width calculation. Assumes that there is an element with
|
||||
* id 'test-scrollbarwidth' in the page.
|
||||
*/
|
||||
function testScrollbarWidth() {
|
||||
var width = goog.style.getScrollbarWidth();
|
||||
assertTrue(width > 0);
|
||||
|
||||
var outer = goog.dom.getElement('test-scrollbarwidth');
|
||||
var inner = goog.dom.getElementsByTagNameAndClass('div', null, outer)[0];
|
||||
assertTrue('should have a scroll bar',
|
||||
hasVerticalScroll(outer));
|
||||
assertTrue('should have a scroll bar',
|
||||
hasHorizontalScroll(outer));
|
||||
|
||||
// Get the inner div absolute width
|
||||
goog.style.setStyle(outer, 'width', '100%');
|
||||
assertTrue('should have a scroll bar',
|
||||
hasVerticalScroll(outer));
|
||||
assertFalse('should not have a scroll bar',
|
||||
hasHorizontalScroll(outer));
|
||||
var innerAbsoluteWidth = inner.offsetWidth;
|
||||
|
||||
// Leave the vertical scroll and remove the horizontal by using the scroll
|
||||
// bar width calculation.
|
||||
goog.style.setStyle(outer, 'width',
|
||||
(innerAbsoluteWidth + width) + 'px');
|
||||
assertTrue('should have a scroll bar',
|
||||
hasVerticalScroll(outer));
|
||||
assertFalse('should not have a scroll bar',
|
||||
hasHorizontalScroll(outer));
|
||||
|
||||
// verify by adding 1 more pixel (brings back the vertical scroll bar).
|
||||
goog.style.setStyle(outer, 'width',
|
||||
(innerAbsoluteWidth + width - 1) + 'px');
|
||||
assertTrue('should have a scroll bar',
|
||||
hasVerticalScroll(outer));
|
||||
assertTrue('should have a scroll bar',
|
||||
hasHorizontalScroll(outer));
|
||||
}
|
||||
|
||||
|
||||
function hasVerticalScroll(el) {
|
||||
return el.clientWidth != 0 && el.offsetWidth - el.clientWidth > 0;
|
||||
}
|
||||
|
||||
|
||||
function hasHorizontalScroll(el) {
|
||||
return el.clientHeight != 0 && el.offsetHeight - el.clientHeight > 0;
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
// Copyright 2011 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 Utility methods to deal with CSS3 transitions
|
||||
* programmatically.
|
||||
*/
|
||||
|
||||
goog.provide('goog.style.transition');
|
||||
goog.provide('goog.style.transition.Css3Property');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.dom.vendor');
|
||||
goog.require('goog.style');
|
||||
goog.require('goog.userAgent');
|
||||
|
||||
|
||||
/**
|
||||
* A typedef to represent a CSS3 transition property. Duration and delay
|
||||
* are both in seconds. Timing is CSS3 timing function string, such as
|
||||
* 'easein', 'linear'.
|
||||
*
|
||||
* Alternatively, specifying string in the form of '[property] [duration]
|
||||
* [timing] [delay]' as specified in CSS3 transition is fine too.
|
||||
*
|
||||
* @typedef { {
|
||||
* property: string,
|
||||
* duration: number,
|
||||
* timing: string,
|
||||
* delay: number
|
||||
* } | string }
|
||||
*/
|
||||
goog.style.transition.Css3Property;
|
||||
|
||||
|
||||
/**
|
||||
* Sets the element CSS3 transition to properties.
|
||||
* @param {Element} element The element to set transition on.
|
||||
* @param {goog.style.transition.Css3Property|
|
||||
* Array.<goog.style.transition.Css3Property>} properties A single CSS3
|
||||
* transition property or array of properties.
|
||||
*/
|
||||
goog.style.transition.set = function(element, properties) {
|
||||
if (!goog.isArray(properties)) {
|
||||
properties = [properties];
|
||||
}
|
||||
goog.asserts.assert(
|
||||
properties.length > 0, 'At least one Css3Property should be specified.');
|
||||
|
||||
var values = goog.array.map(
|
||||
properties, function(p) {
|
||||
if (goog.isString(p)) {
|
||||
return p;
|
||||
} else {
|
||||
goog.asserts.assertObject(p,
|
||||
'Expected css3 property to be an object.');
|
||||
var propString = p.property + ' ' + p.duration + 's ' + p.timing +
|
||||
' ' + p.delay + 's';
|
||||
goog.asserts.assert(p.property && goog.isNumber(p.duration) &&
|
||||
p.timing && goog.isNumber(p.delay),
|
||||
'Unexpected css3 property value: %s', propString);
|
||||
return propString;
|
||||
}
|
||||
});
|
||||
goog.style.transition.setPropertyValue_(element, values.join(','));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Removes any programmatically-added CSS3 transition in the given element.
|
||||
* @param {Element} element The element to remove transition from.
|
||||
*/
|
||||
goog.style.transition.removeAll = function(element) {
|
||||
goog.style.transition.setPropertyValue_(element, '');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {boolean} Whether CSS3 transition is supported.
|
||||
*/
|
||||
goog.style.transition.isSupported = function() {
|
||||
if (!goog.isDef(goog.style.transition.css3TransitionSupported_)) {
|
||||
// Since IE would allow any attribute, we need to explicitly check the
|
||||
// browser version here instead.
|
||||
if (goog.userAgent.IE) {
|
||||
goog.style.transition.css3TransitionSupported_ =
|
||||
goog.userAgent.isVersionOrHigher('10.0');
|
||||
} else {
|
||||
// We create a test element with style=-vendor-transition
|
||||
// We then detect whether those style properties are recognized and
|
||||
// available from js.
|
||||
var el = document.createElement('div');
|
||||
var transition = 'transition:opacity 1s linear;';
|
||||
var vendorPrefix = goog.dom.vendor.getVendorPrefix();
|
||||
var vendorTransition =
|
||||
vendorPrefix ? vendorPrefix + '-' + transition : '';
|
||||
el.innerHTML = '<div style="' + vendorTransition + transition + '">';
|
||||
|
||||
var testElement = /** @type {Element} */ (el.firstChild);
|
||||
goog.asserts.assert(testElement.nodeType == Node.ELEMENT_NODE);
|
||||
|
||||
goog.style.transition.css3TransitionSupported_ =
|
||||
goog.style.getStyle(testElement, 'transition') != '';
|
||||
}
|
||||
}
|
||||
return goog.style.transition.css3TransitionSupported_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Whether CSS3 transition is supported.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
goog.style.transition.css3TransitionSupported_;
|
||||
|
||||
|
||||
/**
|
||||
* Sets CSS3 transition property value to the given value.
|
||||
* @param {Element} element The element to set transition on.
|
||||
* @param {string} transitionValue The CSS3 transition property value.
|
||||
* @private
|
||||
*/
|
||||
goog.style.transition.setPropertyValue_ = function(element, transitionValue) {
|
||||
goog.style.setStyle(element, 'transition', transitionValue);
|
||||
};
|
||||
Reference in New Issue
Block a user