1 Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
3 Ext.override(Ext.Panel,{
5 return { collapsed: this.collapsed };
9 var quick_msg = function(msg)
14 buttons: Ext.MessageBox.OK,
15 icon: Ext.MessageBox.INFO
19 var goto_url = function(www_url)
21 window.location = www_url;
24 var RESIZEME_ARRAY = new Array();
26 var resize_registered_panel = function(pnl){
27 Ext.each(RESIZEME_ARRAY, function(fnc){
32 var resize_registered = function(cmp, adj_w, adj_h, raw_w, raw_h){
33 Ext.each(RESIZEME_ARRAY, function(fnc){
38 $(document).ready(function(){
39 //----------------------------------------
40 // Django Library Page CSS Fix
41 var fix_library_css = function() {
42 var tofix = Ext.fly('library-index-div');
45 tofix.select('*').addClass('djangocss');
51 //----------------------------------------
52 // Dynamically Generate Panels from HTML!
53 var create_dynamic_panels = function(){
54 var wp_items = Ext.fly('west_panel_items');
55 var ul_items = wp_items.query('ul');
57 var dynamic_panels = new Array();
58 Ext.each(ul_items, function(ul) {
59 var panel_obj = new Ext.Panel({
63 //titleCollapse: true,
66 //stateId: 'freezer_panel_state',
70 //stateEvents: ['collapse', 'expand']
72 dynamic_panels.push(panel_obj);
74 return dynamic_panels;
77 var panel_bcmagic = new Ext.Panel({
80 contentEl: 'bcmagic_div',
84 var menuPanel = new Ext.Panel({
92 //cmargins: '2 2 0 2',
103 // Add dynamically generated panels from html and include barcode magic
104 items: create_dynamic_panels().concat([panel_bcmagic])
109 //-------------------------------
111 //-------------------------------
112 var get_east_panel_content = function(){
113 // East panel contentEl id is supplied in html div id of east_region_config.
114 var east_id = Ext.fly('east_region_config').dom.textContent;
116 // Length of zero is a valid response... also happens to return null in next
117 // if statement if not handled before hand.
118 if (east_id.length == 0){
122 // If no element exists with the supplied content id, report and error.
123 if (Ext.fly(east_id) == null){
124 return 'east_region_config_error';
130 var east_panel_content_id = get_east_panel_content();
131 if (east_panel_content_id.length > 0){
132 var eastPanel = new Ext.Panel({
135 //margins: '0 2 0 2',
139 collapseMode: 'mini',
141 contentEl: east_panel_content_id
144 var eastPanel = new Ext.Panel({
147 //margins: '0 2 0 2',
152 collapseMode: 'mini',
159 //-------------------------------
160 // Main Viewport Setup
161 //-------------------------------
162 var mainBorderPanel = new Ext.Viewport({
163 //id: 'main_viewport',
166 id: 'north_border_panel',
185 handler: function() { quick_msg('Messages can be fun!'); }
196 collapseMode: 'mini',
200 id: 'body_content_panel',
208 //title: 'Inner Panel',
209 contentEl: 'body_content',
216 // Using a little trick to resize registered components:
217 // i.e. just use RESIZEME_ARRAY.push(function() { <code> }); to register a function
218 // to be called during these events.
219 mainBorderPanel.on('resize', resize_registered);
220 var northBorderPanel = Ext.getCmp('north_border_panel');
221 northBorderPanel.on('collapse', resize_registered_panel);
222 northBorderPanel.on('expand', resize_registered_panel);
225 //-------------------------------
227 //-------------------------------
228 var main_tb = Ext.getCmp('main_toolbar');
230 var add_buttons_from_html = function(tb, bar_id){
231 var tbar_data = Ext.fly(bar_id);
232 var div_array = tbar_data.query('div');
234 // Loop through each div since it defines a button and link or a spacer and add it to the right side of the toolbar
235 Ext.each(div_array, function(divobj) {
237 if (div_id == 'spacer'){
242 handler: function() { goto_url(divobj.getAttribute('href')); }
248 // Fill in left side of main toolbar
249 add_buttons_from_html(main_tb, 'left_tbar_data');
251 // Shifts the remaining toolbar options to the right side.
252 main_tb.add({ xtype: 'tbfill' });
254 //----------------------------------------
255 // ExtJS Barcode Magic Implementation
256 var bcmagic_ext_keyhandler = function(sObj, e){
257 //Process upon enter key as input.
258 if (e.getKey() == e.ENTER)
262 var bcmagic_input = new Ext.form.TextField({
263 id: 'bcmagic_input_field',
264 emptyText: 'barcode magic'
266 bcmagic_input.on('specialkey', bcmagic_ext_keyhandler);
268 main_tb.add(bcmagic_input);
269 //--------------------------------------
271 var user_info = Ext.fly('login_info');
272 var logout_url = user_info.getAttribute('logouturl');
273 var login_url = user_info.getAttribute('loginurl');
275 if (user_info.getAttribute('authenticated') == 'true') {
278 text: 'User: ' + user_info.getAttribute('user')
281 add_buttons_from_html(main_tb, 'right_tbar_data');
285 handler: function() { goto_url(logout_url); }
291 handler: function() { goto_url(login_url) }
297 //-------------------------------
299 //-------------------------------
300 var app_tb = Ext.getCmp('app_toolbar');
301 add_buttons_from_html(app_tb, 'app_toolbar_west');
302 app_tb.add({ xtype: 'tbfill' });
303 add_buttons_from_html(app_tb, 'app_toolbar_east');
306 // Focus on barcode magic, because it's awesome and needs attention! ;-)
307 bcmagic_input.focus();
309 // FIXME: grid target temp code.
310 var grid_target = Ext.fly('grid_target');
311 if (grid_target != null){
312 var grid = getInventoryDataGrid();
313 grid.render(grid_target);
314 RESIZEME_ARRAY.push(function() {
315 Ext.getCmp('inventory_item_panel').setHeight(Ext.getCmp('body_content_panel').getHeight()-4);
317 grid.setHeight(Ext.get('body_content_panel').getHeight()-4);