URI.js
9 years ago
URI.min.js
6 years ago
css.js
4 years ago
css.min.js
4 years ago
csslint.js
9 years ago
csslint.min.js
6 years ago
editor.js
2 years ago
editor.min.js
2 years ago
inspector.js
4 years ago
inspector.min.js
4 years ago
jquery.sizes.js
11 years ago
jquery.sizes.min.js
6 years ago
specificity.js
11 years ago
specificity.min.js
6 years ago
jquery.sizes.js
76 lines
| 1 | /** |
| 2 | * @preserve JSizes - JQuery plugin v0.33 |
| 3 | * |
| 4 | * Licensed under the revised BSD License. |
| 5 | * Copyright 2008-2010 Bram Stein |
| 6 | * All rights reserved. |
| 7 | */ |
| 8 | /*global jQuery*/ |
| 9 | (function ($) { |
| 10 | 'use strict'; |
| 11 | var num = function (value) { |
| 12 | return parseInt(value, 10) || 0; |
| 13 | }; |
| 14 | |
| 15 | /** |
| 16 | * Sets or gets the values for min-width, min-height, max-width |
| 17 | * and max-height. |
| 18 | */ |
| 19 | $.each(['min', 'max'], function (i, name) { |
| 20 | $.fn[name + 'Size'] = function (value) { |
| 21 | var width, height; |
| 22 | if (value) { |
| 23 | if (value.width !== undefined) { |
| 24 | this.css(name + '-width', value.width); |
| 25 | } |
| 26 | if (value.height !== undefined) { |
| 27 | this.css(name + '-height', value.height); |
| 28 | } |
| 29 | } else { |
| 30 | width = this.css(name + '-width'); |
| 31 | height = this.css(name + '-height'); |
| 32 | // Apparently: |
| 33 | // * Opera returns -1px instead of none |
| 34 | // * IE6 returns undefined instead of none |
| 35 | return {'width': (name === 'max' && (width === undefined || width === 'none' || num(width) === -1) && Number.MAX_VALUE) || num(width), |
| 36 | 'height': (name === 'max' && (height === undefined || height === 'none' || num(height) === -1) && Number.MAX_VALUE) || num(height)}; |
| 37 | } |
| 38 | return this; |
| 39 | }; |
| 40 | }); |
| 41 | |
| 42 | /** |
| 43 | * Returns whether or not an element is visible. |
| 44 | */ |
| 45 | $.fn.isVisible = function () { |
| 46 | return this.is(':visible'); |
| 47 | }; |
| 48 | |
| 49 | /** |
| 50 | * Sets or gets the values for border, margin and padding. |
| 51 | */ |
| 52 | $.each(['border', 'margin', 'padding'], function (i, name) { |
| 53 | $.fn[name] = function (value) { |
| 54 | if (value) { |
| 55 | if (value.top !== undefined) { |
| 56 | this.css(name + '-top' + (name === 'border' ? '-width' : ''), value.top); |
| 57 | } |
| 58 | if (value.bottom !== undefined) { |
| 59 | this.css(name + '-bottom' + (name === 'border' ? '-width' : ''), value.bottom); |
| 60 | } |
| 61 | if (value.left !== undefined) { |
| 62 | this.css(name + '-left' + (name === 'border' ? '-width' : ''), value.left); |
| 63 | } |
| 64 | if (value.right !== undefined) { |
| 65 | this.css(name + '-right' + (name === 'border' ? '-width' : ''), value.right); |
| 66 | } |
| 67 | } else { |
| 68 | return {top: num(this.css(name + '-top' + (name === 'border' ? '-width' : ''))), |
| 69 | bottom: num(this.css(name + '-bottom' + (name === 'border' ? '-width' : ''))), |
| 70 | left: num(this.css(name + '-left' + (name === 'border' ? '-width' : ''))), |
| 71 | right: num(this.css(name + '-right' + (name === 'border' ? '-width' : '')))}; |
| 72 | } |
| 73 | return this; |
| 74 | }; |
| 75 | }); |
| 76 | }(jQuery)); |