/ext-4.0.7/docs/source/Element.style.html
HTML | 1141 lines | 1040 code | 101 blank | 0 comment | 0 complexity | d741833c5720b5a2893f0444b3b3df07 MD5 | raw file
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>The source code</title>
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
- <style type="text/css">
- .highlight { display: block; background-color: #ddd; }
- </style>
- <script type="text/javascript">
- function highlight() {
- document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
- }
- </script>
- </head>
- <body onload="prettyPrint(); highlight();">
- <pre class="prettyprint lang-js"><span id='Ext-Element'>/**
- </span> * @class Ext.Element
- */
- (function(){
- // local style camelizing for speed
- var ELEMENT = Ext.Element,
- supports = Ext.supports,
- view = document.defaultView,
- opacityRe = /alpha\(opacity=(.*)\)/i,
- trimRe = /^\s+|\s+$/g,
- spacesRe = /\s+/,
- wordsRe = /\w/g,
- adjustDirect2DTableRe = /table-row|table-.*-group/,
- INTERNAL = '_internal',
- PADDING = 'padding',
- MARGIN = 'margin',
- BORDER = 'border',
- LEFT = '-left',
- RIGHT = '-right',
- TOP = '-top',
- BOTTOM = '-bottom',
- WIDTH = '-width',
- MATH = Math,
- HIDDEN = 'hidden',
- ISCLIPPED = 'isClipped',
- OVERFLOW = 'overflow',
- OVERFLOWX = 'overflow-x',
- OVERFLOWY = 'overflow-y',
- ORIGINALCLIP = 'originalClip',
- // special markup used throughout Ext when box wrapping elements
- borders = {l: BORDER + LEFT + WIDTH, r: BORDER + RIGHT + WIDTH, t: BORDER + TOP + WIDTH, b: BORDER + BOTTOM + WIDTH},
- paddings = {l: PADDING + LEFT, r: PADDING + RIGHT, t: PADDING + TOP, b: PADDING + BOTTOM},
- margins = {l: MARGIN + LEFT, r: MARGIN + RIGHT, t: MARGIN + TOP, b: MARGIN + BOTTOM},
- data = ELEMENT.data;
- ELEMENT.boxMarkup = '<div class="{0}-tl"><div class="{0}-tr"><div class="{0}-tc"></div></div></div><div class="{0}-ml"><div class="{0}-mr"><div class="{0}-mc"></div></div></div><div class="{0}-bl"><div class="{0}-br"><div class="{0}-bc"></div></div></div>';
- // These property values are read from the parentNode if they cannot be read
- // from the child:
- ELEMENT.inheritedProps = {
- fontSize: 1,
- fontStyle: 1,
- opacity: 1
- };
- Ext.override(ELEMENT, {
- <span id='Ext-Element-method-adjustWidth'> /**
- </span> * TODO: Look at this
- */
- // private ==> used by Fx
- adjustWidth : function(width) {
- var me = this,
- isNum = (typeof width == 'number');
- if(isNum && me.autoBoxAdjust && !me.isBorderBox()){
- width -= (me.getBorderWidth("lr") + me.getPadding("lr"));
- }
- return (isNum && width < 0) ? 0 : width;
- },
- // private ==> used by Fx
- adjustHeight : function(height) {
- var me = this,
- isNum = (typeof height == "number");
- if(isNum && me.autoBoxAdjust && !me.isBorderBox()){
- height -= (me.getBorderWidth("tb") + me.getPadding("tb"));
- }
- return (isNum && height < 0) ? 0 : height;
- },
- <span id='Ext-Element-method-addCls'> /**
- </span> * Adds one or more CSS classes to the element. Duplicate classes are automatically filtered out.
- * @param {String/String[]} className The CSS classes to add separated by space, or an array of classes
- * @return {Ext.Element} this
- */
- addCls : function(className){
- var me = this,
- cls = [],
- space = ((me.dom.className.replace(trimRe, '') == '') ? "" : " "),
- i, len, v;
- if (className === undefined) {
- return me;
- }
- // Separate case is for speed
- if (Object.prototype.toString.call(className) !== '[object Array]') {
- if (typeof className === 'string') {
- className = className.replace(trimRe, '').split(spacesRe);
- if (className.length === 1) {
- className = className[0];
- if (!me.hasCls(className)) {
- me.dom.className += space + className;
- }
- } else {
- this.addCls(className);
- }
- }
- } else {
- for (i = 0, len = className.length; i < len; i++) {
- v = className[i];
- if (typeof v == 'string' && (' ' + me.dom.className + ' ').indexOf(' ' + v + ' ') == -1) {
- cls.push(v);
- }
- }
- if (cls.length) {
- me.dom.className += space + cls.join(" ");
- }
- }
- return me;
- },
- <span id='Ext-Element-method-removeCls'> /**
- </span> * Removes one or more CSS classes from the element.
- * @param {String/String[]} className The CSS classes to remove separated by space, or an array of classes
- * @return {Ext.Element} this
- */
- removeCls : function(className){
- var me = this,
- i, idx, len, cls, elClasses;
- if (className === undefined) {
- return me;
- }
- if (Object.prototype.toString.call(className) !== '[object Array]') {
- className = className.replace(trimRe, '').split(spacesRe);
- }
- if (me.dom && me.dom.className) {
- elClasses = me.dom.className.replace(trimRe, '').split(spacesRe);
- for (i = 0, len = className.length; i < len; i++) {
- cls = className[i];
- if (typeof cls == 'string') {
- cls = cls.replace(trimRe, '');
- idx = Ext.Array.indexOf(elClasses, cls);
- if (idx != -1) {
- Ext.Array.erase(elClasses, idx, 1);
- }
- }
- }
- me.dom.className = elClasses.join(" ");
- }
- return me;
- },
- <span id='Ext-Element-method-radioCls'> /**
- </span> * Adds one or more CSS classes to this element and removes the same class(es) from all siblings.
- * @param {String/String[]} className The CSS class to add, or an array of classes
- * @return {Ext.Element} this
- */
- radioCls : function(className){
- var cn = this.dom.parentNode.childNodes,
- v, i, len;
- className = Ext.isArray(className) ? className : [className];
- for (i = 0, len = cn.length; i < len; i++) {
- v = cn[i];
- if (v && v.nodeType == 1) {
- Ext.fly(v, '_internal').removeCls(className);
- }
- }
- return this.addCls(className);
- },
- <span id='Ext-Element-method-toggleCls'> /**
- </span> * Toggles the specified CSS class on this element (removes it if it already exists, otherwise adds it).
- * @param {String} className The CSS class to toggle
- * @return {Ext.Element} this
- * @method
- */
- toggleCls : Ext.supports.ClassList ?
- function(className) {
- this.dom.classList.toggle(Ext.String.trim(className));
- return this;
- } :
- function(className) {
- return this.hasCls(className) ? this.removeCls(className) : this.addCls(className);
- },
- <span id='Ext-Element-method-hasCls'> /**
- </span> * Checks if the specified CSS class exists on this element's DOM node.
- * @param {String} className The CSS class to check for
- * @return {Boolean} True if the class exists, else false
- * @method
- */
- hasCls : Ext.supports.ClassList ?
- function(className) {
- if (!className) {
- return false;
- }
- className = className.split(spacesRe);
- var ln = className.length,
- i = 0;
- for (; i < ln; i++) {
- if (className[i] && this.dom.classList.contains(className[i])) {
- return true;
- }
- }
- return false;
- } :
- function(className){
- return className && (' ' + this.dom.className + ' ').indexOf(' ' + className + ' ') != -1;
- },
- <span id='Ext-Element-method-replaceCls'> /**
- </span> * Replaces a CSS class on the element with another. If the old name does not exist, the new name will simply be added.
- * @param {String} oldClassName The CSS class to replace
- * @param {String} newClassName The replacement CSS class
- * @return {Ext.Element} this
- */
- replaceCls : function(oldClassName, newClassName){
- return this.removeCls(oldClassName).addCls(newClassName);
- },
- isStyle : function(style, val) {
- return this.getStyle(style) == val;
- },
- <span id='Ext-Element-method-getStyle'> /**
- </span> * Normalizes currentStyle and computedStyle.
- * @param {String} property The style property whose value is returned.
- * @return {String} The current value of the style property for this element.
- * @method
- */
- getStyle : function() {
- return view && view.getComputedStyle ?
- function(prop){
- var el = this.dom,
- v, cs, out, display, cleaner;
- if(el == document){
- return null;
-