diff --git a/config.php b/config.php index da462d5..69280db 100644 --- a/config.php +++ b/config.php @@ -120,6 +120,10 @@ $config = array( ), // }}} + 'site' => array( + 'name' => 'LeaderBin', + 'domain' => 'leaderbin.com', + ), ); ?> diff --git a/public/css/core.css b/public/css/core.css index ae9d7f5..58e582a 100644 --- a/public/css/core.css +++ b/public/css/core.css @@ -1,3 +1,6 @@ body { padding-top: 50px; } +footer { + padding-top: 50px; +} diff --git a/public/css/core.less b/public/css/core.less index d3b19ec..089ec8a 100644 --- a/public/css/core.less +++ b/public/css/core.less @@ -2,3 +2,8 @@ body, { padding-top: 50px; } + +footer, +{ + padding-top: 50px; +} diff --git a/public/css/core.min.css b/public/css/core.min.css index 3af6fdc..9211205 100644 --- a/public/css/core.min.css +++ b/public/css/core.min.css @@ -1 +1 @@ -body{padding-top:50px} \ No newline at end of file +body{padding-top:50px}footer{padding-top:50px} \ No newline at end of file diff --git a/public/js/jerky.js b/public/js/jerky.js new file mode 100755 index 0000000..74d2a4a --- /dev/null +++ b/public/js/jerky.js @@ -0,0 +1,301 @@ +$(function() +{ + // Apply the validator if available + if (jQuery().validate) + { + $('form').validate(); + + /* + TODO, Implement Geoff's fix for the double form issue + Gonna research it a bit more, I'm still perplexed why this wouldn't fire for each selector already + var f = $('form'); + if(f.length > 0){ + $(f).each(function(i, form){ + $(form).validate(); + }); + } + */ + } + + // Catches forms being submitted + $('.ajax [type=submit]').on('click', function() + { + if ($(this).attr('readonly') == 'readonly') + { + return; + } + + // Grabs the form + var form = $(this).parents('form').get(); + + // Removes any messages + $('.alert[generated], label.error', form).remove(); + + // Checks that it's valid + if (typeof $(form).valid == 'undefined' || $(form).valid() == true) + { + if (typeof $(form).data('readonly') == undefined || $(form).data('readonly') != false) + { + // Sets the buttons, inputs and textareas to READONLY + $('button, input, textarea', form).attr('readonly', 'readonly'); + + // Forces the cursor to be waiting + document.body.style.cursor = 'wait'; + + // Swaps the button for a progress meter + $(this).hide(); + $(this).after(''); + } + + var method = $(form).attr('method') == '' ? 'GET' : $(form).attr('method'); + var action = $(form).attr('action'); + + if (action == '') + { + injectMessage(form, 'Form element lacks action attribute', 'error'); + + // Removes READONLY status + $('button, input, textarea', form).removeAttr('readonly'); + + // Returns the cursor to normal... but is anyone really normal? + document.body.style.cursor = 'default'; + + // Brings the button back + $('progress', form).remove(); + $('[type="submit"]', form).show(); + } + else + { + var payload = $(form).serialize(); + var cleared = (typeof $(form).data('readonly') != undefined && $(form).data('readonly') == false); + + if (cleared) + { + if (typeof $(form).data('preprocessor') != undefined) + { + window[$(form).data('preprocessor')](); + } + + $('input[type=text]', form).val(''); + $('select', form).val(''); + $('textarea', form).val(''); + + if (typeof $(form).data('focus') != undefined) + { + $($(form).data('focus')).focus(); + } + } + + $.ajax({ + 'type': method, + 'url': action, + 'data': payload, + 'dataType': 'json', + + 'success': function(data, textStatus, XMLHttpRequest) + { + if (typeof data.success != 'undefined') + { + data.status = 'success'; + data.message = data.success; + } + else if (typeof data.error != 'undefined') + { + data.status = 'error'; + data.message = data.error; + } + + if (data.status != 'success' && typeof data.message != 'undefined') + { + injectMessage(form, data.message, 'error'); + } + else if (data.status == 'success') + { + if ((typeof data.retain == 'undefined' || data.retain == false) && !cleared) + { + $('input[type=text]', form).val(''); + $('input[type=email]', form).val(''); + $('select', form).val(''); + $('textarea', form).val(''); + } + + if (typeof data.message != 'undefined') + { + injectMessage(form, data.message, 'success'); + } + + if (typeof data.url != 'undefined') + { + parent.location.href = data.url; + } + } + else + { + // Only really serves a purpose when debugging + //injectMessage(form, data, 'error'); + } + + if (typeof data.callback != 'undefined') + { + window[data.callback](data); + } + + // Removes READONLY status + $('button, input, textarea', form).removeAttr('readonly'); + + // Returns the cursor to normal... but is anyone really normal? + document.body.style.cursor = 'default'; + + // Brings the button back + $('progress', form).remove(); + $('[type="submit"]', form).show(); + }, + + 'error': function(XMLHttpRequest, textStatus, errorThrown) + { + injectMessage(form, errorThrown, 'error'); + + // Removes READONLY status + $('button, input, textarea', form).removeAttr('readonly'); + + // Returns the cursor to normal... but is anyone really normal? + document.body.style.cursor = 'default'; + + // Brings the button back + $('progress', form).remove(); + $('[type="submit"]', form).show(); + } + }); + } + } + else + { + return false; + } + }); + + // Forces forms to return false on submit + $('form.ajax').submit(function(){ return false; }); + + // Automatically applies zebra stripes to tables + $('table tr:even td').addClass('even'); + $('table tr:odd td').addClass('odd'); +}); + +// Injects a div before the passed element +function injectMessage(element, message, type, duration) +{ + if (typeof type == 'undefined') + { + var type = 'error'; + } + + var id = 'alert-' + Date.now(); + var class_name = 'alert ' + type; + var label = ''; + + $('.alert[generated]', element).remove(); + + if ($(element).hasClass('box') || $(element).parent('.two-column')) + { + $('[type="submit"]', element).before(label); + } + else + { + $(element).prepend(label); + } + + id = '#' + id; + + if (typeof duration != 'undefined') + { + $(id, element).delay(duration).remove(); + } + + return $(id, element); +} + +// Automatically tab to next element when max length is reached +function autoTab(element) +{ + if ($(element).val().length >= $(element).attr('maxlength')) + { + $(element).next().focus(); + } +} + +// Disable Enter Key +function disableEnterKey(e) +{ + var key; + + if(window.event) + { + key = window.event.keyCode; // IE + } + else + { + key = e.which; // Firefox + } + + return (key != 13); +} + +// Truncate a string and optionally create a roll over +function truncate(string, length, hover) +{ + if (string.length > length) + { + if (hover == true) + { + string = '' + string.substring(0, length) + '...'; + } + else + { + string = string.substring(0, length) + '...'; + } + } + + return string; +} + +function getQueryStringVariable(variable) +{ + variable = variable.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); + var regexS = "[\\?&]" + variable + "=([^&#]*)"; + var regex = new RegExp(regexS); + var results = regex.exec(window.location.search); + + if (results === null) + { + return null; + } + else + { + return decodeURIComponent(results[1].replace(/\+/g, " ")); + } +} + +function getGUID() +{ + var guid; + var unique = false; + + while (unique == false) + { + guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) + { + var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8); + return v.toString(16); + }); + + guid = 'guid-' + guid; + + if ($('#' + guid).length == 0) + { + unique = true; + } + } + + return guid; +} diff --git a/public/js/jerky.min.js b/public/js/jerky.min.js new file mode 100644 index 0000000..f043716 --- /dev/null +++ b/public/js/jerky.min.js @@ -0,0 +1,8 @@ +$(function(){jQuery().validate&&$("form").validate();$(".ajax [type=submit]").on("click",function(){if("readonly"!=$(this).attr("readonly")){var a=$(this).parents("form").get();$(".alert[generated], label.error",a).remove();if("undefined"==typeof $(a).valid||!0==$(a).valid()){if(void 0==typeof $(a).data("readonly")||!1!=$(a).data("readonly"))$("button, input, textarea",a).attr("readonly","readonly"),document.body.style.cursor="wait",$(this).hide(),$(this).after("");var c=""== +$(a).attr("method")?"GET":$(a).attr("method"),d=$(a).attr("action");if(""==d)injectMessage(a,"Form element lacks action attribute","error"),$("button, input, textarea",a).removeAttr("readonly"),document.body.style.cursor="default",$("progress",a).remove(),$('[type="submit"]',a).show();else{var f=$(a).serialize(),e=void 0!=typeof $(a).data("readonly")&&!1==$(a).data("readonly");if(e){if(void 0!=typeof $(a).data("preprocessor"))window[$(a).data("preprocessor")]();$("input[type=text]",a).val("");$("select", +a).val("");$("textarea",a).val("");void 0!=typeof $(a).data("focus")&&$($(a).data("focus")).focus()}$.ajax({type:c,url:d,data:f,dataType:"json",success:function(b){"undefined"!=typeof b.success?(b.status="success",b.message=b.success):"undefined"!=typeof b.error&&(b.status="error",b.message=b.error);if("success"!=b.status&&"undefined"!=typeof b.message)injectMessage(a,b.message,"error");else if("success"==b.status){if(("undefined"==typeof b.retain||!1==b.retain)&&!e)$("input[type=text]",a).val(""), +$("input[type=email]",a).val(""),$("select",a).val(""),$("textarea",a).val("");"undefined"!=typeof b.message&&injectMessage(a,b.message,"success");"undefined"!=typeof b.url&&(parent.location.href=b.url)}if("undefined"!=typeof b.callback)window[b.callback](b);$("button, input, textarea",a).removeAttr("readonly");document.body.style.cursor="default";$("progress",a).remove();$('[type="submit"]',a).show()},error:function(b,c,d){injectMessage(a,d,"error");$("button, input, textarea",a).removeAttr("readonly"); +document.body.style.cursor="default";$("progress",a).remove();$('[type="submit"]',a).show()}})}}else return!1}});$("form.ajax").submit(function(){return!1});$("table tr:even td").addClass("even");$("table tr:odd td").addClass("odd")}); +function injectMessage(a,c,d,f){"undefined"==typeof d&&(d="error");var e="alert-"+Date.now();c='";$(".alert[generated]",a).remove();$(a).hasClass("box")||$(a).parent(".two-column")?$('[type="submit"]',a).before(c):$(a).prepend(c);e="#"+e;"undefined"!=typeof f&&$(e,a).delay(f).remove();return $(e,a)}function autoTab(a){$(a).val().length>=$(a).attr("maxlength")&&$(a).next().focus()} +function disableEnterKey(a){return 13!=(window.event?window.event.keyCode:a.which)}function truncate(a,c,d){a.length>c&&(a=!0==d?''+a.substring(0,c)+"...":a.substring(0,c)+"...");return a}function getQueryStringVariable(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");a=RegExp("[\\?&]"+a+"=([^&#]*)").exec(window.location.search);return null===a?null:decodeURIComponent(a[1].replace(/\+/g," "))} +function getGUID(){for(var a,c=!1;!1==c;)a="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var c=16*Math.random()|0;return("x"===a?c:c&3|8).toString(16)}),a="guid-"+a,0==$("#"+a).length&&(c=!0);return a}; diff --git a/templates/__shared/index.phtml b/templates/__shared/index.phtml index fdbbacd..96bdc65 100644 --- a/templates/__shared/index.phtml +++ b/templates/__shared/index.phtml @@ -4,9 +4,9 @@ - LeaderBin + <?php echo $this->config->site['name']; ?> - +