forked from midorikocak/Cakephp-Bootstrappifier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcakebootstrap.js
More file actions
executable file
·75 lines (42 loc) · 1.68 KB
/
cakebootstrap.js
File metadata and controls
executable file
·75 lines (42 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Twitter Bootstrappifier for CakePHP
*
* Author: Mutlu Tevfik Kocak
*
* CakePHP Twitter Bootstrappifier
*
* Selects all con twitter Bootstrap incompatible form and buttons,
* and converts them into pretty Twitter Bootstrap style.
*
*/
function cakebootstrap()
{
//All submit forms wrapped to div.action
$('input][type="submit"][class!="btn primary"]').wrap('<div class="actions" />');
//All submit forms converted to primary button
$('input[type="submit"]').addClass('btn primary');
//All index actions converted into pretty buttons
$('td][class="actions"] > a[class!="btn"]').addClass('btn');
//All (div.inputs) with default FormHelper style (div.input > label ~ input)
//converted into Twitter Bootstrap Style (div.clearfix > label ~ div.input)
$('div[class!="input added"].input').removeClass().addClass('clearfix');
$('div.clearfix > label ~ input').wrap('<div class="input added" />');
$('div.clearfix > label ~ select').wrap('<div class="input added" />');
$('div.clearfix > label ~ textarea').wrap('<div class="input added" />');
}
//Default CakePHP Error inputs are converted to twitter bootstrap style
function errorstrap()
{
$('.message').addClass('alert-message error');
$('.flash_success').addClass('alert-message success');
$('.flash_warning').addClass('alert-message warning');
$('.error-message').addClass('help-inline');
//$('div.error-message').append($('div.error-message').replaceWith('<span class="help-inline">'+$('div.error-message').text()+'</span'));
$('.form-error').addClass('error');
$('.form-error').closest('.clearfix').addClass('error');
}
//Styling start when document loads
$(document).ready(function(){
cakebootstrap();
errorstrap();
});