From 8f659c50c675c427e60a103a19fd3415d0cbbd07 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 3 May 2016 11:01:28 +1000 Subject: [PATCH] Fixed table presentations with new bootstrap, added HTML::abbr(), added public access to Database::config(), enabled DB compression to be disabled in database.php --- classes/lnApp/Database.php | 11 +- classes/lnApp/Form.php | 4 +- classes/lnApp/HTML.php | 20 ++++ classes/lnApp/ORM.php | 3 +- classes/lnApp/Table.php | 132 --------------------- media/js/search.js | 4 +- media/theme/baseadmin/css/base-admin-3.css | 21 ---- media/theme/baseadmin/css/custom.css | 30 +++-- views/pagination/basic.php | 54 +++++---- views/pagination/float.php | 54 +++++---- views/table.php | 14 ++- views/theme/baseadmin/page.php | 3 +- views/theme/focusbusiness/page.php | 2 +- 13 files changed, 126 insertions(+), 226 deletions(-) diff --git a/classes/lnApp/Database.php b/classes/lnApp/Database.php index 15f66bf..accf298 100644 --- a/classes/lnApp/Database.php +++ b/classes/lnApp/Database.php @@ -12,7 +12,14 @@ * @license http://dev.leenooks.net/license.html */ abstract class lnApp_Database extends Kohana_Database { - public function caching() { - return $this->_config['caching']; + /** + * Return a database configuration setting + * + * @param string Configuration value to return + * @return string|NULL Value of setting or NULL if it doesnt exist + */ + public function config($key) { + return isset($this->_config[$key]) ? $this->_config[$key] : NULL; } } +?> diff --git a/classes/lnApp/Form.php b/classes/lnApp/Form.php index 791e961..f7035a0 100644 --- a/classes/lnApp/Form.php +++ b/classes/lnApp/Form.php @@ -27,11 +27,11 @@ abstract class lnApp_Form extends Kohana_Form { $output = ''; - $output .= '
'; + $output .= '
'; // Only need col-md for horizonal forms? if (isset($attributes['label'])) { - $output .= Form::label($name,$attributes['label'],array('class'=>'col-md-2 control-label')); + $output .= Form::label($name,$attributes['label'],array('class'=>'control-label')); unset($attributes['label']); } diff --git a/classes/lnApp/HTML.php b/classes/lnApp/HTML.php index 16d6902..6f75e5b 100644 --- a/classes/lnApp/HTML.php +++ b/classes/lnApp/HTML.php @@ -12,6 +12,26 @@ abstract class lnApp_HTML extends Kohana_HTML { public static $windowed_urls = TRUE; + /** + * Limit the number of characters that some text takes up. + * If the Text is smaller than the number of characters to display, then it is + * displayed normally. + * + * @param string Text to re-format + * @param int Number of characters to display + */ + public static function abbr($string,$chars=0) { + if (! $chars OR strlen($string)<=$chars) + return $string; + + return sprintf('%s',$string,Text::limit_chars($string,$chars)); + } + + /** + * If the string is blank, then return &nbsp; + * + * @param string Text to print. + */ public static function nbsp($string) { if (strlen((string)$string)) return $string; diff --git a/classes/lnApp/ORM.php b/classes/lnApp/ORM.php index ba1eeb9..e5c510a 100644 --- a/classes/lnApp/ORM.php +++ b/classes/lnApp/ORM.php @@ -95,10 +95,11 @@ abstract class lnApp_ORM extends Kohana_ORM { /** * Retrieve and Store DB BLOB data in compressed format. + * Compression can be disabled by setting dbcompress in the database config to FALSE */ private function _blob($data,$set=FALSE) { try { - return $set ? gzcompress($this->_serialize($data,$set)) : $this->_serialize(gzuncompress($data)); + return $set ? ($this->_db->config('compress') ? gzcompress($this->_serialize($data,$set)) : $this->_serialize($data,$set)) : $this->_serialize(gzuncompress($data)); // Maybe the data isnt compressed? } catch (Exception $e) { diff --git a/classes/lnApp/Table.php b/classes/lnApp/Table.php index c7149c4..7698aea 100644 --- a/classes/lnApp/Table.php +++ b/classes/lnApp/Table.php @@ -309,138 +309,6 @@ $(document).ready(function() { return $this; } - // @deprecated - public static function display($data,$rows,array $cols,array $option) { - $prepend = $headers = array(); - - foreach ($cols as $k=>$v) { - if (isset($v['label'])) - $headers[$k] = $v['label']; - if (isset($v['url'])) - $prepend[$k] = array('url'=>$v['url']); - } - - return self::factory() - ->data($data) - ->jssort(TRUE) - ->page_items($rows) - ->columns($headers) - ->prepend($prepend); - -/* -// This JS is failing, any pressing of select all, unselect all, toggle is propaging up and submitting the form - - Script::factory() - ->type('stdin') - ->data(' -(function($) { - // Enable Range Selection - $.fn.enableCheckboxRangeSelection = function() { - var lastCheckbox = null; - var followOn = 0; - var $spec = this; - $spec.bind("click", function(e) { - if (lastCheckbox != null && e.shiftKey) { - x = y = 0; - if (followOn != 0) { - if ($spec.index(lastCheckbox) < $spec.index(e.target)) { - x = 1 - ((followOn == 1) ? 1 : 0); - } else { - y = 1 - ((followOn == -1) ? 1 : 0); - } - } - - $spec.slice( - Math.min($spec.index(lastCheckbox) - x, $spec.index(e.target)) + 1, - Math.max($spec.index(lastCheckbox), $spec.index(e.target)) + y - ).attr("checked",function() { return ! this.checked; }) - .parent().parent().toggleClass("selected"); - - followOn = ($spec.index(lastCheckbox) < $spec.index(e.target)) ? 1 : -1; - } else { - followOn = 0; - } - lastCheckbox = e.target; - }); - - return $spec; - }; - - // Enable Toggle, (De)Select All - $.fn.check = function(mode) { - // if mode is undefined, use "on" as default - var mode = mode || "on"; - - switch(mode) { - case "on": - $("#select-table tr:not(.head)") - .filter(":has(:checkbox:not(checked))") - .toggleClass("selected") - break; - case "off": - $("#select-table tr:not(.head)") - .filter(":has(:checkbox:checked)") - .toggleClass("selected") - break; - case "toggle": - $("#select-table tr:not(.head)") - .toggleClass("selected"); - break; - } - - return this.each(function(e) { - switch(mode) { - case "on": - this.checked = true; - break; - case "off": - this.checked = false; - break; - case "toggle": - this.checked = !this.checked; - break; - } - }); - }; -})(jQuery); - -// Bind our actions -$(document).ready(function() { - $("#select-table :checkbox").enableCheckboxRangeSelection(); - $("#select-menu > #toggle").bind("click",function() { - $("#select-table :checkbox").check("toggle"); - }); - $("#select-menu > #all_on").bind("click",function() { - $("#select-table :checkbox").check("on"); - }); - $("#select-menu > #all_off").bind("click",function() { - $("#select-table :checkbox").check("off"); - }); - - // Click to select Row - $("#select-table tr:not(.head)") - .filter(":has(:checkbox:checked)") - .addClass("selected") - .end() - .click(function(e) { - $(this).toggleClass("selected"); - if (e.target.type !== "checkbox") { - $(":checkbox", this).attr("checked", function() { - return !this.checked; - }); - } - }); - - // Double click to select a row - $("#select-table tr:not(.head)") - .dblclick(function(e) { - window.location = $("a", this).attr("href"); - }); -}); - '); -*/ - } - // This enables us to page through many selected items // @todo This is currently not usable, since our JS above needs to be fixed to work with tablesorter public static function page($key) { diff --git a/media/js/search.js b/media/js/search.js index 979890e..35338f6 100644 --- a/media/js/search.js +++ b/media/js/search.js @@ -26,7 +26,7 @@ var search = _.debounce(function(url,query,process){ cache : false, beforeSend : function() { if (c++ == 0) - $('img[name=searching]').css('visibility', 'visible'); + $('i[name=searching]').removeClass("hidden"); }, success : function(data) { // if json is null, means no match, won't do again. @@ -47,7 +47,7 @@ var search = _.debounce(function(url,query,process){ }, complete : function() { if (--c == 0) - $('img[name=searching]').css('visibility', 'hidden'); + $('i[name=searching]').addClass("hidden"); } }) }, 500); diff --git a/media/theme/baseadmin/css/base-admin-3.css b/media/theme/baseadmin/css/base-admin-3.css index 6fc8c39..ef0678f 100644 --- a/media/theme/baseadmin/css/base-admin-3.css +++ b/media/theme/baseadmin/css/base-admin-3.css @@ -1218,27 +1218,6 @@ a.list-group-item.active > .badge, /*------------------------------------------------------------------ [ Pagination / .pagination ] */ -ul.pagination li a { - padding: 0 10px; - margin-right: .25em; - margin-left: .25em; - color: #444; - line-height: 32px; - border-top-right-radius: 5px; - border-top-left-radius: 5px; - border-bottom-right-radius: 5px; - border-bottom-left-radius: 5px; -} -ul.pagination li.active a { - font-weight: 600; - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45); - background-color: #F90; - border-color: #F90; -} -ul.pagination li.active a:hover { - background-color: #F90; - border-color: #F90; -} .pager li { margin-right: .25em; margin-left: .25em; diff --git a/media/theme/baseadmin/css/custom.css b/media/theme/baseadmin/css/custom.css index 407dd84..994f6f2 100644 --- a/media/theme/baseadmin/css/custom.css +++ b/media/theme/baseadmin/css/custom.css @@ -82,18 +82,24 @@ table .text-right { font-weight: normal; color: #000; } +.form-group [class*=" fa-spin"] { + margin-left: -35px; + position: relative; + margin-top: 10px; +} + +.navbar .navbar-form .navbar-search-addon [class*=" fa-spin"] { + padding: 10px 10px; + pointer-events: none; + right: 0px; + margin-top: 0px; + visibility: visible; +} .navbar .navbar-form .navbar-search-addon i { position: absolute; padding: 10px 10px; pointer-events: none; } -.navbar .navbar-form .navbar-search-addon img { - position: absolute; - padding: 6px 10px; - pointer-events: none; - right: 0px; - visibility: hidden; -} .form-group { margin-bottom: 25px; @@ -102,3 +108,13 @@ table .text-right { ul.typeahead.dropdown-menu { min-width: 560px; } + +legend [class^="fa-"], +legend [class*=" fa-"] { + display: inline-block; + margin-top: -3px; + width: 25px; + font-size: 16px; + color: #555; + vertical-align: middle; +} diff --git a/views/pagination/basic.php b/views/pagination/basic.php index 795e1ef..eadefb9 100644 --- a/views/pagination/basic.php +++ b/views/pagination/basic.php @@ -1,26 +1,28 @@ -
-
    -
  • - -
  • - -
  • - -
  • - - total_pages(); $i++): ?> -
  • - -
  • - - -
  • - -
  • - -
  • - -
  • - -
-
+ diff --git a/views/pagination/float.php b/views/pagination/float.php index 328ed14..e4c05dc 100644 --- a/views/pagination/float.php +++ b/views/pagination/float.php @@ -48,29 +48,31 @@ if ($use_n6) for ($i = $n7; $i <= $n8; $i++) $links[$i] = $i; ?> - + diff --git a/views/table.php b/views/table.php index ae1f845..45ae4b2 100644 --- a/views/table.php +++ b/views/table.php @@ -1,11 +1,15 @@ - - - - - + + + + + + + + +
',$th); ?>
',$details['val']); ?>
Other
',$details['val']); ?>
Other
NO records.
diff --git a/views/theme/baseadmin/page.php b/views/theme/baseadmin/page.php index 78ed788..a996858 100644 --- a/views/theme/baseadmin/page.php +++ b/views/theme/baseadmin/page.php @@ -2,7 +2,7 @@ <?php echo Site::Appname(); ?> - + @@ -51,6 +51,7 @@ diff --git a/views/theme/focusbusiness/page.php b/views/theme/focusbusiness/page.php index 204cf25..6542126 100644 --- a/views/theme/focusbusiness/page.php +++ b/views/theme/focusbusiness/page.php @@ -2,7 +2,7 @@ <?php echo Site::Appname(); ?> - +