|
247 | 247 | var $el = $(this); |
248 | 248 |
|
249 | 249 | //hide no-js content |
250 | | - $el.find('[data-role="nojs"]').addClass('ui-nojs'); |
| 250 | + $el.find('[data-role="nojs"]').addClass('ui-nojs'); |
| 251 | + |
| 252 | + $el.find('input[type=radio],input[type=checkbox]').customCheckboxRadio(); |
| 253 | + $el.find('button, input[type=submit], input[type=reset], input[type=image]').customButton(); |
| 254 | + $el.find('input[type=text],input[type=number],input[type=password],textarea').customTextInput(); |
| 255 | + $el.find("input, select").filter('[data-role="slider"]').slider(); |
| 256 | + $el.find('select').not('[data-role="slider"]').customSelect(); |
| 257 | + |
| 258 | + /*temporary datepicker workaround */ |
| 259 | + $el.find('input[type=date]').hide().after( $('<div />').datepicker() ); |
| 260 | + $('.ui-datepicker-header').addClass('ui-body-c ui-corner-top').removeClass('ui-corner-all'); |
| 261 | + $('.ui-datepicker-prev').buttonMarkup({iconPos: 'notext', icon: 'arrow-l', shadow: true, corners: true}); |
| 262 | + $('.ui-datepicker-next').buttonMarkup({iconPos: 'notext', icon: 'arrow-r', shadow: true, corners: true}); |
| 263 | + $('.ui-datepicker-calendar thead').remove(); |
| 264 | + $('.ui-datepicker-calendar .ui-btn-text span').attr('class',''); |
| 265 | + $('.ui-datepicker-calendar td').addClass('ui-btn-up-c'); |
| 266 | + $('.ui-datepicker-calendar a').buttonMarkup({corners: false, shadow: false}); |
| 267 | + /* //temporary datepicker workaround */ |
251 | 268 |
|
252 | 269 | //pre-find data els |
253 | 270 | var $dataEls = $el.find('[data-role]').andSelf().each(function() { |
|
268 | 285 | case 'ajaxform': |
269 | 286 | $this[role](); |
270 | 287 | break; |
| 288 | + case 'controlgroup': |
| 289 | + // FIXME for some reason this has to come before the form control stuff (see above) |
| 290 | + $this.controlgroup({ |
| 291 | + direction: $this.attr("data-type") |
| 292 | + }); |
| 293 | + break; |
271 | 294 | } |
272 | 295 | }); |
273 | 296 |
|
274 | 297 | //fix toolbars |
275 | 298 | $el.fixHeaderFooter(); |
276 | 299 |
|
277 | | - //form elements |
278 | | - var checksradios = 'input[type=radio],input[type=checkbox]', |
279 | | - buttonInputs = 'button, input[type=submit], input[type=reset], input[type=image]', |
280 | | - textInputs = 'input[type=text],input[type=number],input[type=date],input[type=password],textarea', |
281 | | - dateInputs = 'input[type=date]', |
282 | | - sliders = '[data-role="slider"]', |
283 | | - selects = 'select'; |
284 | | - |
285 | | - $formEls = $el.find( [checksradios, buttonInputs, textInputs, dateInputs, sliders, selects].join(',') ).not('.ui-nojs'); |
286 | | - |
287 | | - $formEls.filter(checksradios).customCheckboxRadio(); |
288 | | - //custom buttons |
289 | | - $formEls.filter(buttonInputs).customButton(); |
290 | | - //custom text inputs |
291 | | - $formEls.filter(textInputs).customTextInput(); |
292 | | - |
293 | | - /*temporary datepicker workaround */ |
294 | | - $formEls.filter(dateInputs).hide().after( $('<div />').datepicker() ); |
295 | | - $('.ui-datepicker-header').addClass('ui-body-c ui-corner-top').removeClass('ui-corner-all'); |
296 | | - $('.ui-datepicker-prev').buttonMarkup({iconPos: 'notext', icon: 'arrow-l', shadow: true, corners: true}); |
297 | | - $('.ui-datepicker-next').buttonMarkup({iconPos: 'notext', icon: 'arrow-r', shadow: true, corners: true}); |
298 | | - $('.ui-datepicker-calendar thead').remove(); |
299 | | - $('.ui-datepicker-calendar .ui-btn-text span').attr('class',''); |
300 | | - $('.ui-datepicker-calendar td').addClass('ui-btn-up-c'); |
301 | | - $('.ui-datepicker-calendar a').buttonMarkup({corners: false, shadow: false}); |
302 | | - /* //temporary datepicker workaround */ |
303 | | - |
304 | | - |
305 | | - //sliders |
306 | | - $formEls.filter(sliders).slider(); |
307 | | - //selects |
308 | | - $formEls.filter(selects).not('[data-role="slider"]').customSelect(); |
309 | | - |
310 | | - //vertical controlgroups |
311 | | - $dataEls.filter('[data-role="controlgroup"]:not([data-type="horizontal"])').controlgroup(); |
312 | | - //horizontal controlgroups |
313 | | - $dataEls.filter('[data-role="controlgroup"][data-type="horizontal"]').controlgroup({direction: 'horizontal'}); |
314 | | - |
315 | 300 | //add back buttons to headers that don't have them |
| 301 | + // FIXME make that optional? |
| 302 | + // TODO don't do that on devices that have a native back button? |
316 | 303 | var backBtn = $el.find('.ui-header a.ui-back'); |
317 | 304 | if(!backBtn.length){ |
318 | 305 | backBtn = jQuery('<a href="#" class="ui-back" data-icon="arrow-l"></a>').appendTo($el.find('.ui-header')); |
|
325 | 312 | //make all back buttons mimic the back button (pre-js, these links are usually "home" links) |
326 | 313 | backBtn |
327 | 314 | .click(function(){ |
| 315 | + // FIXME if you navigated from some page directly to subpage (ala .../#_form-controls.html), back button will actually go to the previous page, instead of the parent page |
328 | 316 | history.go(-1); |
329 | 317 | return false; |
330 | 318 | }) |
331 | 319 | .find('.ui-btn-text').text(backBtnText); |
332 | 320 |
|
333 | | - $el.attr('data-mobilized',true); |
| 321 | + $el.attr('data-mobilized', true); |
334 | 322 | }); |
335 | 323 | }; |
336 | 324 |
|
|
0 commit comments