public function render()
    {
        $this->style();
        parent::render();
        $this->onReadyHook();
        ?>
        <div id="qdmvcRootDiv" style="display: none; width: inherit; height: inherit">
            <style>
                #wpbody-content {
                    overflow-y: hidden !important;
                }
            </style>
            <script>
                MYAPP = {};
                MYAPP.openInNewTab = function (url) {
                    if (window == window.parent) {
                        window.open(url, '_blank');
                        return;
                    }
                    window.parent.MYAPP.openInNewTab(url);
                };
                MYAPP.TreeUnflatten = function( array, parent, tree ){

                    tree = typeof tree !== 'undefined' ? tree : [];
                    parent = typeof parent !== 'undefined' ? parent : { key: -1 };

                    var children = _.filter( array, function(child){ return child.parentid == parent.key; });

                    if( !_.isEmpty( children )  ){
                        if( parent.key == -1 ){
                            tree = children;
                        }else{
                            parent['children'] = children
                        }
                        _.each( children, function( child ){ MYAPP.TreeUnflatten( array, child ) } );
                    }

                    return tree;
                };

                (function ($) {
                    $(document).ready(function () {
                        //height = $(window).height()-3;

                        $("#splitter").jqxSplitter({width: '100%', height: '100%', panels: [{size: 230}]});
                        $("#splitter2").jqxSplitter({orientation: 'horizontal', width: '100%', height: '100%', panels: [{size: '90%'}]});

                        // Create jqxTree
                        Array.prototype.insert = function (index, item) {
                            this.splice(index, 0, item);
                        };

                        var data = <?php 
        echo Qdmvc_Page_Index::buildJSONTree($this->data['language']);
        ?>
;
                        data = MYAPP.TreeUnflatten(data);
                        var autoexpand = false;
                        <?php 
        if ($this->data['setup']->autoexpandmenu == true) {
            ?>
                        autoexpand = true;
                        <?php 
        }
        ?>

                        $("#jqxTree").fancytree({
                            extensions: ["filter"],
                            quicksearch: true,
                            checkbox: false,
                            source: data,
                            autoScroll: true,
                            filter: {
                                autoApply: true,  // Re-apply last filter if lazy data is loaded
                                counter: true,  // Show a badge with number of matching child nodes near parent icons
                                fuzzy: false,  // Match single characters in order, e.g. 'fb' will match 'FooBar'
                                hideExpandedCounter: true,  // Hide counter badge, when parent is expanded
                                highlight: true,  // Highlight matches by wrapping inside <mark> tags
                                mode: "hide"  // Grayout unmatched nodes (pass "hide" to remove unmatched node instead)
                            },
                            click: function(event, data) {
                                var node = data.node;
                                //add tab
                                var args = event.args;

                                var label = node.title;
                                var url = node.data.value;
                                if (url == '') {
                                    return;//ignore folder
                                }

                                //check existed
                                var totaltab = $('#jqxTabs').jqxTabs('length');
                                var i = 0;
                                for (i = 0; i < totaltab; i++) {
                                    var title = $('#jqxTabs').jqxTabs('getTitleAt', i);
                                    if (title == label) {
                                        $('#jqxTabs').jqxTabs('select', i);//switch to tab
                                        return;//ignore duplicate tab
                                    }
                                }

                                $('#jqxTabs').jqxTabs('addLast', label, '<iframe id="pagepart" src="' + url + '" width="100%" height="99%" scrolling="yes" frameborder="0"><p>Your browser does not support iframes</p> </iframe>');
                            },
                            create: function(event, data){
                                //alert('create done');
                            },
                            init: function(event, data){
                                if(autoexpand!=undefined && autoexpand==true) {
                                    $("#jqxTree").fancytree("getRootNode").visit(function (node) {
                                        node.setExpanded(true);
                                    });
                                }
                            }
                        });

                        //Tabs
                        $('#jqxTabs').jqxTabs({height: '100%', width: '100%', showCloseButtons: true, reorder: true});


                        /*Handle Tab Panel Context Menu
                        var contextMenu = $("#jqxMenu").jqxMenu({ width: '120px', height: '80px', autoOpenPopup: false, mode: 'popup'});
                        $("#jqxMenu").bind('itemclick', function(event)
                        {
                            var item = $(event.args).text();
                            var tabS = $('#jqxTabs');
                            switch (item)
                            {
                                case "Close Others":
                                    var currentIndex = tabS.jqxTabs('selectedItem');
                                    var currentTabTitle = tabS.jqxTabs('getTitleAt', currentIndex);
                                    for(var kk=currentIndex+1;kk<tabS.jqxTabs('length');kk++)
                                    {
                                        tabS.jqxTabs('removeAt', kk);
                                    }
                                    while(tabS.jqxTabs('length') > 1){
                                        tabS.jqxTabs('removeFirst');
                                    }
                                    break;
                                case "Close All":

                                    while(tabS.jqxTabs('length') > 0){
                                        tabS.jqxTabs('removeLast');
                                    }
                                    break;
                            }
                        });
                        */
                        // open the context menu when the user presses the mouse right button.
                        $("#jqxTabs").bind('mousedown', function (event) {
                            var rightClick = isRightClick(event);
                            if (rightClick) {
                                var scrollTop = $(window).scrollTop();
                                var scrollLeft = $(window).scrollLeft();

                                contextMenu.jqxMenu('open', parseInt(event.clientX) + 5 + scrollLeft, parseInt(event.clientY) + 5 + scrollTop);
                                return false;
                            }
                        });
                        /*

                        // disable the default browser's context menu.
                        $(document).bind('contextmenu', function (e) {
                            //return false;
                        });
                        */

                        function isRightClick(event) {
                            var rightclick;
                            if (!event) var event = window.event;
                            if (event.which) rightclick = (event.which == 3);
                            else if (event.button) rightclick = (event.button == 2);
                            return rightclick;
                        }
                        /*Handle Context Menu*/
                        $("#searchbox").keyup(function(e){
                            var match = $(this).val();
                            var tree = $("#jqxTree").fancytree("getTree");
                            if(e && e.which === $.ui.keyCode.ESCAPE || $.trim(match) === ""){
                                //reset filter
                                tree.clearFilter();
                                return;
                            }

                            // Pass text as filter string (will be matched as substring in the node title)
                            var n = tree.filterNodes(match, {autoExpand: true});
                        }).focus();

                    });
                })(jQuery);
            </script>
            <div id="splitter">
                <div>
                    <div id="splitter2">
                        <div>
                            <div style="width: 100%;">
                                <div style="float: left;">Search:</div>
                                <input id="searchbox" style="float: left;" />
                                <div style="clear: both"></div>
                            </div>

                            <div id='jqxTree' style="height: 95%; overflow: auto;">

                            </div>
                        </div>
                        <div>
                            <a target="_blank" href="<?php 
        echo admin_url('profile.php');
        ?>
"><?php 
        $tmp = wp_get_current_user();
        echo $tmp->user_login;
        ?>
 </a> |
                            <a onclick="return confirm('<?php 
        echo Qdmvc_Message::getMsg('msg_confirm');
        ?>
')"
                               href="<?php 
        echo wp_logout_url(Qdmvc_Helper::getCompactPageListLink('navigation'));
        ?>
">
                                <?php 
        echo Qdmvc_Message::getMsg('msg_logout');
        ?>
                            </a>
                        </div>
                    </div>

                </div>
                <div id="ContentPanel">
                    <!--
                    <div id='jqxMenu'>
                        <ul>
                            <li>Close Others</li>
                            <li>Close All</li>
                        </ul>
                    </div>-->
                    <div id='jqxTabs' style="float: left;">
                        <ul style="margin-left: 30px;" id="unorderedList">
                            <li>Home</li>
                        </ul>
                        <div>
                            Home page content
                        </div>
                    </div>
                </div>
            </div>
            <script>
                (function ($) {
                    $(document).ready(function () {
                        $('#panelContentpaneljqxTree li').click(function () {
                            //alert('wtf');
                        });


                    });
                })(jQuery);
            </script>
            <style>
                #hidden {
                    display: none
                }
            </style>
        </div>
    <?php 
    }
 public function render()
 {
     $this->style();
     parent::render();
 }
Exemplo n.º 3
0
    public function render()
    {
        if ($this->data['nopermission'] === true) {
            $this->layout_nopermission();
            return;
        }
        $this->style();
        parent::render();
        ?>
        <div id="qdmvcRootDiv" style="display: none; width: inherit; height: inherit">
            <?php 
        echo $this->preConfig();
        ?>
            <?php 
        echo $this->internalGateway();
        ?>
            <?php 
        echo $this->externalGateway();
        ?>

            <?php 
        echo $this->formValidation();
        ?>
            <?php 
        echo $this->progressSpinner();
        ?>
            <?php 
        echo $this->lookupWindowLayout();
        ?>
            <?php 
        echo $this->lookupDatePickerLayout();
        ?>
            <?php 
        echo $this->Bar();
        ?>
            <?php 
        echo $this->msgPanelLayout();
        ?>
            <?php 
        echo $this->progressLoader();
        ?>
            <?php 
        echo $this->onReadyHook();
        ?>
            <?php 
        echo $this->applyKOBinding();
        ?>
        </div>
    <?php 
    }
Exemplo n.º 4
0
    public function render()
    {
        if ($this->data['nopermission'] === true) {
            $this->layout_nopermission();
            return;
        }
        $this->style();
        parent::render();
        ?>
        <div id="qdmvcRootDiv" style="display: none; width: inherit; height: inherit">
            <?php 
        echo $this->onReadyHook();
        ?>
            <?php 
        echo $this->preConfig();
        ?>
            <?php 
        echo $this->externalGateway();
        ?>
            <?php 
        echo $this->internalGateway();
        ?>
            <?php 
        echo $this->generateFields();
        ?>

            <script type="text/javascript">
                (function ($) {
                    $(document).ready(function () {
                        var theme = 'classic';
                        var grid = MYAPP.getGrid();
                        var source =
                        {
                            datatype: "json",
                            datafields: dataSourceDefine,
                            url: MYAPP.data_port,
                            root: 'rows',
                            beforeprocessing: function (data) {
                                source.totalrecords = data.total;
                            },
                            //Server side sorting May 19, 2015
                            sort: function () {
                                // update the grid and send a request to the server.
                                console.log('Send SORT to Server');
                                grid.jqxGrid('updatebounddata', 'sort');
                            },
                            type: 'POST'//switch from GET to POST
                        };

                        var dataadapter = new $.jqx.dataAdapter(source);

                        // initialize jqxGrid
                        grid.jqxGrid(
                            {
                                width: '100%',
                                height: '100%',
                                source: dataadapter,
                                theme: theme,
                                autoheight: false,
                                pageable: true,
                                showfilterrow: true,
                                filterable: true,
                                showgroupsheader: true,
                                groupable: true,
                                virtualmode: true,
                                pagesize: 20,
                                sortable: true, /*May 19 2015*/
                                pagesizeoptions: ['5', '10', '20', '50', '100', '200', '999999'],
                                /*Enable Inline Editing*/
                                /*editable: true,
                                 editmode: "dblclick",*/
                                columnsresize: true,
                                selectionmode: 'singlerow', /*checkbox*/
                                //scrollmode: 'deferred',
                                rendergridrows: function () {
                                    return dataadapter.records;
                                },
                                columns: dataGridDefine,
                                /*
                                 columns: [
                                 { text: 'Ship Name', datafield: 'parent_id', columntype: 'combobox' }
                                 ]*/
                                ready: function () {

                                }
                            });

                        //event
                        grid.on("filter", function (event) {
                            $('#jqxgrid').jqxGrid('updatebounddata');//refresh grid when typing in filter box
                        });
                        grid.on('rowselect', function (event) {
                            // event arguments.
                            var args = event.args;
                            var row = args.row;
                            // row's bound index.
                            //var rowBoundIndex = args.rowindex;
                            // row's data. The row's data object or null(when all rows are being selected or unselected with a single action). If you have a datafield called "firstName", to access the row's firstName, use var firstName = rowData.firstName;
                            //formObj = args.row;

                            //call pass obj to CARD
                            try {
                                <?php 
        if ($this->data['role'] == 'navigate') {
            echo 'parent.MYAPP.clearFormValidationMark();';
            echo 'parent.MYAPP.setObj(args.row, true);';
        }
        ?>
                            } catch (error) {
                                console.log(error);
                            }
                        });

                        grid.on('rowdoubleclick', function (event) {
                            <?php 
        if ($this->data['role'] === 'navigate') {
            ?>
                            rbindex = event.args.rowindex;
                            obj = $(this).jqxGrid('getrowdata', rbindex);
                            parent.MYAPP.doubleClickObj(obj);
                            <?php 
        } else {
            if ($this->data['role'] === 'lookup') {
                ?>
                            $('#qdchoose').trigger('click');
                            <?php 
            }
        }
        ?>
                        });


                        grid.on("pagechanged", function (event) {
                            console.log('jqxgrid page changed');
                        });
                        grid.on("bindingcomplete", function (event) {
                            console.log('jqxgrid binding complete');
                            try {
                                var paging = $(this).jqxGrid('getpaginginformation');
                                var offset = paging.pagenum * paging.pagesize;
                                //reselect row if exist
                                if (MYAPP.TmpVar.keepIndex !== false && MYAPP.TmpVar.id != undefined && MYAPP.TmpVar.id != null) {
                                    var index = 0;
                                    var rows = $(this).jqxGrid('getrows');

                                    for (var i = 0; i < rows.length; i++) {
                                        if (rows[i].id == MYAPP.TmpVar.id) {
                                            $(this).jqxGrid('selectrow', offset + i);
                                            break;
                                        }
                                        if (i == rows.length - 1) {
                                            $(this).jqxGrid('selectrow', offset);
                                        }
                                    }
                                }
                                else {
                                    //var rowindex = $(this).jqxGrid('getselectedrowindex');
                                    $(this).jqxGrid('selectrow', offset);
                                }
                                //reset keep Index
                                MYAPP.TmpVar.keepIndex = true;

                                //Set lookupid filter for 1st time
                                if (parent != undefined && parent != null) {
                                    if (parent.MYAPP.LookupMode.isSetLookupFilterForFirstTime == false && parent.MYAPP.LookupMode.lookupid != '') {
                                        setTimeout(function () {
                                            MYAPP.addGridFilter('id', '=' + parent.MYAPP.LookupMode.lookupid);
                                            parent.MYAPP.LookupMode.isSetLookupFilterForFirstTime = true;
                                        }, 500);
                                    }
                                }
                            } catch (error) {
                                console.log(error);
                            }
                        });
                    });
                })(jQuery);
            </script>

            <?php 
        if ($this->data['role'] == 'lookup') {
            $this->lookupToolbar();
        }
        ?>
            <?php 
        echo $this->generalToolbar();
        ?>
            <div id='jqxWidget'>
                <div id="jqxgrid"></div>
            </div>
        </div>
    <?php 
    }