NetBook.Component = Ext.extend(Ext.util.Observable, {  ID: null, VIEW_ID: null,  HIDE_TOP_PANEL: false, controller: null,  visible: true,  constructor: function(config) { Ext.apply(this, config = config || {}); NetBook.Component.superclass.constructor.call(this, config); this.addEvents('initcomponent','beforeaddcomponent','addcomponent','beforeshow','show','beforeshowmenu','showmenu','backlevel1','backlevel2','collapsetoppanel','toppanelresize' ); this.initComponent(); this.initEvents();  }, initComponent: Ext.emptyFn,  initComponentComplete: Ext.emptyFn, beforeShow: Ext.emptyFn,  show: Ext.emptyFn,  beforeShowMenu: Ext.emptyFn,  showMenu: Ext.emptyFn,  getTopPanel: Ext.emptyFn,  getActions: Ext.emptyFn,  getContentPanel: Ext.emptyFn,  getMenuPanel: Ext.emptyFn,  doBackLevel1: function() { this.controller.showTopMenu();  },  doBackLevel2: function() { this.controller.getMainScreen().doBackLevel2(this.VIEW_ID);  },  doCollapseTopPanel: function() { this.controller.collapseTopPanel();  },  currentInterval : -1,  changeAdvert: function() {  if ((this.advertUrls) && (this.advertUrls.length > 1)) {if (this.currentInterval > 0) {  window.clearInterval(this.currentInterval);}this.currentInterval = window.setInterval(this.doChangeAdvert.createDelegate(this), this.advertUrls[this.advertIndex].interval*1000); }  },  doChangeAdvert: function() { if(!this.visible) {return; } this.advertIndex++; if(this.advertIndex >= this.advertUrls.length) {this.advertIndex = 0; } this.advertPanelObj.setSrc(this.advertUrls[this.advertIndex].url); this.advertPanelObj.getEl().fadeIn({endOpacity: 3, easing: 'easeIn',duration: 3 }); this.changeAdvert();  },  initEvents: function() { this.addListener('addcomponent', this.initComponentComplete.createDelegate(this)); this.addListener('beforeshow', this.beforeShow.createDelegate(this)); this.addListener('show', this.show.createDelegate(this)); this.addListener('beforeshowmenu', this.beforeShowMenu.createDelegate(this)); this.addListener('showmenu', this.showMenu.createDelegate(this)); this.addListener('backlevel1', this.doBackLevel1.createDelegate(this)); this.addListener('backlevel2', this.doBackLevel2.createDelegate(this)); this.addListener('collapsetoppanel', this.doCollapseTopPanel.createDelegate(this));  },  addBreadScrumbLevel3: function(title) { if (!this.hasListener('toppanelresize')) {this.addListener('toppanelresize', this.onTopPanelResize.createDelegate(this)); } this.controller.addBreadScrumbLevel3(this.VIEW_ID, title);  },  onBackLevel2Delegate: function() { this.fireEvent('backlevel2', this);  },  hideMenuLayer: function() { if (this.menuLayer) {if(!this.menuLayer.dockItemClicked) {  this.menuLayer.hide();}this.menuLayer.dockItemClicked = false; }  },  synMenuSize: function() { if (Ext.isIE) {this.menuLayer.setWidth('auto');this.menuLayer.setHeight('auto'); } else {this.menuLayer.setWidth(false);this.menuLayer.setHeight(false); }  },  getEmptyStyle: function(emptyText) { var div = '<div class="empty-info">' + emptyText + '</div>'; return div;  },  getMenuEmptyStyle: function(emptyText) { var div = '<div class="menu-empty-info">' + emptyText + '</div>'; return div;  },  onTopPanelResize: function(sender, adjWidth, adjHeight, rawWidth, rawHeight) { var level3ID = 'level3-btn-panel-' + this.VIEW_ID; if (!Ext.get(level3ID)) {return; } var p = thisMSObj.topPanel.findById('bread-scrumb-panel-' + this.VIEW_ID); var total = 10; for (var i = 0; i < p.items.getCount() - 1; i++) {total += p.items.itemAt(i).getEl().getWidth(); } var width = (adjWidth * 0.48 - 60) - total; var t = truncate(this.breadScrumbLevel3Title, width, 1, level3ID); Ext.get(level3ID).update('<div style="white-space: nowrap;">'+t+'</div>'); thisMSObj.topPanel.doLayout();  }});NetBook.BookmarkletHelperWindow = Ext.extend(NetBook.Component, {  id: NetBook.ID_BOOKMARKLET_HELPER_WINDOW,  title: NetBook.BOOKMARKLET_HELPERWINDOW_TITLE,  width: 460,  height: 412,  resizable: false,  initComponent: function() { NetBook.BookmarkletHelperWindow.superclass.initComponent.call(this); this.firefoxPanel = new Ext.Panel({id: 'bookmarklet-firefoxPanel',layout: 'fit',bodyStyle: 'background:transparent;',border: false,autoHeight:true,collapsed: false,items: [{  bodyStyle: 'background:transparent;padding: 5px 5px 0;p{font-size: 14px; padding: 5px;}',  border: false,  autoHeight:true,  collapsed: false,  html: '<p>' + this.getLink() + '</p>' + NetBook.FF_BOOKMARKLET_HELPER_MOVIE}] }); this.iePanel = new Ext.Panel({id: 'bookmarklet-iePanel',layout: 'fit',bodyStyle: 'background:transparent;',border: false,autoHeight: false,collapsed: false,items: [{  bodyStyle: 'background:transparent;padding: 5px 5px 0;p{font-size: 14px; padding: 5px;}',  border: false,  autoHeight:true,  collapsed: false,  html: '<p>' + this.getLink() + '</p>' + NetBook.IE_BOOKMARKLET_HELPER_MOVIE}] }); this.bodyPanel = new Ext.Panel({id: this.id,bodyStyle: 'background:transparent;padding: 5px 5px 0;',layout: 'card',activeItem: 0,border: false,autoHeight:true,collapsed: false,items: [this.firefoxPanel, this.iePanel]}); this.bookmarkWindow = new Ext.Window({title: this.title,layout: 'fit',bodyStyle: 'background:transparent;',width: this.width,height: this.height,collapsible: false,closable: false,plain: false,resizable: this.resizable,shadow: false,maximizable: false,minimizable: false,modal: true,tools: [{  id: 'close',  qtip: NetBook.ALL_TIP_HIDE,  handler: this.hide.createDelegate(this)}],items: [this.bodyPanel] });  },  show: function() { this.bookmarkWindow.show(); if (Ext.isGecko) {this.bodyPanel.layout.setActiveItem(0); } else if(Ext.isIE) {this.bodyPanel.layout.setActiveItem(1); }  },  hide: function() { this.bookmarkWindow.hide();  },  getLink: function() {var location = document.location;bookmarkletUrl = location.protocol + '//' + location.host;bookmarkletUrl += this.controller.getURL('bookmark', 'makeFrame') + '?let=bookmark';content = 'javascript:(function(){var%20s=document.createElement("script");s.charset="UTF-8";s.src="'+bookmarkletUrl+'";(document.getElementsByTagName("head")[0]||document.body).appendChild(s);})();';content = "<a href='" + content + "'>"+NetBook.BOOKMARKLET_HELPERWINDOW_LINK+"</a>";return content;  }});NetBook.ID_LIST_BOOKMARK_PANEL = 'nb-bookmark-list';NetBook.BookmarkPanel = Ext.extend(NetBook.Component, {  VIEW_ID: NetBook.ID_BOOKMARK_PANEL,  urlListBookmark: '',  urlBookmark: '',  urlDelete: '',  helperWindow: '',  initComponent: function() { NetBook.BookmarkPanel.superclass.initComponent.call(this); this.urlListBookmark = this.controller.getURL('bookmark', 'listBookmark'); this.urlBookmark = this.controller.getURL('bookmark', 'bookmark'); this.urlDelete = this.controller.getURL('bookmark', 'delete'); this.urlIncrement = this.controller.getURL('bookmark', 'increment'); this.contextMenuVisibled = false; thisBmObj = this; this.bookmarkStore = new Ext.data.JsonStore({url: this.urlListBookmark,autoLoad: false,root: 'items',id: 'id',fields: ['id', 'name', 'location', 'no_name', 'icon'] }); var columns = [{dataIndex: 'name',tpl: "<div id='bookmark-menu-{id}' class='dropdown-menu'></div>" + "<div style='margin-left: 25px;'><img src='{icon}' class='favicon'/><div class='name'>{name}</div><br/><div class='location'>{location}</div></div>" }]; this.bookmarkListPanel = new Ext.ListView({id: NetBook.ID_LIST_BOOKMARK_PANEL,bodyStyle: 'margin-top: 5px;',store: this.bookmarkStore,columns: columns,hideHeaders: true,border:false,singleSelect: true,loadingText: NetBook.ALL_LOADING,deferEmptyText: true,emptyText: this.getEmptyStyle(NetBook.BOOKMARK_PANEL_EMPTY_MSG),prepareData: function(data) {  data.name = data.name ? data.name : data.no_name;  return data;} }); var contentPanel = new Ext.Panel({region: 'center',border: true,autoScroll: true,items: this.bookmarkListPanel }); this.view = new Ext.Panel({border: false,autoScroll: true,layout: 'border',items : [contentPanel] }); this.contextMenu = new Ext.menu.Menu({id: 'bookmark-menu',items: [{  text: NetBook.BOOKMARK_PANEL_CONTEXTMENU_EDIT,  iconCls: 'menu-bookmark-edit',  handler: this.executeEditBookmark.createDelegate(this)},{  text: NetBook.BOOKMARK_PANEL_CONTEXTMENU_DELETE,  iconCls: 'menu-bookmark-delete',  handler: this.onDeleteNodeConfirm.createDelegate(this)}] }); this.bookmarkStore.on('load', this.onStoreLoad, this); this.bookmarkListPanel.on('click', this.onBookmarkListClick, this); this.contextMenu.on({'show': this.onShowContextMenu,'hide': this.onHideContextMenu,scope: this });  },  getActions: function() { return Array({id: 'add-bm-btn', cls: 'add-bm-btn', clickListener: this.executeBookmark.createDelegate(this), title: NetBook.BOOKMARK_PANEL_TIP_NEWBOOKMARK},{id: 'bmlet-btn', cls: 'bmlet-btn', clickListener: this.showHelper.createDelegate(this), title: NetBook.BOOKMARK_PANEL_TIP_BOOKMARKLET});  },  getContentPanel: function() { return this.view;  },  initComponentComplete: function() { this.bookmarkStore.load();  },  onStoreLoad: function(sender, records, options) { for(var i = 0; i < sender.getCount(); i++) {Ext.get('bookmark-menu-' + sender.getAt(i).get('id')).on('click', function() {  thisBmObj.contextMenu.show(this.id);}); }  },  onShowContextMenu: function() { this.contextMenuVisibled = true;  },  onHideContextMenu: function() { this.contextMenuVisibled = false;  },  onBookmarkListClick: function(sender, index) { if (this.contextMenuVisibled) {return; } var record = sender.store.getAt(index); this.controller.openURL(record.get('location'), true); this.addBreadScrumbLevel3(record.get('name') ? record.get('name') : record.get('no_name')); this.incrementUsedCount(record.get('id'));  },  executeBookmark: function(sender) { if (!this.popup) {this.popup = new NetBook.BookmarkWindow({controller: this.controller, callback: this.initComponentComplete.createDelegate(this)}); } this.popup.show();  },  executeEditBookmark: function() { if (!this.popup) {this.popup = new NetBook.BookmarkWindow({controller: this.controller, callback: this.initComponentComplete.createDelegate(this)}); } var record = this.bookmarkListPanel.getSelectedRecords()[0]; var data = {id: record.get('id'),action_type: 'edit',name: record.get('name'),location: record.get('location') }; this.popup.show(data);  },  executeDelete: function(sender) {if ('no' == sender) return;var record = this.bookmarkListPanel.getSelectedRecords()[0];var id = record.get('id');showWaitingDlg(null, NetBook.ALL_BTN_WAIT);Ext.Ajax.request({  url: this.urlDelete,  params: { nodeId: id, leaf: 'true'  },  success: function(form, action) { hideWaitingDlg(); thisBmObj.bookmarkStore.load();  },  failure: function(form, action) { hideWaitingDlg(); showActionFailureDlg(action);  }}); },  onDeleteNodeConfirm: function() { var record = this.bookmarkListPanel.getSelectedRecords()[0]; if (record) {showConfirm(NetBook.BOOKMARK_PANEL_DELETE_CONFIRM_TXT1, this.executeDelete.createDelegate(this)); } else {showMessage(NetBook.BOOKMARK_PANEL_DELETE_CONFIRM_TXT2); }  },  showHelper: function() { if (!this.helperWindow) {this.helperWindow = new NetBook.BookmarkletHelperWindow({  controller: this.controller}); } this.helperWindow.show();  },  incrementUsedCount: function(id) { Ext.Ajax.request({url: this.urlIncrement,params: {  id: id},success: function(form, action) {},failure: function(form, action) {} });  }});NetBook.BookmarkWindow = Ext.extend(NetBook.Component, {  id: NetBook.ID_BOOKMARK_WINDOW,  title: NetBook.BOOKMARK_PANEL_NEWBOOKMARK_FORM_TITLE,  width: 300,  height: 200,  resizable: false,  callback: Ext.emptyFn,  initComponent: function() { NetBook.BookmarkWindow.superclass.initComponent.call(this); thisBmwObj = this; this.urlBookmark = this.controller.getURL('bookmark', 'bookmark'); this.bodyPanel = new Ext.form.FormPanel({id: this.id,labelAlign:'top',bodyStyle: 'padding:10px;',border: false,autoHeight:true,defaultType: 'textfield',buttonAlign: 'center',layoutConfig: {  labelSeparator: ''},defaults: {  msgTarget: 'under'},collapsed: false,items:[{  xtype: 'hidden',  name: 'id'},{  xtype: 'hidden',  name: 'action_type'},{ fieldLabel: NetBook.BOOKMARK_PANEL_NEWBOOKMARK_LBL_TITLE, name: 'name', anchor: '100%'  },  { fieldLabel: NetBook.BOOKMARK_PANEL_NEWBOOKMARK_LBL_LOCATION, name: 'location', anchor: '100%', validationEvent: false, validateOnBlur: false, value: 'http://'  }], keys: [{ key: Ext.EventObject.ENTER, fn: this.executeBookmark.createDelegate(this), scope: this }], buttons: [{ text: NetBook.ALL_BTN_DONE, handler: this.executeBookmark.createDelegate(this)  },  { text: NetBook.ALL_BTN_CANCEL, handler: this.hide.createDelegate(this)  }]}); this.bookmarkWindow = new Ext.Window({title: this.title,bodyStyle: 'background:transparent;',width: this.width,height: this.height,border: false,collapsible: false,closable: false,resizable: this.resizable,maximizable: false,minimizable: false,modal: true,plain: false,shadow: false,tools: [{  id: 'close',  qtip: NetBook.ALL_TIP_HIDE,  handler: this.hide.createDelegate(this)}],items: [this.bodyPanel] });  },  show: function(data) { if(data) {this.bookmarkWindow.setTitle(NetBook.BOOKMARK_PANEL_EDITBOOKMARK_FORM_TITLE); } else {this.bookmarkWindow.setTitle(NetBook.BOOKMARK_PANEL_NEWBOOKMARK_FORM_TITLE);data = {}; } this.bookmarkWindow.show(); var form = this.bodyPanel.getForm(); form.clearInvalid(); form.findField('id').setValue(data.id); form.findField('action_type').setValue(data.action_type ? data.action_type : 'new'); form.findField('name').setValue(data.name); form.findField('location').setValue(data.location ? data.location : 'http://'); window.setTimeout(function() {var form = thisBmwObj.bodyPanel.getForm();form.findField('name').focus();form.findField('name').selectText(); }, 500);  },  hide: function() { this.bookmarkWindow.hide();  },  executeBookmark: function(sender) { var form = this.bodyPanel.getForm(); var location = form.findField('location'); if(!location.getValue() || location.getValue() == 'http://') {setErrField(form, 'location', NetBook.BOOKMARK_PANEL_NEWBOOKMARK_ERR1);return; } showWaitingDlg(this.bookmarkWindow.getEl(), NetBook.ALL_BTN_WAIT); form.submit({url: this.urlBookmark ,params: {  folderId: 'source'},success: function(form, action) {  hideWaitingDlg(thisBmwObj.bookmarkWindow.getEl());  thisBmwObj.hide();  thisBmwObj.callback();},failure: function(form, action) {  hideWaitingDlg(thisBmwObj.bookmarkWindow.getEl());  showActionFailureDlg(action);} });  }});NetBook.ID_CALENDAR_PANEL = 'nb-calendar';NetBook.CalendarPanel = Ext.extend(NetBook.Component, {  VIEW_ID: NetBook.ID_CALENDAR_PANEL,  initComponent: function() { NetBook.CalendarPanel.superclass.initComponent.call(this); this.urlCalendarUser = this.controller.getURL('calendar', 'user'); this.calendarUserStore = new Ext.data.JsonStore({url: this.urlCalendarUser,fields: ['id', 'title', 'description', 'webcalendar_url', 'small_icon', 'large_icon', 'over_large_icon', 'index', 'is_in_system', 'target'] }); this.calendarUserStore.setDefaultSort('index', "ASC"); this.calendarUserTpl = new Ext.XTemplate('<tpl for=".">','<div class="thumb-wrap">','<div class="thumb"><table cellspacing="0" cellpadding="0"><tr><td><img src="{large_icon_path}"/></td><td align="left">{other_title}</td></tr></table></div>','</div>','</tpl>' ); thisMailObj = this; this.calendarUserView = new Ext.DataView({store: this.calendarUserStore,tpl: this.calendarUserTpl,multiSelect: false,overClass: 'x-view-over',itemSelector: 'div.thumb-wrap',loadingText: NetBook.ALL_LOADING,deferEmptyText: true,emptyText: this.getMenuEmptyStyle(NetBook.CALENDAR_PANEL_EMPTY_MSG),prepareData: function(data) {  if (data.is_in_system == 0) { data.other_title = data.title;  }  data.large_icon_path = thisMailObj.controller.getImagePath(data.large_icon);  return data;} }); this.calendarUserPanel = new Ext.Panel({id: 'calendar-nav-panel',header :false,border:false,items: [this.calendarUserView] }); this.view = new Ext.Panel({id: this.id,title: this.title,autoScroll: true,header :false,border:false,items : [this.calendarUserPanel] }); this.calendarUserView.addListener("click", this.onCalendarUserClick.createDelegate(this)); this.calendarUserStore.on('load', this.synMenuSize.createDelegate(this));  },  getMenuPanel: function() { return this.view;  },  showMenu: function() { this.calendarUserStore.reload(); this.view.doLayout();  },  onCalendarUserClick: function(object, index, event) { var data = this.calendarUserStore.getAt(index); var url = data.get('webcalendar_url'); var target = data.get('target'); if (target == 'blank') {this.controller.openURLByNewBrowser(url); } else {this.controller.openURL(url, true, true); } this.controller.reloadGAScript(this.gaURL + '/' + data.get('title'));  }});NetBook.ID_DOCK_NAV_PANEL = 'nb-dock-nav-panel';URL_COMBO_WIDTH = 465,KEYWORD_TXT_FIELD_WIDTH = 465,NetBook.DockScreen = Ext.extend(NetBook.Component, {  VIEW_ID: NetBook.ID_DOCKSCREEN,  initComponent: function() { NetBook.DockScreen.superclass.initComponent.call(this); thisDockObj = this; this.intervalIDs = new Array(); this.carousel = null; this.urlChgAddrBarType = this.controller.getURL('setting', 'changeAddrBarType'); this.urlComponent = this.controller.getURL('component', 'index'); this.urlHistory = this.controller.getURL('history', 'search'); this.template = new Ext.XTemplate('<div id="carousel_container" class="carousel_container_style">','<tpl for=".">','<a>','<div class="nb-dockscreen-com-wrap">','<div class="nb-dockscreen-com"><img id="nb-dockscreen-{id}" src="{icon}" class="nb-dockscreen-img"','onMouseOver="onMouseOver(this, &quot;{icon}&quot;, &quot;{over_icon}&quot;)" ','onMouseOut="onMouseOut(this, &quot;{icon}&quot;, &quot;{over_icon}&quot;)" ','onMouseDown="onMouseDown(this, &quot;{icon}&quot;, &quot;{sel_icon}&quot;)"/></div>','</div>','<span>{title}</span>','</a>','</tpl>','</div>' ); this.store = new Ext.data.JsonStore({url: this.urlComponent,autoLoad: false,root: 'components',id: 'id',fields: ['id', 'class_name', 'title', 'description', 'icon', 'over_icon', 'sel_icon', 'adverts', 'externalLink', 'ga_url'] }); this.dataView = new Ext.DataView({itemSelector: 'div.nb-dockscreen-com-wrap',overClass: 'x-view-over',selectedClass: 'x-view-selected',style: 'overflow:auto',singleSelect: true,store: this.store,tpl: this.template,height: NetBook.TOP_PANEL_AD_HEIGHT }); this.historyStore = new Ext.data.JsonStore({url: this.urlHistory,root: 'history',id: 'id',fields: ['id', 'title', 'url', 'favicon'] }); this.urlComboBox = new Ext.form.ComboBox({id: 'url-combobox',store: this.historyStore,emptyText: NetBook.DASHBOARD_PANEL_URLCOMBOBOX_BLANK_TXT,displayField: 'url',typeAhead: false,queryDelay: 200,minChars: 0,editable: true,width: URL_COMBO_WIDTH,allQuery: '_all_history_',triggerAction: 'all',loadingText: NetBook.DASHBOARD_PANEL_URLCOMBOBOX_TXT,itemSelector: 'div.nb-address-item',minListWidth: URL_COMBO_WIDTH,tpl: new Ext.XTemplate(  '<tpl for=".">' +  '<div class="nb-address-item">' + '<table cellspacing="0" cellpadding="0" border="0" width="100%"><tbody>' + '<tr>' +'<td style="width:16px;"><image src="{favicon}" width="16px" height="16px"/></td>' +'<td nowrap="nowrap"><div class="nb-address-item-title"><span>{[this.truncate(values.title,410,"url-combobox")]}</span></div></td>' + '</tr>' + '<tr>' +'<td>&nbsp;</td>' +'<td nowrap="nowrap"><div class="nb-address-item-url"><span>{[this.truncate(values.url,410,"url-combobox")]}</span></div></td>' + '</tr>' + '</tbody></table>' +  '</div>' +  '</tpl>',{ truncate: function(title,width,id)  {var formater = Ext.util.Format;var textMetric = Ext.util.TextMetrics.createInstance(document.getElementById(id));var truncatedContent;if (textMetric.getWidth(title) <= width) { truncatedContent = title;}else { var i = 0; while (textMetric.getWidth(formater.ellipsis(title, i)) <= width) {i++; } truncatedContent = formater.ellipsis(title, i - 1);}return truncatedContent; }}) }); this.keywordTfield = new Ext.form.TextField({id: 'keyword',width: KEYWORD_TXT_FIELD_WIDTH,emptyText: NetBook.DASHBOARD_PANEL_KEYWORD_BLANK_TXT }); this.urlComboBoxPanel = new Ext.Panel({border: false,autoWidth: true,autoHeight: true,bodyStyle: 'padding: 1px 0px 1px 0px;',items: [this.urlComboBox] }); this.keywordTfieldPanel = new Ext.Panel({border: false,autoWidth: true,autoHeight: true,bodyStyle: 'padding: 1px 0px 1px 0px;',items: [this.keywordTfield] }); this.inputPanel = new Ext.Panel({layout: 'card',activeItem: 0,border: false,bodyStyle: 'padding: 0px',autoWidth: true,items: [this.urlComboBoxPanel, this.keywordTfieldPanel],keys: [{  key: Ext.EventObject.ENTER,  fn: this.onEnter.createDelegate(this),  scope: this}] }); var emptyBtnPanel = new Ext.Panel({border: false,width: 10,height: NetBook.TOP_PANEL_NAVIGATION_HEIGHT }); var homeBtnPanel = new Ext.Panel({cls: 'home-btn',id: 'home-btn-child-panel',bodyStyle: 'padding-left: 5px',border: false,width: 34 }); var sepBtnPanel = new Ext.Panel({cls: 'separator-btn',bodyStyle: 'padding-top: 5px;',border: false,width: 5,height: 20 }); this.inputTypePanel = new Ext.Panel({id: 'input-type-panel',bodyStyle: 'padding-left: 5px',border: false,width: 34,html: "<div class='url' id='menu-input-type'></div>" }); var collapse2BtnPanel = new Ext.Panel({id: 'collapse2-btn',border: false,height: NetBook.TOP_PANEL_NAVIGATION_HEIGHT,width: 639 }); var addressPanel = new Ext.Panel({region: 'center',border: false,layout: 'table',layoutConfig: {  columns: 6},items: [  emptyBtnPanel,  {id: 'home-btn-panel', border: false, items: homeBtnPanel},  sepBtnPanel, this.inputTypePanel, this.inputPanel, collapse2BtnPanel] }); var logoutBtnPanel = new Ext.Panel({cls: 'logout-btn',id: 'logout-btn-child-panel',border: false }); var navigationPanel = new Ext.Panel({id: NetBook.ID_DOCK_NAV_PANEL,layout: 'border',border: false,header: false,height: NetBook.TOP_PANEL_NAVIGATION_HEIGHT,items: [addressPanel, {id: 'logout-btn-panel', region: 'east', width: 34, border: false, bodyStyle: 'padding-top: 1px', items: logoutBtnPanel}] }); this.view = new Ext.Panel({id: this.VIEW_ID,border: false,header: false,items: [this.dataView, navigationPanel] }); this.inputContextMenu = new Ext.menu.Menu({id: 'input-context-menu',items: [{  text: ' ' + NetBook.DASHBOARD_PANEL_CONTEXTMENU_URL,  iconCls: 'menu-input-url',  handler: this.executeMenuInputUrl.createDelegate(this)},{  text: NetBook.DASHBOARD_PANEL_CONTEXTMENU_SEARCH,  iconCls: 'menu-input-search',  handler: this.executeMenuInputKeyword.createDelegate(this)}] }); this.store.on('load', this.initCarousel.createDelegate(this)); this.dataView.addListener("click", this.onComponentClick.createDelegate(this)); this.urlComboBox.addListener('select', this.addrOnEnter.createDelegate(this)); this.view.on('resize', this.onResize.createDelegate(this)); homeBtnPanel.on('afterrender', function() {var btn = Ext.get('home-btn-panel');btn.on('click', thisDockObj.onGoHome.createDelegate(thisDockObj));btn.set({title: NetBook.DASHBOARD_PANEL_TIP_HOMEPAGE});btn = Ext.get('home-btn-child-panel');btn.addClassOnClick('click');btn.addClassOnOver('over'); }); logoutBtnPanel.on('afterrender', function() {var btn = Ext.get('logout-btn-panel');btn.on('click', thisDockObj.onLogout.createDelegate(thisDockObj));btn.set({title: NetBook.DASHBOARD_PANEL_TIP_LOGOUT});btn = Ext.get('logout-btn-child-panel');btn.addClassOnClick('click');btn.addClassOnOver('over'); }); this.inputTypePanel.on('afterrender', function() {var inputButton = Ext.get('menu-input-type');if(inputButton) {  inputButton.on('click', function() { thisDockObj.inputContextMenu.show(Ext.get('menu-input-type'));  });} }); collapse2BtnPanel.on('afterrender', function() {var btn = Ext.get('collapse2-btn');btn.on('click', function() {  thisDockObj.fireEvent('collapsetoppanel', thisDockObj);}); });  },  getTopPanel: function() { return this.view;  },  initComponentComplete: function() { this.store.load();  },  onResize: function(sender, adjWidth, adjHeight) { if(this.carousel) {this.carousel.refresh(adjWidth); } this.view.doLayout();  },  activeComponent: function(componentId) { var data = this.store.getById(componentId); if(data.clicked) {this.controller.show(data.VIEW_ID);return; } var component = this.controller.createComponent(data); if (component) {data.clicked = true;data.VIEW_ID = component.VIEW_ID;this.controller.addComponent(component, true);data.hasMenu = component.hasMenu;component.gaURL = data.get('ga_url'); }  },  onComponentClick: function(sender, index) { var data = this.store.getAt(index); if(!data.clicked) {var component = this.controller.createComponent(data);data.clicked = true;data.VIEW_ID = component.VIEW_ID;this.controller.addComponent(component, false);data.hasMenu = component.hasMenu;component.gaURL = data.get('ga_url'); } if(data.hasMenu) {this.controller.showAsMenu(data.VIEW_ID); } else {this.controller.show(data.VIEW_ID); }  },  setActiveComponent: function(componentId) { this.componentId = componentId; this.showComponent();  },  showComponent: function() { if (this.store.getCount() > 0) {for (var i = 0; i < this.intervalIDs.length; i++) {  window.clearInterval(this.intervalIDs[i]);}this.activeComponent(this.componentId); } else {var intervalID = window.setInterval(this.showComponent.createDelegate(this), 200);this.intervalIDs.push(intervalID); }  },  initCarousel: function() { this.carousel = new Ext.ux.Carousel('carousel_container');  },  refresh: function() { if (!this.carousel) {return; } var el = this.carousel.els.slidesWrap; if (el && el.getWidth() == 0) {this.store.reload(); }  },  onEnter: function() { var type = this.controller.getUser().addrBarType; if (type == 0) {this.addrOnEnter(); } else {this.keywordOnEnter(); }  },  addrOnEnter: function() { this.urlComboBox.collapse(); var url = this.urlComboBox.getValue(); if (url && url.trim().length > 0) {if ((url.search("http://")!=0)&&(url.search("https://")!=0)) {  url = 'http://'+url;}this.controller.openURL(url); }  },  keywordOnEnter: function() { var keyword = this.keywordTfield.getValue().trim(); if (!keyword) {  return; } url = NetBook.SEARCH_ENGINE_URL + '&' + NetBook.SEARCH_ENGINE_QUERY_PARAM + '=' + keyword; this.controller.openURL(url, true, true);  },  executeMenuInputUrl: function() { this.showInputUrl(); this.changeAddrBarType(0);  },  executeMenuInputKeyword: function() { this.showInputKeyword(); this.changeAddrBarType(1);  },  setAddressBarType: function(type) { if(this.inputPanel.rendered) {if (type == 0) {  this.showInputUrl();} else {  this.showInputKeyword();} }  },  showInputUrl: function() { this.urlComboBox.setValue(this.keywordTfield.getValue()); this.inputPanel.layout.setActiveItem(0); this.urlComboBox.focus(); Ext.getDom('menu-input-type').className = 'url';  },  showInputKeyword: function() { this.keywordTfield.setValue(this.urlComboBox.getValue()); this.inputPanel.layout.setActiveItem(1); this.keywordTfield.focus(); Ext.getDom('menu-input-type').className = 'search';  },  changeAddrBarType: function(type) { Ext.Ajax.request({url: this.urlChgAddrBarType,params: {  type: type},success: function(result) {  thisDockObj.controller.getUser().addrBarType = type;},failure: function(form, action) {} });  },  onGoHome: function() { this.controller.goHome();  },  onGoBack: function() { this.controller.goBack();  },  onGoNext: function() { this.controller.goNext();  },  onLogout: function() { this.controller.logout();  }});onMouseOver = function(img, icon, over_icon) {  img.src = over_icon;};onMouseOut = function(img, icon, over_icon) {  img.src = icon;};onMouseDown  = function(img, icon, active_icon) {  img.src = active_icon;};

NetBook.ID_NAV_DOCUMENT_PANEL = 'nb-nav-document';

NetBook.DocumentPanel = Ext.extend(NetBook.Component, {

  VIEW_ID: NetBook.ID_DOCUMENT_PANEL,

  initComponent: function() {
    NetBook.DocumentPanel.superclass.initComponent.call(this);

    thisDocObj = this;
    this.urlListDocument = this.controller.getURL('document', 'index');
    this.urlDelete = this.controller.getURL('document', 'delete');
    this.urlDownload = this.controller.getURL('document', 'download');
    this.urlDocUser = this.controller.getURL('document', 'user');

    this.urlEdit = this.controller.getURL('document', 'edit');

    this.docUserStore = new Ext.data.JsonStore({
      url: this.urlDocUser,
      fields: ['id', 'title', 'description', 'webdoc_url', 'small_icon', 'large_icon', 'over_large_icon', 'index', 'is_in_system', 'target']
    });
    this.docUserStore.setDefaultSort('index', "ASC");

    this.docUserTpl = new Ext.XTemplate(
      '<tpl for=".">',
      '<div class="thumb-wrap">',
      '<div class="thumb"><table cellspacing="0" cellpadding="0"><tr><td><img src="{large_icon_path}"/></td></tr></table></div>',
      '</div>',
      '</tpl>'
    );

    this.docUserView = new Ext.DataView({
      store: this.docUserStore,
      tpl: this.docUserTpl,
      multiSelect: false,
      overClass: 'x-view-over',
      itemSelector: 'div.thumb-wrap',
      loadingText: NetBook.ALL_LOADING,
      deferEmptyText: true,
      emptyText: this.getMenuEmptyStyle(NetBook.DOCUMENT_PANEL_EMPTY_MSG),
      prepareData: function(data) {
        if (data.is_in_system == 0) {
          data.other_title = '<span class="x-other-title">'+ data.title +'</span></div>';
        }
        data.large_icon_path = thisDocObj.controller.getImagePath(data.large_icon);
        return data;
      }
    });

    this.docUserPanel = new Ext.Panel({
      id: 'doc-nav-panel',
      header :false,
      border:false,
      items: [this.docUserView]
    });

    this.internalStore = new Ext.data.JsonStore({
      url: this.urlListDocument,
      root: 'items',
      fields: ['id', 'name', {name:'size', type: 'float'}, 'icon_thumb', 'icon_list', 'created_at', 'updated_at','can_edit']
    });

    var columns = [
    {
      id: 'icon',
      dataIndex: 'id',
      header: "",
      width: 40,
      sortable: false,
      fixed: true,
      renderer: this.formatListIcon
    },
    {
      id: 'name',
      header: NetBook.DOCUMENT_PANEL_LISTPANEL_COL_NAME,
      dataIndex: 'name',
      sortable: true,
      renderer: this.formatName
    },
    {
      id: 'updated_at',
      header: NetBook.DOCUMENT_PANEL_LISTPANEL_COL_MODIFY,
      dataIndex: 'updated_at',
      sortable: true,
      fixed: true,
      width: 200,
      renderer: this.formatDate
    },
    {
      id: 'size',
      header: NetBook.DOCUMENT_PANEL_LISTPANEL_COL_SIZE,
      align: 'right',
      dataIndex: 'size',
      sortable: true,
      fixed: true,
      width: 120,
      renderer: this.formatSize
    }];

    this.listPanel = new Ext.grid.GridPanel({
      id: 'doc-list-view',
      region: 'center',
      store: this.internalStore,
      columns: columns,
      hideHeaders: false,
      stripeRows: true,
      autoHeight: true,
      enableHdMenu: false,
      border: false,
      loadMask: { msg:NetBook.ALL_LOADING },
      sm: new Ext.grid.RowSelectionModel({
        singleSelect:true
      }),
      viewConfig: {
        forceFit: true,
        deferEmptyText: true,
        emptyText: this.getEmptyStyle(NetBook.DOCUMENT_PANEL_NOFILE_MSG)
      },
      header:false
    });

    this.view = new Ext.Panel({
      border: false,
      autoScroll: true,
      layout: 'border',
      items : [this.listPanel]
    });

    this.contextMenu = new Ext.menu.Menu({
      id: 'mainMenu',
      items: [
      {
        text: NetBook.DOCUMENT_PANEL_CONTEXTMENU_DOWNLOAD,
        iconCls: 'menu-document-download',
        handler: this.executeDownload.createDelegate(this)
      },

      {
        text: NetBook.DOCUMENT_PANEL_CONTEXTMENU_EDIT,
        iconCls: 'menu-document-edit',
        handler: this.executeEdit.createDelegate(this)
      },
      {
        text: NetBook.DOCUMENT_PANEL_CONTEXTMENU_COPY,
        iconCls: 'menu-document-copy',
        handler: this.executeCopy.createDelegate(this)
      },
      {
        text: NetBook.DOCUMENT_PANEL_CONTEXTMENU_RENAME,
        iconCls: 'menu-document-rename',
        handler: this.executeRename.createDelegate(this)
      },
      {
        text: NetBook.DOCUMENT_PANEL_CONTEXTMENU_DELETE,
        iconCls: 'menu-document-delete',
        handler: this.executeDeleteConfirm.createDelegate(this)
      }
      ]
    });

    this.contextMenuWithoutEdit = new Ext.menu.Menu({
      id: 'mainMenuWithoutEdit',
      items: [
      {
        text: NetBook.DOCUMENT_PANEL_CONTEXTMENU_DOWNLOAD,
        iconCls: 'menu-document-download',
        handler: this.executeDownload.createDelegate(this)
      },
      {
        text: NetBook.DOCUMENT_PANEL_CONTEXTMENU_COPY,
        iconCls: 'menu-document-copy',
        handler: this.executeCopy.createDelegate(this)
      },
      {
        text: NetBook.DOCUMENT_PANEL_CONTEXTMENU_RENAME,
        iconCls: 'menu-document-rename',
        handler: this.executeRename.createDelegate(this)
      },
      {
        text: NetBook.DOCUMENT_PANEL_CONTEXTMENU_DELETE,
        iconCls: 'menu-document-delete',
        handler: this.executeDeleteConfirm.createDelegate(this)
      }
      ]
    });

    this.docUserView.addListener("click", this.onDocUserClick.createDelegate(this));
    this.listPanel.on('cellclick', this.onCellClick, this);
    this.docUserStore.on('load', this.synMenuSize.createDelegate(this));
  },

  getMenuPanelBk: function() {
    return this.docUserPanel;
  },

  showMenu: function() {
    this.docUserStore.reload();
    this.docUserPanel.doLayout();
  },

  getActions: function() {
    return Array(
      {id: 'upload-btn', cls: 'upload-btn', clickListener: this.executeUpload.createDelegate(this), title: NetBook.DOCUMENT_PANEL_TIP_UPLOAD},
      {id: 'writer-btn', cls: 'writer-btn', clickListener: this.executeWriter.createDelegate(this), title: NetBook.DOCUMENT_PANEL_TIP_WRITER},
      {id: 'sheet-btn', cls: 'sheet-btn', clickListener: this.executeSheet.createDelegate(this), title: NetBook.DOCUMENT_PANEL_TIP_SHEET},
	  {id: 'show-btn', cls: 'show-btn', clickListener: this.executeShow.createDelegate(this), title: NetBook.DOCUMENT_PANEL_TIP_SHOW},
	  {id: 'help-btn', cls: 'help-btn', clickListener: this.executeHelp.createDelegate(this), title: NetBook.DOCUMENT_PANEL_TIP_HELP}
	  );
  },

  getContentPanel: function() {
    return this.view;
  },

  initComponentComplete: function() {
    this.internalStore.load();
  },

  executeUpload: function() {
    if (!this.popup) {
      this.popup = new NetBook.DocumentWindow({controller: this.controller, callback: this.initComponentComplete.createDelegate(this)});
    }
    this.popup.show();
  },


  executeWriter: function() {
    if (!this.popup) {
      this.popup = new NetBook.DocumentWindow({controller: this.controller, callback: this.initComponentComplete.createDelegate(this)});
    }
    var data = {
      action_type: 'newwriter'
    };
    this.popup.show(data);
  },

  executeSheet: function() {
    if (!this.popup) {
      this.popup = new NetBook.DocumentWindow({controller: this.controller, callback: this.initComponentComplete.createDelegate(this)});
    }
    var data = {
      action_type: 'newsheet'
    };
    this.popup.show(data);
  },

  executeShow: function() {
    if (!this.popup) {
      this.popup = new NetBook.DocumentWindow({controller: this.controller, callback: this.initComponentComplete.createDelegate(this)});
    }
    var data = {
      action_type: 'newshow'
    };
    this.popup.show(data);
  },

  executeHelp: function() {
	  window.open('/ax/help/storage/can.php');
  },


  executeDownload: function() {
    var record = this.listPanel.getSelectionModel().getSelected();
    var iframe = document.createElement("iframe");
    iframe.src = this.urlDownload + "?id=" + record.get('id');
    iframe.style.display = "none";
    document.body.appendChild(iframe);
  },

  executeDeleteConfirm: function() {
    var record = this.listPanel.getSelectionModel().getSelected();
    if (record) {
      showConfirm(NetBook.DOCUMENT_PANEL_DELETE_CONFIRM, this.executeDelete.createDelegate(this));
    } else {
        showMessage(NetBook.DOCUMENT_PANEL_DELETE_MSG);
    }
  },

  executeDelete: function(sender) {
    if ('no' == sender) return;
    var record = this.listPanel.getSelectionModel().getSelected();
    var id = record.get('id');
    showWaitingDlg(null, NetBook.ALL_BTN_WAIT);
    Ext.Ajax.request({
      url: this.urlDelete,
      params: {
        id: id
      },
      success: function(form, action) {
        hideWaitingDlg();
        thisDocObj.internalStore.load();
      },
      failure: function(form, action) {
        hideWaitingDlg();
        showActionFailureDlg(action);
      }
    });
  },

  executeRename: function() {
    if (!this.popup) {
      this.popup = new NetBook.DocumentWindow({controller: this.controller, callback: this.initComponentComplete.createDelegate(this)});
    }
    var record = this.listPanel.getSelectionModel().getSelected();
    var data = {
      id: record.get('id'),
      action_type: 'rename',
      name: record.get('name')
    };
    this.popup.show(data);
  },

  executeCopy: function() {
    if (!this.popup) {
      this.popup = new NetBook.DocumentWindow({controller: this.controller, callback: this.initComponentComplete.createDelegate(this)});
    }
    var record = this.listPanel.getSelectionModel().getSelected();
    var data = {
      id: record.get('id'),
      action_type: 'copy',
      name: record.get('name')
    };
    this.popup.show(data);
  },

  executeEdit: function() {
    var record = this.listPanel.getSelectionModel().getSelected();
    window.open(this.urlEdit + "?id=" + record.get('id'));
  },



  onCellClick: function(grid, rowIndex, colIndex, event) {
    var record = this.internalStore.getAt(rowIndex);
    if (colIndex == 0) {
		//this.contextMenu.show(Ext.get('icon-' + record.get('id')));
		
		
		var canEdit = record.get('can_edit');
		
		if(canEdit) {
			this.contextMenu.hide();
			this.contextMenuWithoutEdit.hide();
			this.contextMenu.show(Ext.get('icon-' + record.get('id')));
		} else {
			this.contextMenu.hide();
			this.contextMenuWithoutEdit.hide();
			this.contextMenuWithoutEdit.show(Ext.get('icon-' + record.get('id')));
		}
    } else {
      this.executeDownload();
    }
  },

  onDocUserClick: function(object, index, event) {
    var data = this.docUserStore.getAt(index);
    var url = data.get('webdoc_url');
    if (url) {
      var target = data.get('target');
      if (target == NetBook.OPEN_URL_TARGET_BLANK) {
        this.controller.openURLByNewBrowser(url);
      } else {
        this.controller.openURL(url, true, true);
      }
      this.controller.reloadGAScript(this.gaURL);
    } else {
      this.controller.show(this.VIEW_ID);
    }
  },

  formatDate: function(sDate) {
    if (!sDate) {
        return '';
    }
    return sDate;
  },

  formatName: function(value, p, record) {
    return String.format('<div class="topic"><image src="{0}" class="nb-favicon"/>&nbsp<b>{1}</b></div>', record.get('icon_list'), value);
  },

  formatListIcon: function(value, p, record) {
    return String.format('<div class="edit" id="icon-{0}"/>', value);
  },

  formatSize: function(value, p, record) {
    return Ext.util.Format.fileSize(record.get('size'));
  }
});

////////////////////////////////////////////
NetBook.DocumentWindow = Ext.extend(NetBook.Component, {

  title: NetBook.NOTE_PANEL_NEWNOTE_FORM_TITLE,

  width: 400,

  height: 150,

  resizable: false,

  callback: Ext.emptyFn,

  initComponent: function() {
    NetBook.DocumentWindow.superclass.initComponent.call(this);

    thisDocwObj = this;
    this.urlUpload = this.controller.getURL('document', 'upload');
    this.urlRename = this.controller.getURL('document', 'rename');
    this.urlCopy = this.controller.getURL('document', 'copy');

    this.urlNewwriter = this.controller.getURL('document', 'newwriter');
    this.urlNewsheet = this.controller.getURL('document', 'newsheet');
    this.urlNewshow = this.controller.getURL('document', 'newshow');

    this.uploadPanel = new Ext.FormPanel({
        labelAlign:'top',
        buttonAlign: 'center',
        bodyStyle: 'padding: 20px 5px 0;',
        border: false,
        autoHeight: true,
        autoScroll: false,
        fileUpload: true,
        defaultType: 'textfield',
        layoutConfig: {
          labelSeparator: ''
        },
        defaults: {
          msgTarget: 'under'
        },
        keys: [{
          key: Ext.EventObject.ENTER,
          fn: this.executeUpload.createDelegate(this),
          scope: this
        }],
        items:[{
          xtype: 'textfield',
          /** xtype: 'fileuploadfield', */
          inputType: 'file',
          height: 25,
          fieldLabel: NetBook.DOCUMENT_PANEL_UPLOAD_FORM,
          anchor: '100%',
          name: 'file',
          id: 'file-field-upload',
          validationEvent: false,
          validateOnBlur: false
        }],
        buttons:
        [{
            text: NetBook.DOCUMENT_PANEL_UPLOAD_BTN_UPLOAD,
            handler: this.executeUpload.createDelegate(this)
        },
        {
          text: NetBook.ALL_BTN_CANCEL,
          handler: this.hide.createDelegate(this)
        }]
    });

    this.renamePanel = new Ext.FormPanel({
      labelAlign:'top',
      buttonAlign: 'center',
      bodyStyle: 'padding: 20px 5px 0;',
      border: false,
      autoHeight: true,
      autoScroll: false,
      defaultType: 'textfield',
      layoutConfig: {
        labelSeparator: ''
      },
      defaults: {
        msgTarget: 'under'
      },
      keys: [{
        key: Ext.EventObject.ENTER,
        fn: this.executeRename.createDelegate(this),
        scope: this
      }],
      items:[{
        xtype: 'hidden',
        name: 'id'
      },
      {
        xtype: 'textfield',
        fieldLabel: NetBook.DOCUMENT_PANEL_LBL_NEWNAME,
        anchor: '100%',
        name: 'name',
        validationEvent: false,
        validateOnBlur: false
      }],
      buttons:
      [{
          text: NetBook.ALL_BTN_SAVE,
          handler: this.executeRename.createDelegate(this)
      },
      {
        text: NetBook.ALL_BTN_CANCEL,
        handler: this.hide.createDelegate(this)
      }]
    });

////////
    this.newwriterPanel = new Ext.FormPanel({
      labelAlign:'top',
      buttonAlign: 'center',
      bodyStyle: 'padding: 20px 5px 0;',
      border: false,
      autoHeight: true,
      autoScroll: false,
      defaultType: 'textfield',
      layoutConfig: {
        labelSeparator: ''
      },
      defaults: {
        msgTarget: 'under'
      },
      keys: [{
        key: Ext.EventObject.ENTER,
        fn: this.executeNewwriter.createDelegate(this),
        scope: this
      }],
      items:[
	  {
        xtype: 'textfield',
        fieldLabel: NetBook.DOCUMENT_PANEL_LBL_NEWNAME,
        anchor: '100%',
        name: 'name',
        validationEvent: false,
        validateOnBlur: false
      }],
      buttons:
      [{
          text: NetBook.ALL_BTN_SAVE,
          handler: this.executeNewwriter.createDelegate(this)
      },
      {
        text: NetBook.ALL_BTN_CANCEL,
        handler: this.hide.createDelegate(this)
      }]
    });
    this.newsheetPanel = new Ext.FormPanel({
      labelAlign:'top',
      buttonAlign: 'center',
      bodyStyle: 'padding: 20px 5px 0;',
      border: false,
      autoHeight: true,
      autoScroll: false,
      defaultType: 'textfield',
      layoutConfig: {
        labelSeparator: ''
      },
      defaults: {
        msgTarget: 'under'
      },
      keys: [{
        key: Ext.EventObject.ENTER,
        fn: this.executeNewsheet.createDelegate(this),
        scope: this
      }],
      items:[
	  {
        xtype: 'textfield',
        fieldLabel: NetBook.DOCUMENT_PANEL_LBL_NEWNAME,
        anchor: '100%',
        name: 'name',
        validationEvent: false,
        validateOnBlur: false
      }],
      buttons:
      [{
          text: NetBook.ALL_BTN_SAVE,
          handler: this.executeNewsheet.createDelegate(this)
      },
      {
        text: NetBook.ALL_BTN_CANCEL,
        handler: this.hide.createDelegate(this)
      }]
    });
    this.newshowPanel = new Ext.FormPanel({
      labelAlign:'top',
      buttonAlign: 'center',
      bodyStyle: 'padding: 20px 5px 0;',
      border: false,
      autoHeight: true,
      autoScroll: false,
      defaultType: 'textfield',
      layoutConfig: {
        labelSeparator: ''
      },
      defaults: {
        msgTarget: 'under'
      },
      keys: [{
        key: Ext.EventObject.ENTER,
        fn: this.executeNewshow.createDelegate(this),
        scope: this
      }],
      items:[
	  {
        xtype: 'textfield',
        fieldLabel: NetBook.DOCUMENT_PANEL_LBL_NEWNAME,
        anchor: '100%',
        name: 'name',
        validationEvent: false,
        validateOnBlur: false
      }],
      buttons:
      [{
          text: NetBook.ALL_BTN_SAVE,
          handler: this.executeNewshow.createDelegate(this)
      },
      {
        text: NetBook.ALL_BTN_CANCEL,
        handler: this.hide.createDelegate(this)
      }]
    });
////////


    this.copyPanel = new Ext.FormPanel({
      labelAlign:'top',
      buttonAlign: 'center',
      bodyStyle: 'padding: 20px 5px 0;',
      border: false,
      autoHeight: true,
      autoScroll: false,
      defaultType: 'textfield',
      layoutConfig: {
        labelSeparator: ''
      },
      defaults: {
        msgTarget: 'under'
      },
      keys: [{
        key: Ext.EventObject.ENTER,
        fn: this.executeCopy.createDelegate(this),
        scope: this
      }],
      items:[{
        xtype: 'hidden',
        name: 'id'
      },
      {
        xtype: 'textfield',
        fieldLabel: NetBook.DOCUMENT_PANEL_LBL_NEWNAME,
        anchor: '100%',
        name: 'name',
        validationEvent: false,
        validateOnBlur: false
      }],
      buttons:
      [{
          text: NetBook.ALL_BTN_SAVE,
          handler: this.executeCopy.createDelegate(this)
      },
      {
        text: NetBook.ALL_BTN_CANCEL,
        handler: this.hide.createDelegate(this)
      }]
    });

    this.window = new Ext.Window({
      title: this.title,
      bodyStyle: 'background:transparent;',
      width: this.width,
      height: this.height,
      border: false,
      collapsible: false,
      closable: false,
      resizable: this.resizable,
      maximizable: false,
      minimizable: false,
      modal: true,
      plain: false,
      shadow: false,
      tools: [{
        id: 'close',
        qtip: NetBook.ALL_TIP_HIDE,
        handler: this.hide.createDelegate(this)
      }],
      layout: 'card',
      activeItem: 0,
      items: [this.uploadPanel, this.newwriterPanel,  this.newsheetPanel,  this.newshowPanel, this.renamePanel, this.copyPanel]
    });
  },

  show: function(data) {
    if(!data) {
      data = {};
    }
    if(data.action_type == 'copy') {
      this.showCopyForm(data);
    } else if(data.action_type == 'rename') {
      this.showRenameForm(data);
    } else if(data.action_type == 'newwriter') {
      this.showNewwriterForm(data);
    } else if(data.action_type == 'newsheet') {
      this.showNewsheetForm(data);
    } else if(data.action_type == 'newshow') {
      this.showNewshowForm(data);
    } else {
      this.showUploadForm();
    }
  },

  hide: function() {
    this.window.hide();
  },

  showUploadForm: function() {
    this.window.setTitle(NetBook.DOCUMENT_PANEL_UPLOADPANEL_TITLE);
    this.window.show();
    this.window.layout.setActiveItem(0);
    var form = this.uploadPanel.getForm();
    form.clearInvalid();
    form.findField('file').setValue('');

    Ext.get('file-field-upload').set({size: 37});

    window.setTimeout(function() {
      var form = thisDocwObj.uploadPanel.getForm();
      form.findField('file').focus();
    }, 300);
  },

  showCopyForm: function(data) {
    this.window.setTitle(NetBook.DOCUMENT_PANEL_COPYPANEL_TITLE);
    this.window.show();
    this.window.layout.setActiveItem(5);
    var form = this.copyPanel.getForm();
    form.clearInvalid();

    var name = data.name;
    var arr = name.split('.');
    name = name.replace('.' + arr[arr.length - 1], '');
    name = 'copy of ' + name;

    form.findField('id').setValue(data.id);
    form.findField('name').setValue(name);

    window.setTimeout(function() {
      var form = thisDocwObj.copyPanel.getForm();
      form.findField('name').focus();
      form.findField('name').selectText();
    }, 300);
  },

  showRenameForm: function(data) {
    this.window.setTitle(NetBook.DOCUMENT_PANEL_RENAMEPANEL_TITLE);
    this.window.show();
    this.window.layout.setActiveItem(4);
    var form = this.renamePanel.getForm();
    form.clearInvalid();

    var name = data.name;
    var arr = name.split('.');
    name = name.replace('.' + arr[arr.length - 1], '');
    form.findField('id').setValue(data.id);
    form.findField('name').setValue(name);

    window.setTimeout(function() {
      var form = thisDocwObj.renamePanel.getForm();
      form.findField('name').focus();
      form.findField('name').selectText();
    }, 300);
  },


///////////
  showNewwriterForm: function() {
    this.window.setTitle(NetBook.DOCUMENT_PANEL_NEWWRITER_TITLE);
    this.window.show();
    this.window.layout.setActiveItem(1);
    var form = this.newwriterPanel.getForm();
    form.clearInvalid();

    window.setTimeout(function() {
      var form = thisDocwObj.newwriterPanel.getForm();
      form.findField('name').focus();
      form.findField('name').selectText();
    }, 300);
  },
  showNewsheetForm: function() {
    this.window.setTitle(NetBook.DOCUMENT_PANEL_NEWSHEET_TITLE);
    this.window.show();
    this.window.layout.setActiveItem(2);
    var form = this.newsheetPanel.getForm();
    form.clearInvalid();

    window.setTimeout(function() {
      var form = thisDocwObj.newsheetPanel.getForm();
      form.findField('name').focus();
      form.findField('name').selectText();
    }, 300);
  },
  showNewshowForm: function() {
    this.window.setTitle(NetBook.DOCUMENT_PANEL_NEWSHOW_TITLE);
    this.window.show();
    this.window.layout.setActiveItem(3);
    var form = this.newshowPanel.getForm();
    form.clearInvalid();

    window.setTimeout(function() {
      var form = thisDocwObj.newshowPanel.getForm();
      form.findField('name').focus();
      form.findField('name').selectText();
    }, 300);
  },
///////////



  executeUpload: function() {
    var form = this.uploadPanel.getForm();
    if(!form.findField('file').getValue()) {
      setErrField(form, 'file', NetBook.DOCUMENT_PANEL_UPLOAD_ERR1);
      return;
    }
    showWaitingDlg(this.window.getEl(), NetBook.ALL_BTN_WAIT);
    form.submit({
      url: this.urlUpload,
      params: {},
      success: function(form, action) {
        hideWaitingDlg(thisDocwObj.window.getEl());
        thisDocwObj.hide();
        thisDocwObj.callback();
      },
      failure: function(form, action) {
        hideWaitingDlg(thisDocwObj.window.getEl());
        setErrField(form, 'file', NetBook.DOCUMENT_PANEL_UPLOAD_ERR2);
        showActionFailureDlg(action);
      }
    });
  },

  executeRename: function() {
    var form = this.renamePanel.getForm();
    if(!form.findField('name').getValue()) {
      setErrField(form, 'name', NetBook.DOCUMENT_PANEL_FILENAME_ERR1);
      return;
    }
    showWaitingDlg(this.window.getEl(), NetBook.ALL_BTN_WAIT);
    form.submit({
      url: this.urlRename,
      params: {},
      success: function(form, action) {
        hideWaitingDlg(thisDocwObj.window.getEl());
        thisDocwObj.hide();
        thisDocwObj.callback();
      },
      failure: function(form, action) {
        hideWaitingDlg(thisDocwObj.window.getEl());
        setErrField(form, 'name', NetBook.DOCUMENT_PANEL_FILENAME_ERR2);
        showActionFailureDlg(action);
      }
    });
  },

////////
  executeNewwriter: function() {
    var form = this.newwriterPanel.getForm();
    if(!form.findField('name').getValue()) {
      setErrField(form, 'name', NetBook.DOCUMENT_PANEL_FILENAME_ERR1);
      return;
    }
    showWaitingDlg(this.window.getEl(), NetBook.ALL_BTN_WAIT);
    form.submit({
      url: this.urlNewwriter,
      params: {},
      success: function(form, action) {
        hideWaitingDlg(thisDocwObj.window.getEl());
        thisDocwObj.hide();
        thisDocwObj.callback();
      },
      failure: function(form, action) {
        hideWaitingDlg(thisDocwObj.window.getEl());
        setErrField(form, 'name', NetBook.DOCUMENT_PANEL_FILENAME_ERR2);
        showActionFailureDlg(action);
      }
    });
  },
  executeNewsheet: function() {
    var form = this.newsheetPanel.getForm();
    if(!form.findField('name').getValue()) {
      setErrField(form, 'name', NetBook.DOCUMENT_PANEL_FILENAME_ERR1);
      return;
    }
    showWaitingDlg(this.window.getEl(), NetBook.ALL_BTN_WAIT);
    form.submit({
      url: this.urlNewsheet,
      params: {},
      success: function(form, action) {
        hideWaitingDlg(thisDocwObj.window.getEl());
        thisDocwObj.hide();
        thisDocwObj.callback();
      },
      failure: function(form, action) {
        hideWaitingDlg(thisDocwObj.window.getEl());
        setErrField(form, 'name', NetBook.DOCUMENT_PANEL_FILENAME_ERR2);
        showActionFailureDlg(action);
      }
    });
  },
  executeNewshow: function() {
    var form = this.newshowPanel.getForm();
    if(!form.findField('name').getValue()) {
      setErrField(form, 'name', NetBook.DOCUMENT_PANEL_FILENAME_ERR1);
      return;
    }
    showWaitingDlg(this.window.getEl(), NetBook.ALL_BTN_WAIT);
    form.submit({
      url: this.urlNewshow,
      params: {},
      success: function(form, action) {
        hideWaitingDlg(thisDocwObj.window.getEl());
        thisDocwObj.hide();
        thisDocwObj.callback();
      },
      failure: function(form, action) {
        hideWaitingDlg(thisDocwObj.window.getEl());
        setErrField(form, 'name', NetBook.DOCUMENT_PANEL_FILENAME_ERR2);
        showActionFailureDlg(action);
      }
    });
  },
////////

  executeCopy: function() {
    var form = this.copyPanel.getForm();
    if(!form.findField('name').getValue()) {
      setErrField(form, 'name', NetBook.DOCUMENT_PANEL_FILENAME_ERR1);
      return;
    }
    showWaitingDlg(this.window.getEl(), NetBook.ALL_BTN_WAIT);
    form.submit({
      url: this.urlCopy,
      params: {},
      success: function(form, action) {
        hideWaitingDlg(thisDocwObj.window.getEl());
        thisDocwObj.hide();
        thisDocwObj.callback();
      },
      failure: function(form, action) {
        hideWaitingDlg(thisDocwObj.window.getEl());
        setErrField(form, 'name', NetBook.DOCUMENT_PANEL_FILENAME_ERR2);
        showActionFailureDlg(action);
      }
    });
  }
});


NetBook.ID_EMAIL_PANEL = 'nb-email';NetBook.EmailPanel = Ext.extend(NetBook.Component, {  VIEW_ID: NetBook.ID_EMAIL_PANEL,  initComponent: function() { NetBook.EmailPanel.superclass.initComponent.call(this); this.urlMailUser = this.controller.getURL('mail', 'user'); this.mailUserStore = new Ext.data.JsonStore({url: this.urlMailUser,id: 'id',fields: ['id', 'title', 'description', 'webmail_url', 'small_icon', 'large_icon', 'over_large_icon', 'index', 'is_in_system', 'target'] }); this.mailUserStore.setDefaultSort('index', "ASC"); this.mailUserTpl = new Ext.XTemplate('<tpl for=".">','<div class="thumb-wrap">','<div class="thumb"><table cellspacing="0" cellpadding="0"><tr><td><img src="{large_icon_path}"/></td><td align="left">{other_title}</td></tr></table></div>','</div>','</tpl>' ); thisMailObj = this; this.mailUserView = new Ext.DataView({store: this.mailUserStore,tpl: this.mailUserTpl,multiSelect: false,overClass: 'x-view-over',itemSelector: 'div.thumb-wrap',loadingText: NetBook.ALL_LOADING,deferEmptyText: true,emptyText: this.getMenuEmptyStyle(NetBook.EMAIL_PANEL_EMPTY_MSG),prepareData: function(data) {  if (data.is_in_system == 0) {data.other_title = data.title;  }  data.large_icon_path = thisMailObj.controller.getImagePath(data.large_icon);  return data;} }); var mailUserPanel = new Ext.Panel({id: 'mail-nav-panel',border:false,items: [this.mailUserView] }); this.view = new Ext.Panel({border:false,items : [mailUserPanel] }); this.mailUserView.addListener("click", this.onMailUserClick.createDelegate(this)); this.mailUserStore.on('load', this.synMenuSize.createDelegate(this));  },  getMenuPanel: function() { return this.view;  },  showMenu: function() { this.mailUserStore.reload(); this.view.doLayout();  },  onMailUserClick: function(object, index, event) { var data = this.mailUserStore.getAt(index); var url = data.get('webmail_url'); var target = data.get('target'); if (target == NetBook.OPEN_URL_TARGET_BLANK) {this.controller.openURLByNewBrowser(url); } else {this.controller.openURL(url, true, true); } this.controller.reloadGAScript(this.gaURL + '/' + data.get('title'));  }});NetBook.FeedletHelperWindow = Ext.extend(NetBook.Component, {  id: NetBook.ID_FEEDLET_HELPER_WINDOW,  title: NetBook.FEEDLET_HELPERWINDOW_TITLE,  width: 460,  height: 412,  resizable: false,  initComponent: function() { NetBook.FeedletHelperWindow.superclass.initComponent.call(this); this.firefoxPanel = new Ext.Panel({id: 'feedlet-firefoxPanel',layout: 'fit',bodyStyle: 'background:transparent;',border: false,autoHeight:true,collapsed: false,items: [{  bodyStyle: 'background:transparent;padding: 5px 5px 0;p{font-size: 14px; padding: 5px;}',  border: false,  autoHeight:true,  collapsed: false,  html: '<p>' + this.getLink() + '</p>' + NetBook.FF_FEEDLET_HELPER_MOVIE}] }); this.iePanel = new Ext.Panel({id: 'feedlet-iePanel',layout: 'fit',bodyStyle: 'background:transparent;',border: false,autoHeight: false,collapsed: false,items: [{  bodyStyle: 'background:transparent;padding: 5px 5px 0;p{font-size: 14px; padding: 5px;}',  border: false,  autoHeight:true,  collapsed: false,  html: '<p>' + this.getLink() + '</p>' +NetBook.IE_FEEDLET_HELPER_MOVIE}] }); this.bodyPanel = new Ext.Panel({id: this.id,bodyStyle: 'background:transparent;padding: 5px 5px 0;',layout: 'card',activeItem: 0,border: false,autoHeight:true,collapsed: false,items: [this.firefoxPanel, this.iePanel]}); this.bookmarkWindow = new Ext.Window({title: this.title,layout: 'fit',bodyStyle: 'background:transparent;',width: this.width,height: this.height,collapsible: false,closable: false,plain: false,resizable: this.resizable,shadow: false,maximizable: false,minimizable: false,modal: true,tools: [{  id: 'close',  qtip: NetBook.ALL_TIP_HIDE,  handler: this.hide.createDelegate(this)}],items: [this.bodyPanel] });  },  show: function() { this.bookmarkWindow.show(); if (Ext.isGecko) {this.bodyPanel.layout.setActiveItem(0); } else if(Ext.isIE) {this.bodyPanel.layout.setActiveItem(1); }  },  hide: function() { this.bookmarkWindow.hide();  },  getLink: function() {var location = document.location;feedletUrl = location.protocol + '//' + location.host;feedletUrl += this.controller.getURL('bookmark', 'makeFrame') + '?let=feed';content = 'javascript:(function(){var%20let=1,s=document.createElement("script");s.charset="UTF-8";s.src="'+feedletUrl+'";(document.getElementsByTagName("head")[0]||document.body).appendChild(s);})();';content = "<a href='" + content + "'>"+NetBook.FEEDLET_HELPERWINDOW_LINK+"</a>";return content;  }});NetBook.FeedPanel = Ext.extend(NetBook.Component, {  VIEW_ID: NetBook.ID_FEED_PANEL,  ID_LIST_PANEL: 'nb-feed-list',  helperWindow: '',  initComponent: function() { NetBook.FeedPanel.superclass.initComponent.call(this); this.url = this.controller.getURL('news', 'index'); this.fetchUrl  = this.controller.getURL('news', 'fetch'); this.deleteUrl = this.controller.getURL('news', 'delete'); this.urlIncrement = this.controller.getURL('news', 'increment'); this.contextMenuVisibled = false; thisFeedObj = this; var tpl = new Ext.XTemplate('<tpl for=".">','<div class="feed-node-el" id="feed-{id}"><div id="feed-menu-{id}" class="dropdown-menu"></div>','<img src="{icon}" class="favicon" style="margin-top:5px;"/>','<div class="title">{title}</div>','</div>','</tpl>' ); this.feedStore = new Ext.data.JsonStore({url: this.url,autoLoad: false,root: 'feeds',id:'id',fields: ['id', 'title', 'url', 'icon'] }); this.feedListView = new Ext.DataView({itemSelector: 'div.feed-node-el',overClass: 'x-feed-node-over',selectedClass: 'x-feed-node-selected',style: 'overflow:auto',singleSelect: true,loadingText: NetBook.ALL_LOADING,store: this.feedStore,tpl: tpl,deferEmptyText: true,emptyText: this.getEmptyStyle(NetBook.FEED_PANEL_EMPTY_MSG) }); var feedListPanel = new Ext.Panel({id: this.ID_LIST_PANEL,title: "<div style='text-align: center;'>"+NetBook.FEED_PANEL_CONTENTPANEL_LBL_TITLE+"</div>",region: 'west',border: true,width: 300,autoScroll: true,items: this.feedListView }); this.contentStore = new Ext.data.JsonStore({url: this.fetchUrl,autoLoad: false,root: 'items',id: 'id',fields: ['title', 'pubDateView', {name:'pubDate', type:'date'}, 'link', 'description'] }); this.contentStore.setDefaultSort('pubDate', "DESC"); var columns = [{dataIndex: 'title',tpl: "<div class='title'>{title}</div><div class='date'>{pubDateView}</div><br/><div class='description'>{descriptionView}</div>" }]; this.contentGrid = new Ext.ListView({id: 'feed-grid-panel',store: this.contentStore,columns: columns,hideHeaders: true,border: false,autoWidth: true,singleSelect: true,loadingText: NetBook.ALL_LOADING,deferEmptyText: true,emptyText: this.getEmptyStyle(NetBook.FEED_PANEL_EMPTY_CONTENT_MSG),prepareData: this.contentGridPrepareData.createDelegate(this) }); var contentPanel = new Ext.Panel({title: NetBook.FEED_PANEL_CONTENTPANEL_LBL_CONTENT,region: 'center',border: true,autoScroll: true,items: this.contentGrid }); detailPanel = new Ext.Panel({layout: 'border',region: 'center',border: false,items: [feedListPanel, contentPanel] }); this.view = new Ext.Panel({border: false,autoWidth: true,layout: 'border',items: [detailPanel] }); this.contextMenu = new Ext.menu.Menu({id: 'feed-menu',items: [{  text: NetBook.FEED_PANEL_CONTEXTMENU_EDIT,  iconCls: 'menu-feed-edit',  handler: this.executeEditFeed.createDelegate(this)},{  text: NetBook.FEED_PANEL_CONTEXTMENU_DELETE,  iconCls: 'menu-feed-delete',  handler: this.removeFeed.createDelegate(this)}] }); this.feedStore.on('load', this.onFeedLoad, this); this.feedListView.on('click', this.onFeedClick, this); this.contentGrid.on('click', this.onContentGridClick, this); this.contextMenu.on({'show': this.onShowContextMenu,'hide': this.onHideContextMenu,scope: this });  },  getActions: function() { return Array({id: 'add-feed-btn', cls: 'add-feed-btn', title: NetBook.FEED_PANEL_TIP_ADD, clickListener: this.executeFeed.createDelegate(this)},{id: 'feedlet-btn', cls: 'feedlet-btn', title: NetBook.FEED_PANEL_TIP_FEEDLET, clickListener: this.showHelper.createDelegate(this)});  },  getContentPanel: function() { return this.view;  },  initComponentComplete: function() { this.feedStore.load();  },  onFeedLoad: function(sender, records, options) { if(this.feedStore.getCount() > 0) {var record = this.feedStore.getAt(0);this.feedListView.select('feed-' + record.get('id'));this.loadFeed(record.get('url')); } for(var i = 0; i < this.feedStore.getCount(); i++) {Ext.get('feed-menu-' + this.feedStore.getAt(i).get('id')).on('click', function() {  thisFeedObj.contextMenu.show(this.id);}); }  },  onShowContextMenu: function() { this.contextMenuVisibled = true;  },  onHideContextMenu: function() { this.contextMenuVisibled = false;  },  loadFeed: function(feedUrl) { this.contentStore.baseParams = {feed: feedUrl }; this.contentStore.load();  }, onFeedClick: function(sender, index) { if (this.contextMenuVisibled) {return; } var record = sender.store.getAt(index); this.loadFeed(record.get('url'));  }, onContentGridClick: function(sender, index) { var record = sender.store.getAt(index); this.controller.openURL(record.get('link'), true); this.addBreadScrumbLevel3(record.get('title')); record = this.feedListView.getSelectedRecords()[0]; this.incrementUsedCount(record.get('id'));  }, contentGridPrepareData: function(data, recordIndex, record) { data.descriptionView = ''; if (data.description) {data.descriptionView = data.description.trim(); } return data;  },  showHelper: function() { if (!this.helperWindow) {this.helperWindow = new NetBook.FeedletHelperWindow({  controller: this.controller}); } this.helperWindow.show();  },  executeFeed: function(sender) { if (!this.popup) {this.popup = new NetBook.FeedWindow({controller: this.controller, callback: this.initComponentComplete.createDelegate(this)}); } this.popup.show();  },  executeEditFeed: function(sender) { if (!this.popup) {this.popup = new NetBook.FeedWindow({controller: this.controller, callback: this.initComponentComplete.createDelegate(this)}); } var record = this.feedListView.getSelectedRecords()[0]; var data = {id: record.get('id'),action_type: 'edit',url: record.get('url') }; this.popup.show(data);  },  removeFeed: function() { if (this.feedListView.getSelectionCount() > 0) {showConfirm(NetBook.FEED_PANEL_DELETE_CONFIRM_TXT1, this.doDelete.createDelegate(this)); } else {showMessage(NetBook.FEED_PANEL_DELETE_CONFIRM_TXT2); }  },  doDelete: function(btn) { if ('yes' == btn) {var index = this.feedListView.getSelectedIndexes()[0];var record = this.feedStore.getAt(index);var id = record.get('id');Ext.Ajax.request({  url: this.deleteUrl,  params: {feedId: id},  success: this.onDeleteCompleted.createDelegate(this),  failure: this.onDeleteCompleted.createDelegate(this)}); }  },  onDeleteCompleted: function(form, action) { this.feedStore.reload();  },  incrementUsedCount: function(id) { Ext.Ajax.request({url: this.urlIncrement,params: {  id: id},success: function(form, action) {},failure: function(form, action) {} });  }});NetBook.FeedWindow = Ext.extend(NetBook.Component, {  id: NetBook.ID_FEED_WINDOW,  title: NetBook.FEED_PANEL_NEW_FORM_TITLE,  width: 400,  height: 150,  resizable: false,  callback: Ext.emptyFn,  initComponent: function() { NetBook.FeedWindow.superclass.initComponent.call(this); thisFwObj = this; this.urlFeed = this.controller.getURL('news', 'add'); this.bodyPanel = new Ext.form.FormPanel({id: this.id,labelAlign:'top',bodyStyle: 'background:transparent;padding:10px;',buttonAlign: 'center',border: false,autoHeight:true,defaultType: 'textfield',layoutConfig: {  labelSeparator: ''},defaults: {  msgTarget: 'under'},collapsed: false,items :[{  xtype: 'hidden',  name: 'id'},{  xtype: 'hidden',  name: 'action_type'},{  fieldLabel: NetBook.FEED_PANEL_NEWFEED_URL_TXT,  name: 'feedUrl',  validationEvent: false,  validateOnBlur: false,  msgTarget: 'under',  anchor: '100%',  value: 'http://'}],keys: [{  key: Ext.EventObject.ENTER,  fn: this.executeFeed.createDelegate(this),  scope: this}],buttons:[{  text: NetBook.FEED_PANEL_NEWFEED_URL_BTN_ADD,  handler: this.executeFeed.createDelegate(this)},{  text: NetBook.ALL_BTN_CANCEL,  handler: this.hide.createDelegate(this)}]}); this.feedWindow = new Ext.Window({title: this.title,bodyStyle: 'background:transparent;',width: this.width,height: this.height,collapsible: false,closable: false,border: false,plain: false,resizable: this.resizable,shadow: false,maximizable: false,minimizable: false,modal: true,tools: [{  id: 'close',  qtip: NetBook.ALL_TIP_HIDE,  handler: this.hide.createDelegate(this)}],items: [this.bodyPanel] });  },  show: function(data) { if(data) {this.feedWindow.setTitle(NetBook.FEED_PANEL_EDIT_FORM_TITLE); } else {this.feedWindow.setTitle(NetBook.FEED_PANEL_NEW_FORM_TITLE);data = {}; } this.feedWindow.show(); var form = this.bodyPanel.getForm(); form.clearInvalid(); form.findField('id').setValue(data.id); form.findField('action_type').setValue(data.action_type ? data.action_type : 'new'); form.findField('feedUrl').setValue(data.url ? data.url : 'http://'); window.setTimeout(function() {var form = thisFwObj.bodyPanel.getForm();form.findField('feedUrl').focus();form.findField('feedUrl').selectText(); }, 500);  },  hide: function() { this.feedWindow.hide();  },  executeFeed: function(sender) { showWaitingDlg(this.feedWindow.getEl(), NetBook.FEED_PANEL_NEWFEED_URL_MASK); this.bodyPanel.getForm().submit({url: this.urlFeed,success: this.onSaveCompleted.createDelegate(this),failure: this.onSaveCompleted.createDelegate(this) });  },  onSaveCompleted: function(form, action) { hideWaitingDlg(thisFwObj.feedWindow.getEl()); var code = action.result.status_code; if (code == NetBook.STATUS_CODE_SUCCESS) {this.hide();this.callback(); } else if (code == NetBook.STATUS_CODE_INPUT_DATA_INVALID){setErrField(this.bodyPanel.getForm(), 'feedUrl', NetBook.FEED_PANEL_NEWFEED_URL_ERR1); }  }});NetBook.ID_MAINSCREEN_TOP_PANEL = 'mainscreen-top-panel';NetBook.ID_MAINSCREEN_IFRAME = 'mainscreen-iframe';NetBook.ID_MAINSCREEN_CONTENT = 'mainscreen-content';NetBook.MainScreen = Ext.extend(NetBook.Component, {  initComponent: function() { NetBook.MainScreen.superclass.initComponent.call(this); this.componentManager = new Ext.util.MixedCollection(); thisMSObj = this; this.topPanel = new Ext.Panel({id: NetBook.ID_MAINSCREEN_TOP_PANEL,autoHeight: true,region:'north',border: true,collapsible: true,collapsed: false,minSize: NetBook.TOP_PANEL_HEIGHT,maxSize: NetBook.TOP_PANEL_HEIGHT,collapseMode: 'mini',layout: 'card',split: 'true',useSplitTips: true,collapsibleSplitTip: NetBook.MESSAGE_COLLAPSIBLE_TIP }); this.contentPanel = new Ext.Panel({region:'center',border: false,layout: 'card' }); this.taskPanel = new Ext.Panel({border: true,autoHeight: true,hidden: true,html: 'TASKBAR' }); this.copyRightPanel = new Ext.Panel({autoHeight: true,border: false,html: '<div id="nb-basewindow-footer">Powered by '+NetBook.SERVICE_NAME+' 2.0</div>' }); this.bottomPanel = new Ext.Panel({region: 'south',border: false,height: 19,items: [this.copyRightPanel] }); this.basePanel = new Ext.Panel({id: NetBook.ID_MAINSCREEN_CONTENT,border: false,layout: 'border',autoWidth: true,items: [this.contentPanel, this.bottomPanel] }); this.iframePanel = new Ext.ux.ManagedIFrame.Panel({id: NetBook.ID_MAINSCREEN_IFRAME,border: false,header: false,autoHeight: false,region: 'center',frameConfig : {  name : 'iframe-panel',  frameborder : 0,  allowtransparency : true,  style: 'background-color: #FFF'} }); this.detailsPanel = new Ext.Panel({region: 'center',border: false,header: false,layout: 'card',activeItem: 0,items: [this.iframePanel, this.basePanel] }); this.viewport = new Ext.Viewport({layout: 'border',items: [this.topPanel, this.detailsPanel] }); this.topPanel.addListener('collapse', function() {Ext.get('mainscreen-top-panel-xcollapsed').on('mouseover', function() {  thisMSObj.expandTopPanel();}); }, this, {single: true}); this.topPanel.on('resize', this.onTopPanelResize.createDelegate(this));  },  showIFrame: function(url) { if (url) {this.iframePanel.setSrc(url);this.iframePanel.hasSrc = 1; } if(!this.iframePanel.hasSrc) {var user = this.controller.getUser();var page = NetBook.DEFAULT_HOMEPAGE;if (user && user.getHomePage()) {  page = user.getHomePage();}this.iframePanel.setSrc(page);this.iframePanel.hasSrc = 1; } if(!this.iframePanel.isVisible()) {this.detailsPanel.layout.setActiveItem(NetBook.ID_MAINSCREEN_IFRAME); }  },  visibleTopPanel: function(visible) { this.topPanel.setVisible(visible); this.viewport.doLayout();  },  collapseTopPanel: function() { this.visibleTopPanel(true); this.topPanel.collapse();  },  expandTopPanel: function() { this.visibleTopPanel(true); this.topPanel.expand();  },  visibleCopyRightPanel: function(visible) { this.copyRightPanel.setVisible(visible);  },  showContentPanel: function() { this.detailsPanel.layout.setActiveItem(NetBook.ID_MAINSCREEN_CONTENT);  },  createComponent: function(data) { if (!data) {return; } var classname = data.get('class_name'); var component = null; var code = 'component = new ' + classname + '({controller:this.controller});'; eval(code); if (!component) {return null; } component.fireEvent('initcomponent', component); var adverts = data.get('adverts'); if (adverts) {component.advertUrls = new Array();for (var i = 0; i < adverts.length; i++) {  component.advertUrls.push({ url: this.controller.getURL('advertisement', adverts[i].id), interval: adverts[i].interval  });}component.advertIndex = 0; } this.setPropertives(component, data); return component;  },  addComponent: function(component, isActive) { if (!Ext.isObject(component)) {return; } if (!component.VIEW_ID) {return; } this.generateIDs(component); if(component.fireEvent('beforeaddcomponent', component) === false) {return; } this.componentManager.add(component.VIEW_ID, component); if(component.CONTENT_PANEL_ID) {this.contentPanel.add(component.getContentPanel()); } if(component.TOP_PANEL_ID) {var panel = component.getTopPanel();if (!Ext.isObject(panel)) {  panel = this.createTopPanel(component);}this.topPanel.add(panel); } component.fireEvent('addcomponent', component); if (isActive) {this.show(component.VIEW_ID); }  },  generateIDs: function(component) { if (!component.VIEW_ID) {showMessage('Please set a VIEW_ID for object');return; } var panel = component.getMenuPanel(); if(Ext.isObject(panel)) {component.hasMenu = true; } else {component.hasMenu = false; } panel = component.getContentPanel(); if(Ext.isObject(panel)) {if (!panel.id) {  panel.id = 'content-' + component.VIEW_ID;}component.CONTENT_PANEL_ID = panel.id; } else {component.CONTENT_PANEL_ID = null; } panel = component.getTopPanel(); if(Ext.isObject(panel)) {if (!panel.id) {  panel.id = 'top-' + component.VIEW_ID;}component.TOP_PANEL_ID = panel.id; } else {component.TOP_PANEL_ID = 'top-' + component.VIEW_ID; } if (component.HIDE_TOP_PANEL) {component.TOP_PANEL_ID =  null; }  },  setPropertives: function(component, data) { component.ID = data.get('id'); if(!component.VIEW_ID) {var ts = Math.round(new Date().getTime() / 1000);component.VIEW_ID = 'nb-' + ts; } if(!component.title) {component.title = data.get('title'); } if(!component.icon) {component.icon = data.get('icon'); } if(!component.externalLink && data.get('externalLink')) {component.externalLink = data.get('externalLink'); }  },  show: function(viewid) { if (!this.componentManager.containsKey(viewid)) {return; } var component = this.componentManager.get(viewid); if(component.fireEvent('beforeshow', component) === false) {return; } if (this.topPanel.items.containsKey(component.TOP_PANEL_ID)) {this.topPanel.layout.setActiveItem(component.TOP_PANEL_ID);this.expandTopPanel(); } if (this.contentPanel.items.containsKey(component.CONTENT_PANEL_ID)) {this.showContentPanel();this.contentPanel.layout.setActiveItem(component.CONTENT_PANEL_ID);this.doBackLevel2(component.VIEW_ID); } this.topPanel.doLayout(); this.contentPanel.doLayout(); this.basePanel.doLayout(); component.fireEvent('show', component); this.broadcastVisibleExcerptId(component.VIEW_ID); this.controller.reloadGAScript(component.gaURL);  },  showWithoutTopPanel: function(viewid) { if (!this.componentManager.containsKey(viewid)) {return; } var component = this.componentManager.get(viewid); if(component.fireEvent('beforeshow', component) === false) {return; } if (this.contentPanel.items.containsKey(component.CONTENT_PANEL_ID)) {this.showContentPanel();this.contentPanel.layout.setActiveItem(component.CONTENT_PANEL_ID); } this.collapseTopPanel(); this.contentPanel.doLayout(); this.basePanel.doLayout(); component.fireEvent('show', component);  },  showTopPanel: function(viewid) { if (!this.componentManager.containsKey(viewid)) {return; } var component = this.componentManager.get(viewid); this.topPanel.layout.setActiveItem(component.TOP_PANEL_ID); this.expandTopPanel(); this.topPanel.doLayout(); this.basePanel.doLayout();  },  showAsMenu: function(viewid) { if (!this.componentManager.containsKey(viewid)) {return; } this.hideAllMenuPanel(); var component = this.componentManager.get(viewid); if(component.fireEvent('beforeshowmenu', component) === false) {return; } if(!component.menuLayer) {var menuLayer = new Ext.Layer({  id: 'menu-layer-' + component.ID,  shadow: 'frame',  constrain: false,  zindex: 16000});component.getMenuPanel().render(menuLayer.dom);menuLayer.on('click', component.hideMenuLayer.createDelegate(component));Ext.EventManager.onWindowResize(component.hideMenuLayer.createDelegate(component));Ext.EventManager.on(NetBook.ID_DOCKSCREEN, 'click', component.hideMenuLayer.createDelegate(component));component.menuLayer = menuLayer; } component.menuLayer.dockItemClicked = true; var xy = component.menuLayer.getAlignToXY('nb-dockscreen-' + component.ID, 'tl-bl?', [0, 0]); component.menuLayer.setXY(xy); component.menuLayer.show(); component.fireEvent('showmenu', component);  },  showDock: function() { var dock = this.getDock(); this.showTopPanel(NetBook.ID_DOCKSCREEN); var user = this.controller.getUser(); dock.refresh(); dock.setAddressBarType(user.getAddrBarType());  },  getDock: function() { var dock = this.componentManager.get(NetBook.ID_DOCKSCREEN); if (!dock) {dock = new NetBook.DockScreen({controller: this.controller});this.addComponent(dock); } return dock;  },  showHomeScreen: function(activeComponent) { this.showIFrame(); this.showDock();  },  setActiveComponent: function(activeComponent) { var dock = this.getDock(); dock.setActiveComponent(activeComponent);  },  showLoginScreen: function() { var signInObj = new NetBook.SignInPanel({controller: this.controller}); this.addComponent(signInObj); this.addComponent(new NetBook.SignUpPanel({controller: this.controller})); this.showWithoutTopPanel(signInObj.VIEW_ID);  },  showVerifyScreen: function() { var verifySuccessPanel = new NetBook.VerifySuccessPanel({controller: this.controller}); this.addComponent(verifySuccessPanel); this.showWithoutTopPanel(verifySuccessPanel.VIEW_ID);  },  createTopPanel: function(component) { var iframe = new Ext.ux.ManagedIFrame.Panel({border: false,header: false,height: NetBook.TOP_PANEL_AD_HEIGHT,width: NetBook.TOP_PANEL_AD_WIDTH,defaultSrc: component.advertUrls ? component.advertUrls[0].url : null,hidden: component.advertUrls ? false : true,frameConfig : {  frameborder : 0,  allowtransparency : true} }); var adPanel = new Ext.Panel({id: 'collapse-btn-panel-' + component.VIEW_ID,cls: 'ad-panel',border: false,region: 'east',items: iframe }); component.advertPanelObj = iframe; iframe.on('afterrender', component.changeAdvert.createDelegate(component)); var level1BtnPanel = new Ext.Panel({id: 'level1-btn-child-panel-' + component.VIEW_ID,border: false,autoWidth: true,html: '<div style="white-space: nowrap;">' + NetBook.HOMESCREEN_TITLE + '</div>' }); var sepBtnPanel = new Ext.Panel({cls: 'level-separator-btn',border: false,height: 15,width: 25 }); var level2BtnPanel = new Ext.Panel({id: 'level2-btn-child-panel-' + component.VIEW_ID,border: false,autoWidth: true,html: '<div style="white-space: nowrap;">' + component.title + '</div>' }); var breadScrumbPanel = new Ext.Panel({id: 'bread-scrumb-panel-' + component.VIEW_ID,cls: 'bread-scrumb-panel',layout: 'table',border: false,layoutConfig: {  columns: 3},items: [  {cls: 'level-btn', id: 'level1-btn-panel-' + component.VIEW_ID, border: false, items: level1BtnPanel},  sepBtnPanel,  {id: 'level2-btn-panel-' + component.VIEW_ID, border: false, items: level2BtnPanel}] }); var style = "width: 60px; height: 60px; background: transparent url("+component.icon+") no-repeat scroll center center;"; var iconPanel = new Ext.Panel({border: false,html: "<div style='"+style+"'><div>" }); var componentActionsPanel = new Ext.Panel({border: false,width: 240,layout: 'hbox',layoutConfig: {  pack:'start',  align:'top'},items: [{  border: false,  width: 40}] }); var actionsPanel = component.getActions(); if (actionsPanel && Ext.isArray(actionsPanel)) {for(var i = 0; i < actionsPanel.length; i++) {  componentActionsPanel.add(this.convertToBtnPanel(actionsPanel[i], component.VIEW_ID));} } var titlePanel = new Ext.Panel({border: false,width: 522,items: [{  border: false,  layout: 'hbox',  layoutConfig: { pack:'start', align:'middle'  },  items: [{ border: false, height: NetBook.TOP_PANEL_TITLE_HEIGHT, html: "<div id='top-component-title'>"+ NetBook.SERVICE_NAME + ' ' + component.title +"<div>"  },  componentActionsPanel]},breadScrumbPanel] }); var iconTitlePanel = new Ext.Panel({border: false,region: 'center',layout: 'hbox',layoutConfig: {  pack:'start',  align:'top'},items: [iconPanel, titlePanel] }); var panel = new Ext.Panel({id: component.TOP_PANEL_ID,layout: 'border',border: false,height: NetBook.TOP_PANEL_AD_HEIGHT,autoScroll: false,items: [iconTitlePanel, adPanel] }); adPanel.on('afterrender', function() {var btn = Ext.get('collapse-btn-panel-' + component.VIEW_ID);btn.on('click', function() {  component.fireEvent('collapsetoppanel', component);}); }); level1BtnPanel.on('afterrender', function() {var btn = Ext.get('level1-btn-panel-' + component.VIEW_ID);btn.on('click', function() {  var id = this.id;  id = id.replaceAll('level1-btn-panel-', '');  var component = thisMSObj.componentManager.get(id);  component.fireEvent('backlevel1', component);});btn = Ext.get('level1-btn-child-panel-' + component.VIEW_ID);btn.addClassOnOver('over'); }); return panel;  },  addBreadScrumbLevel3: function(componentId, title) { var component = this.componentManager.get(componentId); component.breadScrumbLevel3Title = title; var btn = Ext.get('level2-btn-panel-' + componentId); btn.addClass('level-btn'); btn.on('click', component.onBackLevel2Delegate.createDelegate(component)); btn = Ext.get('level2-btn-child-panel-' + componentId); btn.addClassOnOver('over'); var sepBtnPanel = new Ext.Panel({id: 'level3-separator-btn-' + componentId,cls: 'level-separator-btn',border: false,height: 15,width: 25 }); var level3BtnPanel = new Ext.Panel({id: 'level3-btn-panel-' + componentId,border: false }); level3BtnPanel.on('afterrender', function() {var p = thisMSObj.topPanel.findById('bread-scrumb-panel-' + this.id.replaceAll('level3-btn-panel-', ''));var total = 10;for (var i = 0; i < p.items.getCount() - 1; i++) {  total += p.items.itemAt(i).getEl().getWidth();}var width = (thisMSObj.topPanel.getEl().getWidth() * 0.48 - 60) - total;var t = truncate(component.breadScrumbLevel3Title, width, 1, this.id);Ext.get(this.id).update('<div style="white-space: nowrap;">'+t+'</div>');thisMSObj.topPanel.doLayout(); }); var panel = this.topPanel.findById('bread-scrumb-panel-' + componentId); panel.layout.columns += 2; panel.remove('level3-separator-btn-' + componentId); panel.remove('level3-btn-panel-' + componentId); panel.add(sepBtnPanel); panel.add(level3BtnPanel); panel.doLayout();  },  doBackLevel2: function(componentId) { var component = this.componentManager.get(componentId); this.showContentPanel(); var btn = Ext.get('level2-btn-panel-' + componentId); btn.removeClass('level-btn'); btn.removeAllListeners(); btn = Ext.get('level2-btn-child-panel-' + componentId); btn.removeClass('over'); btn.removeAllListeners(); var panel = this.topPanel.findById('bread-scrumb-panel-' + componentId); panel.remove('level3-separator-btn-' + componentId); panel.remove('level3-btn-panel-' + componentId); panel.doLayout();  },  broadcastVisibleExcerptId: function(id) { for (var i = 0; i < this.componentManager.getCount(); i++) {var component = this.componentManager.itemAt(i);if (component.VIEW_ID == id) {  component.visible = true;  continue;}component.visible = false; }  },  broadcastVisible: function() { this.broadcastVisibleExcerptId(null);  },  convertToBtnPanel: function(attributes, componentId) { var btnPanel = new Ext.Panel({cls: attributes.cls,id: attributes.id + '-' + componentId,bodyStyle: 'padding-left: 5px',border: false,height: 27,width: 34 }); btnPanel.on('afterrender', function() {var btn = Ext.get(attributes.id + '-' + componentId);btn.on('click', attributes.clickListener);btn.set({title: attributes.title}); }); return btnPanel;  },  hideAllMenuPanel: function() { for (var i = 0; i < this.componentManager.getCount(); i++) {var component = this.componentManager.itemAt(i);if (component.menuLayer) {  component.menuLayer.hide();} }  },  onTopPanelResize: function(sender, adjWidth, adjHeight, rawWidth, rawHeight) { for (i = 0; i < this.componentManager.getCount(); i++) {var component = this.componentManager.itemAt(i);component.fireEvent('toppanelresize', component, adjWidth, adjHeight, rawWidth, rawHeight); }  }});NetBook.NBController = Ext.extend(Ext.util.Observable, {  constructor: function(config) { Ext.apply(this, config = config || {}); NetBook.NBController.superclass.constructor.call(this, config); this.initEvents(); this.initialize();  },  initialize: function() { this.addHistoryUrl = this.getURL('history', 'add'); this.logoutUrl  = this.baseURL + 'logout'; this.mainScreen = new NetBook.MainScreen({controller: this}); if (this.verifyUser) {this.mainScreen.showVerifyScreen(); } else if (this.authenticated) {if (this.activeComponent) {  this.mainScreen.setActiveComponent(this.activeComponent);} else {  this.mainScreen.showHomeScreen();} } else {this.mainScreen.showLoginScreen(); }  },  initEvents: function() { Ext.Ajax.on('beforerequest', this.onBeforeRequest.createDelegate(this), this); Ext.Ajax.on('requestcomplete', this.onRequestComplete.createDelegate(this), this);  },  getMainScreen: function() { return this.mainScreen;  }, getUser: function() { return this.user;  }, isAuthenticated: function() { return this.authenticated;  },  getBaseURL: function() { return this.baseURL;  },  getURL: function(module, action) { if (module) {module =  module + '/'; } else {module = ''; } if (!action) {action = ''; } return this.baseURL + module + action;  },  getImagePath: function(img) { return NetBook.IMAGE_PATH + img;  },  createComponent: function(data) { return this.getMainScreen().createComponent(data);  },  addComponent: function(component, isActive) { this.getMainScreen().addComponent(component, isActive);  },  show: function(componentId) { this.getMainScreen().show(componentId);  },  showWithoutTopPanel: function(componentId) { this.getMainScreen().showWithoutTopPanel(componentId);  },  collapseTopPanel: function() { this.getMainScreen().collapseTopPanel();  },  showTopMenu: function() { this.getMainScreen().showDock(); this.getMainScreen().showIFrame(); this.getMainScreen().broadcastVisible();  },  showAsMenu: function(componentId) { this.getMainScreen().showAsMenu(componentId);  },  addBreadScrumbLevel3: function(componentId, title) { this.getMainScreen().addBreadScrumbLevel3(componentId, title);  },  onBeforeRequest: function(conn, options) { return true;  },  onRequestComplete: function(conn, response, options) { var result = Ext.decode(response.responseText); if (result && result.success && result.not_authenticated) {if(this.showMsgTimeout) {  return;}var msg = NetBook.NETBOOKAPP_SESSION_TIMEOUT;showMessage(msg, function(sender) {  if (sender == 'ok') { window.location = location.href;  }});this.showMsgTimeout = true; }  },  onWriteHistoryCompleted: function(res) { },  writeHistory: function(url) { Ext.Ajax.request({url: this.addHistoryUrl,params: {url:url},success: this.onWriteHistoryCompleted.createDelegate(this),failure: this.onWriteHistoryCompleted.createDelegate(this) });  }, openURL: function(url, notWriteHistory) { this.getMainScreen().showIFrame(url); if (!notWriteHistory && this.isAuthenticated()) {this.writeHistory(url); }  },  openURLByNewBrowser: function(url) { window.open(url, '');  },  goBack: function() { history.go(-1);  },  goNext: function() { history.go(1);  },  goHome: function() { var page = NetBook.DEFAULT_HOMEPAGE; if (this.user && this.user.getHomePage()) {page = this.user.getHomePage(); } this.openURL(page, true);  },  logout: function() { showConfirm(NetBook.NETBOOKAPP_LOGOUT_MSG, this.doLogout.createDelegate(this));  },  doLogout: function(btn) { if ('yes' == btn) {window.location = this.logoutUrl; }  },  checkLanguage: function(user) { var langCookie = this.getCookie('nblang'); return langCookie == user.getLanguage();  },  getCookie: function(name) { var start = document.cookie.indexOf(name + "="); var len = start + name.length + 1; if ((!start) && (name != document.cookie.substring(0, name.length))) {return null; } if (start == -1) {return null; } var end = document.cookie.indexOf(";", len); if (end == -1) {end = document.cookie.length; } return decodeURI(document.cookie.substring(len, end));  },  reloadGAScript: function(url) { Ext.getDom('gascript-iframe').src = url;  }});NetBook.NotePanel = Ext.extend(NetBook.Component, {  VIEW_ID: NetBook.ID_WEB_NOTE_PANEL,  initComponent: function() { NetBook.NotePanel.superclass.initComponent.call(this); this.urlIndex = this.controller.getURL('webnote', 'index'); this.urlDelete = this.controller.getURL('webnote', 'delete'); thisNoteObj = this; this.noteStore = new Ext.data.JsonStore({url: this.urlIndex,autoLoad: false,root: 'items',id: 'id',fields: ['id', 'content', 'content_view', 'closed', 'created_at', 'updated_at'] }); var columns = [{dataIndex: 'content',tpl: "<div id='note-menu-{id}' class='dropdown-menu'></div>" + "<div style='margin-left: 25px;'><div class='date'>{updated_at}</div><br/><div class='content'>{content_view}</div></div>" }]; this.contentGrid = new Ext.ListView({id: 'note-grid-panel',store: this.noteStore,columns: columns,hideHeaders: true,border: false,singleSelect: true,loadingText: NetBook.ALL_LOADING,deferEmptyText: true,emptyText: this.getEmptyStyle(NetBook.NOTE_PANEL_EMPTY_MSG),prepareData: function(data) {  var formater = Ext.util.Format;  data.content_view = formater.htmlEncode(data.content_view);  data.content_view = formater.nl2br(data.content_view);  return data;} }); var contentPanel = new Ext.Panel({region: 'center',border: true,autoScroll: true,items: this.contentGrid }); this.view = new Ext.Panel({border: false,autoWidth: true,layout: 'border',items : [contentPanel] }); this.contextMenu = new Ext.menu.Menu({id: 'note-menu',items: [{  text: NetBook.NOTE_PANEL_CONTEXTMENU_EDIT,  iconCls: 'menu-notes-edit',  handler: this.executeEdit.createDelegate(this)},{  text: NetBook.NOTE_PANEL_CONTEXTMENU_DELETE,  iconCls: 'menu-notes-delete',  handler: this.executeDelete.createDelegate(this)}] }); this.noteStore.on('load', this.onStoreLoad, this);  },  getActions: function() { return Array({id: 'add-notes-btn', cls: 'add-notes-btn', clickListener: this.executeNew.createDelegate(this), title: NetBook.NOTE_PANEL_TIP_NEWNOTE});  },  getContentPanel: function() { return this.view;  },  initComponentComplete: function() { this.noteStore.load();  },  onStoreLoad: function(sender, records, options) { for(var i = 0; i < sender.getCount(); i++) {Ext.get('note-menu-' + sender.getAt(i).get('id')).on('click', function() {  thisNoteObj.contextMenu.show(this.id);}); }  }, executeNew: function(sender) { if (!this.popup) {this.popup = new NetBook.NoteWindow({controller: this.controller, callback: this.initComponentComplete.createDelegate(this)}); } this.popup.show();  }, executeEdit: function() { if (!this.popup) {this.popup = new NetBook.NoteWindow({controller: this.controller, callback: this.initComponentComplete.createDelegate(this)}); } var record = this.contentGrid.getSelectedRecords()[0]; var data = {id: record.get('id'),action_type: 'edit',content: record.get('content') }; this.popup.show(data);  },  executeDelete: function() { showConfirm(NetBook.NOTE_PANEL_DELETE_CONFIRM, this.onDelete.createDelegate(this));  },  onDelete: function(sender) { if ('no' == sender) return; var record = this.contentGrid.getSelectedRecords()[0]; var id = record.get('id'); showWaitingDlg(null, NetBook.ALL_BTN_WAIT); Ext.Ajax.request({url: this.urlDelete,params: {  id: id},success: function(form, action) {  hideWaitingDlg();  thisNoteObj.noteStore.load();},failure: function(form, action) {  hideWaitingDlg();  showActionFailureDlg(action);} });  }});NetBook.NoteWindow = Ext.extend(NetBook.Component, {  title: NetBook.NOTE_PANEL_NEWNOTE_FORM_TITLE,  width: 300,  height: 200,  resizable: true,  callback: Ext.emptyFn,  initComponent: function() { NetBook.NoteWindow.superclass.initComponent.call(this); thisNoteWObj = this; this.urlNew = this.controller.getURL('webnote', 'new'); this.urlEdit = this.controller.getURL('webnote', 'edit'); this.bodyPanel = new Ext.form.FormPanel({labelAlign:'top',bodyStyle: 'padding:10px;',border: false,autoHeight:true,buttonAlign: 'center',layoutConfig: {  labelSeparator: ''},defaults: {  msgTarget: 'under'},items:[{  xtype: 'hidden',  name: 'id'},{  xtype: 'hidden',  name: 'action_type'},  { xtype: 'textarea', anchor: '100%', hideLabel: true, emptyText: NetBook.NOTE_PANEL_NEWNOTE_FORM, name: 'content', height: 90, validationEvent: false, validateOnBlur: false  }], buttons: [{ text: NetBook.ALL_BTN_DONE, handler: this.executeNote.createDelegate(this)  },  { text: NetBook.ALL_BTN_CANCEL, handler: this.hide.createDelegate(this)  }]}); this.noteWindow = new Ext.Window({title: this.title,bodyStyle: 'background:transparent;',width: this.width,height: this.height,border: false,collapsible: false,closable: false,resizable: this.resizable,maximizable: false,minimizable: false,modal: true,plain: false,shadow: false,tools: [{  id: 'close',  qtip: NetBook.ALL_TIP_HIDE,  handler: this.hide.createDelegate(this)}],items: [this.bodyPanel] });  },  show: function(data) { if(data) {this.noteWindow.setTitle(NetBook.NOTE_PANEL_EDITNOTE_FORM_TITLE); } else {this.noteWindow.setTitle(NetBook.NOTE_PANEL_NEWNOTE_FORM_TITLE);data = {}; } this.noteWindow.show(); var form = this.bodyPanel.getForm(); form.clearInvalid(); form.findField('id').setValue(data.id); form.findField('action_type').setValue(data.action_type ? data.action_type : 'new'); form.findField('content').setValue(data.content); window.setTimeout(function() {var form = thisNoteWObj.bodyPanel.getForm();form.findField('content').focus();form.findField('content').selectText(); }, 200);  },  hide: function() { this.noteWindow.hide();  },  executeNote: function(sender) { var form = this.bodyPanel.getForm(); var actionType = form.findField('action_type').getValue(); var content = form.findField('content'); if(!content.getValue()) {setErrField(form, 'content', NetBook.NOTE_PANEL_CONTENT_ERR1);return; } showWaitingDlg(this.noteWindow.getEl(), NetBook.ALL_BTN_WAIT); form.submit({url: actionType == 'new' ? this.urlNew : this.urlEdit,params: {},success: function(form, action) {  hideWaitingDlg(thisNoteWObj.noteWindow.getEl());  thisNoteWObj.hide();  thisNoteWObj.callback();},failure: function(form, action) {  hideWaitingDlg(thisNoteWObj.noteWindow.getEl());  showActionFailureDlg(action);} });  }});NetBook.SettingPanel = Ext.extend(NetBook.Component, {  VIEW_ID: NetBook.ID_SETTING_PANEL,  LEFT_MENU_WIDTH: 200,  LEFT_MENU_HEIGHT: 100,  urlListDocument: '',  urlChgHomepage: '',  urlChgPassword: '',  urlDeleteAccount : '',  initComponent: function() { NetBook.SettingPanel.superclass.initComponent.call(this); this.tokenUrl= this.controller.getURL('auth', 'getToken'); this.urlHome= this.controller.getURL('home', 'index'); this.urlListDocument = this.controller.getURL('setting', 'menu'); this.urlChgPassword = this.controller.getURL('setting', 'password'); this.urlUpdateProfile = this.controller.getURL('setting', 'updateProfile'); this.urlHomePage = this.controller.getURL('homepage', 'index'); this.urlGetLanguage = this.controller.getURL('setting', 'getLanguage'); this.urlChgLanguage = this.controller.getURL('setting', 'changeLanguage'); this.urlGetDockStyle  = this.controller.getURL('setting', 'getDockSytle'); this.urlChgDockStyle= this.controller.getURL('setting', 'changeDockStyle'); thisSettingObj = this; this.tpl = new Ext.XTemplate('<tpl for=".">' +  '<div class="nb-address-item">' + '<table cellspacing="0" cellpadding="0" border="0"><tbody>' + '<tr>' +'<td style="width:16px;"><image src="{icon}" width="16px" height="16px"/></td>' +'<td nowrap="nowrap"><div class="nb-address-item-title"><span>{[this.truncate(values.title,200,"setting-center-panel")]}</span></div></td>' + '</tr>' + '<tr>' +'<td>&nbsp;</td>' +'<td nowrap="nowrap"><div class="nb-address-item-url"><span>{[this.truncate(values.url,200,"setting-center-panel")]}</span></div></td>' + '</tr>' + '</tbody></table>' +  '</div>' +  '</tpl>',{  truncate: function(title,width,id){ var formater = Ext.util.Format; var textMetric = Ext.util.TextMetrics.createInstance(document.getElementById(id)); var truncatedContent; if (textMetric.getWidth(title) <= width) {  truncatedContent = title; } else {  var i = 0;  while (textMetric.getWidth(formater.ellipsis(title, i)) <= width)i++;  truncatedContent = formater.ellipsis(title, i - 1); } return truncatedContent;  }} ); this.store = new Ext.data.JsonStore({url: this.urlListDocument,root: 'items',fields: ['id', 'name'] }); this.store.on('load', this.menuShow, this); this.leftMenu = new Ext.DataView({id:'ic-items-menu-inner',itemSelector: 'a',singleSelect: true,overClass: 'hover',selectedClass: 'active',loadMask: { msg:NetBook.ALL_LOADING },tpl: new Ext.XTemplate(  '<tpl for=".">',  '<a id="ic-menu-{id}" hidefocus="on">', '{name:stripTags}',  '</a>',  '</tpl>'),store: this.store }); this.leftMenu.on('click', this.menuClick, this); this.menuView = new Ext.Panel({  id: 'ic-items-menu',  collapsible: false,  header :false,  border: false,  items: [this.leftMenu] }); this.leftPanel = new Ext.Panel({id: 'setting-left-panel',region: 'west',width: this.LEFT_MENU_WIDTH,height: this.LEFT_MENU_HEIGHT,margins:'0 0 0 20px',collapsible: false,header :false,border: false,items: [this.menuView] }); this.updateProfileMsgPanel = new Ext.Panel({id: 'update-profile-mess-panel',cls: 'update-setting-mess-panel',border: false,html : '<span class="mess">'+NetBook.SETTING_PANEL_PROFILE_UPDATED+'<span>',buttonAlign: 'center',buttons:[{  text: NetBook.NETBOOKAPP_SHOWMESSAGE_BTN_OK,  handler: function() { thisSettingObj.updateProfilePanel.items.get(0).layout.setActiveItem(0);  }}] }); this.updateProfileForm = new Ext.FormPanel({id: 'update-profile-form',autoHeight:true,border: false,defaultType: 'textfield',bodyStyle: 'padding-top: 5px;',buttonAlign: 'center',layoutConfig: {  labelSeparator :''},defaults: {  msgTarget: 'under'},items :[{  xtype: 'hidden',  name: 'id'},{  fieldLabel: NetBook.SETTING_PANEL_PROFILE_EMAIL,  name: 'email',  id: 'email',  validationEvent: false,  validateOnBlur: false,  anchor: '100%'}],keys: [{  key: Ext.EventObject.ENTER,  fn: this.executeUpdateProfile.createDelegate(this),  scope: this}],buttons:[{  text: NetBook.SETTING_PANEL_BTN_SAVE,  handler: this.executeUpdateProfile.createDelegate(this)}] }); this.updateProfilePanel = new Ext.Panel({id: 'update-profile-panel',autoHeight: true,bodyStyle: 'background:transparent;padding: 5px 5px 0;',border: false,items: [{  xtype:'fieldset',  autoHeight: true,  checkboxToggle:false,  layout: 'card',  activeItem: 0,  title: NetBook.SETTING_PANEL_PROFILE_FORM,  items: [this.updateProfileForm, this.updateProfileMsgPanel]}] }); this.updatePasswordMsgPanel = new Ext.Panel({id: 'update-password-mess-panel',cls: 'update-setting-mess-panel',border: false,html : '<span class="mess">'+NetBook.SETTING_PANEL_PASS_UPDATED+'<span>',buttonAlign: 'center',buttons:[{  text: NetBook.NETBOOKAPP_SHOWMESSAGE_BTN_OK,  handler: function() { thisSettingObj.updatePasswordPanel.items.get(0).layout.setActiveItem(0); thisSettingObj.showChgPwdPanel();  }}] }); this.updatePasswordForm = new Ext.FormPanel({id: "update-password-form",border: false,autoHeight: true,labelWidth: 110,defaultType: 'textfield',bodyStyle: 'padding-top: 5px;',buttonAlign: 'center',layoutConfig: {  labelSeparator: ''},defaults: {  msgTarget: 'under'},items: [{  xtype: 'hidden',  name: 'id'},{  fieldLabel: NetBook.SETTING_PANEL_PASS_CURRENT,  inputType: 'password',  anchor: '100%',  name: 'current_password',  validationEvent: false,  validateOnBlur: false},{  fieldLabel: NetBook.SETTING_PANEL_PASS_NEW,  inputType: 'password',  anchor: '100%',  name: 'new_password',  validationEvent: false,  validateOnBlur: false},{  fieldLabel: NetBook.SETTING_PANEL_PASS_CONFIRM,  inputType: 'password',  anchor: '100%',  name: 'confirm_password',  validationEvent: false,  validateOnBlur: false}],keys: [{  key: Ext.EventObject.ENTER,  fn: this.executeChgPassword.createDelegate(this),  scope: this}],buttons:[{ text: NetBook.SETTING_PANEL_BTN_SAVE, handler: this.executeChgPassword.createDelegate(this)}] }); this.updatePasswordPanel = new Ext.Panel({id: 'update-password-panel',autoHeight: true,bodyStyle: 'background:transparent;padding: 5px 5px 0;',border: false,items: [{  xtype:'fieldset',  autoHeight: true,  checkboxToggle:false,  layout: 'card',  activeItem: 0,  title: NetBook.SETTING_PANEL_PASS_FORM,  items: [this.updatePasswordForm, this.updatePasswordMsgPanel]}] }); this.urlRegistMail = this.controller.getURL('mail', 'regist'); this.urlMailSystem = this.controller.getURL('mail', 'system'); this.urlRegistOtherMail = this.controller.getURL('mail', 'registOther'); this.urlDeleteMail = this.controller.getURL('mail', 'delete'); this.checkboxMailClicked = false; this.mailSystemStore = new Ext.data.JsonStore({url: this.urlMailSystem,fields: ['id', 'title', 'description', 'webmail_url', 'small_icon', 'large_icon', 'over_large_icon', 'index', 'is_in_system', 'is_using'] }); this.mailSystemStore.setDefaultSort('index', "ASC"); this.mailSystemStore.on('load', this.onLoadMailUser.createDelegate(this)); this.mailSystemTpl = new Ext.XTemplate('<tpl for=".">','<div class="thumb-wrap" id="{id}">','<div class="thumb">','<table cellspacing="0px" cellpadding="0px"><tr>','<td width="90%">','<table cellspacing="0" cellpadding="0"><tr><td><img src="{large_icon_path}"/></td><td align="left">{other_title}</td></tr></table>','</td>','<td align="right" id="mail-td-{id}"><img id="mail-image-checked-{id}" src="{image_checked}"/></td>','</tr></table>','</div>','</div>','</tpl>' ); this.mailSystemView = new Ext.DataView({store: this.mailSystemStore,tpl: this.mailSystemTpl,autoHeight: true,multiSelect: false,overClass: 'x-view-over',itemSelector: 'div.thumb-wrap',emptyText: NetBook.EMAIL_PANEL_EMPTY_MSG,loadMask: { msg:NetBook.ALL_LOADING },prepareData: function(data) {  if (data.is_in_system == 0) {data.other_title = '<span id="mail-title-span">'+ data.title +'</span>';  }  data.large_icon_path = thisSettingObj.controller.getImagePath(data.large_icon);  if (data.is_using == true) { data.hidden_checked = 'checked'; data.image_checked = thisSettingObj.controller.getImagePath('checked_16x16.png');  } else {data.hidden_checked = 'unchecked';data.image_checked = thisSettingObj.controller.getImagePath('unchecked_16x16.png');  }  return data;} }); this.otherMailPanel = new Ext.FormPanel({id: 'other-mail-panel',labelAlign:'top',bodyStyle: 'background:transparent;padding: 0px 5px 0px 5px !important;',buttonAlign: 'center',border: false,autoHeight: true,autoScroll: false,keys: [{  key: Ext.EventObject.ENTER,  fn: this.registOtherMail.createDelegate(this),  scope: this}],items:[{ id: 'other-mail-fieldset', xtype:'fieldset', title: NetBook.EMAIL_PANEL_OTHERMAIL_FORM, autoHeight:true, defaultType: 'textfield', layoutConfig: {labelSeparator: '' }, defaults: {msgTarget: 'under' }, collapsed: false, items: [ {xtype: 'hidden',name: 'data_index' }, {xtype: 'hidden',name: 'large_icon' }, {fieldLabel: NetBook.EMAIL_PANEL_OTHERMAIL_LBL_TITLE,anchor: '100%',name: 'title',validationEvent: false,validateOnBlur: false }, {fieldLabel: NetBook.EMAIL_PANEL_OTHERMAIL_LBL_WEBMAIL,anchor: '100%',name: 'webmail_url',validationEvent: false,validateOnBlur: false }]}],buttons:[{  text: NetBook.ALL_BTN_DONE,  handler: this.registOtherMail.createDelegate(this)},{  text: NetBook.ALL_BTN_CANCEL,  handler: function() { var panel = thisSettingObj.mailSystemPanel.items.get(0); panel.buttons[0].show(); panel.layout.setActiveItem(0);  }}] }); this.updateMailMsgPanel = new Ext.Panel({id: 'update-mail-mess-panel',cls: 'update-setting-mess-panel',border: false,html : '<span class="mess">'+NetBook.SETTING_PANEL_EMAIL_UPDATED+'<span>',buttonAlign: 'center',buttons:[{  text: NetBook.NETBOOKAPP_SHOWMESSAGE_BTN_OK,  handler: function() { var panel = thisSettingObj.mailSystemPanel.items.get(0); panel.buttons[0].show(); panel.layout.setActiveItem(0);  }}] }); this.mailSystemPanel = new Ext.Panel({id: 'mail-service-panel',bodyStyle: 'background:transparent;padding: 5px 5px 0;',border: false,autoHeight: true,autoScroll: false,items:[{  xtype:'fieldset',  checkboxToggle:false,  title: NetBook.SETTING_PANEL_EMAIL_SETTING,  layout: 'card',  activeItem: 0,  collapsed: false,  autoHeight: true,  autoScroll: false,  buttonAlign: 'center',  items: [this.mailSystemView, this.otherMailPanel, this.updateMailMsgPanel],  buttons:[{ text: NetBook.SETTING_PANEL_BTN_SAVE, handler: this.executeMailSetting.createDelegate(this)  }]}] }); this.mailSystemView.addListener("click", this.onMailSytemClick.createDelegate(this)); this.urlRegistCalendar = this.controller.getURL('calendar', 'regist'); this.urlCalendarSystem = this.controller.getURL('calendar', 'system'); this.urlRegistOtherCalendar = this.controller.getURL('calendar', 'registOther'); this.urlDeleteCalendar = this.controller.getURL('calendar', 'delete'); this.checkboxCalendarClicked = false; this.calendarSystemStore = new Ext.data.JsonStore({url: this.urlCalendarSystem,fields: ['id', 'title', 'description', 'webcalendar_url', 'small_icon', 'large_icon', 'over_large_icon', 'index', 'is_in_system', 'is_using'] }); this.calendarSystemStore.setDefaultSort('index', "ASC"); this.calendarSystemStore.on('load', this.onLoadCalendarUser.createDelegate(this)); this.calendarSystemTpl = new Ext.XTemplate('<tpl for=".">','<div class="thumb-wrap" id="{id}">','<div class="thumb">','<table width="100%" cellspacing="0px" cellpadding="0px"><tr>','<td width="90%">','<table cellspacing="0" cellpadding="0"><tr><td><img src="{large_icon_path}"/></td><td align="left">{other_title}</td></tr></table>','</td>','<td align="right" id="calendar-td-{id}"><img id="calendar-image-checked-{id}" src="{image_checked}"/></td>','</tr></table>','</div>','</div>','</tpl>','<div class="x-clear"></div>' ); this.calendarSystemView = new Ext.DataView({store: this.calendarSystemStore,tpl: this.calendarSystemTpl,autoHeight: true,multiSelect: false,overClass: 'x-view-over',itemSelector: 'div.thumb-wrap',emptyText: NetBook.CALENDAR_PANEL_EMPTY_MSG,loadMask: { msg:NetBook.ALL_LOADING },prepareData: function(data) {  if (data.is_in_system == 0) {data.other_title = '<span id="calendar-title-span">'+ data.title +'</span>';  }  data.large_icon_path = thisSettingObj.controller.getImagePath(data.large_icon);  if (data.is_using == true) { data.hidden_checked = 'checked'; data.image_checked = thisSettingObj.controller.getImagePath('checked_16x16.png');  } else {data.hidden_checked = 'unchecked';data.image_checked = thisSettingObj.controller.getImagePath('unchecked_16x16.png');  }  return data;} }); this.otherCalendarPanel = new Ext.FormPanel({id: 'other-calendar-panel',labelAlign:'top',bodyStyle: 'background:transparent;padding: 0px 5px 0px 5px !important;',buttonAlign: 'center',border: false,autoHeight: true,autoScroll: false,keys: [{  key: Ext.EventObject.ENTER,  fn: this.registOtherCalendar.createDelegate(this),  scope: this}],items:[{ id: 'other-calendar-fieldset', xtype:'fieldset', title: NetBook.SETTING_PANEL_OTHERCALENDAR_FORM, autoHeight:true, defaultType: 'textfield', layoutConfig: {labelSeparator: '' }, defaults: {msgTarget: 'under' }, collapsed: false, items: [ {xtype: 'hidden',name: 'data_index' }, {xtype: 'hidden',name: 'large_icon' }, {fieldLabel: NetBook.EMAIL_PANEL_OTHERMAIL_LBL_TITLE,anchor: '100%',name: 'title',validationEvent: false,validateOnBlur: false }, {fieldLabel: NetBook.SETTING_PANEL_OTHERCALENDAR_WEB,anchor: '100%',name: 'webcalendar_url',validationEvent: false,validateOnBlur: false }]}],buttons:[{  text: NetBook.ALL_BTN_DONE,  handler: this.registOtherCalendar.createDelegate(this)},{  text: NetBook.ALL_BTN_CANCEL,  handler: function() { var panel = thisSettingObj.calendarSystemPanel.items.get(0); panel.buttons[0].show(); panel.layout.setActiveItem(0);  }}] }); this.updateCalendarMsgPanel = new Ext.Panel({id: 'update-calendar-mess-panel',cls: 'update-setting-mess-panel',border: false,html : '<span class="mess">'+NetBook.SETTING_PANEL_CALENDAR_UPDATED+'<span>',buttonAlign: 'center',buttons:[{  text: NetBook.NETBOOKAPP_SHOWMESSAGE_BTN_OK,  handler: function() { var panel = thisSettingObj.calendarSystemPanel.items.get(0); panel.buttons[0].show(); panel.layout.setActiveItem(0);  }}] }); this.calendarSystemPanel = new Ext.Panel({id: 'calendar-service-panel',bodyStyle: 'background:transparent;padding: 5px 5px 0;',border: false,autoHeight: true,autoScroll: false,buttonAlign: 'center',items:[{  xtype:'fieldset',  checkboxToggle:false,  title: NetBook.SETTING_PANEL_CALENDAR_SETTING,  layout: 'card',  buttonAlign: 'center',  activeItem: 0,  collapsed: false,  autoHeight: true,  autoScroll: false,  items: [this.calendarSystemView, this.otherCalendarPanel, this.updateCalendarMsgPanel],  buttons:[{ text: NetBook.SETTING_PANEL_BTN_SAVE, handler: this.executeCalendarSetting.createDelegate(this)  }]}] }); this.calendarSystemView.addListener("click", this.onCalendarSytemClick.createDelegate(this)); this.enLanguage = new Ext.form.Radio({boxLabel: 'English',name: 'language',inputValue: 'en_US',value: 'en_US' }); this.jaLanguage = new Ext.form.Radio({boxLabel: '日本語',name: 'language',inputValue: 'ja_JP',value: 'ja_JP' }); this.changeLanguagePanel = new Ext.FormPanel({id: 'change-language-panel',autoHeight:true,bodyStyle: 'background:transparent;padding: 5px 5px 0;',border: false,autoHeight:true,items:[{  xtype:'fieldset',  checkboxToggle:false,  buttonAlign: 'center',  autoHeight:true,  title: NetBook.SETTING_PANEL_LANGUAGE_SETTING,  layoutConfig: { labelSeparator :''  },  defaults: { msgTarget: 'under'  },  items :[ new Ext.form.RadioGroup({hideLabel: true,vertical: false,id:"language",items: [this.enLanguage, this.jaLanguage]  })],  buttons:[{ text: NetBook.SETTING_PANEL_BTN_SAVE, handler: this.checkedLanguage.createDelegate(this)  }]}] }); this.dockStyleStore = new Ext.data.JsonStore({url: this.urlGetDockStyle,root: 'items',fields: ['id', 'name', 'select'] }); this.dockStyleStore.on('load', function() {if(this.getCount() > 0) {  for (i = 0 ; i < this.getCount(); i++) { var record = this.getAt(i); if (record.get('select')) {thisSettingObj.dockStyleDv.select('dockstyle-' + record.get('id'));return; }  }} }); this.dockStyleTpl = new Ext.XTemplate('<tpl for=".">','<div id="dockstyle-{id}" class="dockstyle-wrap {select}">','<div class="{name}"></div>','<div class="selected"></div>','</div>','</tpl>' ); this.dockStyleDv = new Ext.DataView({itemSelector: 'div.dockstyle-wrap',overClass: 'x-view-over',selectedClass: 'x-view-selected',style: 'overflow:auto; padding-left: 17px;',singleSelect: true,store: this.dockStyleStore,tpl: this.dockStyleTpl,autoHeight: true }); this.dockStyleDv.on('click', function() {if(this.execute) {  return;}var record = this.store.getAt(this.store.find('select', 'x-view-selected'));if (this.getSelectedRecords()[0].get('id') == record.get('id')) {  return;}var dom = Ext.get('dockstyle-' + record.get('id'));if (dom.hasClass('x-view-selected')) {  dom.removeClass('x-view-selected');  this.execute = true;} }); this.changeDockPanel = new Ext.Panel({id: 'change-dock-panel',autoHeight:true,bodyStyle: 'background:transparent;padding: 5px 5px 0;',border: false,autoHeight:true,items:[{  xtype:'fieldset',  checkboxToggle:false,  buttonAlign: 'center',  autoHeight:true,  title: NetBook.SETTING_PANEL_DOCK_SETTING,  items: this.dockStyleDv,  buttons:[{ text: NetBook.SETTING_PANEL_BTN_SAVE, handler: this.checkedDock.createDelegate(this)  }]}] }); this.centerDetailPanel = new Ext.Panel({id: 'setting-center-panel',width: 400,autoHeight: true,layout: 'card',activeItem: 0,header: false,border: false,items:[this.updateProfilePanel, this.updatePasswordPanel, this.mailSystemPanel, this.calendarSystemPanel, this.changeLanguagePanel, this.changeDockPanel] }); this.centerPanel = new Ext.Panel({cls: 'setting-detail',region: 'center',bodyStyle: 'padding:10px;',header :false,border: false,items: this.centerDetailPanel }); this.detailPanel = new Ext.Panel({id: 'setting-detail-panel',layout: 'border',height:433,margins: '10',header :false,border: false,width: this.getWidthSize(),items : [this.leftPanel, this.centerPanel] }); this.mainPanel = new Ext.Panel({id: 'setting-main-view',bodyStyle: 'padding:10px;',header :false,border: false,items : [this.detailPanel] });  },  getContentPanel: function() { return this.mainPanel;  },  initComponentComplete: function() {},  show: function() { if (this.leftPanel.getSize().width == 0) {this.leftPanel.setWidth(this.LEFT_MENU_WIDTH); } this.store.reload(); this.showUpdateProfilePanel();  },  menuShow: function() { var el = Ext.getDom('ic-menu-0'); if(el) {el.className = 'active'; }  },  menuClick: function(object, index, event) { var record = thisSettingObj.store.getAt(index); if (record.get('id') != 0) {var el = Ext.getDom('ic-menu-0');if(el) {  el.className = '';} } if (record.get('id') == 0) {this.showUpdateProfilePanel(); } else if (record.get('id') == 1) {this.showChgPwdPanel(); } else if (record.get('id') == 2) {this.showMailSettingPanel(); } else if (record.get('id') == 3) {this.showCalendarSettingPanel(); } else if (record.get('id') == 4) {this.showChgLanguagePanel(); } else if (record.get('id') == 5) {this.showChgDockPanel(); }  },  showUpdateProfilePanel: function() { this.centerDetailPanel.layout.setActiveItem(0); this.updateProfilePanel.items.get(0).layout.setActiveItem(0); var user = this.controller.getUser(); var form = this.updateProfileForm.getForm(); form.findField('id').setValue(user.getUserId()); form.findField('email').setValue(user.getEmail());form.findField('email').focus(); this.centerDetailPanel.doLayout();  },  showChgPwdPanel: function() { this.centerDetailPanel.layout.setActiveItem(1); this.updatePasswordPanel.items.get(0).layout.setActiveItem(0); var user = this.controller.getUser(); var form = this.updatePasswordForm.getForm(); form.findField('id').setValue(user.getUserId()); form.findField('current_password').setValue(''); form.findField('new_password').setValue(''); form.findField('confirm_password').setValue(''); form.findField('current_password').focus(); this.centerDetailPanel.doLayout();  },  showMailSettingPanel: function() { this.mailSystemStore.reload(); this.centerDetailPanel.layout.setActiveItem(2); var panel = this.mailSystemPanel.items.get(0); panel.buttons[0].show(); panel.layout.setActiveItem(0);  },  showCalendarSettingPanel: function() { this.calendarSystemStore.reload(); this.centerDetailPanel.layout.setActiveItem(3); var panel = this.calendarSystemPanel.items.get(0); panel.buttons[0].show(); panel.layout.setActiveItem(0);  },  showChgLanguagePanel: function() { this.centerDetailPanel.layout.setActiveItem(4); var form = this.changeLanguagePanel.getForm(); Ext.Ajax.request({url: this.urlGetLanguage,params: {},success: function(result) {  var ret = eval('(' + result.responseText + ')');  if (ret.language == 'en_US') { form.findField('language').items.get(0).setValue(true); form.findField('language').items.get(1).setValue(false);  }  else { form.findField('language').items.get(0).setValue(false); form.findField('language').items.get(1).setValue(true);  }},failure: function(form, action) {} }); this.centerDetailPanel.doLayout();  },  showChgDockPanel: function() { this.dockStyleDv.execute = false; this.centerDetailPanel.layout.setActiveItem(5); this.dockStyleStore.reload(); this.changeDockPanel.doLayout();  },  checkedLanguage: function(sender) { var form = this.changeLanguagePanel.getForm(); var redioEn = form.findField('language').items.get(0); var lang = null; if(redioEn.getValue()) {lang = 'en_US'; } else {lang = 'ja_JP'; } Ext.Ajax.request({url: this.urlChgLanguage,params: {  language: lang},success: function(result) {  location.reload(true);},failure: function(form, action) {} });  },  checkedDock: function(sender) { var record = this.dockStyleDv.getSelectedRecords()[0]; Ext.Ajax.request({url: this.urlChgDockStyle,params: {  dock_bar_style: record.get('id')},success: function(result) {  location.reload(true);},failure: function(form, action) {} });  },  reloadUser: function() { Ext.Ajax.request({  url: this.tokenUrl,  params: {},  success: this.onGetTokenCompleted.createDelegate(this),  failure: function(form, action) { switch (action.failureType) {case Ext.form.Action.CLIENT_INVALID:  showMessage(NetBook.SIGNIN_PANEL_ERR1);  break;case Ext.form.Action.CONNECT_FAILURE:  showMessage(NetBook.SIGNIN_PANEL_ERR2);  break; }  } });  },  onGetTokenCompleted: function(res) { var ret = eval('(' + res.responseText + ')'); if (ret && ret.isAuthenticated && ret.user) {var user = new NetBook.User({  userId: ret.user.userId,  username: ret.user.username,  fullname: ret.user.fullname,  email: ret.user.email,  gender: ret.user.gender,  type: ret.user.type, addrBarType: ret.user.addressbar_type,  language: ret.user.language});user.setAuthenticated(true);this.controller.user = user;this.controller.getDashBoard().setAuthInfo(user); }  },  executeChgPassword: function() { if (!this.validateChgPassword()) {return; } var form = this.updatePasswordForm.getForm(); var text = this.updatePasswordForm.buttons[0].text; this.updatePasswordForm.buttons[0].setText(NetBook.ALL_BTN_WAIT); form.submit({url: this.urlChgPassword,params: {},success: function(form, action) {  thisSettingObj.updatePasswordForm.buttons[0].setText(text);  thisSettingObj.updatePasswordPanel.items.get(0).layout.setActiveItem(1);},failure: function(form, action) {  thisSettingObj.updatePasswordForm.buttons[0].setText(text);  thisSettingObj.setErrMessField(form, 'current_password', NetBook.SETTING_PANEL_PASS_ERR1);  switch (action.failureType) { case Ext.form.Action.CLIENT_INVALID:showMessage(NetBook.SIGNIN_PANEL_ERR1);break; case Ext.form.Action.CONNECT_FAILURE:showMessage(NetBook.SIGNIN_PANEL_ERR2);break;}} });  },  executeUpdateProfile: function() { if (!this.validateUpdateProfile()) {return; } var form = this.updateProfileForm.getForm(); var text = this.updateProfileForm.buttons[0].text; this.updateProfileForm.buttons[0].setText(NetBook.ALL_BTN_WAIT); form.submit({url: this.urlUpdateProfile,params: {},success: function(form, action) {  thisSettingObj.updateProfileForm.buttons[0].setText(text);  thisSettingObj.reloadUser();  thisSettingObj.updateProfilePanel.items.get(0).layout.setActiveItem(1);},failure: function(form, action) {  thisSettingObj.updateProfileForm.buttons[0].setText(text);  switch (action.failureType) { case Ext.form.Action.CLIENT_INVALID:showMessage(NetBook.SIGNIN_PANEL_ERR1);break; case Ext.form.Action.CONNECT_FAILURE:showMessage(NetBook.SIGNIN_PANEL_ERR2);break;}} });  },  onMailSytemClick: function(object, index, event) { var data = this.mailSystemStore.getAt(index); if (data.get('is_in_system') == 1) {var domImage = Ext.getDom('mail-image-checked-' + data.get('id'));if (data.get('is_using') == true) {  data.set('is_using', false);  domImage.src = this.controller.getImagePath('unchecked_16x16.png');} else {  data.set('is_using', true);  domImage.src = this.controller.getImagePath('checked_16x16.png');}this.mailCheckboxClicked(data.get('id')); } else if (this.checkboxMailClicked && data.get('webmail_url').trim()) {  var domImage = Ext.getDom('mail-image-checked-' + data.get('id'));  if (data.get('is_using') == true) { data.set('is_using', false); domImage.src = this.controller.getImagePath('unchecked_16x16.png');  } else { data.set('is_using', true); domImage.src = this.controller.getImagePath('checked_16x16.png');  }  this.mailCheckboxClicked(data.get('id')); } else {this.showOtherMailPanel(data, index); } this.checkboxMailClicked = false;  },  showOtherMailPanel: function(data, data_index) { var form = this.otherMailPanel.getForm(); form.findField('title').setValue(data.get('title')); var title = data.get('webmail_url'); form.findField('webmail_url').setValue(title ? title : 'http://'); form.findField('large_icon').setValue(data.get('large_icon').trim()); form.findField('data_index').setValue(data_index); var panel = this.mailSystemPanel.items.get(0); panel.buttons[0].hide(); panel.layout.setActiveItem(1); panel.doLayout(); form.findField('title').focus();  },  registOtherMail: function(data) { var form = this.otherMailPanel.getForm(); if (!this.validateEmailSetting(form)) {return; } var data_index = form.findField('data_index').getValue(); var data = this.mailSystemStore.getAt(data_index); data.set('title', form.findField('title').getValue().trim()); data.set('webmail_url', form.findField('webmail_url').getValue().trim()); data.set('is_using', true); this.mailCheckboxClicked(data.get('id')); Ext.getDom('mail-title-span').innerHTML = form.findField('title').getValue().trim(); Ext.getDom('mail-image-checked-' + data.get('id')).src = this.controller.getImagePath('checked_16x16.png'); var panel = this.mailSystemPanel.items.get(0); panel.buttons[0].show(); panel.layout.setActiveItem(0); panel.doLayout();  },  executeMailSetting: function() { var values = ''; for (i = 0; i < this.mailSystemStore.getCount(); i++) {var data = this.mailSystemStore.getAt(i);if (data.get('is_using') == true) {  var value = '{"title": "'+data.get('title')+'",';  value += '"webmail_url": "'+data.get('webmail_url')+'",';  value += '"large_icon": "'+data.get('large_icon')+'",';  value += '"is_in_system": '+data.get('is_in_system')+'},';  values += value;} } var panel = this.mailSystemPanel.items.get(0); var text = panel.buttons[0].text; panel.buttons[0].setText(NetBook.ALL_BTN_WAIT); values = '['+ values.substring(0, values.length - 1) +']'; Ext.Ajax.request({url: this.urlRegistMail,method: 'post',params: {  values: values},success: function(res) {  panel.buttons[0].setText(text);  panel.buttons[0].hide();  panel.layout.setActiveItem(2);},failure: function(res) {  panel.buttons[0].setText(text);} });  },  onLoadMailUser: function(sender, records, options) { for (i = 0; i < records.length; i++) {var id = records[i].get('id');this.mailCheckboxClicked(id); }  },  mailCheckboxClicked: function(id) { var checkbox = Ext.get('mail-td-' + id); checkbox.on('click', function() {thisSettingObj.checkboxMailClicked = true; });  },  onCalendarSytemClick: function(object, index, event) { var data = this.calendarSystemStore.getAt(index); if (data.get('is_in_system') == 1) {var domImage = Ext.getDom('calendar-image-checked-' + data.get('id'));if (data.get('is_using') == true) {  data.set('is_using', false);  domImage.src = this.controller.getImagePath('unchecked_16x16.png');} else {  data.set('is_using', true);  domImage.src = this.controller.getImagePath('checked_16x16.png');}this.calendarCheckboxClicked(data.get('id')); } else if (this.checkboxCalendarClicked && data.get('webcalendar_url').trim()) {  var domImage = Ext.getDom('calendar-image-checked-' + data.get('id'));  if (data.get('is_using') == true) { data.set('is_using', false); domImage.src = this.controller.getImagePath('unchecked_16x16.png');  } else { data.set('is_using', true); domImage.src = this.controller.getImagePath('checked_16x16.png');  }  this.calendarCheckboxClicked(data.get('id')); } else {this.showOtherCalendarPanel(data, index); } this.checkboxCalendarClicked = false;  },  showOtherCalendarPanel: function(data, data_index) { var form = this.otherCalendarPanel.getForm(); form.findField('title').setValue(data.get('title')); var title = data.get('webcalendar_url'); form.findField('webcalendar_url').setValue(title ? title : 'http://'); form.findField('large_icon').setValue(data.get('large_icon').trim()); form.findField('data_index').setValue(data_index); var panel = this.calendarSystemPanel.items.get(0); panel.buttons[0].hide(); panel.layout.setActiveItem(1); panel.doLayout(); form.findField('title').focus();  },  registOtherCalendar: function(data) { var form = this.otherCalendarPanel.getForm(); if (!this.validateCalendarSetting(form)) {  return; } var data_index = form.findField('data_index').getValue(); var data = this.calendarSystemStore.getAt(data_index); data.set('title', form.findField('title').getValue().trim()); data.set('webcalendar_url', form.findField('webcalendar_url').getValue().trim()); data.set('is_using', true); this.calendarCheckboxClicked(data.get('id')); Ext.getDom('calendar-title-span').innerHTML = form.findField('title').getValue().trim(); Ext.getDom('calendar-image-checked-' + data.get('id')).src = this.controller.getImagePath('checked_16x16.png'); var panel = this.calendarSystemPanel.items.get(0); panel.buttons[0].show(); panel.layout.setActiveItem(0); panel.doLayout();  },  executeCalendarSetting: function() { var values = ''; for (i = 0; i < this.calendarSystemStore.getCount(); i++) {var data = this.calendarSystemStore.getAt(i);if (data.get('is_using') == true) {  var value = '{"title": "'+data.get('title')+'",';  value += '"webcalendar_url": "'+data.get('webcalendar_url')+'",';  value += '"large_icon": "'+data.get('large_icon')+'",';  value += '"is_in_system": '+data.get('is_in_system')+'},';  values += value;} } var panel = this.calendarSystemPanel.items.get(0); var text = panel.buttons[0].text; panel.buttons[0].setText(NetBook.ALL_BTN_WAIT); values = '['+ values.substring(0, values.length - 1) +']'; Ext.Ajax.request({url: this.urlRegistCalendar,method: 'post',params: {  values: values},success: function(res) {  panel.buttons[0].setText(text);  panel.buttons[0].hide();  panel.layout.setActiveItem(2);},failure: function(res) {  panel.buttons[0].setText(text);} });  },  onLoadCalendarUser: function(sender, records, options) { for (i = 0; i < records.length; i++) {var id = records[i].get('id');this.calendarCheckboxClicked(id); }  },  calendarCheckboxClicked: function(id) { var checkbox = Ext.get('calendar-td-' + id); checkbox.on('click', function() {thisSettingObj.checkboxCalendarClicked = true; });  },  validateChgPassword: function() { var form = this.updatePasswordForm.getForm(); form.clearInvalid(); mess = NetBook.SETTING_PANEL_PASS_ERR2; if(form.findField("current_password").getValue() == '') {this.setErrMessField(form, 'current_password', mess);return false; } if(form.findField("new_password").getValue() == '') {this.setErrMessField(form, 'new_password', mess);return false; } if(form.findField("new_password").getValue() != form.findField("confirm_password").getValue()) {this.setErrMessField(form, 'confirm_password', NetBook.SETTING_PANEL_PASS_ERR3);return false; } return true;  },  validateEmailSetting: function() { var form = this.otherMailPanel.getForm(); form.clearInvalid(); if(form.findField("title").getValue() == '') {this.setErrMessField(form, 'title', NetBook.EMAIL_PANEL_OTHERMAIL_ERR1);return false; } var webmail = form.findField("webmail_url"); if(!webmail.getValue() || webmail.getValue() == 'http://') {this.setErrMessField(form, 'webmail_url', NetBook.EMAIL_PANEL_OTHERMAIL_ERR2);return false; } return true;  },  validateCalendarSetting: function() { var form = this.otherCalendarPanel.getForm(); form.clearInvalid(); if(form.findField("title").getValue() == '') {this.setErrMessField(form, 'title', NetBook.EMAIL_PANEL_OTHERMAIL_ERR1);return false; } var webcalendar = form.findField("webcalendar_url"); if(!webcalendar.getValue() || webcalendar.getValue() == 'http://') {this.setErrMessField(form, 'webcalendar_url', NetBook.SETTING_PANEL_OTHERCALENDAR_ERR1);return false; } return true;  },  validateUpdateProfile: function() { var form = this.updateProfileForm.getForm(); form.clearInvalid(); if(form.findField("email").getValue().trim() == '') {this.setErrMessField(form, 'email', NetBook.SETTING_PANEL_PROFILE_ERR3);return false; }  return true;  },  setErrMessField: function(form, fielddId, message) { form.markInvalid([{'id': fielddId,msg: message }]); form.findField(fielddId).focus();  },  getWidthSize: function() { if(Ext.isIE) {return 710; } else {return 885; }  }});NetBook.SimplePanel = Ext.extend(NetBook.Component, {  initComponent: function() { NetBook.SimplePanel.superclass.initComponent.call(this);  },  show: function() { var target_url = this.externalLink.target_url; if (this.externalLink.email_on_url) {if (target_url.lastIndexOf('/') != target_url.length - 1) {  target_url += "/";}var user = this.controller.getUser();target_url += "?email=" + user.getEmail(); } if (this.externalLink.open_in_new_window == 0) {this.controller.openURL(target_url, true, true); } else {this.fireEvent('backlevel1', this);this.controller.openURLByNewBrowser(target_url); }  }});NetBook.ID_TWITTER_PANEL = 'nb-twitter';NetBook.TwitterPanel = Ext.extend(NetBook.Component, {  VIEW_ID: NetBook.ID_TWITTER_PANEL,  initComponent: function() { NetBook.TwitterPanel.superclass.initComponent.call(this); this.urlTwitterUser = this.controller.getURL('twitter', 'user'); this.twitterUserStore = new Ext.data.JsonStore({url: this.urlTwitterUser,id: 'id',fields: ['id', 'title', 'description', 'twitter_url', 'small_icon', 'large_icon', 'over_large_icon', 'index', 'is_in_system', 'target'] }); this.twitterUserStore.setDefaultSort('index', "ASC"); this.twitterUserTpl = new Ext.XTemplate('<tpl for=".">','<div class="thumb-wrap">','<div class="thumb"><table cellspacing="0" cellpadding="0"><tr><td><img src="{large_icon_path}"/></td><td align="left">{other_title}</td></tr></table></div>','</div>','</tpl>' ); thisTwitterObj = this; this.twitterUserView = new Ext.DataView({store: this.twitterUserStore,tpl: this.twitterUserTpl,multiSelect: false,overClass: 'x-view-over',itemSelector: 'div.thumb-wrap',loadingText: NetBook.ALL_LOADING,deferEmptyText: true,emptyText: this.getMenuEmptyStyle(NetBook.TWITTER_PANEL_EMPTY_MSG),prepareData: function(data) {  if (data.is_in_system == 0) {data.other_title = data.title;  }  data.large_icon_path = thisTwitterObj.controller.getImagePath(data.large_icon);  return data;} }); var twitterUserPanel = new Ext.Panel({id: 'twitter-nav-panel',border:false,items: [this.twitterUserView] }); this.view = new Ext.Panel({border:false,items : [twitterUserPanel] }); this.twitterUserView.addListener("click", this.onTwitterUserClick.createDelegate(this)); this.twitterUserStore.on('load', this.synMenuSize.createDelegate(this));  },  getMenuPanel: function() { return this.view;  },  showMenu: function() { this.twitterUserStore.reload(); this.view.doLayout();  },  onTwitterUserClick: function(object, index, event) { var data = this.twitterUserStore.getAt(index); var url = data.get('twitter_url'); var target = data.get('target'); if (target == NetBook.OPEN_URL_TARGET_BLANK) {this.controller.openURLByNewBrowser(url); } else {this.controller.openURL(url, true, true); } this.controller.reloadGAScript(this.gaURL + '/' + data.get('title'));  }});