日期:2014-05-16 浏览次数:20532 次
(function ($) {
$.fn.addGrid = function (cols, options) {
var defaults = {
default_cols: 12,
z_index: 999,
img_path: '/images/',
opacity:.6
};
// Extend our default options with those provided.
var opts = $.extend(defaults, options);
var cols = cols != null && (cols === 12 || cols === 16) ? cols : 12;
var cols = cols === opts.default_cols ? '12_col' : '16_col';
return this.each(function () {
var $el = $(this);
var height = $el.height();
var wrapper = $('<div id="'+opts.grid_id+'"/>')
.appendTo($el)
.css({
'display':'none',
'position':'absolute',
'top':0,
'z-index':(opts.z_index -1),
'height':height,
'opacity':opts.opacity,
'width':'100%'});
$('<div/>')
.addClass('container_12')
.css({
'margin':'0 auto',
'width':'960px',
'height':height,
'background-image': 'url('+opts.img_path+cols + '.png)',
'background-repeat': 'repeat-y'})
.appendTo(wrapper);
// add toggle
$('<div>grid on</div>')
.appendTo($el)
.css({
'position':'absolute',
'top':0,
'left':0,
'z-index':opts.z_index,
'background': '#222',
'color':'#fff',
'padding': '3px 6px',
'width': '40px',
'text-align':'center'
})
.hover( function() {
$(this).css("cursor", "pointer");
}, function() {
$(this).css("cursor", "default");
})
.toggle( function () {
$(this).text("grid off");
$('#'+opts.grid_id).slideDown();
},
function() {
$(this).text("grid on");
$('#'+opts.grid_id).slideUp();
});
});
};
})(jQuery);
(function( window, undefined ) {
var
// A central reference to the root jQuery(document)
rootjQuery,
// The deferred used on DOM ready
readyList,
// Use the correct document accordingly with window argument (sandbox)
document = window.document,
location = window.location,
navigator = window.navigator,
// Map over jQuery in case of overwrite
_jQuery = window.jQuery,
// Map over the $ in case of overwrite
_$ = window.$,