/*! * samaxesJS JavaScript Library * jQuery CSS Float Check Plugin v1.0.1 * http://code.google.com/p/samaxesjs/ * * Copyright (c) 2008 samaxes.com * * 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. */ (function($) { /* * The CSS Float plugin is capable of detecting floating errors and adding a * border to elements which should be cleared - but aren't. */ $.fn.cssfloat = function(options) { var opts = $.extend({}, $.fn.cssfloat.defaults, options); return this.each(function() { var element = $(this); if (element.css('float') !== 'none' && element.next().length !== 0) { checkNextFloat(element.next(), element.css('float'), opts); } }); }; /* * Browse CSS float error detection with jQuery. */ function checkNextFloat(element, floating, opts) { if (element.css('clear') !== 'none') { var clearing = true; } else { if (element.next().length !== 0) { var clearing = false; checkNextFloat(element.next(), floating, opts); } else { debug(element); element.css({border: opts.border}); } } }; /* * Logging and debugging. */ function debug(object) { if (window.console && window.console.log) { window.console.log(object); } }; $.fn.cssfloat.defaults = {border: '2px dotted orange'} })(jQuery);