From 8ff02d9aa97295bd19ab21c08001b23e3302d175 Mon Sep 17 00:00:00 2001 From: Cameron <e107inc@gmail.com> Date: Sun, 10 Apr 2016 17:52:30 -0700 Subject: [PATCH] Default loading icon added to form->button() method when font-awesome is present. --- e107_admin/menus.php | 201 +++++++++--------- e107_handlers/form_handler.php | 5 +- .../gallery/includes/gallery_load.php | 3 +- e107_web/js/core/all.jquery.js | 26 ++- 4 files changed, 133 insertions(+), 102 deletions(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index d634ae98a..d92e0b60b 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -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); - }); - - - - - }); - '); - /* diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 9bbed591f..fea12f412 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -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> "; } diff --git a/e107_plugins/gallery/includes/gallery_load.php b/e107_plugins/gallery/includes/gallery_load.php index 615c1d388..9523ee241 100644 --- a/e107_plugins/gallery/includes/gallery_load.php +++ b/e107_plugins/gallery/includes/gallery_load.php @@ -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; diff --git a/e107_web/js/core/all.jquery.js b/e107_web/js/core/all.jquery.js index 023387c26..a0ebaa8b6 100644 --- a/e107_web/js/core/all.jquery.js +++ b/e107_web/js/core/all.jquery.js @@ -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 --------------------------------------------------