### Example GNU GPL Notice for Interactive Terminal Program Startup Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/licence_gpl.txt This snippet provides an example of a concise notice to be displayed when a program starts in an interactive terminal mode. It includes copyright information, a brief warranty disclaimer, and prompts the user to type specific commands for more detailed license information. ```Plain Text Galleria Copyright (C) 2008 David Hellsing This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### Example GNU GPL License Notice for JavaScript Source Files Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/licence_gpl.txt This snippet illustrates the standard copyright and license notice to be included at the beginning of source files for programs distributed under the GNU General Public License. It specifies the applicable GPL version, disclaims warranty, and directs users to the full license text. This example is tailored for a JavaScript project. ```JavaScript Galleria is a javascript image gallery written in jQuery Copyright (C) 2008 David Hellsing This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ``` -------------------------------- ### Configure Fluid ComboTree Dimensions Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/combotree/fluid.html Examples demonstrating how to set the width of the ComboTree to a percentage of its parent container, and also how to specify both width and a fixed height. ```CSS width: 50% ``` ```CSS width: 30%, height: 26px ``` -------------------------------- ### Handle Search Input with JavaScript Alert Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/searchbox/basic.html This JavaScript function, `doSearch`, takes a single `value` parameter, which represents the text entered into a search box. It then displays an alert dialog showing the input value. This is a basic example for demonstrating user input capture. ```JavaScript function doSearch(value){ alert('You input: ' + value); } ``` -------------------------------- ### Initial Form Field Population on Document Ready Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/WEB-INF/views/planset/edit.html This JavaScript snippet, executed when the DOM is ready, initializes various form fields. It retrieves values from existing attributes to set input fields, parses a period time string to populate separate start and end time inputs, and applies a background color based on a stored value. ```JavaScript var defineType = $("#inputDefineType").attr("value"); $("#inputDefineType").val(defineType); var planType = $("#inputPlanType").attr("value"); $("#inputPlanType").val(planType); $("#bcgl_color_img").css("background-color",$("#inputColor").attr("value")); var periodTime=$("#inputPeriodTime").attr("value").split("-"); $('#inputStartTime').val(periodTime[0]); $('#inputEndTime').val(periodTime[1]); ``` -------------------------------- ### Datetimepicker Initialization for Start and End Times Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/WEB-INF/views/planset/edit.html This JavaScript snippet initializes two datetimepicker instances for the 'planStartTime' and 'planEndTime' input fields. It configures the pickers with specific language, view settings, and auto-closure. A 'changeDate' event listener is attached to both pickers, triggering the `planTimeChange()` function upon date selection to recalculate total time. ```JavaScript //datetimepicker日期选择控件 $('#planStartTime').datetimepicker({ language: 'fr', weekStart: 1, todayBtn: 1, autoclose: 1, todayHighlight: 1, startView: 1, minView: 0, maxView: 1, forceParse: 0 }).on('changeDate', function(ev){ planTimeChange(ev); }); $('#planEndTime').datetimepicker({ language: 'fr', weekStart: 1, todayBtn: 1, autoclose: 1, todayHighlight: 1, startView: 1, minView: 0, maxView: 1, forceParse: 0 }).on('changeDate', function(ev){ planTimeChange(ev); }); ``` -------------------------------- ### jQuery EasyUI ComboGrid: Get and Set Values Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/combogrid/setvalue.html Demonstrates how to retrieve the current value from a ComboGrid and how to set its value using both a simple string and a complex object in jQuery EasyUI. ```JavaScript function getValue(){ var val = $('#cc').combogrid('getValue'); alert(val); } ``` ```JavaScript function setValue1(){ $('#cc').combogrid('setValue', 'EST-13'); } ``` ```JavaScript function setValue2(){ $('#cc').combogrid('setValue', { itemid: 'customid', productname: 'CustomName' }); } ``` -------------------------------- ### Configure jQuery EasyUI NumberBox Width with Percentages Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/numberbox/fluid.html This snippet illustrates how to set the width of a jQuery EasyUI NumberBox component using percentage values, allowing it to adapt to its parent container's size. Examples include setting the width to 100% and 50%. ```Configuration width: 100% ``` ```Configuration width: 50% ``` -------------------------------- ### Get ComboTree Value with jQuery EasyUI Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/combotree/actions.html Retrieves the current value of the ComboTree component using the 'getValue' method and displays it in an alert. ```JavaScript function getValue(){ var val = $('#cc').combotree('getValue'); alert(val); } ``` -------------------------------- ### Get Multiple Selected Rows from jQuery EasyUI DataGrid Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/datagrid/selection.html Retrieves all selected rows from a jQuery EasyUI DataGrid, iterates through them, and constructs an HTML string with each row's item ID, product ID, and attribute 1. The combined information is then displayed in a messager alert, with each row's data on a new line. ```javascript function getSelections(){ var ss = []; var rows = $('#dg').datagrid('getSelections'); for(var i=0; i'+row.itemid+":"+row.productid+":"+row.attr1+''); } $.messager.alert('Info', ss.join('
')); } ``` -------------------------------- ### Get Selected Tree Node Information with jQuery EasyUI Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/tree/actions.html This JavaScript function retrieves the currently selected node from a jQuery EasyUI tree. If a node is selected, it extracts its text and any custom attributes (p1, p2) and displays them in an alert. ```JavaScript function getSelected(){ var node = $('#tt').tree('getSelected'); if (node){ var s = node.text; if (node.attributes){ s += ","+node.attributes.p1+","+node.attributes.p2; } alert(s); } } ``` -------------------------------- ### Customizing DateTimeSpinner Formatting and Parsing in jQuery EasyUI Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/datetimespinner/format.html This snippet demonstrates how to implement custom 'formatter' and 'parser' functions for the jQuery EasyUI DateTimeSpinner. It includes examples for using default datebox functions and for custom 'yyyy-mm' formatting, allowing flexible display and input of date and time values. ```javascript function formatter1(date){ if (!date){return '';} return $.fn.datebox.defaults.formatter.call(this, date); } function parser1(s){ if (!s){return null;} return $.fn.datebox.defaults.parser.call(this, s); } function formatter2(date){ if (!date){return '';} var y = date.getFullYear(); var m = date.getMonth() + 1; return y + '-' + (m<10?('0'+m):m); } function parser2(s){ if (!s){return null;} var ss = s.split('-'); var y = parseInt(ss[0],10); var m = parseInt(ss[1],10); if (!isNaN(y) && !isNaN(m)){ return new Date(y,m-1,1); } else { return new Date(); } } ``` -------------------------------- ### Extend jQuery EasyUI Textbox with Clear Button Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/textbox/clearicon.html This JavaScript code extends the jQuery EasyUI textbox component by adding a new method `addClearBtn`. This method attaches a clear icon to the textbox. The icon's visibility is managed based on whether the textbox has content, and clicking it clears the input and hides the icon. It also includes an example of how to apply this extension to a textbox. ```JavaScript $.extend($.fn.textbox.methods, { addClearBtn: function(jq, iconCls){ return jq.each(function(){ var t = $(this); var opts = t.textbox('options'); opts.icons = opts.icons || []; opts.icons.unshift({ iconCls: iconCls, handler: function(e){ $(e.data.target).textbox('clear').textbox('textbox').focus(); $(this).css('visibility','hidden'); } }); t.textbox(); if (!t.textbox('getText')){ t.textbox('getIcon',0).css('visibility','hidden'); } t.textbox('textbox').bind('keyup', function(){ var icon = t.textbox('getIcon',0); if ($(this).val()){ icon.css('visibility','visible'); } else { icon.css('visibility','hidden'); } }); }); } }); $(function(){ $('#tt').textbox().textbox('addClearBtn', 'icon-clear'); }); ``` -------------------------------- ### Merge DataGrid Cells on Load Success with jQuery EasyUI Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/datagrid/mergecells.html This JavaScript function, `onLoadSuccess`, demonstrates how to programmatically merge cells in a jQuery EasyUI DataGrid. It defines an array of merge configurations, each specifying the starting row index and the number of rows to span. The function then iterates through these configurations, applying the `mergeCells` method to a specified field (e.g., 'productid') of the DataGrid. This is typically used after data has been successfully loaded into the grid to achieve a desired visual layout. ```JavaScript function onLoadSuccess(data){ var merges = [{ index: 2, rowspan: 2 },{ index: 5, rowspan: 2 },{ index: 7, rowspan: 2 }]; for(var i=0; i'), showEvent: 'click', onUpdate: function(content){ content.panel({ width: 200, border: false, title: 'Login', href: '_dialog.html' }); }, onShow: function(){ var t = $(this); t.tooltip('tip').unbind().bind('mouseenter', function(){ t.tooltip('show'); }).bind('mouseleave', function(){ t.tooltip('hide'); }); } }); }); ``` -------------------------------- ### Set ComboTree Value with jQuery EasyUI Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/combotree/actions.html Sets a specific value for the ComboTree component using the 'setValue' method. In this example, it sets the value to '122'. ```JavaScript function setValue(){ $('#cc').combotree('setValue', '122'); } ``` -------------------------------- ### Seajs Module Loading and Plan Update Action Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/WEB-INF/views/planset/edit.html This JavaScript code, part of the document ready block, uses Seajs to asynchronously load the 'app/planset/index' module. Once loaded, it attaches a click event listener to the 'updatePlanBtnn' button, which triggers the `updatePlan()` function from the loaded module, facilitating the submission of updated plan data. ```JavaScript seajs.use('app/planset/index',function(index){ $("#updatePlanBtnn").click(function(){ index.updatePlan(); }); }); ``` -------------------------------- ### Get TimeSpinner Value with jQuery EasyUI Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/timespinner/actions.html Retrieves the current value from the TimeSpinner component. It uses the 'getValue' method of the timespinner plugin and displays the result in an alert box. ```JavaScript function getValue(){ var val = $('#dt').timespinner('getValue'); alert(val); } ``` -------------------------------- ### Initialize UI Theme, Popovers, and Sidebar Menu Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/WEB-INF/views/index.html This JavaScript block handles various UI initializations. It retrieves a 'color' preference from cookies to apply a theme class to the body, initializes Bootstrap popovers, and attempts to clone sidebar navigation elements for mobile visibility (though the 'uls' variable is commented out in the source, leading to a potential runtime error). ```JavaScript $(function() { var match = document.cookie.match(new RegExp('color=(\[^;\]+)')); if (match) var color = match[1]; if (color) { $('body').removeClass(function(index, css) { return (css.match(/\\btheme-\\S+/g) || []).join(' ') }) $('body').addClass('theme-' + color); } $('[data-popover="true"]').popover({ html: true }); // var uls = $('.sidebar-nav > ul > *').clone(); uls.addClass('visible-xs'); $('#main-menu').append(uls.clone()); }); ``` -------------------------------- ### Load jQuery EasyUI Calendar Dynamically Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/easyloader/basic.html This JavaScript function demonstrates how to dynamically load and initialize the jQuery EasyUI Calendar component using the 'using' utility. It configures the calendar's width and height upon loading. ```javascript function load1(){ using('calendar', function(){ $('#cc').calendar({ width:180, height:180 }); }); } ``` -------------------------------- ### Get Checked Nodes with jQuery EasyUI Tree Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/tree/checkbox.html This JavaScript function demonstrates how to retrieve all checked nodes from a jQuery EasyUI tree component. It iterates through the selected nodes and concatenates their text property into a comma-separated string, which is then displayed in an alert box. ```javascript function getChecked(){ var nodes = $('#tt').tree('getChecked'); var s = ''; for(var i=0; i').appendTo('body'); cmenu.menu({ onClick: function(item){ if (item.iconCls == 'icon-ok'){ $('#dg').datagrid('hideColumn', item.name); cmenu.menu('setIcon', { target: item.target, iconCls: 'icon-empty' }); } else { $('#dg').datagrid('showColumn', item.name); cmenu.menu('setIcon', { target: item.target, iconCls: 'icon-ok' }); } } }); var fields = $('#dg').datagrid('getColumnFields'); for(var i=0; i ${location} =========== * [Home](./) * ${subLocation} ``` -------------------------------- ### FreeMarker Pagination Macro Definition Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/WEB-INF/views/common/_paginate.html This FreeMarker macro, `paginate`, generates a set of pagination links. It calculates the range of page numbers to display, handles edge cases for the first and last pages, and includes navigation for first, previous, next, and last pages, along with ellipsis for large page ranges. It also optionally displays the total number of records if `totalRows` is provided. ```FreeMarker <#macro paginate currentPage totalPage actionUrl ui urlParas=""> <#if (totalPage <= 0) || (currentPage > totalPage)><#return> <#local startPage = currentPage - 4> <#if (startPage < 1)><#local startPage = 1> <#local endPage = currentPage + 4> <#if (endPage > totalPage)><#local endPage = totalPage> <#if (currentPage <= 8)> <#local startPage = 1> <#if ((totalPage - currentPage) < 8)> <#local endPage = totalPage> <#if (currentPage == 1)>* [«](#) <#else>* [«](#) <#if (currentPage > 8)>* [#{1}](#) * [#{2}](#) * […](#) <#list startPage..endPage as i> <#if currentPage == i>* [#{i}(current)](#) <#else>* [#{i}](#) * <#if ((totalPage - currentPage) >= 8)> * […](#) * [#{totalPage - 1}](#) * [#{totalPage}](#) * <#if (currentPage == totalPage)> * [»](#) <#else>* [»](#) <#if totalRows??> * (共${totalRows}条记录) ``` -------------------------------- ### FreeMarker Template Includes and Layout Definition Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/WEB-INF/views/planset/edit.html This snippet demonstrates the use of FreeMarker directives for including common header content and defining the page layout. It sets the page title and breadcrumbs dynamically based on the `result.planName` variable, ensuring consistent page structure and navigation. ```FreeMarker <#include "../common/_contentHeader.html"/> <@layout location="编辑班次" subLocation="[班次设置](#) / ${(result.planName!)}" /> <#include "_form.html"/> ``` -------------------------------- ### Restrict Date Range in jQuery EasyUI DateBox Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/datebox/restrict.html This JavaScript snippet demonstrates how to configure a jQuery EasyUI DateBox to restrict the selectable date range. It sets a validator function on the calendar component that ensures users can only select dates within a 10-day period starting from the current date. The code requires the jQuery and jQuery EasyUI libraries to be loaded. ```JavaScript $(function(){ $('#dd').datebox().datebox('calendar').calendar({ validator: function(date){ var now = new Date(); var d1 = new Date(now.getFullYear(), now.getMonth(), now.getDate()); var d2 = new Date(now.getFullYear(), now.getMonth(), now.getDate()+10); return d1<=date && date<=d2; } }); }); ``` -------------------------------- ### jQuery EasyUI DataGrid Client-Side Pagination Implementation Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/datagrid/clientpagination.html This comprehensive JavaScript code provides a client-side pagination solution for jQuery EasyUI DataGrid. It includes a custom plugin that extends the DataGrid's functionality to handle pagination locally, a utility function to generate sample data, and the initialization script to apply the client-side paging to a DataGrid instance. The plugin intercepts data loading to filter rows based on the current page and size, ensuring efficient display of large datasets without server-side interaction for pagination. ```JavaScript (function($){ function pagerFilter(data){ if ($.isArray(data)){ // is array data = { total: data.length, rows: data } } var dg = $(this); var state = dg.data('datagrid'); var opts = dg.datagrid('options'); if (!state.allRows){ state.allRows = (data.rows); } var start = (opts.pageNumber-1)*parseInt(opts.pageSize); var end = start + parseInt(opts.pageSize); data.rows = $.extend(true,[],state.allRows.slice(start, end)); return data; } var loadDataMethod = $.fn.datagrid.methods.loadData; $.extend($.fn.datagrid.methods, { clientPaging: function(jq){ return jq.each(function(){ var dg = $(this); var state = dg.data('datagrid'); var opts = state.options; opts.loadFilter = pagerFilter; var onBeforeLoad = opts.onBeforeLoad; opts.onBeforeLoad = function(param){ state.allRows = null; return onBeforeLoad.call(this, param); } dg.datagrid('getPager').pagination({ onSelectPage:function(pageNum, pageSize){ opts.pageNumber = pageNum; opts.pageSize = pageSize; $(this).pagination('refresh',{ pageNumber:pageNum, pageSize:pageSize }); dg.datagrid('loadData',state.allRows); } }); $(this).datagrid('loadData', state.data); if (opts.url){ $(this).datagrid('reload'); } }); }, loadData: function(jq, data){ jq.each(function(){ $(this).data('datagrid').allRows = null; }); return loadDataMethod.call($.fn.datagrid.methods, jq, data); }, getAllRows: function(jq){ return jq.data('datagrid').allRows; } }) })(jQuery); function getData(){ var rows = []; for(var i=1; i<=800; i++){ var amount = Math.floor(Math.random()*1000); var price = Math.floor(Math.random()*1000); rows.push({ inv: 'Inv No '+i, date: $.fn.datebox.defaults.formatter(new Date()), name: 'Name '+i, amount: amount, price: price, cost: amount*price, note: 'Note '+i }); } return rows; } $(function(){ $('#dg').datagrid({data:getData()}).datagrid('clientPaging'); }); ``` -------------------------------- ### Displaying and closing a jQuery EasyUI progress messager box Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/messager/basic.html This snippet illustrates how to display a progress messager box using $.messager.progress and then programmatically close it after a delay (5 seconds) using $.messager.progress('close'). ```javascript function progress(){ var win = $.messager.progress({ title:'Please waiting', msg:'Loading data...' }); setTimeout(function(){ $.messager.progress('close'); },5000) } ``` -------------------------------- ### CSS: Basic Styles for Textbox Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/validatebox/validateonblur.html This CSS snippet defines basic styling for elements with the class 'textbox', setting their height, margins, padding, and box-sizing for consistent display. ```css .textbox{ height:20px; margin:0; padding:0 2px; box-sizing:content-box; } ``` -------------------------------- ### Enable Cell Editing in jQuery EasyUI DataGrid Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/datagrid/cellediting.html This JavaScript code extends the jQuery EasyUI DataGrid methods to enable direct cell editing. It adds an 'editCell' method to manage the editing state of individual cells and an 'enableCellEditing' method that overrides the default 'onClickCell' behavior to start editing when a cell is clicked. It ensures only one cell is in edit mode at a time and validates changes upon exiting edit mode. ```javascript $.extend($.fn.datagrid.methods, { editCell: function(jq,param){ return jq.each(function(){ var opts = $(this).datagrid('options'); var fields = $(this).datagrid('getColumnFields',true).concat($(this).datagrid('getColumnFields')); for(var i=0; i' + value + '%' '' ''; return s; } else { return ''; } } } ]] }); }) ``` -------------------------------- ### Implement Row Editing for jQuery EasyUI DataGrid Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/datagrid/rowediting.html This comprehensive JavaScript code provides a set of functions for managing row editing in a jQuery EasyUI DataGrid. It includes logic to start and end editing, handle cell clicks, append new rows, remove existing rows, accept or reject changes, and retrieve all modified rows. The `editIndex` variable tracks the currently edited row to ensure only one row is edited at a time. ```JavaScript var editIndex = undefined; function endEditing(){ if (editIndex == undefined){return true} if ($('#dg').datagrid('validateRow', editIndex)){ var ed = $('#dg').datagrid('getEditor', {index:editIndex,field:'productid'}); var productname = $(ed.target).combobox('getText'); $('#dg').datagrid('getRows')[editIndex]['productname'] = productname; $('#dg').datagrid('endEdit', editIndex); editIndex = undefined; return true; } else { return false; } } function onClickCell(index, field){ if (editIndex != index){ if (endEditing()){ $('#dg').datagrid('selectRow', index) .datagrid('beginEdit', index); var ed = $('#dg').datagrid('getEditor', {index:index,field:field}); ($(ed.target).data('textbox') ? $(ed.target).textbox('textbox') : $(ed.target)).focus(); editIndex = index; } else { $('#dg').datagrid('selectRow', editIndex); } } } function append(){ if (endEditing()){ $('#dg').datagrid('appendRow',{status:'P'}); editIndex = $('#dg').datagrid('getRows').length-1; $('#dg').datagrid('selectRow', editIndex) .datagrid('beginEdit', editIndex); } } function removeit(){ if (editIndex == undefined){return} $('#dg').datagrid('cancelEdit', editIndex) .datagrid('deleteRow', editIndex); editIndex = undefined; } function accept(){ if (endEditing()){ $('#dg').datagrid('acceptChanges'); } } function reject(){ $('#dg').datagrid('rejectChanges'); editIndex = undefined; } function getChanges(){ var rows = $('#dg').datagrid('getChanges'); alert(rows.length+' rows are changed!'); } ``` -------------------------------- ### Configure jQuery EasyUI Pagination Layouts Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/pagination/layout.html This JavaScript function demonstrates how to dynamically set different pagination layouts for a jQuery EasyUI pagination component. It takes a 'type' parameter to switch between various predefined layouts, including combinations of first/prev/next/last buttons, page lists, manual input, and numeric links. ```JavaScript function setLayout(type){ var p = $('#pp'); switch(parseInt(type)){ case 1: p.pagination({layout:['first','prev','next','last']}); break; case 2: p.pagination({ layout:['list','sep','first','prev','sep','manual','sep','next','last','sep','refresh'], beforePageText:'Page', afterPageText:'of {pages}' }); break; case 3: p.pagination({layout:['links']}); break; case 4: p.pagination({layout:['first','prev','links','next','last']}); break; case 5: p.pagination({ layout:['first','prev','next','last','sep','links','sep','manual'], beforePageText:'Go Page', afterPageText:'' }); break; } } ``` -------------------------------- ### Enable ComboTree with jQuery EasyUI Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/combotree/actions.html Enables the ComboTree component, restoring its interactivity, using the 'enable' method. ```JavaScript function enable(){ $('#cc').combotree('enable'); } ``` -------------------------------- ### Display Context Menu with jQuery EasyUI Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/menu/basic.html This JavaScript snippet uses jQuery to bind a 'contextmenu' event to the entire document. It prevents the default browser context menu and instead displays a custom menu (identified by '#mm') at the exact coordinates of the mouse click using jQuery EasyUI's menu plugin. ```JavaScript $(function(){ $(document).bind('contextmenu',function(e){ e.preventDefault(); $('#mm').menu('show', { left: e.pageX, top: e.pageY }); }); }); ``` -------------------------------- ### Initialize jQuery EasyUI Combo Box for Language Selection Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/combo/basic.html This jQuery snippet initializes an EasyUI combo box (`#cc`) as required and non-editable. It appends a selection panel (`#sp`) to the combo box and sets up a click handler for its input elements. When an input is clicked, it updates the combo box's value and text, then hides the panel, effectively selecting a language. ```javascript $(function(){ $('#cc').combo({ required:true, editable:false }); $('#sp').appendTo($('#cc').combo('panel')); $('#sp input').click(function(){ var v = $(this).val(); var s = $(this).next('span').text(); $('#cc').combo('setValue', v).combo('setText', s).combo('hidePanel'); }); }); ``` -------------------------------- ### Handle jQuery EasyUI Menu Events Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/menu/events.html This JavaScript code defines a handler for menu item clicks and binds a context menu to the document, displaying it on right-click at the mouse position. ```JavaScript function menuHandler(item){ $('#log').prepend('

Click Item: '+item.name+'

'); } $(function(){ $(document).bind('contextmenu',function(e){ e.preventDefault(); $('#mm').menu('show', { left: e.pageX, top: e.pageY }); }); }); ``` -------------------------------- ### Initialize jQuery Tooltip Plugin Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/WEB-INF/views/index.html Applies the jQuery tooltip plugin to all elements with the attribute `rel=tooltip`. This provides interactive tooltips on hover. ```JavaScript $("[rel=tooltip]").tooltip(); ``` -------------------------------- ### Displaying a sliding jQuery EasyUI messager box with timeout Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/messager/basic.html This snippet shows how to display a messager box that slides into view and automatically closes after a specified timeout (5 seconds) using $.messager.show with showType:'slide'. ```javascript function slide(){ $.messager.show({ title:'My Title', msg:'Message will be closed after 5 seconds.', timeout:5000, showType:'slide' }); } ``` -------------------------------- ### jQuery EasyUI TreeGrid Context Menu Operations Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/treegrid/contextmenu.html This snippet provides JavaScript functions for managing a jQuery EasyUI TreeGrid, including custom progress formatting, displaying a context menu on right-click, and performing actions like appending, removing, collapsing, and expanding tree nodes. It demonstrates interaction with the TreeGrid API and a jQuery EasyUI menu component. ```JavaScript function formatProgress(value){ if (value){ var s = '
' + '
' + value + '%' + '
' + '
'; return s; } else { return ''; } } function onContextMenu(e,row){ e.preventDefault(); $(this).treegrid('select', row.id); $('#mm').menu('show',{ left: e.pageX, top: e.pageY }); } var idIndex = 100; function append(){ idIndex++; var d1 = new Date(); var d2 = new Date(); d2.setMonth(d2.getMonth()+1); var node = $('#tg').treegrid('getSelected'); $('#tg').treegrid('append',{ parent: node.id, data: [{ id: idIndex, name: 'New Task'+idIndex, persons: parseInt(Math.random()*10), begin: $.fn.datebox.defaults.formatter(d1), end: $.fn.datebox.defaults.formatter(d2), progress: parseInt(Math.random()*100) }] }) } function removeIt(){ var node = $('#tg').treegrid('getSelected'); if (node){ $('#tg').treegrid('remove', node.id); } } function collapse(){ var node = $('#tg').treegrid('getSelected'); if (node){ $('#tg').treegrid('collapse', node.id); } } function expand(){ var node = $('#tg').treegrid('getSelected'); if (node){ $('#tg').treegrid('expand', node.id); } } ``` -------------------------------- ### Show PropertyGrid Header with jQuery EasyUI Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/propertygrid/basic.html This JavaScript function configures a jQuery EasyUI propertygrid to display its header. It targets the element with ID 'pg' and sets the 'showHeader' option to true. ```javascript function showHeader(){ $('#pg').propertygrid({ showHeader:true }); } ``` -------------------------------- ### CSS Styling for Draggable and Droppable Elements Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/droppable/accept.html Defines basic styles for draggable elements (.drag), including dimensions, padding, margin, border, and background. It also includes styles for the drag proxy element (.dp) to make it semi-transparent and a style for the droppable area when an item is hovered over it (.over). ```css .drag{ width:100px; height:50px; padding:10px; margin:5px; border:1px solid #ccc; background:#AACCFF; } .dp{ opacity:0.5; filter:alpha(opacity=50); } .over{ background:#FBEC88; } ``` -------------------------------- ### Initialize jQuery EasyUI Tabs with Dropdown Menu Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/tabs/dropdown.html This JavaScript snippet initializes a jQuery EasyUI tabs component, specifically targeting the third tab (index 2). It then attaches a menubutton to this tab's inner link, linking it to a menu with ID '#mm' and an 'icon-help' class. Clicking this menubutton will select the third tab, providing a dropdown functionality over the tab. ```JavaScript $(function(){ var p = $('#tt').tabs().tabs('tabs')[2]; var mb = p.panel('options').tab.find('a.tabs-inner'); mb.menubutton({ menu:'#mm', iconCls:'icon-help' }).click(function(){ $('#tt').tabs('select',2); }); }); ``` -------------------------------- ### Initialize Draggable Elements with jQuery EasyUI Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/droppable/basic.html Initializes draggable functionality for elements with the class 'dragitem' using jQuery EasyUI. It configures the draggable behavior to revert to its original position after a drag, sets drag deltas for precise positioning, and defines a custom proxy element for visual feedback during dragging. ```JavaScript $(function(){ $('.dragitem').draggable({ revert:true, deltaX:10, deltaY:10, proxy:function(source){ var n = $('
'); n.html($(source).html()).appendTo('body'); return n; } }); }); ``` -------------------------------- ### jQuery EasyUI Draggable and Droppable Implementation with Acceptance Rules Source: https://github.com/giscafer/finalscheduler/blob/master/WebRoot/public/js/modules/easyui/demo/droppable/accept.html Initializes draggable behavior for elements with the class 'drag', configuring them to use a clone as a proxy, revert to their original position on drop, and change cursor during drag. It also sets up event handlers for 'onStartDrag' and 'onStopDrag' to modify the cursor and proxy appearance. The '#target' element is made droppable, accepting only elements with IDs '#d1' or '#d3'. Event handlers 'onDragEnter', 'onDragLeave', and 'onDrop' provide visual feedback and append the dropped element. ```javascript $(function(){ $('.drag').draggable({ proxy:'clone', revert:true, cursor:'auto', onStartDrag:function(){ $(this).draggable('options').cursor='not-allowed'; $(this).draggable('proxy').addClass('dp'); }, onStopDrag:function(){ $(this).draggable('options').cursor='auto'; } }); $('#target').droppable({ accept:'#d1,#d3', onDragEnter:function(e,source){ $(source).draggable('options').cursor='auto'; $(source).draggable('proxy').css('border','1px solid red'); $(this).addClass('over'); }, onDragLeave:function(e,source){ $(source).draggable('options').cursor='not-allowed'; $(source).draggable('proxy').css('border','1px solid #ccc'); $(this).removeClass('over'); }, onDrop:function(e,source){ $(this).append(source) $(this).removeClass('over'); } }); }); ```