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 $(document).ready(function(){
25 //----------------------------------------
26 // Django Library Page CSS Fix
27 var fix_library_css = function() {
28 var tofix = Ext.fly('library-index-div');
31 tofix.select('*').addClass('djangocss');
37 //----------------------------------------
38 // Dynamically Generate Panels from HTML!
39 var create_dynamic_panels = function(){
40 var wp_items = Ext.fly('west_panel_items');
41 var ul_items = wp_items.query('ul');
43 var dynamic_panels = new Array();
44 Ext.each(ul_items, function(ul) {
45 var panel_obj = new Ext.Panel({
49 //titleCollapse: true,
52 //stateId: 'freezer_panel_state',
56 //stateEvents: ['collapse', 'expand']
58 dynamic_panels.push(panel_obj);
60 return dynamic_panels;
63 var panel_bcmagic = new Ext.Panel({
66 contentEl: 'bcmagic_div',
70 var menuPanel = new Ext.Panel({
78 //cmargins: '2 2 0 2',
89 // Add dynamically generated panels from html and include barcode magic
90 items: create_dynamic_panels().concat([panel_bcmagic])
95 //-------------------------------
97 //-------------------------------
98 var get_east_panel_content = function(){
99 // East panel contentEl id is supplied in html div id of east_region_config.
100 var east_id = Ext.fly('east_region_config').dom.textContent;
102 // Length of zero is a valid response... also happens to return null in next
103 // if statement if not handled before hand.
104 if (east_id.length == 0){
108 // If no element exists with the supplied content id, report and error.
109 if (Ext.fly(east_id) == null){
110 return 'east_region_config_error';
116 var east_panel_content_id = get_east_panel_content();
117 if (east_panel_content_id.length > 0){
118 var eastPanel = new Ext.Panel({
121 //margins: '0 2 0 2',
125 collapseMode: 'mini',
127 contentEl: east_panel_content_id
130 var eastPanel = new Ext.Panel({
133 //margins: '0 2 0 2',
138 collapseMode: 'mini',
145 //-------------------------------
146 // Main Viewport Setup
147 //-------------------------------
148 var mainBorderPanel = new Ext.Viewport({
169 handler: function() { quick_msg('Messages can be fun!'); }
180 collapseMode: 'mini',
190 //title: 'Inner Panel',
191 contentEl: 'body_content',
198 //-------------------------------
200 //-------------------------------
201 var main_tb = Ext.getCmp('main_toolbar');
203 var add_buttons_from_html = function(tb, bar_id){
204 var tbar_data = Ext.fly(bar_id);
205 var div_array = tbar_data.query('div');
207 // Loop through each div since it defines a button and link or a spacer and add it to the right side of the toolbar
208 Ext.each(div_array, function(divobj) {
210 if (div_id == 'spacer'){
215 handler: function() { goto_url(divobj.getAttribute('href')); }
221 // Fill in left side of main toolbar
222 add_buttons_from_html(main_tb, 'left_tbar_data');
224 // Shifts the remaining toolbar options to the right side.
225 main_tb.add({ xtype: 'tbfill' });
227 //----------------------------------------
228 // ExtJS Barcode Magic Implementation
229 var bcmagic_ext_keyhandler = function(sObj, e){
230 //Process upon enter key as input.
231 if (e.getKey() == e.ENTER)
235 var bcmagic_input = new Ext.form.TextField({
236 id: 'bcmagic_input_field',
237 emptyText: 'barcode magic'
239 bcmagic_input.on('specialkey', bcmagic_ext_keyhandler);
241 main_tb.add(bcmagic_input);
242 //--------------------------------------
244 var user_info = Ext.fly('login_info');
245 var logout_url = user_info.getAttribute('logouturl');
246 var login_url = user_info.getAttribute('loginurl');
248 if (user_info.getAttribute('authenticated') == 'true') {
251 text: 'User: ' + user_info.getAttribute('user')
254 add_buttons_from_html(main_tb, 'right_tbar_data');
258 handler: function() { goto_url(logout_url); }
264 handler: function() { goto_url(login_url) }
270 //-------------------------------
272 //-------------------------------
273 var app_tb = Ext.getCmp('app_toolbar');
274 add_buttons_from_html(app_tb, 'app_toolbar_west');
275 app_tb.add({ xtype: 'tbfill' });
276 add_buttons_from_html(app_tb, 'app_toolbar_east');
279 // Focus on barcode magic, because it's awesome and needs attention! ;-)
280 bcmagic_input.focus();
282 // FIXME: grid target temp code.
283 var grid_target = Ext.fly('grid_target');
284 if (grid_target != null){
285 var grid = getInventoryDataGrid();
286 grid.render(grid_target);