1/* 2 Formalize - version 1.1 3 4 Note: This file depends on the jQuery library. 5*/ 6 7// Module pattern: 8// http://yuiblog.com/blog/2007/06/12/module-pattern 9var FORMALIZE = (function($, window, document, undefined) { 10 // Private constants. 11 var PLACEHOLDER_SUPPORTED = 'placeholder' in document.createElement('input'); 12 var AUTOFOCUS_SUPPORTED = 'autofocus' in document.createElement('input'); 13 var IE6 = !!($.browser.msie && parseInt($.browser.version, 10) === 6); 14 var IE7 = !!($.browser.msie && parseInt($.browser.version, 10) === 7); 15 16 // Expose innards of FORMALIZE. 17 return { 18 // FORMALIZE.go 19 go: function() { 20 for (var i in FORMALIZE.init) { 21 FORMALIZE.init[i](); 22 } 23 }, 24 // FORMALIZE.init 25 init: { 26 // FORMALIZE.init.ie6_skin_inputs 27 ie6_skin_inputs: function() { 28 // Test for Internet Explorer 6. 29 if (!IE6 || !$('input, select, textarea').length) { 30 // Exit if the browser is not IE6, 31 // or if no form elements exist. 32 return; 33 } 34 35 // For <input type="submit" />, etc. 36 var button_regex = /button|submit|reset/; 37 38 // For <input type="text" />, etc. 39 var type_regex = /date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/; 40 41 $('input').each(function() { 42 var el = $(this); 43 44 // Is it a button? 45 if (this.getAttribute('type').match(button_regex)) { 46 el.addClass('ie6-button'); 47 48 /* Is it disabled? */ 49 if (this.disabled) { 50 el.addClass('ie6-button-disabled'); 51 } 52 } 53 // Or is it a textual input? 54 else if (this.getAttribute('type').match(type_regex)) { 55 el.addClass('ie6-input'); 56 57 /* Is it disabled? */ 58 if (this.disabled) { 59 el.addClass('ie6-input-disabled'); 60 } 61 } 62 }); 63 64 $('textarea, select').each(function() { 65 /* Is it disabled? */ 66 if (this.disabled) { 67 $(this).addClass('ie6-input-disabled'); 68 } 69 }); 70 }, 71 // FORMALIZE.init.autofocus 72 autofocus: function() { 73 if (AUTOFOCUS_SUPPORTED || !$(':input[autofocus]').length) { 74 return; 75 } 76 77 $(':input[autofocus]:visible:first').focus(); 78 }, 79 // FORMALIZE.init.placeholder 80 placeholder: function() { 81 if (PLACEHOLDER_SUPPORTED || !$(':input[placeholder]').length) { 82 // Exit if placeholder is supported natively, 83 // or if page does not have any placeholder. 84 return; 85 } 86 87 FORMALIZE.misc.add_placeholder(); 88 89 $(':input[placeholder]').each(function() { 90 var el = $(this); 91 var text = el.attr('placeholder'); 92 93 el.focus(function() { 94 if (el.val() === text) { 95 el.val('').removeClass('placeholder-text'); 96 } 97 }).blur(function() { 98 FORMALIZE.misc.add_placeholder(); 99 }); 100 101 // Prevent <form> from accidentally 102 // submitting the placeholder text. 103 el.closest('form').submit(function() { 104 if (el.val() === text) { 105 el.val('').removeClass('placeholder-text'); 106 } 107 }).bind('reset', function() { 108 setTimeout(FORMALIZE.misc.add_placeholder, 50); 109 }); 110 }); 111 } 112 }, 113 // FORMALIZE.misc 114 misc: { 115 // FORMALIZE.misc.add_placeholder 116 add_placeholder: function() { 117 if (PLACEHOLDER_SUPPORTED || !$(':input[placeholder]').length) { 118 // Exit if placeholder is supported natively, 119 // or if page does not have any placeholder. 120 return; 121 } 122 123 $(':input[placeholder]').each(function() { 124 var el = $(this); 125 var text = el.attr('placeholder'); 126 127 if (!el.val() || el.val() === text) { 128 el.val(text).addClass('placeholder-text'); 129 } 130 }); 131 } 132 } 133 }; 134// Alias jQuery, window, document. 135})(jQuery, this, this.document); 136 137// Automatically calls all functions in FORMALIZE.init 138jQuery(document).ready(function() { 139 FORMALIZE.go(); 140});; 141/** 142 * @todo 143 */ 144 145Drupal.omega = Drupal.omega || {}; 146 147(function($) { 148 /** 149 * @todo 150 */ 151 var current; 152 var previous; 153 154 /** 155 * @todo 156 */ 157 var setCurrentLayout = function (index) { 158 index = parseInt(index); 159 previous = current; 160 current = Drupal.settings.omega.layouts.order.hasOwnProperty(index) ? Drupal.settings.omega.layouts.order[index] : 'mobile'; 161 162 if (previous != current) { 163 $('body').removeClass('responsive-layout-' + previous).addClass('responsive-layout-' + current); 164 $.event.trigger('responsivelayout', {from: previous, to: current}); 165 } 166 }; 167 168 /** 169 * @todo 170 */ 171 Drupal.omega.getCurrentLayout = function () { 172 return current; 173 }; 174 175 /** 176 * @todo 177 */ 178 Drupal.omega.getPreviousLayout = function () { 179 return previous; 180 }; 181 182 /** 183 * @todo 184 */ 185 Drupal.omega.crappyBrowser = function () { 186 return $.browser.msie && parseInt($.browser.version, 10) < 9; 187 }; 188 189 /** 190 * @todo 191 */ 192 Drupal.omega.checkLayout = function (layout) { 193 if (Drupal.settings.omega.layouts.queries.hasOwnProperty(layout) && Drupal.settings.omega.layouts.queries[layout]) { 194 var output = Drupal.omega.checkQuery(Drupal.settings.omega.layouts.queries[layout]); 195 196 if (!output && layout == Drupal.settings.omega.layouts.primary) { 197 var dummy = $('<div id="omega-check-query"></div>').prependTo('body'); 198 199 dummy.append('<style media="all">#omega-check-query { position: relative; z-index: -1; }</style>'); 200 dummy.append('<!--[if (lt IE 9)&(!IEMobile)]><style media="all">#omega-check-query { z-index: 100; }</style><![endif]-->'); 201 202 output = parseInt(dummy.css('z-index')) == 100; 203 204 dummy.remove(); 205 } 206 207 return output; 208 } 209 210 return false;
211 }; 212 213 /** 214 * @todo 215 */ 216 Drupal.omega.checkQuery = function (query) { 217 var dummy = $('<div id="omega-check-query"></div>').prependTo('body'); 218 219 dummy.append('<style media="all">#omega-check-query { position: relative; z-index: -1; }</style>'); 220 dummy.append('<style media="' + query + '">#omega-check-query { z-index: 100; }</style>'); 221 222 var output = parseInt(dummy.css('z-index')) == 100; 223 224 dummy.remove(); 225 226 return output; 227 }; 228 229 /** 230 * @todo 231 */ 232 Drupal.behaviors.omegaMediaQueries = { 233 attach: function (context) { 234 $('body', context).once('omega-mediaqueries', function () { 235 var primary = $.inArray(Drupal.settings.omega.layouts.primary, Drupal.settings.omega.layouts.order); 236 var dummy = $('<div id="omega-media-query-dummy"></div>').prependTo('body'); 237 238 dummy.append('<style media="all">#omega-media-query-dummy { position: relative; z-index: -1; }</style>'); 239 dummy.append('<!--[if (lt IE 9)&(!IEMobile)]><style media="all">#omega-media-query-dummy { z-index: ' + primary + '; }</style><![endif]-->'); 240 241 for (var i in Drupal.settings.omega.layouts.order) { 242 dummy.append('<style media="' + Drupal.settings.omega.layouts.queries[Drupal.settings.omega.layouts.order[i]] + '">#omega-media-query-dummy { z-index: ' + i + '; }</style>'); 243 } 244 245 $(window).bind('resize.omegamediaqueries', function () { 246 setCurrentLayout(dummy.css('z-index')); 247 }).load(function () { 248 $(this).trigger('resize.omegamediaqueries'); 249 }); 250 }); 251 } 252 }; 253})(jQuery);;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.