Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
Yii Bootstrap 3
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Common
Yii Bootstrap 3
Commits
a8ced14d
Commit
a8ced14d
authored
Dec 16, 2011
by
Crisu83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the BootTabs widget and made some minor improvements.
parent
483dc174
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
277 additions
and
27 deletions
+277
-27
jquery.ui.boottabs.js
assets/js/jquery.ui.boottabs.js
+87
-0
jquery.ui.boottwipsy.js
assets/js/jquery.ui.boottwipsy.js
+5
-6
BootstrapCode.php
gii/bootstrap/BootstrapCode.php
+2
-2
reset.less
vendors/bootstrap/lib/reset.less
+0
-1
BootAlert.php
widgets/BootAlert.php
+2
-1
BootDataColumn.php
widgets/BootDataColumn.php
+48
-9
BootInput.php
widgets/BootInput.php
+5
-5
BootMenu.php
widgets/BootMenu.php
+3
-3
BootTabs.php
widgets/BootTabs.php
+125
-0
No files found.
assets/js/jquery.ui.boottabs.js
0 → 100644
View file @
a8ced14d
/*!
* Bootstrap Tabs jQuery UI widget file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright © Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @see http://twitter.github.com/bootstrap
*/
(
function
(
$
)
{
"use strict"
// set strict mode
var
widget
=
$
.
extend
(
{},
$
.
ui
.
bootWidget
.
prototype
,
{
/**
* The name of the widget.
* @type String
*/
name
:
'tabs'
,
/**
* Widget options.
* @type Object
*/
options
:
{
},
/**
* Creates the widget.
*/
_create
:
function
()
{
var
self
=
this
,
element
=
self
.
element
,
options
=
self
.
options
,
title
=
self
.
element
.
attr
(
'title'
);
element
.
bind
(
'click'
,
function
(
event
)
{
self
.
_tab
(
event
);
});
},
_activate
:
function
(
element
,
container
)
{
container
.
find
(
'> .active'
)
.
removeClass
(
'active'
)
.
find
(
'> .dropdown-menu > .active'
)
.
removeClass
(
'active'
);
element
.
addClass
(
'active'
);
if
(
element
.
parent
(
'.dropdown-menu'
)
)
{
element
.
closest
(
'li.dropdown'
).
addClass
(
'active'
);
}
},
_tab
:
function
(
event
)
{
var
self
=
this
,
element
=
self
.
element
,
ul
=
element
.
closest
(
'ul:not(.dropdown-menu)'
),
href
=
element
.
attr
(
'href'
),
previous
,
pane
;
if
(
/^#
\w
+/
.
test
(
href
)
)
{
event
.
preventDefault
();
if
(
!
element
.
parent
(
'li'
).
hasClass
(
'active'
)
)
{
previous
=
ul
.
find
(
'.active a'
).
last
()[
0
];
pane
=
$
(
href
);
self
.
_activate
(
element
.
parent
(
'li'
),
ul
);
self
.
_activate
(
pane
,
pane
.
parent
()
);
element
.
trigger
(
{
type
:
'change'
,
relatedTarget
:
previous
}
);
}
}
},
/**
* Destructs this widget.
*/
_destroy
:
function
()
{
// Nothing here yet...
}
}
);
/**
* BootTabs jQuery UI widget.
*/
$
.
widget
(
'ui.bootTabs'
,
widget
);
}
)(
jQuery
);
\ No newline at end of file
assets/js/jquery.ui.boottwipsy.js
View file @
a8ced14d
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
var
self
=
this
,
var
self
=
this
,
element
=
self
.
element
,
element
=
self
.
element
,
options
=
self
.
options
,
options
=
self
.
options
,
title
=
self
.
element
.
attr
(
'title'
),
title
=
element
.
attr
(
'title'
),
binder
=
options
.
live
?
'live'
:
'bind'
;
binder
=
options
.
live
?
'live'
:
'bind'
;
if
(
title
&&
title
.
length
>
0
)
{
if
(
title
&&
title
.
length
>
0
)
{
...
@@ -54,12 +54,11 @@
...
@@ -54,12 +54,11 @@
element
.
attr
(
'data-title'
,
title
);
element
.
attr
(
'data-title'
,
title
);
element
[
binder
](
options
.
showEvent
,
function
()
{
element
[
binder
](
options
.
showEvent
,
function
()
{
self
.
show
();
self
.
show
();
});
});
element
[
binder
](
options
.
hideEvent
,
function
()
{
element
[
binder
](
options
.
hideEvent
,
function
()
{
self
.
hide
();
self
.
hide
();
});
});
}
}
},
},
/**
/**
...
...
gii/bootstrap/BootstrapCode.php
View file @
a8ced14d
...
@@ -12,9 +12,9 @@ class BootstrapCode extendS CrudCode
...
@@ -12,9 +12,9 @@ class BootstrapCode extendS CrudCode
public
function
generateActiveRow
(
$modelClass
,
$column
)
public
function
generateActiveRow
(
$modelClass
,
$column
)
{
{
if
(
$column
->
type
===
'boolean'
)
if
(
$column
->
type
===
'boolean'
)
return
"
\$
form->checkBox
Row
(
\$
model,'
{
$column
->
name
}
')"
;
return
"
\$
form->checkBox
Block
(
\$
model,'
{
$column
->
name
}
')"
;
else
if
(
stripos
(
$column
->
dbType
,
'text'
)
!==
false
)
else
if
(
stripos
(
$column
->
dbType
,
'text'
)
!==
false
)
return
"
\$
form->textArea
Row
(
\$
model,'
{
$column
->
name
}
',array('rows'=>6, 'cols'=>50, 'class'=>'span8'))"
;
return
"
\$
form->textArea
Block
(
\$
model,'
{
$column
->
name
}
',array('rows'=>6, 'cols'=>50, 'class'=>'span8'))"
;
else
else
{
{
if
(
preg_match
(
'/^(password|pass|passwd|passcode)$/i'
,
$column
->
name
))
if
(
preg_match
(
'/^(password|pass|passwd|passcode)$/i'
,
$column
->
name
))
...
...
vendors/bootstrap/lib/reset.less
View file @
a8ced14d
/* Reset.less
/* Reset.less
* Props to Eric Meyer (meyerweb.com) for his CSS reset file. We're using an adapted version here that cuts out some of the reset HTML elements we will never need here (i.e., dfn, samp, etc).
* ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
* ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
...
...
widgets/BootAlert.php
View file @
a8ced14d
...
@@ -58,7 +58,7 @@ class BootAlert extends BootWidget
...
@@ -58,7 +58,7 @@ class BootAlert extends BootWidget
$this
->
options
[
'keys'
]
=
$this
->
keys
;
$this
->
options
[
'keys'
]
=
$this
->
keys
;
$this
->
options
[
'template'
]
=
$this
->
template
;
$this
->
options
[
'template'
]
=
$this
->
template
;
$options
=
CJavaScript
::
encode
(
$this
->
options
)
;
$options
=
!
empty
(
$this
->
options
)
?
CJavaScript
::
encode
(
$this
->
options
)
:
''
;
Yii
::
app
()
->
getClientScript
()
->
registerScript
(
__CLASS__
.
'#'
.
$id
,
"jQuery('#
{
$id
}
').bootAlert(
{
$options
}
);"
);
Yii
::
app
()
->
getClientScript
()
->
registerScript
(
__CLASS__
.
'#'
.
$id
,
"jQuery('#
{
$id
}
').bootAlert(
{
$options
}
);"
);
}
}
}
}
\ No newline at end of file
widgets/BootDataColumn.php
View file @
a8ced14d
...
@@ -6,38 +6,77 @@
...
@@ -6,38 +6,77 @@
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
*/
Yii
::
import
(
'zii.widgets.grid.CDataColumn'
);
/**
/**
* Thanks to Simo Jokela <rBoost@gmail.com> for writing the original version of this class.
* Thanks to Simo Jokela <rBoost@gmail.com> for writing the original version of this class.
*/
*/
Yii
::
import
(
'zii.widgets.grid.CDataColumn'
);
class
BootDataColumn
extends
CDataColumn
class
BootDataColumn
extends
CDataColumn
{
{
/**
/**
* @properties string the header color for sortable columns.
* Valid values are: 'blue', 'green', 'red', 'yellow', 'orange' and 'purple'.
*/
public
$color
;
/**
* Initializes the column.
* Initializes the column.
*/
*/
public
function
init
()
public
function
init
()
{
{
if
(
isset
(
$this
->
headerHtmlOptions
[
'class'
]))
if
(
$this
->
grid
->
enableSorting
&&
$this
->
sortable
&&
$this
->
name
!==
null
)
$this
->
headerHtmlOptions
[
'class'
]
.=
' header'
;
{
else
$colorCss
=
$this
->
color
!==
null
?
' '
.
$this
->
color
:
''
;
$this
->
headerHtmlOptions
[
'class'
]
=
'header'
;
$class
=
'header'
.
$colorCss
;
if
(
isset
(
$this
->
headerHtmlOptions
[
'class'
]))
$this
->
headerHtmlOptions
[
'class'
]
.=
$class
;
else
$this
->
headerHtmlOptions
[
'class'
]
=
$class
;
}
/*
$matches = array();
preg_match('/href\="(.*)"/i', $this->grid->dataProvider->sort->link($this->name), $matches);
if (isset($matches[1]))
$url = $matches[1];
*/
parent
::
init
();
parent
::
init
();
}
}
/**
/**
* Renders the header cell content.
*/
/*
protected function renderHeaderCellContent()
{
if($this->name!==null && $this->header===null)
{
if($this->grid->dataProvider instanceof CActiveDataProvider)
echo CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name));
else
echo CHtml::encode($this->name);
}
else
echo trim($this->header) !== '' ? $this->header : $this->grid->blankDisplay;
}
*/
/**
* Renders the header cell.
* Renders the header cell.
*/
*/
public
function
renderHeaderCell
()
public
function
renderHeaderCell
()
{
{
if
(
$this
->
grid
->
enableSorting
&&
$this
->
sortable
&&
$this
->
name
!==
null
)
if
(
$this
->
grid
->
enableSorting
&&
$this
->
sortable
&&
$this
->
name
!==
null
)
{
{
$
sortDir
=
$this
->
grid
->
dataProvider
->
getSort
()
->
getDirection
(
$this
->
name
);
$
direction
=
$this
->
grid
->
dataProvider
->
sort
->
getDirection
(
$this
->
name
);
if
(
$
sortDir
!==
null
)
if
(
$
direction
!==
null
)
{
{
$sortCssClass
=
$
sortDir
?
'headerSortDown'
:
'headerSortUp'
;
$sortCssClass
=
$
direction
?
'headerSortDown'
:
'headerSortUp'
;
$this
->
headerHtmlOptions
[
'class'
]
.=
' '
.
$sortCssClass
;
$this
->
headerHtmlOptions
[
'class'
]
.=
' '
.
$sortCssClass
;
}
}
}
}
...
...
widgets/BootInput.php
View file @
a8ced14d
...
@@ -101,7 +101,7 @@ class BootInput extends CInputWidget
...
@@ -101,7 +101,7 @@ class BootInput extends CInputWidget
break
;
break
;
default
:
default
:
throw
new
CException
(
Yii
::
t
(
'bootstrap'
,
__CLASS__
.
':
Failed to run widget! Input type is invalid.'
));
throw
new
CException
(
__CLASS__
.
': '
.
Yii
::
t
(
'bootstrap'
,
'
Failed to run widget! Input type is invalid.'
));
}
}
echo
'</div>'
;
echo
'</div>'
;
...
@@ -109,12 +109,12 @@ class BootInput extends CInputWidget
...
@@ -109,12 +109,12 @@ class BootInput extends CInputWidget
protected
function
checkBox
()
protected
function
checkBox
()
{
{
echo
'<div class="input">'
;
echo
'<div class="input">
<div class="inputs-list">
'
;
echo
'<label for="'
.
CHtml
::
getIdByName
(
CHtml
::
resolveName
(
$this
->
model
,
$this
->
attribute
))
.
'">'
;
echo
'<label for="'
.
CHtml
::
getIdByName
(
CHtml
::
resolveName
(
$this
->
model
,
$this
->
attribute
))
.
'">'
;
echo
$this
->
form
->
checkBox
(
$this
->
model
,
$this
->
attribute
,
$this
->
htmlOptions
)
.
' '
;
echo
$this
->
form
->
checkBox
(
$this
->
model
,
$this
->
attribute
,
$this
->
htmlOptions
)
.
' '
;
echo
'<span>'
.
$this
->
model
->
getAttributeLabel
(
$this
->
attribute
)
.
'</span>'
;
echo
'<span>'
.
$this
->
model
->
getAttributeLabel
(
$this
->
attribute
)
.
'</span>'
;
echo
$this
->
getHint
()
.
$this
->
getError
();
echo
$this
->
getHint
()
.
$this
->
getError
();
echo
'</label></div>'
;
echo
'</label></div>
</div>
'
;
}
}
protected
function
checkBoxList
()
protected
function
checkBoxList
()
...
@@ -151,12 +151,12 @@ class BootInput extends CInputWidget
...
@@ -151,12 +151,12 @@ class BootInput extends CInputWidget
protected
function
radioButton
()
protected
function
radioButton
()
{
{
echo
'<div class="input">'
;
echo
'<div class="input">
<div class="inputs-list">
'
;
echo
'<label for="'
.
CHtml
::
getIdByName
(
CHtml
::
resolveName
(
$this
->
model
,
$this
->
attribute
))
.
'">'
;
echo
'<label for="'
.
CHtml
::
getIdByName
(
CHtml
::
resolveName
(
$this
->
model
,
$this
->
attribute
))
.
'">'
;
echo
$this
->
form
->
radioButton
(
$this
->
model
,
$this
->
attribute
,
$this
->
htmlOptions
)
.
' '
;
echo
$this
->
form
->
radioButton
(
$this
->
model
,
$this
->
attribute
,
$this
->
htmlOptions
)
.
' '
;
echo
'<span>'
.
$this
->
model
->
getAttributeLabel
(
$this
->
attribute
)
.
'</span>'
;
echo
'<span>'
.
$this
->
model
->
getAttributeLabel
(
$this
->
attribute
)
.
'</span>'
;
echo
$this
->
getHint
()
.
$this
->
getError
();
echo
$this
->
getHint
()
.
$this
->
getError
();
echo
'</label></div>'
;
echo
'</label></div>
</div>
'
;
}
}
protected
function
radioButtonList
()
protected
function
radioButtonList
()
...
...
widgets/BootMenu.php
View file @
a8ced14d
...
@@ -14,7 +14,7 @@ class BootMenu extends CMenu
...
@@ -14,7 +14,7 @@ class BootMenu extends CMenu
* @property string the type of menu to display.
* @property string the type of menu to display.
* Following types are supported: 'tabs' and 'pills'.
* Following types are supported: 'tabs' and 'pills'.
*/
*/
public
$type
=
'tabs'
;
public
$type
=
'tabs'
;
/**
/**
* Initializes the menu widget.
* Initializes the menu widget.
...
@@ -24,9 +24,9 @@ class BootMenu extends CMenu
...
@@ -24,9 +24,9 @@ class BootMenu extends CMenu
public
function
init
()
public
function
init
()
{
{
if
(
isset
(
$this
->
htmlOptions
[
'class'
]))
if
(
isset
(
$this
->
htmlOptions
[
'class'
]))
$this
->
htmlOptions
[
'class'
]
.=
' '
.
$this
->
type
;
$this
->
htmlOptions
[
'class'
]
.=
' '
.
$this
->
type
;
else
else
$this
->
htmlOptions
[
'class'
]
=
$this
->
type
;
$this
->
htmlOptions
[
'class'
]
=
$this
->
type
;
parent
::
init
();
parent
::
init
();
}
}
...
...
widgets/BootTabs.php
0 → 100644
View file @
a8ced14d
<?php
/**
* BootTabs class file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright © Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @since 0.9.6
*/
Yii
::
import
(
'ext.bootstrap.widgets.BootWidget'
);
class
BootTabs
extends
BootWidget
{
/**
* @property string the type of tabs to display. Defaults to 'tabs'.
* Valid values are 'tabs' and 'pills'.
*/
public
$type
=
'tabs'
;
/**
* @property array the tab configuration.
*/
public
$tabs
=
array
();
/**
* @property string the name of the container element that contains all panels. Defaults to 'div'.
*/
public
$tagName
=
'div'
;
/**
* @property string the template to use for displaying the header.
*/
public
$headerTemplate
=
'<li class="{class}"><a href="{url}">{title}</a></li>'
;
/**
* @property string the template to use for displaying the content.
*/
public
$contentTemplate
=
'<div class="tab-pane {class}" id="{id}">{content}</div>'
;
/**
* @property string the CSS selector to use for selecting the tabs elements.
*/
public
$selector
=
'.tabs li > a, .pills > li > a'
;
/**
* Initializes the widget.
*/
public
function
init
()
{
parent
::
init
();
$this
->
registerScriptFile
(
'jquery.ui.boottabs.js'
);
}
/**
* Run this widget.
*/
public
function
run
()
{
$id
=
$this
->
getId
();
if
(
isset
(
$this
->
htmlOptions
[
'id'
]))
$id
=
$this
->
htmlOptions
[
'id'
];
else
$this
->
htmlOptions
[
'id'
]
=
$id
;
echo
CHtml
::
openTag
(
$this
->
tagName
,
$this
->
htmlOptions
);
$tabsOut
=
''
;
$contentOut
=
''
;
$tabCount
=
0
;
foreach
(
$this
->
tabs
as
$title
=>
$content
)
{
$tabId
=
(
is_array
(
$content
)
&&
isset
(
$content
[
'id'
]))
?
$content
[
'id'
]
:
$id
.
'_tab_'
.
$tabCount
++
;
if
(
!
is_array
(
$content
))
{
$tabsOut
.=
strtr
(
$this
->
headerTemplate
,
array
(
'{title}'
=>
$title
,
'{url}'
=>
'#'
.
$tabId
,
'{id}'
=>
'#'
.
$tabId
,
'{class}'
=>
$tabCount
===
1
?
'active'
:
''
,
));
$contentOut
.=
strtr
(
$this
->
contentTemplate
,
array
(
'{content}'
=>
$content
,
'{id}'
=>
$tabId
,
'{class}'
=>
$tabCount
===
1
?
'active'
:
''
,
));
}
elseif
(
isset
(
$content
[
'ajax'
]))
{
$tabsOut
.=
strtr
(
$this
->
headerTemplate
,
array
(
'{title}'
=>
$title
,
'{url}'
=>
CHtml
::
normalizeUrl
(
$content
[
'ajax'
]),
'{id}'
=>
'#'
.
$tabId
,
'{class}'
=>
$tabCount
===
1
?
'active'
:
''
,
));
}
else
{
$tabsOut
.=
strtr
(
$this
->
headerTemplate
,
array
(
'{title}'
=>
$title
,
'{url}'
=>
'#'
.
$tabId
,
'{class}'
=>
$tabCount
===
1
?
'active'
:
''
,
));
if
(
isset
(
$content
[
'content'
]))
{
$contentOut
.=
strtr
(
$this
->
contentTemplate
,
array
(
'{content}'
=>
$content
[
'content'
],
'{id}'
=>
$tabId
,
'{class}'
=>
$tabCount
===
1
?
'active'
:
''
,
));
}
}
}
echo
CHtml
::
openTag
(
'ul'
,
array
(
'class'
=>
$this
->
type
,
'data-'
.
$this
->
type
=>
$this
->
type
));
echo
$tabsOut
;
echo
'</ul>'
;
echo
CHtml
::
openTag
(
'div'
,
array
(
'class'
=>
$this
->
type
===
'tabs'
?
'tab-content'
:
'pill-content'
));
echo
$contentOut
;
echo
'</div>'
;
echo
CHtml
::
closeTag
(
$this
->
tagName
);
$options
=
!
empty
(
$this
->
options
)
?
CJavaScript
::
encode
(
$this
->
options
)
:
''
;
Yii
::
app
()
->
clientScript
->
registerScript
(
__CLASS__
.
'#'
.
$id
,
"jQuery('
{
$this
->
selector
}
').bootTabs(
{
$options
}
);"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment