1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-20 04:32:01 +02:00

Default loading icon added to form->button() method when font-awesome is present.

This commit is contained in:
Cameron 2016-04-10 17:52:30 -07:00
parent 12a6367fdf
commit 8ff02d9aa9
4 changed files with 133 additions and 102 deletions

View File

@ -425,7 +425,105 @@ TEMPL;
",'jquery');
e107::js('url',"http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js");
e107::js('url', "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/base/jquery-ui.css");
e107::js('footer-inline','
$(function()
{
// post the form back to this script.
var saveData = function(areaid)
{
var formid = "#form-" + areaid;
var form = $(formid);
var data = form.serialize();
$.ajax({
type: "POST",
url: "menus.php",
data: data
}).done(function( msg )
{
$(".menuOption").show();
// alert("POSTED: "+ msg );
});
}
$(".sortable").sortable({
connectWith: $("#area-1,#area-2,#area-3,#area-4,#area-5"),
revert: true,
cursor: "move",
distance: 20,
// containment: $(".sortable"),
update: function(ev,ui)
{
var areaid = $(this).attr("id");
saveData(areaid);
}
});
/*
$( ".draggable", window.top.document).click(function()
{
alert("hi there");
});*/
// http://jsfiddle.net/DT764/2/
/*
$(".draggable", window.top.document).draggable({
// connectToSortable: ".sortable",
helper: "clone",
// appendTo: $(this), // ".sortable", // "#area-1", //FIXME Needs to be a specific area.
// revert: "invalid",
containment: "parent",
// delay: 0,
// revertDuration: 100,
cursor: "move",
iframeFix: true,
// containment: false,
stop: function(e, ui) { //TODO Rename layout and area in the hidden fields to that of the where the menu was dropped.
// Figure out positioning magic to determine if e.ui.position is in the iframe
// var what = $(this).parent().attr("id");
// $(".sortable").draggable( "disable" );
alert(what);
}
});*/
// $( "ul, li", window.top.document ).disableSelection();
$( ".deleteMenu").on("click", function()
{
var deleteId = $(this).attr("data-delete");
var area = $(this).attr("data-area");
$("#"+deleteId).hide("slow", function(){
$("#"+deleteId).remove();
});
// $("#"+deleteId).remove();
// alert(deleteId + " " + area);
saveData(area);
});
});
');
}
@ -460,6 +558,9 @@ else
");
@ -652,105 +753,7 @@ class e_layout
require_once(e_CORE."templates/admin_icons_template.php");
e107::js('url',"http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js");
e107::js('url', "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/base/jquery-ui.css");
e107::js('inline','
$(function()
{
// post the form back to this script.
var saveData = function(areaid)
{
var formid = "#form-" + areaid;
var form = $(formid);
var data = form.serialize();
$.ajax({
type: "POST",
url: "menus.php",
data: data
}).done(function( msg )
{
$(".menuOption").show();
// alert("POSTED: "+ msg );
});
}
$(".sortable").sortable({
connectWith: $("#area-1,#area-2,#area-3,#area-4,#area-5"),
revert: true,
cursor: "move",
distance: 20,
// containment: $(".sortable"),
update: function(ev,ui)
{
var areaid = $(this).attr("id");
saveData(areaid);
}
});
// $( ".draggable", window.top.document).click(function()
// {
// alert("hi there");
// });
// http://jsfiddle.net/DT764/2/
$( ".draggable", window.top.document).draggable({
connectToSortable: ".sortable",
helper: "clone",
appendTo: $(this), // ".sortable", // "#area-1", //FIXME Needs to be a specific area.
revert: "invalid",
containment: "parent",
delay: 0,
revertDuration: 100,
cursor: "move",
iframeFix: true,
containment: false,
stop: function(e, ui) { //TODO Rename layout and area in the hidden fields to that of the where the menu was dropped.
// Figure out positioning magic to determine if e.ui.position is in the iframe
// var what = $(this).parent().attr("id");
// $(".sortable").draggable( "disable" );
// alert(what);
}
});
// $( "ul, li", window.top.document ).disableSelection();
$( ".deleteMenu").on("click", function()
{
var deleteId = $(this).attr("data-delete");
var area = $(this).attr("data-area");
$("#"+deleteId).hide("slow", function(){
$("#"+deleteId).remove();
});
// $("#"+deleteId).remove();
// alert(deleteId + " " + area);
saveData(area);
});
});
');
/*

View File

@ -2511,9 +2511,12 @@ class e_form
$options['class'] .= 'btn-default';
break;
}
$include = (deftrue("FONTAWESOME")) ? "data-loading-icon='fa-spinner' data-disable='true'" : "";
return "
<button type='{$btype}' name='{$name}' value='{$value}'".$this->get_attributes($options, $name)."><span>{$label}</span></button>
<button ".$include." type='{$btype}' name='{$name}' value='{$value}'".$this->get_attributes($options, $name)."><span>{$label}</span></button>
";
}

View File

@ -14,8 +14,9 @@
/**
* Helper function to load prettyPhoto library's settings and files.
*/
function gallery_load_prettyphoto()
function gallery_load_prettyphoto() // @lonalore FIXME Stop loading this on every page.
{
// Re-use the statically cached value to save memory. Load settings and files only once!!!
static $gallery_load_prettyphoto;

View File

@ -741,7 +741,31 @@ $(document).ready(function()
return false;
});
$('button[type=submit]').on('click', function()
{
var caption = $(this).text();
var type = $(this).attr('data-loading-icon');
if(type === undefined)
{
return true;
}
caption = "<i class='fa fa-spin " + type + " fa-fw'></i><span>" + caption + "</span>";
$(this).html(caption);
if($(this).attr('data-disable') == 'true')
{
$(this).addClass('disabled');
}
return true;
}
);
// Dates --------------------------------------------------