Skip to content

Commit

Permalink
Fix AdmiteLTE.js
Browse files Browse the repository at this point in the history
  • Loading branch information
amosfolz committed Jul 14, 2019
1 parent c3dd512 commit b5d8060
Showing 1 changed file with 151 additions and 149 deletions.
300 changes: 151 additions & 149 deletions app/sprinkles/core/assets/userfrosting/js/AdminLTE.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,152 +623,154 @@ function _init() {
*/
(function($) {

"use strict";

$.fn.boxRefresh = function(options) {

// Render options
var settings = $.extend({
//Refresh button selector
trigger: ".refresh-btn",
//File source to be loaded (e.g: ajax/src.php)
source: "",
//Callbacks
onLoadStart: function(box) {
return box;
}, //Right after the button has been clicked
onLoadDone: function(box) {
return box;
} //When the source has been loaded

}, options);

//The overlay
var overlay = $('<div class="overlay"><div class="fas fa-refresh fa-spin"></div></div>');

return this.each(function() {
//if a source is specified
if (settings.source === "") {
if (window.console) {
window.console.log("Please specify a source first - boxRefresh()");
}
return;
}
//the box
var box = $(this);
//the button
var rBtn = box.find(settings.trigger).first();

//On trigger click
rBtn.on('click', function(e) {
e.preventDefault();
//Add loading overlay
start(box);

//Perform ajax call
box.find(".box-body").load(settings.source, function() {
done(box);
});

function start(box) {
//Add overlay and loading img
box.append(overlay);

settings.onLoadStart.call(box);
}

function done(box) {
//Remove overlay and loading img
box.find(overlay).remove();

settings.onLoadDone.call(box);
}

};

})(jQuery);

/*
* EXPLICIT BOX CONTROLS
* -----------------------
* 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, toggle and remove box.
*
* @type plugin
* @usage $("#box-widget").activateBox();
* @usage $("#box-widget").toggleBox();
* @usage $("#box-widget").removeBox();
*/
(function($) {

'use strict';

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

$.fn.toggleBox = function() {
var button = $($.AdminLTE.boxWidget.selectors.collapse, this);
$.AdminLTE.boxWidget.collapse(button);
};

$.fn.removeBox = function() {
var button = $($.AdminLTE.boxWidget.selectors.remove, this);
$.AdminLTE.boxWidget.remove(button);
};

})(jQuery);

/*
* TODO LIST CUSTOM PLUGIN
* -----------------------
* This plugin depends on iCheck plugin for checkbox and radio inputs
*
* @type plugin
* @usage $("#todo-widget").todolist( options );
*/
(function($) {

'use strict';

$.fn.todolist = function(options) {
// Render options
var settings = $.extend({
//When the user checks the input
onCheck: function(ele) {
return ele;
},
//When the user unchecks the input
onUncheck: function(ele) {
return ele;
}
}, options);

return this.each(function() {

if (typeof $.fn.iCheck != 'undefined') {
$('input', this).on('ifChecked', function() {
var ele = $(this).parents("li").first();
ele.toggleClass("done");
settings.onCheck.call(ele);
});

$('input', this).on('ifUnchecked', function() {
var ele = $(this).parents("li").first();
ele.toggleClass("done");
settings.onUncheck.call(ele);
});
} else {
$('input', this).on('change', function() {
var ele = $(this).parents("li").first();
ele.toggleClass("done");
if ($('input', ele).is(":checked")) {
settings.onCheck.call(ele);
} else {
settings.onUncheck.call(ele);
}
});
}
});
};
}(jQuery));
"use strict";

$.fn.boxRefresh = function(options) {

// Render options
var settings = $.extend({
//Refresh button selector
trigger: ".refresh-btn",
//File source to be loaded (e.g: ajax/src.php)
source: "",
//Callbacks
onLoadStart: function(box) {
return box;
}, //Right after the button has been clicked
onLoadDone: function(box) {
return box;
} //When the source has been loaded

}, options);

//The overlay
var overlay = $('<div class="overlay"><div class="fa fa-refresh fa-spin"></div></div>');

return this.each(function() {
//if a source is specified
if (settings.source === "") {
if (window.console) {
window.console.log("Please specify a source first - boxRefresh()");
}
return;
}
//the box
var box = $(this);
//the button
var rBtn = box.find(settings.trigger).first();

//On trigger click
rBtn.on('click', function(e) {
e.preventDefault();
//Add loading overlay
start(box);

//Perform ajax call
box.find(".box-body").load(settings.source, function() {
done(box);
});
});
});

function start(box) {
//Add overlay and loading img
box.append(overlay);

settings.onLoadStart.call(box);
}

function done(box) {
//Remove overlay and loading img
box.find(overlay).remove();

settings.onLoadDone.call(box);
}

};

})(jQuery);

/*
* EXPLICIT BOX CONTROLS
* -----------------------
* 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, toggle and remove box.
*
* @type plugin
* @usage $("#box-widget").activateBox();
* @usage $("#box-widget").toggleBox();
* @usage $("#box-widget").removeBox();
*/
(function($) {

'use strict';

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

$.fn.toggleBox = function() {
var button = $($.AdminLTE.boxWidget.selectors.collapse, this);
$.AdminLTE.boxWidget.collapse(button);
};

$.fn.removeBox = function() {
var button = $($.AdminLTE.boxWidget.selectors.remove, this);
$.AdminLTE.boxWidget.remove(button);
};

})(jQuery);

/*
* TODO LIST CUSTOM PLUGIN
* -----------------------
* This plugin depends on iCheck plugin for checkbox and radio inputs
*
* @type plugin
* @usage $("#todo-widget").todolist( options );
*/
(function($) {

'use strict';

$.fn.todolist = function(options) {
// Render options
var settings = $.extend({
//When the user checks the input
onCheck: function(ele) {
return ele;
},
//When the user unchecks the input
onUncheck: function(ele) {
return ele;
}
}, options);

return this.each(function() {

if (typeof $.fn.iCheck != 'undefined') {
$('input', this).on('ifChecked', function() {
var ele = $(this).parents("li").first();
ele.toggleClass("done");
settings.onCheck.call(ele);
});

$('input', this).on('ifUnchecked', function() {
var ele = $(this).parents("li").first();
ele.toggleClass("done");
settings.onUncheck.call(ele);
});
} else {
$('input', this).on('change', function() {
var ele = $(this).parents("li").first();
ele.toggleClass("done");
if ($('input', ele).is(":checked")) {
settings.onCheck.call(ele);
} else {
settings.onUncheck.call(ele);
}
});
}
});
};
}(jQuery));

0 comments on commit b5d8060

Please sign in to comment.