[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [14847] custom savestate
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [14847] custom savestate |
Date: |
Wed, 16 Mar 2016 20:38:45 +0000 |
Revision: 14847
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14847
Author: sigurdne
Date: 2016-03-16 20:38:45 +0000 (Wed, 16 Mar 2016)
Log Message:
-----------
custom savestate
Modified Paths:
--------------
trunk/phpgwapi/js/jquery/common.js
trunk/phpgwapi/templates/base/datatable_jquery.xsl
Modified: trunk/phpgwapi/js/jquery/common.js
===================================================================
--- trunk/phpgwapi/js/jquery/common.js 2016-03-16 14:11:21 UTC (rev 14846)
+++ trunk/phpgwapi/js/jquery/common.js 2016-03-16 20:38:45 UTC (rev 14847)
@@ -12,6 +12,32 @@
JqueryPortico.inlineTablesDefined = 0;
JqueryPortico.inlineTablesRendered = 0;
+JqueryPortico.parseURL = function(url)
+{
+ var parser = document.createElement('a'),
+ searchObject = {},
+ queries, split, i;
+ // Let the browser do the work
+ parser.href = url;
+ // Convert query string to object
+ queries = parser.search.replace(/^\?/, '').split('&');
+ for (i = 0; i < queries.length; i++)
+ {
+ split = queries[i].split('=');
+ searchObject[split[0]] = split[1];
+ }
+ return {
+ protocol: parser.protocol,
+ host: parser.host,
+ hostname: parser.hostname,
+ port: parser.port,
+ pathname: parser.pathname,
+ search: parser.search,
+ searchObject: searchObject,
+ hash: parser.hash
+ };
+}
+
JqueryPortico.formatLink = function (key, oData)
{
Modified: trunk/phpgwapi/templates/base/datatable_jquery.xsl
===================================================================
--- trunk/phpgwapi/templates/base/datatable_jquery.xsl 2016-03-16 14:11:21 UTC
(rev 14846)
+++ trunk/phpgwapi/templates/base/datatable_jquery.xsl 2016-03-16 20:38:45 UTC
(rev 14847)
@@ -94,7 +94,7 @@
<xsl:value-of select="php:function('lang', 'toolbar')"/>
</label>
- <div id="toolbar">
+ <div id="toolbar" class='dtable_custom_controls'>
<!--xsl:if test="item/text and normalize-space(item/text)"-->
<xsl:if test="item">
<table id="toolbar_table" class="pure-table
pure-table-horizontal">
@@ -903,6 +903,17 @@
}
$(document).ready(function() {
+
+ /*
+ * For namespacing the state
+ */
+ var table_url =
JqueryPortico.parseURL(window.location.href);
+ var menuaction =
table_url.searchObject.menuaction.replace(/\./g, '_');
+ /*
+ * Find and assign actions to filters
+ */
+ var oControls =
$('.dtable_custom_controls:first').find(':input[name]');
+
oTable = $('#datatable-container').dataTable({
paginate: disablePagination ?
false : true,
processing: true,
@@ -927,6 +938,51 @@
},
type: 'POST'
},
+ fnStateSaveParams: function ( oSettings,
sValue ) {
+ //Save custom filters
+ var temp = {};
+ temp[menuaction] = {}
+ oControls.each(function() {
+ if ( $(this).attr('name') )
+ {
+ sValue[
$(this).attr('name') ] = $(this).val().replace('"', '"');
+ temp[
$(this).attr('name') ] = $(this).val().replace('"', '"');
+ }
+ });
+ for (var attrname in sValue)
+ {
+ temp[attrname] =
sValue[attrname];
+ }
+ localStorage.setItem('state_' +
menuaction, JSON.stringify(temp));
+ return sValue;
+ },
+ fnStateLoadParams: function ( oSettings, oData
) {
+ //Load custom filters
+ var retrievedObject =
localStorage.getItem('state_' + menuaction);
+ if(typeof(retrievedObject) !=
'undefined')
+ {
+ try
+ {
+ var params =
JSON.parse(retrievedObject);
+ }
+ catch(err)
+ {
+ params = {}
+ }
+ }
+ console.log(oData);
+ console.log(params);
+ oControls.each(function() {
+ var oControl = $(this);
+ $.each(params, function(index,
value) {
+ if ( index ==
oControl.attr('name') )
+ {
+ oControl.val(
value );
+ }
+ });
+ });
+ return true;
+ },
fnServerParams: function ( aoData ) {
if(typeof(aoData.order[0]) !=
'undefined')
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [14847] custom savestate,
Sigurd Nes <=