Skip to content

Commit

Permalink
Merge pull request #450 from pbihler/boxActivate
Browse files Browse the repository at this point in the history
Enable explicit box activation
  • Loading branch information
almasaeed2010 committed May 23, 2015
2 parents d08e0e0 + 3eb31be commit 6f09c02
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
26 changes: 23 additions & 3 deletions dist/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,16 +528,19 @@ function _init() {
$.AdminLTE.boxWidget = {
selectors: $.AdminLTE.options.boxWidgetOptions.boxWidgetSelectors,
icons: $.AdminLTE.options.boxWidgetOptions.boxWidgetIcons,
activate: function () {
activate: function (_box) {
var _this = this;
if (! _box) {
_box = document; // activate all boxes per default
}
//Listen for collapse event triggers
$(_this.selectors.collapse).on('click', function (e) {
$(_box).find(_this.selectors.collapse).on('click', function (e) {
e.preventDefault();
_this.collapse($(this));
});

//Listen for remove event triggers
$(_this.selectors.remove).on('click', function (e) {
$(_box).find(_this.selectors.remove).on('click', function (e) {
e.preventDefault();
_this.remove($(this));
});
Expand Down Expand Up @@ -656,6 +659,23 @@ function _init() {

})(jQuery);

/*
* EXPLICIT BOX ACTIVATION
* -----------------------
* This is a custom plugin to use with the component BOX. It allows you to activate
* a box inserted in the DOM after the app.js was loaded.
*
* @type plugin
* @usage $("#box-widget").activateBox();
*/
(function ($) {

$.fn.activateBox = function () {
$.AdminLTE.boxWidget.activate(this);
};

})(jQuery);

/*
* TODO LIST CUSTOM PLUGIN
* -----------------------
Expand Down
2 changes: 1 addition & 1 deletion dist/js/app.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions documentation/build/include/components.html
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,13 @@ <h3 class="box-title">Tootips on buttons</h3>
&LT;/div>&LT;!-- /.box --></pre>
</div><!-- /.col -->
</div><!-- /.row -->
<p>
If you inserted a box into the document after <code>app.js</code> was loaded, you have to activate
the collapse/remove buttons explicitly by calling <code>.activateBox()</code>:
</p>
<pre class='prettyprint'><code class='html'>&LT;script>
$("#box-widget").activateBox();
&LT;/script></code></pre>

<h4>Loading States</h4>
<div class="row">
Expand Down
7 changes: 7 additions & 0 deletions documentation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,13 @@ <h3 class="box-title">Tootips on buttons</h3>
&LT;/div>&LT;!-- /.box --></pre>
</div><!-- /.col -->
</div><!-- /.row -->
<p>
If you inserted a box into the document after <code>app.js</code> was loaded, you have to activate
the collapse/remove buttons explicitly by calling <code>.activateBox()</code>:
</p>
<pre class='prettyprint'><code class='html'>&LT;script>
$("#box-widget").activateBox();
&LT;/script></code></pre>

<h4>Loading States</h4>
<div class="row">
Expand Down

0 comments on commit 6f09c02

Please sign in to comment.