fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [7643] controller: yui tweaks


From: Sigurd Nes
Subject: [Fmsystem-commits] [7643] controller: yui tweaks
Date: Sat, 17 Sep 2011 21:18:16 +0000

Revision: 7643
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7643
Author:   sigurdne
Date:     2011-09-17 21:18:15 +0000 (Sat, 17 Sep 2011)
Log Message:
-----------
controller: yui tweaks

Modified Paths:
--------------
    trunk/controller/inc/class.uicommon.inc.php
    trunk/controller/inc/class.uicontrol_item2.inc.php
    trunk/controller/js/yahoo/controller.item.js
    trunk/controller/js/yahoo/datatable.js
    trunk/controller/templates/base/datatable.xsl
    trunk/demo/templates/base/images/navbar.png

Modified: trunk/controller/inc/class.uicommon.inc.php
===================================================================
--- trunk/controller/inc/class.uicommon.inc.php 2011-09-16 13:48:10 UTC (rev 
7642)
+++ trunk/controller/inc/class.uicommon.inc.php 2011-09-17 21:18:15 UTC (rev 
7643)
@@ -75,7 +75,10 @@
        {
                $keys = func_get_args();
                $strings = array();
-               foreach($keys as $key) { $strings[$key] = is_string($key) ? 
lang($key) : call_user_func_array('lang', $key); }
+               foreach($keys as $key)
+               {
+                       $strings[$key] = is_string($key) ? lang($key) : 
call_user_func_array('lang', $key);
+               }
                return json_encode($strings);
        }
 
@@ -85,7 +88,10 @@
        function lang_array()
        {
                $keys = func_get_args();
-               foreach($keys as &$key) $key = lang($key);
+               foreach($keys as &$key)
+               {
+                       $key = lang($key);
+               }
                return $keys;
        }
 

Modified: trunk/controller/inc/class.uicontrol_item2.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_item2.inc.php  2011-09-16 13:48:10 UTC 
(rev 7642)
+++ trunk/controller/inc/class.uicontrol_item2.inc.php  2011-09-17 21:18:15 UTC 
(rev 7643)
@@ -16,7 +16,9 @@
                public $public_functions = array
                (
                        'index'                                 => true,
-                       'display_control_items' => true
+                       'display_control_items' => true,
+                       'delete'                                => true,
+                       'js_poll'                               => true
                );
 
                public function __construct()
@@ -260,14 +262,13 @@
                                )
                        );
 
-
                        $actions = array
                        (
                                array
                                (
                                        'my_name'               => 'view',
                                        'text'                  => lang('view'),
-                                       'confirm_msg'   => lang('do you really 
want to view this entry'),
+                               //      'confirm_msg'   => lang('do you really 
want to view this entry'),
                                        'action'                => 
$GLOBALS['phpgw']->link('/index.php',array
                                        (
                                                'menuaction'    => 
'controller.uicontrol_item2.index',
@@ -284,6 +285,17 @@
                                                'menuaction'    => 
'controller.uicontrol_item2.index',
                                        )),
                                        'parameters'    => $parameters
+                               ),
+                               array
+                               (
+                                       'my_name'               => 'delete',
+                                       'text'                  => 
lang('delete'),
+                                       'confirm_msg'   => lang('do you really 
want to delete this entry'),
+                                       'action'                => 
$GLOBALS['phpgw']->link('/index.php',array
+                                       (
+                                               'menuaction'    => 
'controller.uicontrol_item2.delete',
+                                       )),
+                                       'parameters'    => $parameters
                                )
                        );
 
@@ -394,11 +406,25 @@
                                }
                        }
                        array_walk($applications["results"], array($this, 
"_add_links"), "controller.uicontrol_item2.index");
-
+//_debug_array($this->yui_results($applications));
                        return $this->yui_results($applications);
                }
                                        
 
+               public function delete()
+               {
+                       return 'deleted';
+               }
+
+               public function js_poll()
+               {
+                       if($poll = phpgw::get_var('poll'))
+                       {
+                               return $poll;
+                       }
+                       return 'hello world';
+               }
+
                public function query()
                {
                        var_dump("Er i uicontrol");

Modified: trunk/controller/js/yahoo/controller.item.js
===================================================================
--- trunk/controller/js/yahoo/controller.item.js        2011-09-16 13:48:10 UTC 
(rev 7642)
+++ trunk/controller/js/yahoo/controller.item.js        2011-09-17 21:18:15 UTC 
(rev 7643)
@@ -2,4 +2,21 @@
  *
  */
 
-alert('dette er respons fra "controller/js/yahoo/controller.item.js"');
+//alert('dette er respons fra "controller/js/yahoo/controller.item.js"');
+
+       this.get_translations = function()
+       {
+               var callback =  {success: function(o){
+                                                       lang = 
JSON.parse(o.responseText);
+       //                                              console.log(lang);
+                                                       alert(lang);
+                                                       },
+                                                       failure: 
function(o){window.alert('Server or your connection is dead.')},
+                                                       timeout: 10000
+                                               };
+               var oArgs = 
{menuaction:'controller.uicontrol_item2.js_poll',poll:''};
+               var strURL = phpGWLink('index.php', oArgs, true);
+               var request = YAHOO.util.Connect.asyncRequest('POST', strURL, 
callback);
+       }
+
+       get_translations();

Modified: trunk/controller/js/yahoo/datatable.js
===================================================================
--- trunk/controller/js/yahoo/datatable.js      2011-09-16 13:48:10 UTC (rev 
7642)
+++ trunk/controller/js/yahoo/datatable.js      2011-09-17 21:18:15 UTC (rev 
7643)
@@ -94,7 +94,7 @@
 
 //------------
                myContextMenu = new YAHOO.widget.ContextMenu("mycontextmenu", 
{trigger:myDataTable.getTbodyEl()});
-               myContextMenu.addItems(GetMenuContext());
+               myContextMenu.addItems(YAHOO.portico.GetMenuContext());
 
                myDataTable.subscribe("rowMouseoverEvent", 
myDataTable.onEventHighlightRow);
                myDataTable.subscribe("rowMouseoutEvent", 
myDataTable.onEventUnhighlightRow);
@@ -110,10 +110,10 @@
                                                                                
           }
           );*/
 
-               myContextMenu.subscribe("beforeShow", onContextMenuBeforeShow);
-               myContextMenu.subscribe("hide", onContextMenuHide);
+               myContextMenu.subscribe("beforeShow", 
YAHOO.portico.onContextMenuBeforeShow);
+               myContextMenu.subscribe("hide", 
YAHOO.portico.onContextMenuHide);
                //Render the ContextMenu instance to the parent container of 
the DataTable
-               myContextMenu.subscribe("click", onContextMenuClick, 
myDataTable);
+               myContextMenu.subscribe("click", 
YAHOO.portico.onContextMenuClick, myDataTable);
                myContextMenu.render(myDataTable);
 //--------------
 
@@ -194,21 +194,19 @@
 
 };
 
-       this.GetMenuContext = function()
+       YAHOO.portico.GetMenuContext = function()
        {
                var opts = new Array();
                var p=0;
                for(var k =0; k < actions.length; k ++)
                {
-                       //if(actions[k].my_name != 'add')
-                       {       opts[p]=[{text: actions[k].text}];
-                               p++;
-                       }
+                       opts[p]=[{text: actions[k].text}];
+                       p++;
                }
                return opts;
    }
 
-       this.onContextMenuBeforeShow = function(p_sType, p_aArgs)
+       YAHOO.portico.onContextMenuBeforeShow = function(p_sType, p_aArgs)
        {
                var prefixSelected = '';
                var oTarget = this.contextEventTarget;
@@ -227,7 +225,7 @@
  
/********************************************************************************
  *
  */
-       this.onContextMenuHide = function(p_sType, p_aArgs)
+       YAHOO.portico.onContextMenuHide = function(p_sType, p_aArgs)
        {
                var prefixSelected = '';
                if (this.getRoot() == this && oSelectedTR)
@@ -238,11 +236,21 @@
                }
        }
  
-       this.onContextMenuClick = function(p_sType, p_aArgs, p_myDataTable)
+       YAHOO.portico.onContextMenuClick = function(p_sType, p_aArgs, 
p_myDataTable)
        {
+               
                var task = p_aArgs[1];
                        if(task)
                        {
+                               if(actions[task.groupIndex].confirm_msg)
+                               {
+                                       confirm_msg = 
actions[task.groupIndex].confirm_msg;
+                                       if(!confirm(confirm_msg))
+                                       {
+                                               return false;
+                                       }                               
+                               }
+
                                // Extract which TR element triggered the 
context menu
                                var elRow = 
p_myDataTable.getTrEl(this.contextEventTarget);
                                if(elRow)
@@ -271,25 +279,21 @@
                                                sUrl = url;
                                        }
                                        //Convert all HTML entities to their 
applicable characters
-                                       sUrl=html_entity_decode(sUrl);
+                                       
sUrl=YAHOO.portico.html_entity_decode(sUrl);
 
                                        // look for the word "DELETE" in URL
-                                       if(substr_count(sUrl,'delete')>0)
+                                       
if(YAHOO.portico.substr_count(sUrl,'delete')>0)
                                        {
-                                               confirm_msg = 
actions[task.groupIndex].confirm_msg;
-                                               if(confirm(confirm_msg))
-                                               {
-                                                       sUrl = sUrl + 
"&confirm=yes&phpgw_return_as=json";
-                                                       delete_record(sUrl);
-                                               }
+                                               sUrl = sUrl + 
"&confirm=yes&phpgw_return_as=json";
+                                               
YAHOO.portico.delete_record(sUrl);
                                        }
                                        else
                                        {
-                                               
if(substr_count(sUrl,'target=_blank')>0)
+                                               
if(YAHOO.portico.substr_count(sUrl,'target=_blank')>0)
                                                {
                                                        
window.open(sUrl,'_blank');
                                                }
-                                               else 
if(substr_count(sUrl,'target=_lightbox')>0)
+                                               else 
if(YAHOO.portico.substr_count(sUrl,'target=_lightbox')>0)
                                                {
                                                        //have to be defined as 
a local function. Example in invoice.list_sub.js
                                                        //console.log(sUrl); // 
firebug
@@ -305,7 +309,7 @@
                        }
        };
 
-       this.html_entity_decode = function(string)
+       YAHOO.portico.html_entity_decode = function(string)
        {
                var histogram = {}, histogram_r = {}, code = 0;
                var entity = chr = '';
@@ -427,5 +431,99 @@
                });
        }
 
+       YAHOO.portico.substr_count = function( haystack, needle, offset, length 
)
+       {
+               var pos = 0, cnt = 0;
 
+               haystack += '';
+               needle += '';
+               if(isNaN(offset)) offset = 0;
+               if(isNaN(length)) length = 0;
+               offset--;
+
+               while( (offset = haystack.indexOf(needle, offset+1)) != -1 )
+               {
+                       if(length > 0 && (offset+needle.length) > length)
+                       {
+                               return false;
+                       } else
+                       {
+                               cnt++;
+                       }
+               }
+               return cnt;
+       }
+ 
/********************************************************************************
+ *
+ */
+       YAHOO.portico.delete_record = function(sUrl)
+       {
+               var callback =  {success: function(o){
+                                                       message_delete = 
o.responseText.toString().replace("\"","").replace("\"","");
+                                                       
//YAHOO.portico.initializeDataTable()
+                                                       
YAHOO.portico.update_datatable()
+                                                       alert(message_delete);
+                                                       },
+                                                       failure: 
function(o){window.alert('Server or your connection is dead.')},
+                                                       timeout: 10000
+                                               };
+               var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, 
callback);
+
+       }
+
+/****************************************************************************************
+*
+*/
+
+
+       //Not working...
+       
+       YAHOO.portico.update_datatable = function()
+       {
+alert('YAHOO.portico.update_datatable');
+               //delete values of datatable
+               myDataTable.getRecordSet().reset();
+
+
+               //reset total records always to zero
+               pag.setTotalRecords(0,true);
+
+               //change PaginatorĊ½s configuration.
+               if(path_values.allrows == 1 )
+               {
+                       pag.set("rowsPerPage",ResultSet.totalResultsAvailable)
+               }
+
+               //obtain records of the last DS and add to datatable
+               var record = values_ds.records;
+               var newTotalRecords = values_ds.totalRecords;
+
+               if(record.length)
+               {
+                       myDataTable.addRows(record);
+               }
+               else
+               {
+                       myDataTable.render();
+               }
+
+               //update paginator with news values
+               pag.setTotalRecords(newTotalRecords,true);
+
+               //update globals variables for pagination
+               myrowsPerPage = values_ds.recordsReturned;
+               mytotalRows = values_ds.totalRecords;
+
+               //update combo box pagination
+               pag.set('rowsPerPageOptions',[myrowsPerPage,mytotalRows]);
+
+               pag.setPage(parseInt(values_ds.currentPage),true); //true no 
fuerza un recarge solo cambia el paginator
+
+               //update "sortedBy" values
+
+               (values_ds.dir == "asc")? dir_ds = 
YAHOO.widget.DataTable.CLASS_ASC : dir_ds = YAHOO.widget.DataTable.CLASS_DESC;
+               myDataTable.set("sortedBy",{key:values_ds.sort,dir:dir_ds});
+       }
+
+
 YAHOO.util.Event.addListener(window, "load", 
YAHOO.portico.initializeDataTable);

Modified: trunk/controller/templates/base/datatable.xsl
===================================================================
--- trunk/controller/templates/base/datatable.xsl       2011-09-16 13:48:10 UTC 
(rev 7642)
+++ trunk/controller/templates/base/datatable.xsl       2011-09-17 21:18:15 UTC 
(rev 7643)
@@ -240,6 +240,9 @@
                        <xsl:when test="//actions != ''">
                                var actions = <xsl:value-of select="//actions" 
disable-output-escaping="yes" />;
                        </xsl:when>
+                       <xsl:otherwise>
+                               var actions = new Array();
+                       </xsl:otherwise>        
                </xsl:choose>
 
        </script>

Modified: trunk/demo/templates/base/images/navbar.png
===================================================================
(Binary files differ)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]