PageRenderTime 58ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/squelettes/javascript/jquery.960grid-1.0.js

https://github.com/rougerose/actup
JavaScript | 89 lines | 64 code | 7 blank | 18 comment | 3 complexity | 6eaa4fde9a5a60dc801bac23da29e024 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. /*
  2. * @ description: Plugin to display 960.gs gridlines See http://960.gs/
  3. * @author: badlyDrawnToy sharp / http://www.badlydrawntoy.com
  4. * @license: Creative Commons License - ShareAlike http://creativecommons.org/licenses/by-sa/3.0/
  5. * @version: 1.0 20th April 2009
  6. * @params:
  7. * cols - Either 12 or 16. Defaults to 12
  8. * options - Default options are as follows. They may be overridden by passing in this param
  9. * var defaults = {
  10. * default_cols: 12,
  11. * z_index: 999,
  12. * img_path: '/images/',
  13. * opacity:.6
  14. * };
  15. */
  16. (function ($) {
  17. $.fn.addGrid = function (cols, options) {
  18. var defaults = {
  19. default_cols: 12,
  20. z_index: 999,
  21. img_path: '/images/',
  22. opacity:.6,
  23. left:'auto'
  24. };
  25. // Extend our default options with those provided.
  26. var opts = $.extend(defaults, options);
  27. var cols = cols != null && (cols === 12 || cols === 16) ? cols : 12;
  28. var cols = cols === opts.default_cols ? '12_col' : '16_col';
  29. return this.each(function () {
  30. var $el = $(this);
  31. var height = $el.height();
  32. var wrapper = $('<div id="'+opts.grid_id+'"/>')
  33. .appendTo($el)
  34. .css({
  35. 'display':'none',
  36. 'position':'absolute',
  37. 'top':0,
  38. 'left':opts.left,
  39. 'z-index':(opts.z_index -1),
  40. 'height':height,
  41. 'opacity':opts.opacity,
  42. 'width':'100%'});
  43. $('<div/>')
  44. .addClass('container_12')
  45. .css({
  46. 'margin':'0 auto',
  47. 'width':'960px',
  48. 'height':height,
  49. 'background-image': 'url('+opts.img_path+cols + '.png)',
  50. //'background-repeat': 'repeat-y'})
  51. 'background-repeat': 'repeat'})
  52. .appendTo(wrapper);
  53. // add toggle
  54. $('<div>grid on</div>')
  55. .appendTo($el)
  56. .css({
  57. 'position':'absolute',
  58. 'top':'30px',
  59. 'left':'10px',
  60. 'z-index':opts.z_index,
  61. 'background': '#222',
  62. 'color':'#fff',
  63. 'padding': '3px 6px',
  64. 'width': '40px',
  65. 'text-align':'center'
  66. })
  67. .hover( function() {
  68. $(this).css("cursor", "pointer");
  69. }, function() {
  70. $(this).css("cursor", "default");
  71. })
  72. .toggle( function () {
  73. $(this).text("grid off");
  74. $('#'+opts.grid_id).slideDown();
  75. },
  76. function() {
  77. $(this).text("grid on");
  78. $('#'+opts.grid_id).slideUp();
  79. });
  80. });
  81. };
  82. })(jQuery);