Minor code clean

This commit is contained in:
Sam Georges 2014-10-18 15:52:44 +11:00
parent 8ee28b214d
commit ed552f1591
5 changed files with 25 additions and 33 deletions

View File

@ -1,13 +0,0 @@
/*
* Filter Behavior
*
* Data attributes:
* - data-behavior="filter" - enables the filter plugin
*
* JavaScript API:
* $('a#someLink').filterBehavior()
*
* Dependences:
* - October Popover (october.popover.js)
*/

View File

@ -9,8 +9,8 @@
// <tr> // <tr>
// <th class="list-checkbox"> // <th class="list-checkbox">
// <div class="checkbox custom-checkbox nolabel"> // <div class="checkbox custom-checkbox nolabel">
// <input type="checkbox" id="checkbox_0" /> // <input type="checkbox" id="checkboxAll" />
// <label for="checkbox_0"></label> // <label for="checkboxAll"></label>
// </div> // </div>
// </th> // </th>
// <th class="sort-desc"><a href="/">Title</a></th> // <th class="sort-desc"><a href="/">Title</a></th>
@ -26,7 +26,8 @@
// <tr> // <tr>
// <td class="list-checkbox nolink"> // <td class="list-checkbox nolink">
// <div class="checkbox custom-checkbox nolabel"> // <div class="checkbox custom-checkbox nolabel">
// <input id="checkbox_1" type="checkbox" /><label for="checkbox_1"></label> // <input id="checkbox_1" type="checkbox" />
// <label for="checkbox_1">Check</label>
// </div> // </div>
// </td> // </td>
// <td><a href="/">Welcome to October</a></td> // <td><a href="/">Welcome to October</a></td>

View File

@ -122,7 +122,7 @@ class Index extends Controller
return [ return [
'tabTitle' => $this->getTabTitle($type, $template), 'tabTitle' => $this->getTabTitle($type, $template),
'tab' => $this->makePartial('form_page', [ 'tab' => $this->makePartial('form_page', [
'form' => $widget, 'form' => $widget,
'templateType' => $type, 'templateType' => $type,
'templateTheme' => $this->theme->getDirName(), 'templateTheme' => $this->theme->getDirName(),

View File

@ -46,7 +46,7 @@ class TemplateList extends WidgetBase
/** /**
* @var string Message to display when there are no records in the list. * @var string Message to display when there are no records in the list.
*/ */
public $noRecordsMessage = 'No records found'; public $noRecordsMessage = 'No records found';
/** /**
* @var string Message to display when the Delete button is clicked. * @var string Message to display when the Delete button is clicked.
@ -216,13 +216,13 @@ class TemplateList extends WidgetBase
} }
$result = [ $result = [
'title' => $this->getItemTitle($item), 'title' => $this->getItemTitle($item),
'fileName' => $item->getFileName(), 'fileName' => $item->getFileName(),
'description' => $description, 'description' => $description,
'descriptions' => $descriptions 'descriptions' => $descriptions
]; ];
return (object)$result; return (object) $result;
} }
protected function getItemTitle($item) protected function getItemTitle($item)
@ -270,16 +270,19 @@ class TemplateList extends WidgetBase
if (strlen($item->title)) { if (strlen($item->title)) {
if (Str::contains(Str::lower($item->title), $word)) if (Str::contains(Str::lower($item->title), $word))
return true; return true;
} else }
if (Str::contains(Str::lower($item->fileName), $word)) else if (Str::contains(Str::lower($item->fileName), $word)) {
return true;
if (Str::contains(Str::lower($item->description), $word) && strlen($item->description))
return true; return true;
}
foreach ($item->descriptions as $value) if (Str::contains(Str::lower($item->description), $word) && strlen($item->description)) {
return true;
}
foreach ($item->descriptions as $value) {
if (Str::contains(Str::lower($value), $word) && strlen($value)) if (Str::contains(Str::lower($value), $word) && strlen($value))
return true; return true;
}
return false; return false;
} }

View File

@ -8,14 +8,15 @@
<?= $this->makePartial('items', ['items'=>$item->items, 'nested'=>true]) ?> <?= $this->makePartial('items', ['items'=>$item->items, 'nested'=>true]) ?>
</li> </li>
<?php endif ?> <?php endif ?>
<?php else: <?php else: ?>
<?php
$dataId = $this->itemType.'-'.$this->theme->getDirName().'-'.$item->fileName; $dataId = $this->itemType.'-'.$this->theme->getDirName().'-'.$item->fileName;
?> ?>
<li class="item" data-item-path="<?= e($item->fileName) ?>" data-item-theme="<?= e($this->theme->getDirName()) ?>" data-item-type="<?= $this->itemType ?>" data-id="<?= e($dataId) ?>"> <li class="item" data-item-path="<?= e($item->fileName) ?>" data-item-theme="<?= e($this->theme->getDirName()) ?>" data-item-type="<?= $this->itemType ?>" data-id="<?= e($dataId) ?>">
<a href="#"> <a href="#">
<span class="title"><?= e($item->title) ?></span> <span class="title"><?= e($item->title) ?></span>
<span class="description"> <span class="description">
<?php foreach ($item->descriptions as $title=>$value): ?> <?php foreach ($item->descriptions as $title => $value): ?>
<?php if (strlen($value)): ?> <?php if (strlen($value)): ?>
<?= e($title) ?>: <strong><?= e($value) ?></strong> <?= e($title) ?>: <strong><?= e($value) ?></strong>
<?php endif ?> <?php endif ?>
@ -29,11 +30,11 @@
<input type="hidden" name="template[<?= e($item->fileName) ?>]" value="0"/> <input type="hidden" name="template[<?= e($item->fileName) ?>]" value="0"/>
<div class="checkbox custom-checkbox nolabel"> <div class="checkbox custom-checkbox nolabel">
<?php $cbId = 'cb'.md5($item->fileName) ?> <?php $cbId = 'cb'.md5($item->fileName) ?>
<input <input
id="<?= $cbId ?>" id="<?= $cbId ?>"
type="checkbox" type="checkbox"
name="template[<?= e($item->fileName) ?>]" name="template[<?= e($item->fileName) ?>]"
<?= $this->isTemplateSelected($item) ? 'checked' : null ?> <?= $this->isTemplateSelected($item) ? 'checked' : null ?>
data-request="<?= $this->getEventHandler('onSelect') ?>" data-request="<?= $this->getEventHandler('onSelect') ?>"
value="1"> value="1">
<label for="<?= $cbId ?>">Select</label> <label for="<?= $cbId ?>">Select</label>