Code Tidy - Pastebin

New     Fork     Embed     View raw     Report
benn987EXTCODE - javascript

Embed

You can embed this paste into a blog or website with this code:

<iframe class="codetidy" type="text/html" width="100%" src="http://codetidy.com/paste/embed/182" frameborder="0"></iframe>

Add comment

Captcha
  1. var personModuleFilterHTML = '';?
  2. var woModuleFilterHTML = '';?
  3.  ?
  4. /* GREG'S CODE TO RENDER GRAPHS & SEARCH - TEMPORARY */?
  5. function drawChartView()?
  6. {?
  7.  ?
  8.         //Loop through each chart view?
  9.         for(var i = 0; i < chartViews.length; i++)?
  10.         {?
  11.  ?
  12.                 (function(){?
  13.                         var chartView =  chartViews[i];?
  14.  ?
  15.                         //Create a container DIV element for the chart?
  16.                         Ext.getCmp("personsChart").body.update("<div id=\""+chartView.name+"\"></div>");?
  17.                         //$("plotcanvas").append("<div id=\""+chartView.name+"\"></div>"); // OLD CODE?
  18.  ?
  19.                         //Fetch the chart's data?
  20.                         chartView.update(function(){?
  21.                                 //After the update is complete, execute this code?
  22.  ?
  23.                                 //Define a chart click handler to set the filters of the grid view?
  24.                                 function onBarClick()?
  25.                                 {?
  26.                                         var filterVals = chartView.getChartDataFilterValues(this.index)[0];?
  27.                                         var filters = chartView.getFieldFilters();?
  28.                                         for(var j = 0; j < filters.length; j++)?
  29.                                         {?
  30.                                                 setFilter(filters[j].filter.field,filterVals[j+1],chartView);?
  31.                                         }?
  32.                                         applyFilters();?
  33.  ?
  34.                                 }?
  35.  ?
  36.                                 //Draw the chart, passing the ID of the DIV created above as the "canvas" property, and the click handler?
  37.                                 chartView.drawChart({canvas: chartView.name, onBarClick: onBarClick});?
  38.  ?
  39.                         });?
  40.                 })();?
  41.         }?
  42.  ?
  43.  ?
  44. }?
  45.  ?
  46. /*************************************************************?
  47. **************************************************************?
  48. /* LOTS OF CODE GOES IN BETWEEN HERE */?
  49. **************************************************************?
  50. **************************************************************/?
  51.  ?
  52.  ?
  53.  ?
  54. /* VARS FOR PERSONS MODULE */?
  55. var store = "";?
  56. var colModel = "";?
  57. var chartViews = "";?
  58. /* END VARS FOR PERSONS MODULE */?
  59. MyDesktop.GridWindow = Ext.extend(Ext.app.Module, {?
  60.     id:'grid-win',?
  61.     init : function(){?
  62.         this.launcher = {?
  63.             text: 'Persons Module',?
  64.             iconCls:'icon-grid',?
  65.             handler : this.createWindow,?
  66.             scope: this?
  67.         }?
  68.         /* XML PERSONS OBJECT */?
  69.  ?
  70.         //Load the Module by requesting its definition XML from the server?
  71.         var app = PTS.ApplicationManager.loadApplication("PersonDetails_File");?
  72.  ?
  73.         //Get the Person Details View object?
  74.         view = app.getView("PersonDetailsGridView");?
  75.  ?
  76.         //Create the Ext Js Store and ColumnModel objects from the PTS View object?
  77.         store = view.getDataModel(new PTS.DataView.Ext.ExtDataStoreAdapter());?
  78.         colModel = view.getFieldModel(new PTS.DataView.Ext.ExtColumnModelAdapter());?
  79.  ?
  80.         var viewFilters = view.getFieldFilters(true);?
  81.  ?
  82.         var filtersForm = $("<div id=\"filtersdiv\"><form id=\"filtersform\" method=\"post\" action=\"\"><div id=\"autofilters\"></div><button onclick=\"applyFilters(); return false;\">Apply Filters</button><button onclick=\"clearFilters(); return false;\">Clear Filters</button></form></div>");?
  83.     var filtersFormFilterContainer = filtersForm.find("#autofilters");?
  84.  ?
  85.         //Get chart views for this module?
  86.         chartViews = app.getViewsByType("ChartView");?
  87.  ?
  88.         //function to recursively draw the filters for each view/sub-view?
  89.         var drawFilters = function(filters,drawElem)?
  90.         {?
  91.                 for(var i = 0; i < filters.length; i++)?
  92.                 {?
  93.                         var filter = filters[i];?
  94.                         if(filter.filter.length)?
  95.                         {?
  96.                                 //Filter is a subview and has an array of filters as its value?
  97.  ?
  98.                                 //Draw a fieldset?
  99.                                 var fieldSet = $("<fieldset style=\"width:25%\"></fieldset>");?
  100.                                 fieldSet.append("<legend>"+filter.fieldLabel+"</legend>");?
  101.                                 //Recursively draw all child filters?
  102.                                 drawFilters(filter.filter,fieldSet);?
  103.                                 drawElem.append(fieldSet);?
  104.                                 drawElem.append("<br/>");?
  105.                         }?
  106.                         else?
  107.                         {?
  108.                                 drawFilter(filter.filter,drawElem);?
  109.                         }?
  110.                 }?
  111.         };?
  112.  ?
  113.         //Draws an individual filter?
  114.         function drawFilter(filter,drawElem)?
  115.         {?
  116.                 //Get the label to use for the filter edit?
  117.                 var filterLabel = filter.label;?
  118.  ?
  119.                 //Draw a different edit control depending on the filter type?
  120.                 if(filter.type == "text")?
  121.                 {?
  122.                         drawElem.append("<label>"+filterLabel+": </label><input class=\"extfilter\" id=\""+filter.field.replace(/\./g,"-")+"\" type=\"text\"/><br/>");?
  123.                 }?
  124.                 else if(filter.type == "select")?
  125.                 {?
  126.                         var selHTML = "<label>"+filterLabel+": </label><select class=\"extfilter\" id=\""+filter.field.replace(/\./g,"-")+"\"><option value=\"\"></option>";?
  127.                         for(var j = 0;  j < filter.filterOptions.length; j++)?
  128.                                 selHTML += "<option value=\""+filter.filterOptions[j].value+"\">"+filter.filterOptions[j].text+"</option>";?
  129.                         selHTML += "</select><br/>";?
  130.                         drawElem.append(selHTML);?
  131.                 }?
  132.         }?
  133.  ?
  134.         drawFilters(viewFilters,filtersFormFilterContainer);?
  135.  ?
  136.     personModuleFilterHTML = $("<div></div>").append(filtersForm);?
  137.     personModuleFilterHTML = personModuleFilterHTML.html();?
  138.  ?
  139.  ?
  140.         function clearFilters()?
  141.         {?
  142.                 $(".extfilter").val('');?
  143.                 view.clearFieldFilters(true);?
  144.         }?
  145.  ?
  146.  ?
  147.  ?
  148.     },?
  149.  ?
  150.     createWindow: function() {?
  151.         var desktop = this.app.getDesktop();?
  152.         var win = desktop.getWindow('grid-win');?
  153.         if(!win) {?
  154.             win = desktop.createWindow ({?
  155.                 id: 'grid-win',?
  156.                 title: 'Person Module',?
  157.                 width: 824,?
  158.                 height: 630,?
  159.                 iconCls: 'icon-grid',?
  160.                 shim: false,?
  161.                 animCollapse: false,?
  162.                 border: false,?
  163.                 constraintHeader: true,?
  164.  ?
  165.                 layout: 'border',?
  166.                 defaults: {?
  167.                     collapsible: false,?
  168.                     split: true,?
  169.                     border: false,?
  170.                     frame: false?
  171.                 },?
  172.                 items: [?
  173.                     {?
  174.                         title: false,?
  175.                         region: 'north',?
  176.                         height: 25,?
  177.                         items: myTopToolbar?
  178.                     },{?
  179.                         title: 'Search Pane',?
  180.                         region: 'west',?
  181.                         collapsible: true,?
  182.                         width: 150,?
  183.                         layout: 'accordion',?
  184.                         items: [{?
  185.                                 title: 'Search',?
  186.                                 html: personModuleFilterHTML?
  187.                         },{?
  188.                                 title: 'Saved Searches',?
  189.                                 html: 'Saved Search Results'?
  190.                         }]?
  191.                     },{?
  192.                         title: 'Data',?
  193.                         region: 'center',?
  194.                         items:?
  195.                             new Ext.TabPanel({?
  196.                                 activeTab: 0,?
  197.                                 items: [?
  198.                                     {?
  199.                                         title: 'Persons',?
  200.                                         xtype: 'grid',?
  201.                                         loadMask: true,?
  202.                                         height: 500,?
  203.                     store: store,?
  204.                     cm: colModel,?
  205.                     stripeRows: true,?
  206.                     bbar: new Ext.PagingToolbar({pageSize: 10, store: store, displayInfo: true})?
  207.                                     },{?
  208.                                         title: 'Charts & Graphs',?
  209.                                         id: 'personsChart'?
  210.                                     }?
  211.                                 ]?
  212.                             })?
  213.                     }?
  214.  ?
  215.                 ]?
  216.             })?
  217.         }?
  218.         win.show();?
  219.         drawChartView();?
  220.     }?
  221. });?
  222.  ?
  223.  ?
© 2011 Code Tidy  Terms and conditions