Skip to content

Commit

Permalink
Add localstorage option (#4928) Port K50
Browse files Browse the repository at this point in the history
  • Loading branch information
810 committed Nov 18, 2016
1 parent 04edf37 commit 0716364
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 50 deletions.
Expand Up @@ -426,6 +426,8 @@ COM_KUNENA_EDITOR_COLOR_WHITE = "White"
COM_KUNENA_EDITOR_COLOR_GRAY = "Gray"
COM_KUNENA_TEMPLATE_LOAD_TOOLTIPS="Load Tooltips"
COM_KUNENA_TEMPLATE_LOAD_TOOLTIPS_DESC="Set <em><strong>Yes</strong></em> to load the Jquery tooltips"
COM_KUNENA_TEMPLATE_LOCALSTORAGE="Load Localstorage"
COM_KUNENA_TEMPLATE_LOCALSTORAGE_DESC="Remember the collapse state of the windows. Like announcements"

; Automatically generated strings for COM_KUNENA_MYPROFILE_*

Expand Down
@@ -0,0 +1,18 @@
jQuery(document).ready(function($) {
/* To hide or open collapse localStorage */
$('.collapse').on('hidden', function () {
if (this.id) {
if (this.id != 'search') {
localStorage[this.id] = 'true';
}
}
}).on('shown', function () {
if (this.id) {
localStorage.removeItem(this.id);
}
}).each(function () {
if (this.id && localStorage[this.id] === 'true') {
$(this).collapse('hide');
}
});
});
19 changes: 1 addition & 18 deletions src/components/com_kunena/template/crypsis/assets/js/main.js
Expand Up @@ -15,24 +15,7 @@ function kunenatableOrdering(order, dir, task, form) {
form.submit(task);
}

jQuery(document).ready(function ($) {
/* To hide or open collapse localStorage */
$('.collapse').on('hidden', function () {
if (this.id) {
if (this.id != 'search') {
localStorage[this.id] = 'true';
}
}
}).on('shown', function () {
if (this.id) {
localStorage.removeItem(this.id);
}
}).each(function () {
if (this.id && localStorage[this.id] === 'true') {
$(this).collapse('hide');
}
});

jQuery(document).ready(function($) {
/* To check or uncheck boxes to select items */
$('input.kcheckall').click(function () {
$('.kcheck').prop('checked', $(this).prop("checked"));
Expand Down
12 changes: 8 additions & 4 deletions src/components/com_kunena/template/crypsis/config/config.xml
Expand Up @@ -127,16 +127,20 @@
<option value="minima">COM_KUNENA_MINIMA</option>
<option value="plain">COM_KUNENA_PLAIN</option>
</field>
<field name="optional_username" type="list" default="0" label="COM_KUNENA_TEMPLATE_DISPLAY_OPTIONAL_USERNAME"
description="COM_KUNENA_TEMPLATE_DISPLAY_OPTIONAL_USERNAME_DESC">
<option value="0">COM_KUNENA_NO</option>
<option value="1">COM_KUNENA_USERNAME</option>
<option value="2">COM_KUNENA_REALNAME</option>
</field>
<field name="writeaccess" type="list" default="0" label="COM_KUNENA_TEMPLATE_DISPLAY_WRITEACCESS"
description="COM_KUNENA_TEMPLATE_DISPLAY_WRITEACCESS_DESC">
<option value="0">COM_KUNENA_NO</option>
<option value="1">COM_KUNENA_YES</option>
</field>
<field name="optional_username" type="list" default="0" label="COM_KUNENA_TEMPLATE_DISPLAY_OPTIONAL_USERNAME"
description="COM_KUNENA_TEMPLATE_DISPLAY_OPTIONAL_USERNAME_DESC">
<field name="localstorage" type="list" default="0" label="COM_KUNENA_TEMPLATE_LOCALSTORAGE" description="COM_KUNENA_TEMPLATE_LOCALSTORAGE_DESC">
<option value="0">COM_KUNENA_NO</option>
<option value="1">COM_KUNENA_USERNAME</option>
<option value="2">COM_KUNENA_REALNAME</option>
<option value="1">COM_KUNENA_YES</option>
</field>
</fieldset>

Expand Down
13 changes: 10 additions & 3 deletions src/components/com_kunena/template/crypsis/template.php
Expand Up @@ -48,6 +48,14 @@ public function initialize()
// Load JavaScript.
$this->addScript('assets/js/main.js');

$this->ktemplate = KunenaFactory::getTemplate();
$storage = $this->ktemplate->params->get('storage');

if ($storage)
{
$this->addScript('assets/js/localstorage.js');
}

// Compile CSS from LESS files.
$this->compileLess('assets/less/crypsis.less', 'kunena.css');
$this->addStyleSheet('kunena.css');
Expand All @@ -67,9 +75,8 @@ public function initialize()
$this->addStyleSheet('assets/css/custom.css');
}

$this->ktemplate = KunenaFactory::getTemplate();
$bootstrap = $this->ktemplate->params->get('bootstrap');
$doc = JFactory::getDocument();
$bootstrap = $this->ktemplate->params->get('bootstrap');
$doc = JFactory::getDocument();

if ($bootstrap)
{
Expand Down
@@ -0,0 +1,18 @@
jQuery(document).ready(function($) {
/* To hide or open collapse localStorage */
$('.collapse').on('hidden', function () {
if (this.id) {
if (this.id != 'search') {
localStorage[this.id] = 'true';
}
}
}).on('shown', function () {
if (this.id) {
localStorage.removeItem(this.id);
}
}).each(function () {
if (this.id && localStorage[this.id] === 'true') {
$(this).collapse('hide');
}
});
});
19 changes: 1 addition & 18 deletions src/components/com_kunena/template/crypsisb3/assets/js/main.js
Expand Up @@ -15,24 +15,7 @@ function kunenatableOrdering(order, dir, task, form) {
form.submit(task);
}

jQuery(document).ready(function ($) {
/* To hide or open collapse localStorage */
$('.collapse').on('hidden', function () {
if (this.id) {
if (this.id != 'search') {
localStorage[this.id] = 'true';
}
}
}).on('shown', function () {
if (this.id) {
localStorage.removeItem(this.id);
}
}).each(function () {
if (this.id && localStorage[this.id] === 'true') {
$(this).collapse('hide');
}
});

jQuery(document).ready(function($) {
/* To check or uncheck boxes to select items */
$('input.kcheckall').click(function () {
$('.kcheck').prop('checked', $(this).prop("checked"));
Expand Down
12 changes: 8 additions & 4 deletions src/components/com_kunena/template/crypsisb3/config/config.xml
Expand Up @@ -122,16 +122,20 @@
<option value="minima">COM_KUNENA_MINIMA</option>
<option value="plain">COM_KUNENA_PLAIN</option>
</field>
<field name="optional_username" type="list" default="0" label="COM_KUNENA_TEMPLATE_DISPLAY_OPTIONAL_USERNAME"
description="COM_KUNENA_TEMPLATE_DISPLAY_OPTIONAL_USERNAME_DESC">
<option value="0">COM_KUNENA_NO</option>
<option value="1">COM_KUNENA_USERNAME</option>
<option value="2">COM_KUNENA_REALNAME</option>
</field>
<field name="writeaccess" type="list" default="0" label="COM_KUNENA_TEMPLATE_DISPLAY_WRITEACCESS"
description="COM_KUNENA_TEMPLATE_DISPLAY_WRITEACCESS_DESC">
<option value="0">COM_KUNENA_NO</option>
<option value="1">COM_KUNENA_YES</option>
</field>
<field name="optional_username" type="list" default="0" label="COM_KUNENA_TEMPLATE_DISPLAY_OPTIONAL_USERNAME"
description="COM_KUNENA_TEMPLATE_DISPLAY_OPTIONAL_USERNAME_DESC">
<field name="localstorage" type="list" default="0" label="COM_KUNENA_TEMPLATE_LOCALSTORAGE" description="COM_KUNENA_TEMPLATE_LOCALSTORAGE_DESC">
<option value="0">COM_KUNENA_NO</option>
<option value="1">COM_KUNENA_USERNAME</option>
<option value="2">COM_KUNENA_REALNAME</option>
<option value="1">COM_KUNENA_YES</option>
</field>
</fieldset>

Expand Down
13 changes: 10 additions & 3 deletions src/components/com_kunena/template/crypsisb3/template.php
Expand Up @@ -102,6 +102,14 @@ public function initialize()
$this->compileLess('assets/less/crypsisb3.less', 'kunena.css');
$this->addStyleSheet('kunena.css');

$this->ktemplate = KunenaFactory::getTemplate();
$storage = $this->ktemplate->params->get('storage');

if ($storage)
{
$this->addScript('assets/js/localstorage.js');
}

$filenameless = JPATH_SITE . '/components/com_kunena/template/crypsisb3/assets/less/custom.less';

if (file_exists($filenameless) && 0 != filesize($filenameless))
Expand All @@ -117,9 +125,8 @@ public function initialize()
$this->addStyleSheet('assets/css/custom.css');
}

$this->ktemplate = KunenaFactory::getTemplate();
$fontawesome = $this->ktemplate->params->get('fontawesome');
$doc = JFactory::getDocument();
$fontawesome = $this->ktemplate->params->get('fontawesome');
$doc = JFactory::getDocument();

if ($fontawesome)
{
Expand Down

0 comments on commit 0716364

Please sign in to comment.