Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactored the Plugin.

  • Loading branch information...
commit dc635c438b493c5141e93cdf23e7f7540649fed8 1 parent 0359099
@JacopKane JacopKane authored
Showing with 79 additions and 15 deletions.
  1. +17 −15 README.txt
  2. +62 −0 webroot/js/cakebootstrap.js
View
32 README.txt
@@ -2,22 +2,24 @@
Bootstrappifier for CakePHP is a Javascript library to use Twitter Bootstrap library with CakePHP without need of FormHelper hacks.
For download:
-
-https://github.com/mtkocak/Cakephp-Bootstrappifier
+https://github.com/JacopKane/Cakephp-Bootstrappifier/zipball/master
For install:
-
-0. You have to have Jquery Library
-
-1. You have to have Twitter Bootstrap configured. (cake.generic.css removed from default.ctp, files downloaded and included to you webroot/css and web root/js folders )
-
-2. Copy cakebootstrap.js in your webroot/js folder
-
-3. Your View/Layouts/default.ctp file must include this in head tag:
-
-echo $this->Html->css('bootstrap.min'); //You don't need to add again if you have this
-echo $this->Html->script('libs/jquery-1.6.2.min.js');// You don't need this if you have Jquery
-
-echo $this->Html->script('cakebootstrap.js');
+1. You have to include jQuery library and bootstrap.css (or bootstrap.less and less.js as your preference) in your layout.
+2. Clone repository to your plugin directory at unix terminal:
+ as Submodule:
+ $ git submodule add https://github.com/mtkocak/Cakephp-Bootstrappifier.git /Your/Path/To/app/Plugins/CakeBootstrappifier
+ ...or Clone:
+ $ git clone https://github.com/mtkocak/Cakephp-Bootstrappifier.git /Your/Path/To/app/Plugins/CakeBootstrappifier
+3. Example layout configuration:
+
+ <?php
+ echo $this->Html->script(array(
+ 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js',
+ '/CakeBootstrappifier/js/cakebootstrap'
+ ));
+
+ echo $this->Html->css(array('bootstrap'));
+ ?>
- For any question mtkocak@gmail.com
View
62 webroot/js/cakebootstrap.js
@@ -0,0 +1,62 @@
+/*
+* 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.
+*
+*/
+
+var Bootstrappifier = {
+ straps : {
+ cake : function() {
+ //All submit forms wrapped to div.action
+ $('input][type="submit"][class!="btn btn-primary"]').wrap('<div class="actions" />');
+ //All submit forms converted to primary button
+ $('input[type="submit"]').addClass('btn 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" />');
+ },
+ error : function() {
+ $('.message').addClass('alert alert-info');
+ $('.flash_success').addClass('alert alert-success');
+ $('.flash_warning').addClass('alert');
+ $('.error-message').addClass('alert alert-error');
+ //$('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');
+ }
+ },
+ getStraps : function() {
+ var strapsList = new Array();
+ $.each(this.straps, function(key, name) {
+ strapsList.push(key);
+ });
+ strapsList = strapsList.join(',');
+ return typeof(strapsList == 'array') ? strapsList : new Array();
+ },
+ load : function(straps) {
+ straps = typeof(straps !== 'string') ? this.getStraps() : straps;
+ return $.each(straps.split(','), function(key, value) {
+ if(typeof(Bootstrappifier.straps[value] === 'function')) {
+ var strapFunction = Bootstrappifier.straps[value];
+ strapFunction();
+ }
+ }) ? true : false;
+ },
+}
+//Styling start when document loads
+$(document).ready(function(){
+ Bootstrappifier.load();
+});
Please sign in to comment.
Something went wrong with that request. Please try again.