diff options
| author | Andreas Brachold <vdr07@deltab.de> | 2010-10-07 19:22:36 +0000 |
|---|---|---|
| committer | Andreas Brachold <vdr07@deltab.de> | 2010-10-07 19:22:36 +0000 |
| commit | 11f97b0d0ec698d978e14226647c31b823ff87e4 (patch) | |
| tree | 40652a224461efa380e33e30edd6df94cd97d88f | |
| parent | 8e90628c62bf33b4baffb33576e89b5e708fd934 (diff) | |
| download | xxv-11f97b0d0ec698d978e14226647c31b823ff87e4.tar.gz xxv-11f97b0d0ec698d978e14226647c31b823ff87e4.tar.bz2 | |
jason: fix misspelled javascript syntax (Bug #017539)
33 files changed, 1545 insertions, 1544 deletions
diff --git a/skins/jason/audio.js b/skins/jason/audio.js index 2a620d5..200826a 100644 --- a/skins/jason/audio.js +++ b/skins/jason/audio.js @@ -45,7 +45,7 @@ Ext.xxv.AudioWindow = function(item) { }); this.on('beforeshow', this.onBeforeShow, this); Ext.xxv.AudioWindow.superclass.show.apply(this, arguments); -} +}; Ext.extend(Ext.xxv.AudioWindow, Ext.Window, { szTitle: "Music playback" diff --git a/skins/jason/autotimers.js b/skins/jason/autotimers.js index 76e4859..cf07ec9 100644 --- a/skins/jason/autotimers.js +++ b/skins/jason/autotimers.js @@ -89,7 +89,6 @@ Ext.xxv.autotimerGrid = function(viewer, channels) { region: 'center' ,id: 'autotimer-view-grid' ,loadMask: true - ,plugins:[this.activeColumn] ,clicksToEdit:1 ,autoExpandColumn:'expand' ,cm: cm @@ -116,7 +115,8 @@ Ext.xxv.autotimerGrid = function(viewer, channels) { ,handler: function(){ this.EditItem(null); } } ]}) - ,plugins:[new Ext.ux.grid.Search({ + ,plugins:[this.activeColumn, + new Ext.ux.grid.Search({ position:'top' ,shortcutKey:null ,paramNames: { @@ -210,8 +210,9 @@ Ext.extend(Ext.xxv.autotimerGrid, Ext.grid.EditorGridPanel, { var items = this.menu.items; if(items) { items.eachKey(function(key, f) { - if(XXV.help.cmdAllowed(f.itemId)) - f.enable(); + if(XXV.help.cmdAllowed(f.itemId)) { + f.enable(); + } },items); } @@ -229,10 +230,10 @@ Ext.extend(Ext.xxv.autotimerGrid, Ext.grid.EditorGridPanel, { } } ,formatTitle: function(value, p, record) { - var style = ""; - if((record.data.active & 1) == 0) { - style = " deactive"; - } + var style = ""; + if((record.data.active & 1) === 0) { + style = " deactive"; + } return String.format( '<div class="topic{1}"><b>{0}</b></div>', value, style @@ -249,7 +250,7 @@ Ext.extend(Ext.xxv.autotimerGrid, Ext.grid.EditorGridPanel, { new Ext.xxv.MessageBox().msgSuccess(this.szDeleteSuccess, o.data); var gsm = this.getSelectionModel(); - var sel = options.params.data.split(","); + var sel = options.params.data.split(","); sel.reverse(); for(var i = 0, len = sel.length; i < len; i++){ if(gsm.isIdSelected(sel[i])) { @@ -281,16 +282,17 @@ Ext.extend(Ext.xxv.autotimerGrid, Ext.grid.EditorGridPanel, { this.loadMask.show(); var gsm = this.getSelectionModel(); - var sel = gsm.getSelections() + var sel = gsm.getSelections(); if(sel.length <= 0) { gsm.selectRecords([record]); sel.push(record); } var todel = ""; for(var i = 0, len = sel.length; i < len; i++){ - if(i != 0) - todel += ','; - todel += sel[i].data.id; + if(i !== 0) { + todel += ','; + } + todel += sel[i].data.id; } Ext.Ajax.request({ scope: this @@ -307,7 +309,7 @@ Ext.extend(Ext.xxv.autotimerGrid, Ext.grid.EditorGridPanel, { this.stopEditing(); var item; - if(record != null) { + if(record !== null) { var gsmTimer = this.getSelectionModel(); gsmTimer.selectRecords([record]); @@ -362,27 +364,27 @@ Ext.extend(Ext.xxv.autotimerGrid, Ext.grid.EditorGridPanel, { new Ext.xxv.MessageBox().msgFailure(this.szUpgradeFailure, response.statusText); } ,UpgradeItem : function() { - Ext.Ajax.request({ - scope: this - ,url: XXV.help.cmdAJAX('au') - ,timeout: 120000 - ,success: this.onUpgradeSuccess - ,failure: this.onUpgradeFailure - }); + Ext.Ajax.request({ + scope: this + ,url: XXV.help.cmdAJAX('au') + ,timeout: 120000 + ,success: this.onUpgradeSuccess + ,failure: this.onUpgradeFailure + }); Ext.MessageBox.show({ title: this.szUpgradeWait ,msg: this.szUpgrade ,width:240 ,wait:true - ,waitConfig:{ - interval:200 - ,duration:119000 - ,increment:15 - ,fn:function() { + ,waitConfig:{ + interval:200 + ,duration:119000 + ,increment:15 + ,fn:function() { Ext.MessageBox.hide(); - } - } + } + } }); } ,updateTimer : function() { diff --git a/skins/jason/channels.js b/skins/jason/channels.js index 60aaf14..1a0be35 100644 --- a/skins/jason/channels.js +++ b/skins/jason/channels.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -49,6 +49,6 @@ Ext.xxv.ChannelsCombo.prototype ={ return rec.data.name; } } - return record.data.channel; + return record.data.channel; } }; diff --git a/skins/jason/channelspanel.js b/skins/jason/channelspanel.js index 26290e6..2ce7c2e 100644 --- a/skins/jason/channelspanel.js +++ b/skins/jason/channelspanel.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -88,14 +88,15 @@ Ext.xxv.channelsPanel = function() { if(node){ var record = this.store.getById(node.attributes.channel); var top = Ext.getCmp('main-tabs'); - switch(top.getActiveTab().id) { - case 'vt': top.openTeleText(node.attributes.text, node.attributes.channel); break; - default: top.openProgram(record.data); break; + if(top.getActiveTab().id == 'vt') { + top.openTeleText(node.attributes.text, node.attributes.channel); + } else { + top.openProgram(record.data); } var items = this.topToolbar.items; if(items) { items.eachKey(function(key, f) { - if(XXV.help.cmdAllowed(key)) f.enable(); + if(XXV.help.cmdAllowed(key)) { f.enable(); } },items); } } }, @@ -201,7 +202,7 @@ Ext.extend(Ext.xxv.channelsPanel, Ext.tree.TreePanel, { var items = this.menu.items; if(items) { items.eachKey(function(key, f) { if(XXV.help.cmdAllowed(f.itemId)) - f.enable(); + { f.enable(); } },items); } @@ -242,7 +243,7 @@ Ext.extend(Ext.xxv.channelsPanel, Ext.tree.TreePanel, { if(!inactive){ if(!preventAnim){ Ext.fly(node.ui.elNode).slideIn('l', { - callback: node.select, scope: node, duration: .4 + callback: node.select, scope: node, duration: 0.4 }); }else{ node.select(); @@ -264,19 +265,19 @@ Ext.extend(Ext.xxv.channelsPanel, Ext.tree.TreePanel, { } ,onLoad : function( store, records, opt ) { - var node,grpname; + var i,node,grpname; - for(var i = this.root.childNodes.length; i > 0; i--){ + for(i = this.root.childNodes.length; i > 0; i--){ this.root.removeChild(this.root.item(i-1)); } - for(var i = 0, len = records.length; i < len; i++){ + for(i = 0, len = records.length; i < len; i++){ if(!node || records[i].data.grpname != grpname) { node = this.root.appendChild( new Ext.tree.TreeNode({ text:records[i].data.grpname, cls:'channels-node', - expanded: (i == 0 ? true: false) + expanded: (i === 0 ? true: false) }) ); grpname = records[i].data.grpname; diff --git a/skins/jason/chronicle.js b/skins/jason/chronicle.js index 7fceda1..b4c3500 100644 --- a/skins/jason/chronicle.js +++ b/skins/jason/chronicle.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -207,7 +207,7 @@ Ext.extend(Ext.xxv.ChronicleGrid, Ext.grid.EditorGridPanel, { new Ext.xxv.MessageBox().msgSuccess(this.szDeleteSuccess, o.data); var gsm = this.getSelectionModel(); - var sel = options.params.data.split(","); + var sel = options.params.data.split(","); sel.sort(function (a, b) { return b - a; }); for(var i = 0, len = sel.length; i < len; i++){ if(gsm.isIdSelected(sel[i])) { @@ -237,14 +237,14 @@ Ext.extend(Ext.xxv.ChronicleGrid, Ext.grid.EditorGridPanel, { this.loadMask.show(); var gsm = this.getSelectionModel(); - var sel = gsm.getSelections() + var sel = gsm.getSelections(); if(sel.length <= 0) { gsm.selectRecords([record]); sel.push(record); } var todel = ""; for(var i = 0, len = sel.length; i < len; i++){ - if(i != 0) + if(i !== 0) todel += ','; todel += sel[i].data.id; } diff --git a/skins/jason/common.js b/skins/jason/common.js index 3370862..25429ba 100644 --- a/skins/jason/common.js +++ b/skins/jason/common.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -124,7 +124,7 @@ Ext.extend(Ext.xxv.TagClouds, Ext.Component, { initComponent : function(){ Ext.xxv.TagClouds.superclass.initComponent.call(this); - this.addEvents({'selectKeyword' : true}); + this.addEvents({'selectKeyword' : true}); }, setvalue : function(keywords){ @@ -133,8 +133,8 @@ Ext.extend(Ext.xxv.TagClouds, Ext.Component, { if(this.cloudlist) { this.cloudlist.remove(); - delete this.cloudlist; - this.cloudlist = null; + delete this.cloudlist; + this.cloudlist = null; } }, @@ -142,31 +142,31 @@ Ext.extend(Ext.xxv.TagClouds, Ext.Component, { if(!this.cloudlist && this.keywords && this.keywords.length) { this.cloudlist = ct.createChild({tag: "ol", cls: "x-cloud-list"}); - for(var i = 0, len = this.keywords.length; i < len; i++){ - var child = this.cloudlist.createChild({ + for(var i = 0, len = this.keywords.length; i < len; i++){ + var child = this.cloudlist.createChild({ tag: "li", cls: "x-cloud-item "+this.getWeight(this.keywords[i][1]), html: '<a href="#">'+this.keywords[i][0]+'</a>' }); - - child.on('click', this.onSelectKeyWord, this); + + child.on('click', this.onSelectKeyWord, this); } } } /**************************************************************************/ - ,getWeight : function(weight){ + ,getWeight : function(weight){ var nmax = 100; var nmin = 0; - var styles = new Array('smallest','smaller','small','medium','large','larger','largest'); + var styles = new Array("smallest","smaller","small","medium","large","larger","largest"); var value = weight / (nmax - nmin) * 6; - if(value >= 6.0) - return styles[6]; - if(value <= 0.0) - return styles[0]; + if(value >= 6.0) + return styles[6]; + if(value <= 0.0) + return styles[0]; - return styles[Math.round(value)]; - } + return styles[Math.round(value)]; + } /**************************************************************************/ ,onSelectKeyWord : function(e, t){ diff --git a/skins/jason/fixes.js b/skins/jason/fixes.js index b3ae7b9..1c4352a 100644 --- a/skins/jason/fixes.js +++ b/skins/jason/fixes.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -18,7 +18,7 @@ Ext.override(Ext.form.TimeField, { initComponent : function(){ Ext.form.TimeField.superclass.initComponent.call(this); - this.minValue = this.parseDate(this.minValue) || Date.parseDate(this.initDate, this.initDateFormat).clearTime();; + this.minValue = this.parseDate(this.minValue) || Date.parseDate(this.initDate, this.initDateFormat).clearTime(); this.maxValue = this.parseDate(this.maxValue) || this.minValue.add('mi', (24 * 60) - 1); if(!this.store){ diff --git a/skins/jason/form.js b/skins/jason/form.js index 04f9c0e..c106999 100644 --- a/skins/jason/form.js +++ b/skins/jason/form.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * diff --git a/skins/jason/help.js b/skins/jason/help.js index 3732147..09ff4e7 100644 --- a/skins/jason/help.js +++ b/skins/jason/help.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -41,7 +41,7 @@ Ext.extend(Ext.xxv.help, Ext.util.Observable, { for(var i = 0, len = store.getCount(); i < len; i++){ var record = store.getAt(i); if(!lastModule || record.data.module != lastModule) { - lastModule = record.data.module + lastModule = record.data.module; XXV.configMenu.add(new Ext.menu.Item( { text: record.data.module diff --git a/skins/jason/index.tmpl b/skins/jason/index.tmpl index 87b2b10..7a24a6b 100644 --- a/skins/jason/index.tmpl +++ b/skins/jason/index.tmpl @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="<?% charset %?>"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<?% verbose = 0 %?> +<?% verbose = 1 %?> <?% compressed = 0 %?> <?% lang = locale.split('_') %?> <html xmlns="http://www.w3.org/1999/xhtml" <?% IF lang.1 %?>xml:lang="<?% lang.0 %?>" lang="<?% lang.0 %?>"<?% ELSE %?>xml:lang="en" lang="en"<?% END %?>> diff --git a/skins/jason/login.js b/skins/jason/login.js index b8b12dc..eba6dc9 100644 --- a/skins/jason/login.js +++ b/skins/jason/login.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2009, anbr + * Copyright(c) 2009-2010, anbr * * http://xxv.berlios.de/ * @@ -15,7 +15,7 @@ Ext.LoginPanel = function() { ,frame:true ,title:this.szTitle ,defaultType:'textfield' - ,monitorValid:true + ,monitorValid:true ,items:[ { xtype:'box' ,anchor:'' @@ -46,7 +46,7 @@ Ext.LoginPanel = function() { ,handler:this.onSubmit }] }); -} +}; Ext.extend(Ext.LoginPanel, Ext.FormPanel, { szTitle: 'Please login' @@ -130,9 +130,9 @@ Ext.onReady(function(){ plain: true, border: false, items: [new Ext.LoginPanel()] - }); + }); - win.show(); + win.show(); setTimeout(function(){ var l = Ext.get('loading'); diff --git a/skins/jason/main.js b/skins/jason/main.js index 150ac80..33a10e3 100644 --- a/skins/jason/main.js +++ b/skins/jason/main.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -8,7 +8,7 @@ */ var XXV = { -} +}; Ext.Component.prototype.stateful = false; @@ -30,7 +30,7 @@ Ext.onReady(function(){ if(!all.subtitle) { var Woerter = title.split("~"); if(Woerter.length > 1) { - var subtitle = Woerter.pop(); + /*var subtitle = */Woerter.pop(); return Woerter.join('~'); } } @@ -61,7 +61,7 @@ Ext.onReady(function(){ }); XXV.getTemplate = function(){ return tpl; - } + }; XXV.help = new Ext.xxv.help(); XXV.side = new Ext.xxv.channelsPanel(); diff --git a/skins/jason/menus.js b/skins/jason/menus.js index 4787226..b294fc6 100644 --- a/skins/jason/menus.js +++ b/skins/jason/menus.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -9,8 +9,8 @@ Ext.xxv.MainSearchField = Ext.extend(Ext.form.TwinTriggerField, { initComponent : function(){ - Ext.xxv.MainSearchField.superclass.initComponent.call(this); - this.on('specialkey', function(f, e){ + Ext.xxv.MainSearchField.superclass.initComponent.call(this); + this.on('specialkey', function(f, e){ if(e.getKey() == e.ENTER){ this.onTrigger2Click(); } @@ -35,9 +35,9 @@ Ext.xxv.MainSearchField = Ext.extend(Ext.form.TwinTriggerField, { Ext.xxv.Menu = Ext.extend(Ext.menu.Menu, { initComponent : function(){ - Ext.xxv.Menu.superclass.initComponent.call(this); + Ext.xxv.Menu.superclass.initComponent.call(this); this.on('beforerender', function(menu) { - menu.items.eachKey(function(key, f) { + menu.items.eachKey(function(key, f) { if(f.cmd && XXV.help.cmdAllowed(f.cmd)) f.enable(); },menu.items); @@ -58,13 +58,13 @@ Ext.xxv.MainMenu = function(/*config*/){ ,handler: function(b,e) { XXV.tab.openTab(b.cmd); } } ,items:[{ - text:this.szOwnSettings + text:this.szOwnSettings ,iconCls: 'setup-icon' ,handler: XXV.help.Settings ,scope:XXV.help ,cmd: 'up' },{ - text:this.szGlobalSettings + text:this.szGlobalSettings ,iconCls: 'setup-icon' ,menu: XXV.configMenu ,cmd: 'ce' @@ -86,12 +86,12 @@ Ext.xxv.MainMenu = function(/*config*/){ var systemMenu = new Ext.menu.Menu({ items:[{ - text:this.szMenuItemSetup + text:this.szMenuItemSetup ,iconCls: 'setup-icon' ,menu: setupMenu },'-',{ text:this.szMenuItemLogout - ,handler: this.Logout + ,handler: this.Logout ,iconCls:"logout-icon" ,disabled:false } @@ -136,7 +136,7 @@ Ext.xxv.MainMenu = function(/*config*/){ }/*,{ text: Ext.xxv.mediaDataView.prototype.szTitle, iconCls:"media-icon", - ,cmd: 'mll' + ,cmd: 'mll' }*/ ] }); @@ -163,13 +163,13 @@ Ext.xxv.MainMenu = function(/*config*/){ // see this.styles to enum themes var themes = new Array; for(var i = 0, len = this.styles.length; i < len; i++){ - themes.push({ - text: this.styles[i][1], - checked: selTheme == i ? true : false, - group: 'theme', - checkHandler: this.onSelectTheme, - scope: this - }); + themes.push({ + text: this.styles[i][1], + checked: selTheme == i ? true : false, + group: 'theme', + checkHandler: this.onSelectTheme, + scope: this + }); } Ext.xxv.MainMenu.superclass.constructor.call(this, { @@ -271,7 +271,7 @@ Ext.extend(Ext.xxv.MainMenu, Ext.Toolbar, { ,szMenuItemSetup : "Setup" ,szGlobalSettings : "Global settings" ,szOwnSettings : "Own settings" - ,szMenuItemLogout : "Logout" + ,szMenuItemLogout : "Logout" ,szMenuItemLogoutTooltip : "Click this button to logout from XXV" ,szSelectTheme : "Select theme" @@ -333,11 +333,11 @@ Ext.extend(Ext.xxv.MainMenu, Ext.Toolbar, { Ext.Ajax.request({ url: XXV.help.cmdAJAX('logout') }); - setTimeout(function(){ + setTimeout(function(){ XXV.viewport.container.fadeOut( { remove:true - ,duration: .5 + ,duration: 0.5 ,callback:function(){ Ext.MessageBox.updateText('Session closed!'); } @@ -382,13 +382,13 @@ Ext.extend(Ext.xxv.MainMenu, Ext.Toolbar, { } if(rec.data.active) { r.addItem({ - text: rec.data.host - ,checked: this.host == rec.data.id ? true : false - ,group: 'host' - ,checkHandler: this.onSelectHost - ,scope: this + text: rec.data.host + ,checked: this.host == rec.data.id ? true : false + ,group: 'host' + ,checkHandler: this.onSelectHost + ,scope: this ,disabled: e - }); + }); } } } diff --git a/skins/jason/monitor.js b/skins/jason/monitor.js index e6d8839..2578427 100644 --- a/skins/jason/monitor.js +++ b/skins/jason/monitor.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -71,7 +71,7 @@ Ext.xxv.MonitorWindow = function() { this.on('resize', this.onresize, this); this.update(); -} +}; Ext.extend(Ext.xxv.MonitorWindow, Ext.Window, { @@ -110,10 +110,10 @@ Ext.extend(Ext.xxv.MonitorWindow, Ext.Window, { this.update(); //var tool = Ext.getCmp(this.tools.minus.id); //tool.enable(); - } else { + } /*else { //var tool = Ext.getCmp(this.tools.plus.id); //tool.disable(); - } + } */ } ,upSlow : function(){ if(this.UpdateRate < this.UpdateRateInv.length) { @@ -121,10 +121,10 @@ Ext.extend(Ext.xxv.MonitorWindow, Ext.Window, { this.update(); //var tool = Ext.getCmp(this.tools.plus.id); //tool.enable(); - } else { + } /*else { //var tool = Ext.getCmp(this.tools.minus.id); //tool.disable(); - } + } */ } ,update : function(){ var monitor = Ext.getCmp('monitor'); @@ -168,4 +168,5 @@ Ext.xxv.MonitorWindowOpen = function(){ viewer.monitor.show(); viewer.monitor.update(); } -} +}; + diff --git a/skins/jason/movetimers.js b/skins/jason/movetimers.js index 2e30508..47a5eb2 100644 --- a/skins/jason/movetimers.js +++ b/skins/jason/movetimers.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -180,7 +180,7 @@ Ext.extend(Ext.xxv.movetimersGrid, Ext.grid.EditorGridPanel, { new Ext.xxv.MessageBox().msgSuccess(this.szDeleteSuccess, o.data); var gsm = this.getSelectionModel(); - var sel = options.params.data.split(","); + var sel = options.params.data.split(","); sel.reverse(); for(var i = 0, len = sel.length; i < len; i++){ if(gsm.isIdSelected(sel[i])) { @@ -213,16 +213,16 @@ Ext.extend(Ext.xxv.movetimersGrid, Ext.grid.EditorGridPanel, { this.loadMask.show(); var gsm = this.getSelectionModel(); - var sel = gsm.getSelections() + var sel = gsm.getSelections(); if(sel.length <= 0) { gsm.selectRecords([record]); sel.push(record); } var todel = ""; for(var i = 0, len = sel.length; i < len; i++){ - if(i != 0) - todel += ','; - todel += sel[i].data.id; + if(i !== 0) + todel += ','; + todel += sel[i].data.id; } Ext.Ajax.request({ scope: this @@ -239,7 +239,7 @@ Ext.extend(Ext.xxv.movetimersGrid, Ext.grid.EditorGridPanel, { this.stopEditing(); var item; - if(record != null) { + if(record !== null) { var gsmTimer = this.getSelectionModel(); gsmTimer.selectRecords([record]); diff --git a/skins/jason/music.js b/skins/jason/music.js index 0365bb7..9996a4e 100644 --- a/skins/jason/music.js +++ b/skins/jason/music.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -287,7 +287,7 @@ Ext.extend(Ext.xxv.musicGrid, Ext.grid.GridPanel, { // Ext.grid.EditorGridPanel } ,reload : function(topic, value) { var f = this.filter.field.getValue(); - if(f && f != '') { + if(f && f !== '') { this.filter.field.setValue(''); } this.store.baseParams = { @@ -312,7 +312,7 @@ Ext.extend(Ext.xxv.musicGrid, Ext.grid.GridPanel, { // Ext.grid.EditorGridPanel //this.loadMask.show(); var gsm = this.getSelectionModel(); - var sel = gsm.getSelections() + var sel = gsm.getSelections(); if(sel.length <= 0) { gsm.selectRecords([record]); sel.push(record); diff --git a/skins/jason/now.js b/skins/jason/now.js index 6378c51..3e68395 100644 --- a/skins/jason/now.js +++ b/skins/jason/now.js @@ -42,7 +42,7 @@ Ext.xxv.NowStore = function() { ,hasMultiSort:false ,multiSortInfo:{} }); -} +}; Ext.xxv.NowGrid = function(viewer) { @@ -141,7 +141,7 @@ Ext.xxv.NowGrid = function(viewer) { }) }); - var tbPosition = 15 + var tbPosition = 15; var tb = this.topToolbar; tb.insert(tbPosition+0, '-'); tb.insert(tbPosition+1, this.timefield); @@ -322,11 +322,11 @@ Ext.extend(Ext.xxv.NowGrid, Ext.grid.GridPanel, { } ,reload : function() { if(this.store.baseParams.data) - delete(this.store.baseParams['data']); + delete(this.store.baseParams.data); var time = this.timefield.lastQuery; - if(!time || time == '') time = this.timefield.getValue(); - if(!time || time == this.szPresent) { + if(!time || time === '') time = this.timefield.getValue(); + if(!time || time === this.szPresent) { this.store.baseParams.cmd = 'n'; } else if(time == this.szFollowing) { this.store.baseParams.cmd = 'nx'; @@ -447,16 +447,16 @@ Ext.extend(Ext.xxv.NowGrid, Ext.grid.GridPanel, { } ,DeleteTimer : function(record) { var gsm = this.getSelectionModel(); - var sel = gsm.getSelections() + var sel = gsm.getSelections(); if(sel.length <= 0) { gsm.selectRecords([record]); sel.push(record); } var items = ""; for(var i = 0, len = sel.length; i < len; i++){ - if(i != 0) + if(i !== 0) items += ','; - if(sel[i].data.timerid == 0) { + if(sel[i].data.timerid === 0) { continue; } items += sel[i].data.timerid; diff --git a/skins/jason/program.js b/skins/jason/program.js index 7b9e096..16defc7 100644 --- a/skins/jason/program.js +++ b/skins/jason/program.js @@ -37,7 +37,7 @@ Ext.xxv.programStore = function(data) { sortInfo:{field:'day', direction:'ASC'}, groupField:'day' }); -} +}; Ext.xxv.programGrid = function(viewer, record) { this.viewer = viewer; @@ -229,14 +229,14 @@ Ext.extend(Ext.xxv.programGrid, Ext.grid.GridPanel, { } ,Record : function( record ) { var gsm = this.getSelectionModel(); - var sel = gsm.getSelections() + var sel = gsm.getSelections(); if(sel.length <= 0) { gsm.selectRecords([record]); sel.push(record); } var ids = ""; for(var i = 0, len = sel.length; i < len; i++){ - if(i != 0) + if(i !== 0) ids += ','; ids += sel[i].data.id; } @@ -262,16 +262,16 @@ Ext.extend(Ext.xxv.programGrid, Ext.grid.GridPanel, { } ,DeleteTimer : function(record) { var gsm = this.getSelectionModel(); - var sel = gsm.getSelections() + var sel = gsm.getSelections(); if(sel.length <= 0) { gsm.selectRecords([record]); sel.push(record); } var items = ""; for(var i = 0, len = sel.length; i < len; i++){ - if(i != 0) + if(i !== 0) items += ','; - if(sel[i].data.timerid == 0) { + if(sel[i].data.timerid === 0) { continue; } items += sel[i].data.timerid; diff --git a/skins/jason/reader.js b/skins/jason/reader.js index 042a44b..863a8a4 100644 --- a/skins/jason/reader.js +++ b/skins/jason/reader.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -15,7 +15,7 @@ Ext.extend(Ext.xxv.jsonReader, Ext.data.DataReader, { read : function(r){ if(r.status != 200) { - throw {message: "XXVReader.read: " . r.statusText }; + throw {message: "XXVReader.read: " + r.statusText }; } var o = eval('('+r.responseText+')'); if(!o || !o.data || typeof(o.data) != 'object') { diff --git a/skins/jason/recordings.js b/skins/jason/recordings.js index 4fe0562..c744116 100644 --- a/skins/jason/recordings.js +++ b/skins/jason/recordings.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -11,26 +11,26 @@ minTime = function() { return Date.parseDate(Ext.form.TimeField.prototype.initDate, Ext.form.TimeField.prototype.initDateFormat).clearTime(); -} +}; SecondsToHMS = function(t) { return new Date(minTime().getTime()+(t * 1000)).dateFormat('H:i:s'); -} +}; /******************************************************************************/ HMSToSeconds = function(s) { var seconds; var tt = s.replace(/\..*/g, ''); var x = tt.split(":"); - seconds = parseInt(x.pop()); + seconds = parseInt(x.pop(),10); if(x.length > 0) { - seconds += ( 60 * parseInt(x.pop())); + seconds += ( 60 * parseInt(x.pop(),10)); } if(x.length > 0) { - seconds += (3600 * parseInt(x.pop())); + seconds += (3600 * parseInt(x.pop(),10)); } return seconds; -} +}; /******************************************************************************/ Ext.xxv.slider = function(config){ @@ -45,7 +45,7 @@ Ext.extend(Ext.xxv.slider, Ext.Component, { ,initComponent : function(){ Ext.xxv.slider.superclass.initComponent.call(this); - this.addEvents({'MoveSlider' : true}); + this.addEvents({'MoveSlider' : true}); }, setvalue : function(marks, duration){ @@ -61,56 +61,56 @@ Ext.extend(Ext.xxv.slider, Ext.Component, { if(this.slider) { //this.slider.remove(); ct.dom.innerHTML = ''; - delete this.slider; - this.slider = null; + delete this.slider; + this.slider = null; //this.slider.sliders.clear(); //this.slider.maxValue = this.duration; } //else - { - this.slider = new Ext.ux.SlideZone(ct.id, { - type: 'horizontal' - ,size: ct.getWidth() + //{ + this.slider = new Ext.ux.SlideZone(ct.id, { + type: 'horizontal' + ,size: ct.getWidth() ,sliderWidth: 16 - ,sliderHeight: 24 - ,minValue: 0 - ,maxValue: this.duration - //,sliderSnap: 1 - ,allowSliderCrossing: true - }); - this.ts = new Ext.ux.ThumbSlider({ - value: 0 - ,name: 'cutpoint_thumb' - ,cls: 'x-slide-zone-bottom' - ,allowMove: true - }); - this.ts.on('drag', - function() { - var v = parseInt(this.ts.value * 1000); - this.fireEvent('MoveSlider', this, new Date((minTime().getTime())+v), null, null); - },this); - } + ,sliderHeight: 24 + ,minValue: 0 + ,maxValue: this.duration + //,sliderSnap: 1 + ,allowSliderCrossing: true + }); + this.ts = new Ext.ux.ThumbSlider({ + value: 0 + ,name: 'cutpoint_thumb' + ,cls: 'x-slide-zone-bottom' + ,allowMove: true + }); + this.ts.on('drag', + function() { + var v = parseInt(this.ts.value * 1000,10); + this.fireEvent('MoveSlider', this, new Date((minTime().getTime())+v), null, null); + },this); + //} if(this.marks && this.marks.length) { - var cutpoint = this.marks.split(","); - for(var i = 0, len = cutpoint.length; i < len; i += 2){ - var first = HMSToSeconds(cutpoint[i]); - var second; - if(i+1 < cutpoint.length) { - second = HMSToSeconds(cutpoint[i+1]); - } else { - second = this.duration; - } - var rs = new Ext.ux.RangeSlider({ - value: [first,second] - ,name: 'cutpoint_'+i - ,cls: 'x-slide-zone-top' - ,allowMove: false - }); - this.slider.add(rs); - } - } - this.slider.add(this.ts); + var cutpoint = this.marks.split(","); + for(var i = 0, len = cutpoint.length; i < len; i += 2){ + var first = HMSToSeconds(cutpoint[i]); + var second; + if(i+1 < cutpoint.length) { + second = HMSToSeconds(cutpoint[i+1]); + } else { + second = this.duration; + } + var rs = new Ext.ux.RangeSlider({ + value: [first,second] + ,name: 'cutpoint_'+i + ,cls: 'x-slide-zone-top' + ,allowMove: false + }); + this.slider.add(rs); + } + } + this.slider.add(this.ts); } }); @@ -138,21 +138,21 @@ Ext.extend(Ext.xxv.RecHeader, Ext.Component, { '</div>' ,{ compiled: true - ,formatSubtitle : function(t) { - if(t && t != '') - return ' - ' + t; + ,formatSubtitle : function(t) { + if(t && t !== '') + return ' - ' + t; return ' '; - } - ,formatChannel : function(t) { - if(t && t != '') - return '<div class="preview-channel"><b>' + t + '</b> </div>'; + } + ,formatChannel : function(t) { + if(t && t !== '') + return '<div class="preview-channel"><b>' + t + '</b> </div>'; return ''; - } - ,formatCutlength : function(t) { - if(t && t != '') - return ' (' + t + ')'; + } + ,formatCutlength : function(t) { + if(t && t !== '') + return ' (' + t + ')'; return ''; - } + } } ); }, @@ -205,7 +205,7 @@ Ext.DataView.LabelEditor = function(cfg, field){ selectOnFocus:true }), cfg ); -} +}; Ext.extend(Ext.DataView.LabelEditor, Ext.Editor, { alignment: "tl-tl", @@ -379,7 +379,7 @@ Ext.xxv.recordingsDataView = function(viewer, preview, store, config) { var tpl = new Ext.XTemplate( '<tpl for=".">', '<div class="thumb-wrap" id="{id}">', - '<div class="thumb">', + '<div class="thumb">', '<tpl if="isrecording == 0">', '<img src="pic/folder.png"<tpl if="group != 0"> ext:qtitle="{shortTitle}" ext:qtip="{ToolTip}"</tpl>/>', '</tpl>', @@ -407,7 +407,7 @@ Ext.xxv.recordingsDataView = function(viewer, preview, store, config) { return name == 'RADIO'; } } - ); + ); this.filter = new Ext.ux.grid.Search({ position:'owner' @@ -488,12 +488,12 @@ Ext.xxv.recordingsDataView = function(viewer, preview, store, config) { return data; } ,listeners: { - 'selectionchange': {fn:this.doClick, scope:this, buffer:100} - ,'contextmenu' : {fn:this.onContextClick, scope:this} - ,'dblclick' : {fn:this.doDblclick, scope:this} -// ,'loadexception' : {fn:this.onLoadException, scope:this} - ,'beforeselect' : {fn:function(view){ return view.store.getRange().length > 0; } } - } + 'selectionchange': {fn:this.doClick, scope:this, buffer:100} + ,'contextmenu' : {fn:this.onContextClick, scope:this} + ,'dblclick' : {fn:this.doDblclick, scope:this} +// ,'loadexception' : {fn:this.onLoadException, scope:this} + ,'beforeselect' : {fn:function(view){ return view.store.getRange().length > 0; } } + } ,plugins: [ new Ext.DataView.DragSelector() //,new Ext.DataView.LabelEditor({dataIndex: 'fulltitle', allow: 'isrecording'}) ,this.filter @@ -539,12 +539,12 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { ,szFolderTip2 : "There are {0} recordings<br />Have {1} new recordings<br />Total time {2}" ,onLoadException : function( scope, o, arg, e) { - new Ext.xxv.MessageBox().msgFailure(this.szLoadException, e.message); + new Ext.xxv.MessageBox().msgFailure(this.szLoadException, e.message); } ,onBeforeLoad : function( scope, params ) { if(this.DetailsTransaction) Ext.Ajax.abort(this.DetailsTransaction); - this.preview.clear(); + this.preview.clear(); } ,onLoad : function( store, records, opt ) { @@ -570,7 +570,7 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { // Show details from first recording for(var i = 0, len = store.getCount(); i < len; i++){ var record = store.getAt(i); - if(record.data.isrecording != 0) { + if(record.data.isrecording !== 0) { this.showDetails(record); //this.select(record.data.id,false,false); break; @@ -583,15 +583,15 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { //tb.displayMsg += Ext.PagingToolbar.prototype.displayMsg; } if(store.title) { - this.ownerCt.SetPanelTitle(store.title); + this.ownerCt.SetPanelTitle(store.title); store.title = undefined; } else { - this.ownerCt.SetPanelTitle(this.szTitle); + this.ownerCt.SetPanelTitle(this.szTitle); } } ,doSelectKeyword : function(tag) { if(tag) { - delete(this.store.baseParams['data']); + delete(this.store.baseParams.data); this.store.title = tag; this.store.baseParams.cmd = 'rk'; this.store.baseParams.data = tag; @@ -599,14 +599,14 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { } } ,doDblclick : function() { - var selNode = this.getSelectedNodes(); - if(selNode && selNode.length > 0){ + var selNode = this.getSelectedNodes(); + if(selNode && selNode.length > 0){ var firstNode = selNode[0]; var record = this.store.getById(firstNode.id); if(record) { - if(record.data.isrecording == 0) { - var data = this.store.baseParams['data']; - delete(this.store.baseParams['data']); + if(record.data.isrecording === 0) { + var data = this.store.baseParams.data; + delete(this.store.baseParams.data); this.store.baseParams.cmd = 'rl'; if(record.id == 'up') { if(this.filter.field.isValid()) { @@ -631,17 +631,17 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { } }, - doClick : function(){ - var selNode = this.getSelectedNodes(); - if(selNode && selNode.length > 0){ + doClick : function(){ + var selNode = this.getSelectedNodes(); + if(selNode && selNode.length > 0){ var record = this.store.getById(selNode[0].id); this.showDetails(record); } }, - showDetails : function(record){ + showDetails : function(record){ this.preview.content(record,this.filter.getValue()); this.DetailsItem(record); - }, + }, /******************************************************************************/ onDetailsSuccess : function( response,options ) { @@ -659,8 +659,8 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { this.store.data.items[iSel].data.channel = o.data.Channel; this.store.data.items[iSel].data.marks = o.data.Marks; - this.store.data.items[iSel].data.lifetime = parseInt(o.data.lifetime); - this.store.data.items[iSel].data.priority = parseInt(o.data.priority); + this.store.data.items[iSel].data.lifetime = parseInt(o.data.lifetime,10); + this.store.data.items[iSel].data.priority = parseInt(o.data.priority,10); this.store.data.items[iSel].data.keywords = o.data.keywords; var record = this.store.getById(RecordingsID[j]); @@ -693,8 +693,8 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { if(record && record.data) { toDetails = record.data.id; } else { - var selNode = this.getSelectedNodes(); - if(selNode && selNode.length > 0){ + var selNode = this.getSelectedNodes(); + if(selNode && selNode.length > 0){ for(var i = 0, len = selNode.length; i < len; i++){ if(selNode[i].id == 'up') continue; @@ -702,7 +702,7 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { toDetails += ','; } var r = this.store.getById(selNode[i].id); - if(r.data.isrecording == 0) { + if(!r.data.isrecording) { //toDetails += 'all:'; continue; } @@ -799,11 +799,11 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { var enable = XXV.help.cmdAllowed(f.itemId); if(enable) { switch(f.itemId) { - case 're': enable = (record.data.isrecording == 0) ? false : true; break; - case 'rcu': enable = (record.data.isrecording == 0) ? false : true; break; - case 'rc': enable = (record.data.isrecording == 0) ? false : true; break; - case 'rpv': enable = (record.data.isrecording == 0) ? false : true; break; - case 'pre': enable = (record.data.isrecording == 0) ? false : true; break; + case 're': enable = (record.data.isrecording) ? true : false; break; + case 'rcu': enable = (record.data.isrecording) ? true : false; break; + case 'rc': enable = (record.data.isrecording) ? true : false; break; + case 'rpv': enable = (record.data.isrecording) ? true : false; break; + case 'pre': enable = (record.data.isrecording) ? true : false; break; } if(enable && node.id != 'up') { f.enable(); @@ -863,8 +863,8 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { if(record && record.data) { toCut = record.data.id; } else { - var selNode = this.getSelectedNodes(); - if(selNode && selNode.length > 0){ + var selNode = this.getSelectedNodes(); + if(selNode && selNode.length > 0){ for(var i = 0, len = selNode.length; i < len; i++){ if(selNode[i].id == 'up') continue; @@ -872,7 +872,7 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { toCut += ','; } var r = this.store.getById(selNode[i].id); - if(r.data.isrecording == 0) { + if(!r.data.isrecording) { //toCut += 'all:'; continue; } @@ -918,14 +918,14 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { if(iSel >= 0 && iSel < this.store.getCount()) { selRecord = this.store.getAt(iSel); } - if(!selRecord || selRecord.data.isrecording == 0) { + if(!selRecord || !selRecord.data.isrecording) { for(iSel++;iSel < this.store.getCount();iSel++) { selRecord = this.store.getAt(iSel); - if(selRecord.data.isrecording != 0) + if(selRecord.data.isrecording) break; } } - if(selRecord && selRecord.data.isrecording != 0) { + if(selRecord && selRecord.data.isrecording) { this.select(selRecord.data.id,false,false); } @@ -951,8 +951,8 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { if(record && record.data) { todelete = record.data.id; } else { - var selNode = this.getSelectedNodes(); - if(selNode && selNode.length > 0){ + var selNode = this.getSelectedNodes(); + if(selNode && selNode.length > 0){ for(var i = 0, len = selNode.length; i < len; i++){ if(selNode[i].id == 'up') continue; @@ -960,7 +960,7 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { todelete += ','; } var r = this.store.getById(selNode[i].id); - if(r.data.isrecording == 0) { + if(!r.data.isrecording) { todelete += 'all:'; } todelete += r.data.id; @@ -1001,7 +1001,7 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { onPlay : function( record, begin ) { if(this.PlayTransaction) Ext.Ajax.abort(this.PlayTransaction); - if(record.data.isrecording != 0) { + if(record.data.isrecording) { this.PlayTransaction = Ext.Ajax.request({ url: XXV.help.cmdAJAX('rpv',{ data: record.data.id, '__start':begin, '__vdr': XXV.menu.host }) ,success: this.onPlaySuccess @@ -1066,7 +1066,7 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { && o.success) { new Ext.xxv.MessageBox().msgSuccess(this.szUpgradeSuccess, o.data); - this.reload(); + this.reload(); } else { var msg = ''; @@ -1082,27 +1082,27 @@ Ext.extend(Ext.xxv.recordingsDataView, Ext.DataView, { new Ext.xxv.MessageBox().msgFailure(this.szUpgradeFailure, response.statusText); } ,UpgradeItem : function() { - Ext.Ajax.request({ - scope: this - ,url: XXV.help.cmdAJAX('ru') - ,timeout: 120000 - ,success: this.onUpgradeSuccess - ,failure: this.onUpgradeFailure - }); + Ext.Ajax.request({ + scope: this + ,url: XXV.help.cmdAJAX('ru') + ,timeout: 120000 + ,success: this.onUpgradeSuccess + ,failure: this.onUpgradeFailure + }); Ext.MessageBox.show({ title: this.szUpgradeWait ,msg: this.szUpgrade ,width:240 ,wait:true - ,waitConfig:{ - interval:200 - ,duration:119000 - ,increment:15 - ,fn:function() { + ,waitConfig:{ + interval:200 + ,duration:119000 + ,increment:15 + ,fn:function() { Ext.MessageBox.hide(); - } - } + } + } }); } ,reload : function() { @@ -1173,7 +1173,7 @@ function createRecordingsView(viewer,id) { },{ //content id: 'preview-recordings-frame' ,cls: 'preview-body' - ,xtype: 'box' + ,xtype: 'box' ,flex: 3 },{ // keywords xtype:'container' @@ -1245,7 +1245,7 @@ function createRecordingsView(viewer,id) { } , timefield ] - ,content : function(record,lookup){ + ,content : function(record,lookup){ if(record && this.record != record && record.data.isrecording @@ -1279,7 +1279,7 @@ function createRecordingsView(viewer,id) { highlightText(content,lookup,'x-highlight',1); this.doLayout(); } - } + } ,update : function(record,lookup) { if(record && record.data.isrecording @@ -1417,21 +1417,21 @@ function createRecordingsView(viewer,id) { ,hidden:XXV.RightPreview }] ,tbar:new Ext.PagingToolbar({ - pageSize: viewer.gridRecordings.store.autoLoad.params.limit - ,store: viewer.gridRecordings.store - ,displayInfo: true + pageSize: viewer.gridRecordings.store.autoLoad.params.limit + ,store: viewer.gridRecordings.store + ,displayInfo: true ,items: [ { id:'ru' ,iconCls: 'upgrade-icon' - ,tooltip: viewer.gridRecordings.szUpgrade + ,tooltip: viewer.gridRecordings.szUpgrade ,scope: viewer.gridRecordings ,disabled:false ,handler: function(){ this.UpgradeItem(); } },{ id:'rru' ,iconCls: 'recover-icon' - ,tooltip: viewer.gridRecordings.szRecover + ,tooltip: viewer.gridRecordings.szRecover ,scope: viewer.gridRecordings ,disabled:false ,handler: function(){ this.Recover(); } diff --git a/skins/jason/remote.js b/skins/jason/remote.js index e612424..8e7667e 100644 --- a/skins/jason/remote.js +++ b/skins/jason/remote.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -105,7 +105,7 @@ Ext.xxv.RemoteWindow = function() { }); Ext.xxv.RemoteWindow.superclass.show.apply(this, arguments); -} +}; Ext.extend(Ext.xxv.RemoteWindow, Ext.Window, { @@ -131,9 +131,7 @@ Ext.extend(Ext.xxv.RemoteWindow, Ext.Window, { if(!o || !o.data || typeof(o.data) != 'string') { throw {message: "Ajax.read: Json message not found"}; } - if(o.success) { - //new Ext.xxv.MessageBox().msgSuccess(this.szRemoteSuccess, o.data); - }else { + if(!o.success) { new Ext.xxv.MessageBox().msgFailure(this.szRemoteFailure, o.data); } } @@ -159,4 +157,5 @@ Ext.xxv.RemoteWindowOpen = function(){ } else { viewer.Remote.show(); } -} +}; + diff --git a/skins/jason/search.js b/skins/jason/search.js index 554a2d2..ce1f458 100644 --- a/skins/jason/search.js +++ b/skins/jason/search.js @@ -216,14 +216,14 @@ Ext.extend(Ext.xxv.searchGrid, Ext.grid.GridPanel, { } ,Record : function( record ) { var gsm = this.getSelectionModel(); - var sel = gsm.getSelections() + var sel = gsm.getSelections(); if(sel.length <= 0) { gsm.selectRecords([record]); sel.push(record); } var ids = ""; for(var i = 0, len = sel.length; i < len; i++){ - if(i != 0) + if(i) ids += ','; ids += sel[i].data.id; } @@ -249,16 +249,16 @@ Ext.extend(Ext.xxv.searchGrid, Ext.grid.GridPanel, { } ,DeleteTimer : function(record) { var gsm = this.getSelectionModel(); - var sel = gsm.getSelections() + var sel = gsm.getSelections(); if(sel.length <= 0) { gsm.selectRecords([record]); sel.push(record); } var items = ""; for(var i = 0, len = sel.length; i < len; i++){ - if(i != 0) + if(i) items += ','; - if(sel[i].data.timerid == 0) { + if(!sel[i].data.timerid) { continue; } items += sel[i].data.timerid; @@ -321,7 +321,6 @@ Ext.extend(Ext.xxv.searchPreview, Ext.Panel, { highlightText(this.body.dom,lookup,'x-highlight',1); // Enable all toolbar buttons var items = this.topToolbar.items; - var items = this.topToolbar.items; if(items) { items.eachKey(function(key, f) { if(f.id == 'tn') { if(record.data.timerid) f.hide(); else f.show(); } diff --git a/skins/jason/stream.js b/skins/jason/stream.js index 2978fea..0029cb6 100644 --- a/skins/jason/stream.js +++ b/skins/jason/stream.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -72,7 +72,7 @@ Ext.xxv.StreamWindow = function(item) { Ext.xxv.StreamWindow.superclass.show.apply(this, arguments); this.on('resize', this.onresize, this); -} +}; Ext.extend(Ext.xxv.StreamWindow, Ext.Window, { @@ -98,7 +98,11 @@ Ext.extend(Ext.xxv.StreamWindow, Ext.Window, { } ,hide : function(){ var video = Ext.getCmp('video'); - if(video && video.body) video.body.update(''); + if(video) { + video.destroy(); + if(video.body) + video.body.update(''); + } Ext.xxv.StreamWindow.superclass.hide.apply(this, arguments); } ,show : function(item){ diff --git a/skins/jason/tabpanel.js b/skins/jason/tabpanel.js index 8952351..42ed3bd 100644 --- a/skins/jason/tabpanel.js +++ b/skins/jason/tabpanel.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * diff --git a/skins/jason/teletext.js b/skins/jason/teletext.js index 021900d..da7e625 100644 --- a/skins/jason/teletext.js +++ b/skins/jason/teletext.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2009, anbr + * Copyright(c) 2009-201ß, anbr * * http://xxv.berlios.de/ * @@ -47,7 +47,7 @@ Ext.xxv.TeleTextView = function(viewer, store, config) { ,'</div>' ,'</tpl>' ,'<div class="x-clear"></div>' - ); + ); this.filter = new Ext.ux.grid.Search({ position:'owner' @@ -71,9 +71,9 @@ Ext.xxv.TeleTextView = function(viewer, store, config) { ,itemSelector:'div.thumb-wrap' ,loadMask:null ,listeners: { - 'beforeselect' : {fn:function(view){ return view.store.getRange().length > 0; } } - ,'selectionchange': {fn:this.doClick, scope:this, buffer:100} - } + 'beforeselect' : {fn:function(view){ return view.store.getRange().length > 0; } } + ,'selectionchange': {fn:this.doClick, scope:this, buffer:100} + } ,plugins: [ this.filter ] @@ -96,7 +96,7 @@ Ext.extend(Ext.xxv.TeleTextView, Ext.DataView, { ,onLoadException : function( scope, o, arg, e) { this.viewer.loadMask.hide(); - new Ext.xxv.MessageBox().msgFailure(this.szLoadException, e.message); + new Ext.xxv.MessageBox().msgFailure(this.szLoadException, e.message); var tb = this.ownerCt.getTopToolbar(); tb.get('teletext-refresh').enable(); } @@ -151,9 +151,9 @@ Ext.extend(Ext.xxv.TeleTextView, Ext.DataView, { tb.get('teletext-refresh').enable(); this.viewer.loadMask.hide(); } - ,doClick : function(){ - var selNode = this.getSelectedNodes(); - if(selNode && selNode.length > 0){ + ,doClick : function(){ + var selNode = this.getSelectedNodes(); + if(selNode && selNode.length > 0){ var page = this.store.getById(selNode[0].id); if(page) { var tb = this.ownerCt.getTopToolbar(); @@ -284,12 +284,12 @@ function createTeleTextView(viewer,id,name, channel) { items: [ { id: 'teletext-first' ,iconCls: 'x-tbar-page-first' - ,tooltip: Ext.PagingToolbar.prototype.firstText + ,tooltip: Ext.PagingToolbar.prototype.firstText ,scope: viewer.pageTeleText ,disabled:true ,handler: viewer.pageTeleText.moveFirst },{ id: 'teletext-prev' ,iconCls: 'x-tbar-page-prev' - ,tooltip: Ext.PagingToolbar.prototype.prevText + ,tooltip: Ext.PagingToolbar.prototype.prevText ,scope: viewer.pageTeleText ,disabled:true ,handler: viewer.pageTeleText.movePrev },'-',{ @@ -311,19 +311,19 @@ function createTeleTextView(viewer,id,name, channel) { },'-',{ id: 'teletext-next' ,iconCls: 'x-tbar-page-next' - ,tooltip: Ext.PagingToolbar.prototype.nextText + ,tooltip: Ext.PagingToolbar.prototype.nextText ,scope: viewer.pageTeleText ,disabled:true ,handler: viewer.pageTeleText.moveNext },{ id: 'teletext-last' ,iconCls: 'x-tbar-page-last' - ,tooltip: Ext.PagingToolbar.prototype.lastText + ,tooltip: Ext.PagingToolbar.prototype.lastText ,scope: viewer.pageTeleText ,disabled:true ,handler: viewer.pageTeleText.moveLast },'-',{ id: 'teletext-refresh' ,iconCls: 'x-tbar-loading' - ,tooltip: Ext.PagingToolbar.prototype.refreshText + ,tooltip: Ext.PagingToolbar.prototype.refreshText ,scope: viewer.pageTeleText ,disabled:false ,handler: viewer.pageTeleText.retryPage },'->' diff --git a/skins/jason/timers.js b/skins/jason/timers.js index 026e537..a7bf85f 100644 --- a/skins/jason/timers.js +++ b/skins/jason/timers.js @@ -52,7 +52,7 @@ Ext.xxv.timerGrid = function(viewer) { this.store.setDefaultSort('day', "ASC"); // create the channels store - var channels = new Ext.xxv.storeChannels; + var channels = new Ext.xxv.storeChannels(); // custom columns as plugins this.activeColumn = new Ext.grid.CheckColumn({ @@ -155,7 +155,7 @@ Ext.xxv.timerGrid = function(viewer) { region: 'center' ,id: 'timer-view-grid' ,loadMask: false - ,plugins:[this.activeColumn,this.vpsColumn,this.ChannelsCombo] + ,plugins:[this.activeColumn,this.vpsColumn,this.ChannelsCombo,this.filter] ,clicksToEdit:1 ,autoExpandColumn:'expand' ,cm: cm @@ -182,7 +182,6 @@ Ext.xxv.timerGrid = function(viewer) { ,handler: function(){ this.EditItem(null); } } ]}) - ,plugins:[this.filter] }); this.store.on({ @@ -283,7 +282,7 @@ Ext.extend(Ext.xxv.timerGrid, Ext.grid.GridPanel, { // Ext.grid.EditorGridPanel ,scope:this ,disabled: true ,handler: function(){ this.viewer.searchTab(this.ctxRecord);} - }, + } ] }); this.menu.on('hide', this.onContextHide, this); @@ -300,7 +299,7 @@ Ext.extend(Ext.xxv.timerGrid, Ext.grid.GridPanel, { // Ext.grid.EditorGridPanel var hasAutotimer = (this.ctxRecord.data.autotimerid <= 0) ? 0 : 1; var items = this.menu.items; if(items) { items.eachKey(function(key, f) { - if(f.itemId == 'ae') { if(hasAutotimer) f.show(); else f.hide(); }; + if(f.itemId == 'ae') { if(hasAutotimer) f.show(); else f.hide(); } if(XXV.help.cmdAllowed(f.itemId)) f.enable(); },items); @@ -400,14 +399,14 @@ Ext.extend(Ext.xxv.timerGrid, Ext.grid.GridPanel, { // Ext.grid.EditorGridPanel this.viewer.loadMask.show(); var gsm = this.getSelectionModel(); - var sel = gsm.getSelections() + var sel = gsm.getSelections(); if(sel.length <= 0) { gsm.selectRecords([record]); sel.push(record); } var todo = ""; for(var i = 0, len = sel.length; i < len; i++){ - if(i != 0) + if(i) todo += ','; todo += sel[i].data.id; } @@ -463,14 +462,14 @@ Ext.extend(Ext.xxv.timerGrid, Ext.grid.GridPanel, { // Ext.grid.EditorGridPanel this.viewer.loadMask.show(); var gsm = this.getSelectionModel(); - var sel = gsm.getSelections() + var sel = gsm.getSelections(); if(sel.length <= 0) { gsm.selectRecords([record]); sel.push(record); } var todel = ""; for(var i = 0, len = sel.length; i < len; i++){ - if(i != 0) + if(i) todel += ','; todel += sel[i].data.id; } @@ -499,7 +498,7 @@ Ext.extend(Ext.xxv.timerGrid, Ext.grid.GridPanel, { // Ext.grid.EditorGridPanel this.stopEditing(); var item; - if(record != null) { + if(record) { var gsmTimer = this.getSelectionModel(); gsmTimer.selectRecords([record]); @@ -534,7 +533,7 @@ Ext.extend(Ext.xxv.timerGrid, Ext.grid.GridPanel, { // Ext.grid.EditorGridPanel this.stopEditing(); var item; - if(record != null) { + if(record) { var gsmTimer = this.getSelectionModel(); gsmTimer.selectRecords([record]); @@ -613,7 +612,7 @@ Ext.extend(Ext.xxv.timerPreview, Ext.Panel, { var items = this.topToolbar.items; if(items) { items.eachKey(function(key, f) { - if(f.id == 'ae') { if(hasAutotimer) f.show(); else f.hide(); }; + if(f.id == 'ae') { if(hasAutotimer) f.show(); else f.hide(); } if(XXV.help.cmdAllowed(key)) f.enable(); },items); } diff --git a/skins/jason/users.js b/skins/jason/users.js index 142453d..bf83fed 100644 --- a/skins/jason/users.js +++ b/skins/jason/users.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -185,7 +185,7 @@ Ext.extend(Ext.xxv.usersGrid, Ext.grid.EditorGridPanel, { new Ext.xxv.MessageBox().msgSuccess(this.szDeleteSuccess, o.data); var gsm = this.getSelectionModel(); - var sel = options.params.data.split(","); + var sel = options.params.data.split(","); sel.reverse(); for(var i = 0, len = sel.length; i < len; i++){ if(gsm.isIdSelected(sel[i])) { @@ -218,16 +218,16 @@ Ext.extend(Ext.xxv.usersGrid, Ext.grid.EditorGridPanel, { this.loadMask.show(); var gsm = this.getSelectionModel(); - var sel = gsm.getSelections() + var sel = gsm.getSelections(); if(sel.length <= 0) { gsm.selectRecords([record]); sel.push(record); } var todel = ""; for(var i = 0, len = sel.length; i < len; i++){ - if(i != 0) - todel += ','; - todel += sel[i].data.id; + if(i) + todel += ','; + todel += sel[i].data.id; } Ext.Ajax.request({ scope: this @@ -244,7 +244,7 @@ Ext.extend(Ext.xxv.usersGrid, Ext.grid.EditorGridPanel, { this.stopEditing(); var item; - if(record != null) { + if(record) { var gsmTimer = this.getSelectionModel(); gsmTimer.selectRecords([record]); diff --git a/skins/jason/ux/Carousel.js b/skins/jason/ux/Carousel.js index be16b88..a7efec4 100644 --- a/skins/jason/ux/Carousel.js +++ b/skins/jason/ux/Carousel.js @@ -70,7 +70,7 @@ Ext.ux.layout.Carousel = Ext.extend(Ext.layout.ContainerLayout, { duration: this.chunkedScroll ? this.scrollDuration : this.scrollDuration * 2, callback: this.updateScrollButtons, scope: this - } + }; } else { this.scrollAnimationConfig = this.animScroll ? { duration: this.scrollDuration, @@ -80,10 +80,10 @@ Ext.ux.layout.Carousel = Ext.extend(Ext.layout.ContainerLayout, { } // if (Ext.isIE){ -// if (!this.defaults) { this.defaults={} } -// if (!this.defaults.bodyStyle) { this.defaults.bodyStyle={} } -// this.defaults.bodyStyle.position='static'; -// } +// if (!this.defaults) { this.defaults={} } +// if (!this.defaults.bodyStyle) { this.defaults.bodyStyle={} } +// this.defaults.bodyStyle.position='static'; +// } }, @@ -91,10 +91,7 @@ Ext.ux.layout.Carousel = Ext.extend(Ext.layout.ContainerLayout, { * @cfg {Number} marginScrollButtons This is to set aside space for the left and right navigation buttons. */ - marginScrollButtons : 10, - /** - * @cfg scrollElementTag {String} The tag name of the carousel item container. If each item's main Element - * is an <LI> then this could be specified as '<UL>. Defaults to '<DIV>'. + marginScrollButtons : 10, /** * @cfg {Number} scrollIncrement The number of pixels to scroll each time a tab scroll button is pressed (defaults * to 10, or if {@link #Ext.ux.layout.Carousel-resizeTabs} = true, the calculated tab width). @@ -125,7 +122,7 @@ Ext.ux.layout.Carousel = Ext.extend(Ext.layout.ContainerLayout, { /** * @cfg {Boolean} pageScroll Scroll full pages */ - pagedScroll: false, + pagedScroll: false, /** * @cfg {Boolean} loopCount This does an intro page loop this many times after render @@ -147,24 +144,24 @@ Ext.ux.layout.Carousel = Ext.extend(Ext.layout.ContainerLayout, { loopImages: function(){ - - if (this.loopCount <= 0){ return } - + + if (this.loopCount <= 0){ return; } + var s = this.getScrollTo(1); if (s) { s = Math.min(this.getMaxScrollPos(), s); if(s != this.getScrollPos()) { this.scrollTo(s); }else{ - return; /*it should not get here*/ + return; /*it should not get here*/ } }else{ this.scrollTo(0); - this.loopCount--; - if (this.loopCount <= 0){ return } + this.loopCount--; + if (this.loopCount <= 0){ return; } } - - this.loopImages.defer(this.loopPictureDelay * 1000, this); + + this.loopImages.defer(this.loopPictureDelay * 1000, this); }, @@ -226,10 +223,10 @@ Ext.ux.layout.Carousel = Ext.extend(Ext.layout.ContainerLayout, { this.updateScrollButtons.defer(10, this); - if (this.loopCount > 0 && (this.chunkedScroll || this.pagedScroll) && !this.startedLoop){ - this.startedLoop=true; /*this var is important since onLayout can be called more than once*/ - this.loopImages.defer(this.loopPictureDelay * 1000, this); - } + if (this.loopCount > 0 && (this.chunkedScroll || this.pagedScroll) && !this.startedLoop){ + this.startedLoop=true; /*this var is important since onLayout can be called more than once*/ + this.loopImages.defer(this.loopPictureDelay * 1000, this); + } }, @@ -265,7 +262,7 @@ Ext.ux.layout.Carousel = Ext.extend(Ext.layout.ContainerLayout, { } if(!this.strip) return; - this.setItemsEdges(); + this.setItemsEdges(); // If width increase has introduced spare space to the right, close it up. var r = this.getMaxScrollPos(); @@ -276,7 +273,7 @@ Ext.ux.layout.Carousel = Ext.extend(Ext.layout.ContainerLayout, { }, - setItemsEdges:function(){ + setItemsEdges:function(){ // Register strip-relative left/right edges for easy chunked scrolling var stripLeft = this.strip.getLeft(); var t = this.container.items.items; @@ -315,8 +312,8 @@ Ext.ux.layout.Carousel = Ext.extend(Ext.layout.ContainerLayout, { // Work out average item width this.itemWidth = t[lt - 1].edges.rightAnchor / lt; - - }, + + }, getNextOnLeft: function() { var t = this.container.items.items; if (t.length) { @@ -399,7 +396,7 @@ Ext.ux.layout.Carousel = Ext.extend(Ext.layout.ContainerLayout, { var t = this.container.items.items; if (t.length && ! t[0].edges){ - this.setItemsEdges(); + this.setItemsEdges(); } return t.length ? t[t.length - 1].edges.rightAnchor : 0; diff --git a/skins/jason/ux/DDView.js b/skins/jason/ux/DDView.js index cadbefd..e502493 100644 --- a/skins/jason/ux/DDView.js +++ b/skins/jason/ux/DDView.js @@ -6,605 +6,605 @@ * http://extjs.com/license
*/
-/* - * Software License Agreement (BSD License) - * Copyright (c) 2008, Nige "Animal" White - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the original author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/** - * @class Ext.ux.DDView - * <p>A DnD-enabled version of {@link Ext.DataView}. Drag/drop is implemented by adding - * {@link Ext.data.Record}s to the target DDView. If copying is not being performed, - * the original {@link Ext.data.Record} is removed from the source DDView.</p> - * @constructor - * Create a new DDView - * @param {Object} config The configuration properties. - */ -Ext.ux.DDView = function(config) { - if (!config.itemSelector) { - var tpl = config.tpl; - if (this.classRe.test(tpl)) { - config.tpl = tpl.replace(this.classRe, 'class=$1x-combo-list-item $2$1'); - } - else { - config.tpl = tpl.replace(this.tagRe, '$1 class="x-combo-list-item" $2'); - } - config.itemSelector = ".x-combo-list-item"; - } - Ext.ux.DDView.superclass.constructor.call(this, Ext.apply(config, { - border: false - })); -}; - -Ext.extend(Ext.ux.DDView, Ext.DataView, { - /** - * @cfg {String/Array} dragGroup The ddgroup name(s) for the View's DragZone (defaults to undefined). - */ - /** - * @cfg {String/Array} dropGroup The ddgroup name(s) for the View's DropZone (defaults to undefined). - */ - /** - * @cfg {Boolean} copy Causes drag operations to copy nodes rather than move (defaults to false). - */ - /** - * @cfg {Boolean} allowCopy Causes ctrl/drag operations to copy nodes rather than move (defaults to false). - */ - /** - * @cfg {String} sortDir Sort direction for the view, 'ASC' or 'DESC' (defaults to 'ASC'). - */ - sortDir: 'ASC', - - // private - isFormField: true, - classRe: /class=(['"])(.*)\1/, - tagRe: /(<\w*)(.*?>)/, - reset: Ext.emptyFn, - clearInvalid: Ext.form.Field.prototype.clearInvalid, - - // private - afterRender: function() { - Ext.ux.DDView.superclass.afterRender.call(this); - if (this.dragGroup) { - this.setDraggable(this.dragGroup.split(",")); - } - if (this.dropGroup) { - this.setDroppable(this.dropGroup.split(",")); - } - if (this.deletable) { - this.setDeletable(); - } - this.isDirtyFlag = false; - this.addEvents( - "drop" - ); - }, - - // private - validate: function() { - return true; - }, - - // private - destroy: function() { - this.purgeListeners(); - this.getEl().removeAllListeners(); - this.getEl().remove(); - if (this.dragZone) { - if (this.dragZone.destroy) { - this.dragZone.destroy(); - } - } - if (this.dropZone) { - if (this.dropZone.destroy) { - this.dropZone.destroy(); - } - } - }, - - /** - * Allows this class to be an Ext.form.Field so it can be found using {@link Ext.form.BasicForm#findField}. - */ - getName: function() { - return this.name; - }, - - /** - * Loads the View from a JSON string representing the Records to put into the Store. - * @param {String} value The JSON string - */ - setValue: function(v) { - if (!this.store) { - throw "DDView.setValue(). DDView must be constructed with a valid Store"; - } - var data = {}; - data[this.store.reader.meta.root] = v ? [].concat(v) : []; - this.store.proxy = new Ext.data.MemoryProxy(data); - this.store.load(); - }, - - /** - * Returns the view's data value as a list of ids. - * @return {String} A parenthesised list of the ids of the Records in the View, e.g. (1,3,8). - */ - getValue: function() { - var result = '('; - this.store.each(function(rec) { - result += rec.id + ','; - }); - return result.substr(0, result.length - 1) + ')'; - }, - - getIds: function() { - var i = 0, result = new Array(this.store.getCount()); - this.store.each(function(rec) { - result[i++] = rec.id; - }); - return result; - }, - - /** - * Returns true if the view's data has changed, else false. - * @return {Boolean} - */ - isDirty: function() { - return this.isDirtyFlag; - }, - - /** - * Part of the Ext.dd.DropZone interface. If no target node is found, the - * whole Element becomes the target, and this causes the drop gesture to append. - */ - getTargetFromEvent : function(e) { - var target = e.getTarget(); - while ((target !== null) && (target.parentNode != this.el.dom)) { - target = target.parentNode; - } - if (!target) { - target = this.el.dom.lastChild || this.el.dom; - } - return target; - }, - - /** - * Create the drag data which consists of an object which has the property "ddel" as - * the drag proxy element. - */ - getDragData : function(e) { - var target = this.findItemFromChild(e.getTarget()); - if(target) { - if (!this.isSelected(target)) { - delete this.ignoreNextClick; - this.onItemClick(target, this.indexOf(target), e); - this.ignoreNextClick = true; - } - var dragData = { - sourceView: this, - viewNodes: [], - records: [], - copy: this.copy || (this.allowCopy && e.ctrlKey) - }; - if (this.getSelectionCount() == 1) { - var i = this.getSelectedIndexes()[0]; - var n = this.getNode(i); - dragData.viewNodes.push(dragData.ddel = n); - dragData.records.push(this.store.getAt(i)); - dragData.repairXY = Ext.fly(n).getXY(); - } else { - dragData.ddel = document.createElement('div'); - dragData.ddel.className = 'multi-proxy'; - this.collectSelection(dragData); - } - return dragData; - } - return false; - }, - - // override the default repairXY. - getRepairXY : function(e){ - return this.dragData.repairXY; - }, - - // private - collectSelection: function(data) { - data.repairXY = Ext.fly(this.getSelectedNodes()[0]).getXY(); - if (this.preserveSelectionOrder === true) { - Ext.each(this.getSelectedIndexes(), function(i) { - var n = this.getNode(i); - var dragNode = n.cloneNode(true); - dragNode.id = Ext.id(); - data.ddel.appendChild(dragNode); - data.records.push(this.store.getAt(i)); - data.viewNodes.push(n); - }, this); - } else { - var i = 0; - this.store.each(function(rec){ - if (this.isSelected(i)) { - var n = this.getNode(i); - var dragNode = n.cloneNode(true); - dragNode.id = Ext.id(); - data.ddel.appendChild(dragNode); - data.records.push(this.store.getAt(i)); - data.viewNodes.push(n); - } - i++; - }, this); - } - }, - - /** - * Specify to which ddGroup items in this DDView may be dragged. - * @param {String} ddGroup The DD group name to assign this view to. - */ - setDraggable: function(ddGroup) { - if (ddGroup instanceof Array) { - Ext.each(ddGroup, this.setDraggable, this); - return; - } - if (this.dragZone) { - this.dragZone.addToGroup(ddGroup); - } else { - this.dragZone = new Ext.dd.DragZone(this.getEl(), { - containerScroll: true, - ddGroup: ddGroup - }); - // Draggability implies selection. DragZone's mousedown selects the element. - if (!this.multiSelect) { this.singleSelect = true; } - - // Wire the DragZone's handlers up to methods in *this* - this.dragZone.getDragData = this.getDragData.createDelegate(this); - this.dragZone.getRepairXY = this.getRepairXY; - this.dragZone.onEndDrag = this.onEndDrag; - } - }, - - /** - * Specify from which ddGroup this DDView accepts drops. - * @param {String} ddGroup The DD group name from which to accept drops. - */ - setDroppable: function(ddGroup) { - if (ddGroup instanceof Array) { - Ext.each(ddGroup, this.setDroppable, this); - return; - } - if (this.dropZone) { - this.dropZone.addToGroup(ddGroup); - } else { - this.dropZone = new Ext.dd.DropZone(this.getEl(), { - owningView: this, - containerScroll: true, - ddGroup: ddGroup - }); - - // Wire the DropZone's handlers up to methods in *this* - this.dropZone.getTargetFromEvent = this.getTargetFromEvent.createDelegate(this); - this.dropZone.onNodeEnter = this.onNodeEnter.createDelegate(this); - this.dropZone.onNodeOver = this.onNodeOver.createDelegate(this); - this.dropZone.onNodeOut = this.onNodeOut.createDelegate(this); - this.dropZone.onNodeDrop = this.onNodeDrop.createDelegate(this); - } - }, - - // private - getDropPoint : function(e, n, dd){ - if (n == this.el.dom) { return "above"; } - var t = Ext.lib.Dom.getY(n), b = t + n.offsetHeight; - var c = t + (b - t) / 2; - var y = Ext.lib.Event.getPageY(e); - if(y <= c) { - return "above"; - }else{ - return "below"; - } - }, - - // private - isValidDropPoint: function(pt, n, data) { - if (!data.viewNodes || (data.viewNodes.length != 1)) { - return true; - } - var d = data.viewNodes[0]; - if (d == n) { - return false; - } - if ((pt == "below") && (n.nextSibling == d)) { - return false; - } - if ((pt == "above") && (n.previousSibling == d)) { - return false; - } - return true; - }, - - // private - onNodeEnter : function(n, dd, e, data){ - if (this.highlightColor && (data.sourceView != this)) { - this.el.highlight(this.highlightColor); - } - return false; - }, - - // private - onNodeOver : function(n, dd, e, data){ - var dragElClass = this.dropNotAllowed; - var pt = this.getDropPoint(e, n, dd); - if (this.isValidDropPoint(pt, n, data)) { - if (this.appendOnly || this.sortField) { - return "x-tree-drop-ok-below"; - } - - // set the insert point style on the target node - if (pt) { - var targetElClass; - if (pt == "above"){ - dragElClass = n.previousSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-above"; - targetElClass = "x-view-drag-insert-above"; - } else { - dragElClass = n.nextSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-below"; - targetElClass = "x-view-drag-insert-below"; - } - if (this.lastInsertClass != targetElClass){ - Ext.fly(n).replaceClass(this.lastInsertClass, targetElClass); - this.lastInsertClass = targetElClass; - } - } - } - return dragElClass; - }, - - // private - onNodeOut : function(n, dd, e, data){ - this.removeDropIndicators(n); - }, - - // private - onNodeDrop : function(n, dd, e, data){ - if (this.fireEvent("drop", this, n, dd, e, data) === false) { - return false; - } - var pt = this.getDropPoint(e, n, dd); - var insertAt = (this.appendOnly || (n == this.el.dom)) ? this.store.getCount() : n.viewIndex; - if (pt == "below") { - insertAt++; - } - - // Validate if dragging within a DDView - if (data.sourceView == this) { - // If the first element to be inserted below is the target node, remove it - if (pt == "below") { - if (data.viewNodes[0] == n) { - data.viewNodes.shift(); - } - } else { // If the last element to be inserted above is the target node, remove it - if (data.viewNodes[data.viewNodes.length - 1] == n) { - data.viewNodes.pop(); - } - } - - // Nothing to drop... - if (!data.viewNodes.length) { - return false; - } - - // If we are moving DOWN, then because a store.remove() takes place first, - // the insertAt must be decremented. - if (insertAt > this.store.indexOf(data.records[0])) { - insertAt--; - } - } - - // Dragging from a Tree. Use the Tree's recordFromNode function. - if (data.node instanceof Ext.tree.TreeNode) { - var r = data.node.getOwnerTree().recordFromNode(data.node); - if (r) { - data.records = [ r ]; - } - } - - if (!data.records) { - alert("Programming problem. Drag data contained no Records"); - return false; - } - - for (var i = 0; i < data.records.length; i++) { - var r = data.records[i]; - var dup = this.store.getById(r.id); - if (dup && (dd != this.dragZone)) { - if(!this.allowDup && !this.allowTrash){ - Ext.fly(this.getNode(this.store.indexOf(dup))).frame("red", 1); - return true - } - var x=new Ext.data.Record(); - r.id=x.id; - delete x; - } - if (data.copy) { - this.store.insert(insertAt++, r.copy()); - } else { - if (data.sourceView) { - data.sourceView.isDirtyFlag = true; - data.sourceView.store.remove(r); - } - if(!this.allowTrash)this.store.insert(insertAt++, r); - } - if(this.sortField){ - this.store.sort(this.sortField, this.sortDir); - } - this.isDirtyFlag = true; - } - this.dragZone.cachedTarget = null; - return true; - }, - - // private - onEndDrag: function(data, e) { - var d = Ext.get(this.dragData.ddel); - if (d && d.hasClass("multi-proxy")) { - d.remove(); - //delete this.dragData.ddel; - } - }, - - // private - removeDropIndicators : function(n){ - if(n){ - Ext.fly(n).removeClass([ - "x-view-drag-insert-above", - "x-view-drag-insert-left", - "x-view-drag-insert-right", - "x-view-drag-insert-below"]); - this.lastInsertClass = "_noclass"; - } - }, - - /** - * Add a delete option to the DDView's context menu. - * @param {String} imageUrl The URL of the "delete" icon image. - */ - setDeletable: function(imageUrl) { - if (!this.singleSelect && !this.multiSelect) { - this.singleSelect = true; - } - var c = this.getContextMenu(); - this.contextMenu.on("itemclick", function(item) { - switch (item.id) { - case "delete": - this.remove(this.getSelectedIndexes()); - break; - } - }, this); - this.contextMenu.add({ - icon: imageUrl || AU.resolveUrl("/images/delete.gif"), - id: "delete", - text: AU.getMessage("deleteItem") - }); - }, - - /** - * Return the context menu for this DDView. - * @return {Ext.menu.Menu} The context menu - */ - getContextMenu: function() { - if (!this.contextMenu) { - // Create the View's context menu - this.contextMenu = new Ext.menu.Menu({ - id: this.id + "-contextmenu" - }); - this.el.on("contextmenu", this.showContextMenu, this); - } - return this.contextMenu; - }, - - /** - * Disables the view's context menu. - */ - disableContextMenu: function() { - if (this.contextMenu) { - this.el.un("contextmenu", this.showContextMenu, this); - } - }, - - // private - showContextMenu: function(e, item) { - item = this.findItemFromChild(e.getTarget()); - if (item) { - e.stopEvent(); - this.select(this.getNode(item), this.multiSelect && e.ctrlKey, true); - this.contextMenu.showAt(e.getXY()); - } - }, - - /** - * Remove {@link Ext.data.Record}s at the specified indices. - * @param {Array/Number} selectedIndices The index (or Array of indices) of Records to remove. - */ - remove: function(selectedIndices) { - selectedIndices = [].concat(selectedIndices); - for (var i = 0; i < selectedIndices.length; i++) { - var rec = this.store.getAt(selectedIndices[i]); - this.store.remove(rec); - } - }, - - /** - * Double click fires the {@link #dblclick} event. Additionally, if this DDView is draggable, and there is only one other - * related DropZone that is in another DDView, it drops the selected node on that DDView. - */ - onDblClick : function(e){ - var item = this.findItemFromChild(e.getTarget()); - if(item){ - if (this.fireEvent("dblclick", this, this.indexOf(item), item, e) === false) { - return false; - } - if (this.dragGroup) { - var targets = Ext.dd.DragDropMgr.getRelated(this.dragZone, true); - - // Remove instances of this View's DropZone - while (targets.indexOf(this.dropZone) !== -1) { - targets.remove(this.dropZone); - } - - // If there's only one other DropZone, and it is owned by a DDView, then drop it in - if ((targets.length == 1) && (targets[0].owningView)) { - this.dragZone.cachedTarget = null; - var el = Ext.get(targets[0].getEl()); - var box = el.getBox(true); - targets[0].onNodeDrop(el.dom, { - target: el.dom, - xy: [box.x, box.y + box.height - 1] - }, null, this.getDragData(e)); - } - } - } - return true; - }, - - // private - onItemClick : function(item, index, e){ - // The DragZone's mousedown->getDragData already handled selection - if (this.ignoreNextClick) { - delete this.ignoreNextClick; - return false; - } - - if(this.fireEvent("beforeclick", this, index, item, e) === false){ - return false; - } - if(this.multiSelect || this.singleSelect){ - if(this.multiSelect && e.shiftKey && this.lastSelection){ - this.select(this.getNodes(this.indexOf(this.lastSelection), index), false); - } else if (this.isSelected(item) && e.ctrlKey) { - this.deselect(item); - }else{ - this.deselect(item); - this.select(item, this.multiSelect && e.ctrlKey); - this.lastSelection = item; - } - e.preventDefault(); - } - return true; - } -}); +/*
+ * Software License Agreement (BSD License)
+ * Copyright (c) 2008, Nige "Animal" White
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the original author nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/**
+ * @class Ext.ux.DDView
+ * <p>A DnD-enabled version of {@link Ext.DataView}. Drag/drop is implemented by adding
+ * {@link Ext.data.Record}s to the target DDView. If copying is not being performed,
+ * the original {@link Ext.data.Record} is removed from the source DDView.</p>
+ * @constructor
+ * Create a new DDView
+ * @param {Object} config The configuration properties.
+ */
+Ext.ux.DDView = function(config) {
+ if (!config.itemSelector) {
+ var tpl = config.tpl;
+ if (this.classRe.test(tpl)) {
+ config.tpl = tpl.replace(this.classRe, 'class=$1x-combo-list-item $2$1');
+ }
+ else {
+ config.tpl = tpl.replace(this.tagRe, '$1 class="x-combo-list-item" $2');
+ }
+ config.itemSelector = ".x-combo-list-item";
+ }
+ Ext.ux.DDView.superclass.constructor.call(this, Ext.apply(config, {
+ border: false
+ }));
+};
+
+Ext.extend(Ext.ux.DDView, Ext.DataView, {
+ /**
+ * @cfg {String/Array} dragGroup The ddgroup name(s) for the View's DragZone (defaults to undefined).
+ */
+ /**
+ * @cfg {String/Array} dropGroup The ddgroup name(s) for the View's DropZone (defaults to undefined).
+ */
+ /**
+ * @cfg {Boolean} copy Causes drag operations to copy nodes rather than move (defaults to false).
+ */
+ /**
+ * @cfg {Boolean} allowCopy Causes ctrl/drag operations to copy nodes rather than move (defaults to false).
+ */
+ /**
+ * @cfg {String} sortDir Sort direction for the view, 'ASC' or 'DESC' (defaults to 'ASC').
+ */
+ sortDir: 'ASC',
+
+ // private
+ isFormField: true,
+ classRe: /class=(['"])(.*)\1/,
+ tagRe: /(<\w*)(.*?>)/,
+ reset: Ext.emptyFn,
+ clearInvalid: Ext.form.Field.prototype.clearInvalid,
+
+ // private
+ afterRender: function() {
+ Ext.ux.DDView.superclass.afterRender.call(this);
+ if (this.dragGroup) {
+ this.setDraggable(this.dragGroup.split(","));
+ }
+ if (this.dropGroup) {
+ this.setDroppable(this.dropGroup.split(","));
+ }
+ if (this.deletable) {
+ this.setDeletable();
+ }
+ this.isDirtyFlag = false;
+ this.addEvents(
+ "drop"
+ );
+ },
+
+ // private
+ validate: function() {
+ return true;
+ },
+
+ // private
+ destroy: function() {
+ this.purgeListeners();
+ this.getEl().removeAllListeners();
+ this.getEl().remove();
+ if (this.dragZone) {
+ if (this.dragZone.destroy) {
+ this.dragZone.destroy();
+ }
+ }
+ if (this.dropZone) {
+ if (this.dropZone.destroy) {
+ this.dropZone.destroy();
+ }
+ }
+ },
+
+ /**
+ * Allows this class to be an Ext.form.Field so it can be found using {@link Ext.form.BasicForm#findField}.
+ */
+ getName: function() {
+ return this.name;
+ },
+
+ /**
+ * Loads the View from a JSON string representing the Records to put into the Store.
+ * @param {String} value The JSON string
+ */
+ setValue: function(v) {
+ if (!this.store) {
+ throw "DDView.setValue(). DDView must be constructed with a valid Store";
+ }
+ var data = {};
+ data[this.store.reader.meta.root] = v ? [].concat(v) : [];
+ this.store.proxy = new Ext.data.MemoryProxy(data);
+ this.store.load();
+ },
+
+ /**
+ * Returns the view's data value as a list of ids.
+ * @return {String} A parenthesised list of the ids of the Records in the View, e.g. (1,3,8).
+ */
+ getValue: function() {
+ var result = '(';
+ this.store.each(function(rec) {
+ result += rec.id + ',';
+ });
+ return result.substr(0, result.length - 1) + ')';
+ },
+
+ getIds: function() {
+ var i = 0, result = new Array(this.store.getCount());
+ this.store.each(function(rec) {
+ result[i++] = rec.id;
+ });
+ return result;
+ },
+
+ /**
+ * Returns true if the view's data has changed, else false.
+ * @return {Boolean}
+ */
+ isDirty: function() {
+ return this.isDirtyFlag;
+ },
+
+ /**
+ * Part of the Ext.dd.DropZone interface. If no target node is found, the
+ * whole Element becomes the target, and this causes the drop gesture to append.
+ */
+ getTargetFromEvent : function(e) {
+ var target = e.getTarget();
+ while ((target !== null) && (target.parentNode != this.el.dom)) {
+ target = target.parentNode;
+ }
+ if (!target) {
+ target = this.el.dom.lastChild || this.el.dom;
+ }
+ return target;
+ },
+
+ /**
+ * Create the drag data which consists of an object which has the property "ddel" as
+ * the drag proxy element.
+ */
+ getDragData : function(e) {
+ var target = this.findItemFromChild(e.getTarget());
+ if(target) {
+ if (!this.isSelected(target)) {
+ delete this.ignoreNextClick;
+ this.onItemClick(target, this.indexOf(target), e);
+ this.ignoreNextClick = true;
+ }
+ var dragData = {
+ sourceView: this,
+ viewNodes: [],
+ records: [],
+ copy: this.copy || (this.allowCopy && e.ctrlKey)
+ };
+ if (this.getSelectionCount() == 1) {
+ var i = this.getSelectedIndexes()[0];
+ var n = this.getNode(i);
+ dragData.viewNodes.push(dragData.ddel = n);
+ dragData.records.push(this.store.getAt(i));
+ dragData.repairXY = Ext.fly(n).getXY();
+ } else {
+ dragData.ddel = document.createElement('div');
+ dragData.ddel.className = 'multi-proxy';
+ this.collectSelection(dragData);
+ }
+ return dragData;
+ }
+ return false;
+ },
+
+ // override the default repairXY.
+ getRepairXY : function(e){
+ return this.dragData.repairXY;
+ },
+
+ // private
+ collectSelection: function(data) {
+ data.repairXY = Ext.fly(this.getSelectedNodes()[0]).getXY();
+ if (this.preserveSelectionOrder === true) {
+ Ext.each(this.getSelectedIndexes(), function(i) {
+ var n = this.getNode(i);
+ var dragNode = n.cloneNode(true);
+ dragNode.id = Ext.id();
+ data.ddel.appendChild(dragNode);
+ data.records.push(this.store.getAt(i));
+ data.viewNodes.push(n);
+ }, this);
+ } else {
+ var i = 0;
+ this.store.each(function(rec){
+ if (this.isSelected(i)) {
+ var n = this.getNode(i);
+ var dragNode = n.cloneNode(true);
+ dragNode.id = Ext.id();
+ data.ddel.appendChild(dragNode);
+ data.records.push(this.store.getAt(i));
+ data.viewNodes.push(n);
+ }
+ i++;
+ }, this);
+ }
+ },
+
+ /**
+ * Specify to which ddGroup items in this DDView may be dragged.
+ * @param {String} ddGroup The DD group name to assign this view to.
+ */
+ setDraggable: function(ddGroup) {
+ if (ddGroup instanceof Array) {
+ Ext.each(ddGroup, this.setDraggable, this);
+ return;
+ }
+ if (this.dragZone) {
+ this.dragZone.addToGroup(ddGroup);
+ } else {
+ this.dragZone = new Ext.dd.DragZone(this.getEl(), {
+ containerScroll: true,
+ ddGroup: ddGroup
+ });
+ // Draggability implies selection. DragZone's mousedown selects the element.
+ if (!this.multiSelect) { this.singleSelect = true; }
+
+ // Wire the DragZone's handlers up to methods in *this*
+ this.dragZone.getDragData = this.getDragData.createDelegate(this);
+ this.dragZone.getRepairXY = this.getRepairXY;
+ this.dragZone.onEndDrag = this.onEndDrag;
+ }
+ },
+
+ /**
+ * Specify from which ddGroup this DDView accepts drops.
+ * @param {String} ddGroup The DD group name from which to accept drops.
+ */
+ setDroppable: function(ddGroup) {
+ if (ddGroup instanceof Array) {
+ Ext.each(ddGroup, this.setDroppable, this);
+ return;
+ }
+ if (this.dropZone) {
+ this.dropZone.addToGroup(ddGroup);
+ } else {
+ this.dropZone = new Ext.dd.DropZone(this.getEl(), {
+ owningView: this,
+ containerScroll: true,
+ ddGroup: ddGroup
+ });
+
+ // Wire the DropZone's handlers up to methods in *this*
+ this.dropZone.getTargetFromEvent = this.getTargetFromEvent.createDelegate(this);
+ this.dropZone.onNodeEnter = this.onNodeEnter.createDelegate(this);
+ this.dropZone.onNodeOver = this.onNodeOver.createDelegate(this);
+ this.dropZone.onNodeOut = this.onNodeOut.createDelegate(this);
+ this.dropZone.onNodeDrop = this.onNodeDrop.createDelegate(this);
+ }
+ },
+
+ // private
+ getDropPoint : function(e, n, dd){
+ if (n == this.el.dom) { return "above"; }
+ var t = Ext.lib.Dom.getY(n), b = t + n.offsetHeight;
+ var c = t + (b - t) / 2;
+ var y = Ext.lib.Event.getPageY(e);
+ if(y <= c) {
+ return "above";
+ }else{
+ return "below";
+ }
+ },
+
+ // private
+ isValidDropPoint: function(pt, n, data) {
+ if (!data.viewNodes || (data.viewNodes.length != 1)) {
+ return true;
+ }
+ var d = data.viewNodes[0];
+ if (d == n) {
+ return false;
+ }
+ if ((pt == "below") && (n.nextSibling == d)) {
+ return false;
+ }
+ if ((pt == "above") && (n.previousSibling == d)) {
+ return false;
+ }
+ return true;
+ },
+
+ // private
+ onNodeEnter : function(n, dd, e, data){
+ if (this.highlightColor && (data.sourceView != this)) {
+ this.el.highlight(this.highlightColor);
+ }
+ return false;
+ },
+
+ // private
+ onNodeOver : function(n, dd, e, data){
+ var dragElClass = this.dropNotAllowed;
+ var pt = this.getDropPoint(e, n, dd);
+ if (this.isValidDropPoint(pt, n, data)) {
+ if (this.appendOnly || this.sortField) {
+ return "x-tree-drop-ok-below";
+ }
+
+ // set the insert point style on the target node
+ if (pt) {
+ var targetElClass;
+ if (pt == "above"){
+ dragElClass = n.previousSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-above";
+ targetElClass = "x-view-drag-insert-above";
+ } else {
+ dragElClass = n.nextSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-below";
+ targetElClass = "x-view-drag-insert-below";
+ }
+ if (this.lastInsertClass != targetElClass){
+ Ext.fly(n).replaceClass(this.lastInsertClass, targetElClass);
+ this.lastInsertClass = targetElClass;
+ }
+ }
+ }
+ return dragElClass;
+ },
+
+ // private
+ onNodeOut : function(n, dd, e, data){
+ this.removeDropIndicators(n);
+ },
+
+ // private
+ onNodeDrop : function(n, dd, e, data){
+ if (this.fireEvent("drop", this, n, dd, e, data) === false) {
+ return false;
+ }
+ var pt = this.getDropPoint(e, n, dd);
+ var insertAt = (this.appendOnly || (n == this.el.dom)) ? this.store.getCount() : n.viewIndex;
+ if (pt == "below") {
+ insertAt++;
+ }
+
+ // Validate if dragging within a DDView
+ if (data.sourceView == this) {
+ // If the first element to be inserted below is the target node, remove it
+ if (pt == "below") {
+ if (data.viewNodes[0] == n) {
+ data.viewNodes.shift();
+ }
+ } else { // If the last element to be inserted above is the target node, remove it
+ if (data.viewNodes[data.viewNodes.length - 1] == n) {
+ data.viewNodes.pop();
+ }
+ }
+
+ // Nothing to drop...
+ if (!data.viewNodes.length) {
+ return false;
+ }
+
+ // If we are moving DOWN, then because a store.remove() takes place first,
+ // the insertAt must be decremented.
+ if (insertAt > this.store.indexOf(data.records[0])) {
+ insertAt--;
+ }
+ }
+
+ // Dragging from a Tree. Use the Tree's recordFromNode function.
+ if (data.node instanceof Ext.tree.TreeNode) {
+ var r = data.node.getOwnerTree().recordFromNode(data.node);
+ if (r) {
+ data.records = [ r ];
+ }
+ }
+
+ if (!data.records) {
+ alert("Programming problem. Drag data contained no Records");
+ return false;
+ }
+
+ for (var i = 0; i < data.records.length; i++) {
+ var r = data.records[i];
+ var dup = this.store.getById(r.id);
+ if (dup && (dd != this.dragZone)) {
+ if(!this.allowDup && !this.allowTrash){
+ Ext.fly(this.getNode(this.store.indexOf(dup))).frame("red", 1);
+ return true;
+ }
+ var x=new Ext.data.Record();
+ r.id=x.id;
+ delete x;
+ }
+ if (data.copy) {
+ this.store.insert(insertAt++, r.copy());
+ } else {
+ if (data.sourceView) {
+ data.sourceView.isDirtyFlag = true;
+ data.sourceView.store.remove(r);
+ }
+ if(!this.allowTrash)this.store.insert(insertAt++, r);
+ }
+ if(this.sortField){
+ this.store.sort(this.sortField, this.sortDir);
+ }
+ this.isDirtyFlag = true;
+ }
+ this.dragZone.cachedTarget = null;
+ return true;
+ },
+
+ // private
+ onEndDrag: function(data, e) {
+ var d = Ext.get(this.dragData.ddel);
+ if (d && d.hasClass("multi-proxy")) {
+ d.remove();
+ //delete this.dragData.ddel;
+ }
+ },
+
+ // private
+ removeDropIndicators : function(n){
+ if(n){
+ Ext.fly(n).removeClass([
+ "x-view-drag-insert-above",
+ "x-view-drag-insert-left",
+ "x-view-drag-insert-right",
+ "x-view-drag-insert-below"]);
+ this.lastInsertClass = "_noclass";
+ }
+ },
+
+ /**
+ * Add a delete option to the DDView's context menu.
+ * @param {String} imageUrl The URL of the "delete" icon image.
+ */
+ setDeletable: function(imageUrl) {
+ if (!this.singleSelect && !this.multiSelect) {
+ this.singleSelect = true;
+ }
+ var c = this.getContextMenu();
+ this.contextMenu.on("itemclick", function(item) {
+ switch (item.id) {
+ case "delete":
+ this.remove(this.getSelectedIndexes());
+ break;
+ }
+ }, this);
+ this.contextMenu.add({
+ icon: imageUrl || AU.resolveUrl("/images/delete.gif"),
+ id: "delete",
+ text: AU.getMessage("deleteItem")
+ });
+ },
+
+ /**
+ * Return the context menu for this DDView.
+ * @return {Ext.menu.Menu} The context menu
+ */
+ getContextMenu: function() {
+ if (!this.contextMenu) {
+ // Create the View's context menu
+ this.contextMenu = new Ext.menu.Menu({
+ id: this.id + "-contextmenu"
+ });
+ this.el.on("contextmenu", this.showContextMenu, this);
+ }
+ return this.contextMenu;
+ },
+
+ /**
+ * Disables the view's context menu.
+ */
+ disableContextMenu: function() {
+ if (this.contextMenu) {
+ this.el.un("contextmenu", this.showContextMenu, this);
+ }
+ },
+
+ // private
+ showContextMenu: function(e, item) {
+ item = this.findItemFromChild(e.getTarget());
+ if (item) {
+ e.stopEvent();
+ this.select(this.getNode(item), this.multiSelect && e.ctrlKey, true);
+ this.contextMenu.showAt(e.getXY());
+ }
+ },
+
+ /**
+ * Remove {@link Ext.data.Record}s at the specified indices.
+ * @param {Array/Number} selectedIndices The index (or Array of indices) of Records to remove.
+ */
+ remove: function(selectedIndices) {
+ selectedIndices = [].concat(selectedIndices);
+ for (var i = 0; i < selectedIndices.length; i++) {
+ var rec = this.store.getAt(selectedIndices[i]);
+ this.store.remove(rec);
+ }
+ },
+
+ /**
+ * Double click fires the {@link #dblclick} event. Additionally, if this DDView is draggable, and there is only one other
+ * related DropZone that is in another DDView, it drops the selected node on that DDView.
+ */
+ onDblClick : function(e){
+ var item = this.findItemFromChild(e.getTarget());
+ if(item){
+ if (this.fireEvent("dblclick", this, this.indexOf(item), item, e) === false) {
+ return false;
+ }
+ if (this.dragGroup) {
+ var targets = Ext.dd.DragDropMgr.getRelated(this.dragZone, true);
+
+ // Remove instances of this View's DropZone
+ while (targets.indexOf(this.dropZone) !== -1) {
+ targets.remove(this.dropZone);
+ }
+
+ // If there's only one other DropZone, and it is owned by a DDView, then drop it in
+ if ((targets.length == 1) && (targets[0].owningView)) {
+ this.dragZone.cachedTarget = null;
+ var el = Ext.get(targets[0].getEl());
+ var box = el.getBox(true);
+ targets[0].onNodeDrop(el.dom, {
+ target: el.dom,
+ xy: [box.x, box.y + box.height - 1]
+ }, null, this.getDragData(e));
+ }
+ }
+ }
+ return true;
+ },
+
+ // private
+ onItemClick : function(item, index, e){
+ // The DragZone's mousedown->getDragData already handled selection
+ if (this.ignoreNextClick) {
+ delete this.ignoreNextClick;
+ return false;
+ }
+
+ if(this.fireEvent("beforeclick", this, index, item, e) === false){
+ return false;
+ }
+ if(this.multiSelect || this.singleSelect){
+ if(this.multiSelect && e.shiftKey && this.lastSelection){
+ this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
+ } else if (this.isSelected(item) && e.ctrlKey) {
+ this.deselect(item);
+ }else{
+ this.deselect(item);
+ this.select(item, this.multiSelect && e.ctrlKey);
+ this.lastSelection = item;
+ }
+ e.preventDefault();
+ }
+ return true;
+ }
+});
diff --git a/skins/jason/ux/Search.js b/skins/jason/ux/Search.js index 7295aca..13c8619 100644 --- a/skins/jason/ux/Search.js +++ b/skins/jason/ux/Search.js @@ -205,7 +205,7 @@ Ext.extend(Ext.ux.grid.Search, Ext.util.Observable, { * get value of search field */ ,getValue:function() { - return this.field.isValid() ? this.field.getValue() : null + return this.field.isValid() ? this.field.getValue() : null; } // eo function disable // }}} diff --git a/skins/jason/ux/SlideZone.js b/skins/jason/ux/SlideZone.js index 3932525..8b9ad58 100644 --- a/skins/jason/ux/SlideZone.js +++ b/skins/jason/ux/SlideZone.js @@ -12,623 +12,622 @@ */ Ext.ux.SlideZone = function(id, config) { - if(id) { - Ext.apply(this, config); - this.init(id, config || {}); + if(id) { + Ext.apply(this, config); + this.init(id, config || {}); return this; - } else { - return null; - } -} + } else { + return null; + } +}; Ext.extend(Ext.ux.SlideZone, Ext.BoxComponent, { - size: 100, - sliderSnap: [0], - type: 'horizontal', - sliderWidth: 20, - sliderHeight: 20, - cls: null, - minValue: 0, - maxValue: 100, - allowSliderCrossing: true, - value: null, - - init: function(id, config) { - this.size = this.size instanceof Array ? this.size : [this.size]; - this.minValue = this.minValue instanceof Array ? this.minValue : [this.minValue]; - this.maxValue = this.maxValue instanceof Array ? this.maxValue : [this.maxValue]; - this.sliderSnap = this.sliderSnap instanceof Array ? this.sliderSnap : [this.sliderSnap]; - - this.el = Ext.DomHelper.append(Ext.get(id), { tag: 'div', - id: Ext.id(), - style: 'position: relative; ' - }, true); - this.el.addClass('x-slide-zone-' + this.type); - this.el.addClass(this.cls); - - switch(this.type) { - case 'horizontal': - this.sliderSize = [this.sliderWidth]; - this.el.applyStyles({width:this.size[0] + 'px'}); - this.el.lowLimit = [this.el.getX()]; - this.el.highLimit = [this.el.getRight()]; - break; - - case 'vertical': - this.sliderSize = [this.sliderHeight] - this.el.applyStyles({height:this.size[0] + 'px'}); - this.el.lowLimit = [this.el.getY()]; - this.el.highLimit = [this.el.getBottom()]; - break; - - case 'area': - this.sliderSize = [this.sliderWidth, this.sliderHeight]; - this.el.applyStyles({width:this.size[0] + 'px'}); - this.el.applyStyles({height:this.size[1] + 'px'}); - this.el.lowLimit = this.el.getXY(); - this.el.highLimit = [this.el.getRight(), this.el.getBottom()]; - break - } - - //normalize width/height for slider centering calculations - var l = this.sliderSize.length; - for(var i = 0; i < l; i++) { - this.sliderSize[i] = this.sliderSize[i] % 2 ? this.sliderSize[i] + 1: this.sliderSize[i] - } - - - var s = this.sliders; - this.sliders = new Ext.util.MixedCollection(); - if(s){ - this.add.apply(this, s); - } - - }, - - add: function(){ - var a = arguments, l = a.length - for(var i = 0; i < l; i++){ - var el = a[i]; - if (el instanceof Ext.ux.Slider) { - this.initSlider(el); - this.sliders.add(el) - } else if (typeof el == 'object') { - //initalize new slider and add to the items list - var s = new Ext.ux.ThumbSlider(el); - this.initSlider(s); - this.sliders.add(s) - } - } - this.updateValues(); - this.updateConstraints(); - }, - - enableCrossing: function() { - this.allowSliderCrossing = true; - this.updateConstraints(); - }, - - disableCrossing: function() { - this.allowSliderCrossing = false; - this.updateConstraints(); - }, - - getSlider: function(selector) { - /* Given a slider index or name, returns a slider object - * @selector slider index|name - */ - switch (typeof selector) { - case 'number': - return this.sliders.items[selector]; - break; - - case 'string': - var l = this.sliders.length; - for(var i = 0; i < l; i++){ - if(this.sliders.items[i].name == selector) return this.sliders.items[i]; - } - break; - } + size: 100, + sliderSnap: [0], + type: 'horizontal', + sliderWidth: 20, + sliderHeight: 20, + cls: null, + minValue: 0, + maxValue: 100, + allowSliderCrossing: true, + value: null, + + init: function(id, config) { + this.size = this.size instanceof Array ? this.size : [this.size]; + this.minValue = this.minValue instanceof Array ? this.minValue : [this.minValue]; + this.maxValue = this.maxValue instanceof Array ? this.maxValue : [this.maxValue]; + this.sliderSnap = this.sliderSnap instanceof Array ? this.sliderSnap : [this.sliderSnap]; + + this.el = Ext.DomHelper.append(Ext.get(id), { tag: 'div', + id: Ext.id(), + style: 'position: relative; ' + }, true); + this.el.addClass('x-slide-zone-' + this.type); + this.el.addClass(this.cls); + + switch(this.type) { + case 'horizontal': + this.sliderSize = [this.sliderWidth]; + this.el.applyStyles({width:this.size[0] + 'px'}); + this.el.lowLimit = [this.el.getX()]; + this.el.highLimit = [this.el.getRight()]; + break; + + case 'vertical': + this.sliderSize = [this.sliderHeight]; + this.el.applyStyles({height:this.size[0] + 'px'}); + this.el.lowLimit = [this.el.getY()]; + this.el.highLimit = [this.el.getBottom()]; + break; + + case 'area': + this.sliderSize = [this.sliderWidth, this.sliderHeight]; + this.el.applyStyles({width:this.size[0] + 'px'}); + this.el.applyStyles({height:this.size[1] + 'px'}); + this.el.lowLimit = this.el.getXY(); + this.el.highLimit = [this.el.getRight(), this.el.getBottom()]; + break; + } + + //normalize width/height for slider centering calculations + var l = this.sliderSize.length; + for(var i = 0; i < l; i++) { + this.sliderSize[i] = this.sliderSize[i] % 2 ? this.sliderSize[i] + 1: this.sliderSize[i]; + } + + + var s = this.sliders; + this.sliders = new Ext.util.MixedCollection(); + if(s){ + this.add.apply(this, s); + } + + }, + + add: function(){ + var a = arguments, l = a.length; + for(var i = 0; i < l; i++){ + var el = a[i]; + if (el instanceof Ext.ux.Slider) { + this.initSlider(el); + this.sliders.add(el); + } else if (typeof el == 'object') { + //initalize new slider and add to the items list + var s = new Ext.ux.ThumbSlider(el); + this.initSlider(s); + this.sliders.add(s); + } + } + this.updateValues(); + this.updateConstraints(); + }, + + enableCrossing: function() { + this.allowSliderCrossing = true; + this.updateConstraints(); + }, + + disableCrossing: function() { + this.allowSliderCrossing = false; + this.updateConstraints(); + }, + + getSlider: function(selector) { + /* Given a slider index or name, returns a slider object + * @selector slider index|name + */ + switch (typeof selector) { + case 'number': + return this.sliders.items[selector]; + + case 'string': + var l = this.sliders.length; + for(var i = 0; i < l; i++){ + if(this.sliders.items[i].name == selector) return this.sliders.items[i]; + } + break; + } return null; - }, - - - updateConstraints: function() { - if(!this.allowSliderCrossing && this.sliders.length > 1 && this.type != 'area') { - // multiple sliders exists and sliders can't cross, - // so we have to take into account the - // positions of all sliders - sortFN = function(a,b){ - var v1 = a.value instanceof Array ? a.value[0] : a.value; - var v2 = b.value instanceof Array ? b.value[0] : b.value; - return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0); - } - this.sliders.sort('asc',sortFN);//put in order by their value - - var l = this.sliders.length; - for (var i=0; i< l; i++) { //forloop required, as we have to get -1 and +1 slider positions - var leftTravel = 0, rightTravel = 0; - var sliderL = this.sliders.get(i-1); - var slider = this.sliders.get(i); - var sliderR = this.sliders.get(i+1); - - - if (sliderL && sliderR) { - if (sliderL instanceof Ext.ux.ThumbSlider) { - var leftTravel = slider.getTL()[0] - sliderL.getTL()[0] - this.sliderSnap[0]; - } - if (sliderL instanceof Ext.ux.RangeSlider) { - var leftTravel = slider.getTL()[0] - sliderL.getBR()[0] - this.sliderSnap[0]; - } - if (sliderR instanceof Ext.ux.ThumbSlider) { - var rightTravel = sliderR.getTL()[0] - slider.getTL()[0] - this.sliderSnap[0]; - } - if (sliderR instanceof Ext.ux.RangeSlider) { - var rightTravel = sliderR.getTL()[0] - slider.getBR()[0] - this.sliderSnap[0] ; - } - } else if(sliderL) { - if (sliderL instanceof Ext.ux.ThumbSlider) { - var rightTravel = this.el.highLimit[0] - slider.getTL()[0] - ( 0.5 * this.sliderSize[0]) ; - var leftTravel = slider.getTL()[0] - sliderL.getTL()[0] - this.sliderSnap[0]; - } - if (sliderL instanceof Ext.ux.RangeSlider) { - var rightTravel = this.el.highLimit[0] - slider.getBR()[0]; - var leftTravel = slider.getTL()[0] - sliderL.getBR()[0] - this.sliderSnap[0]; - } - } else if(sliderR) { - if (sliderR instanceof Ext.ux.ThumbSlider) { - var leftTravel = slider.getTL()[0] - this.el.lowLimit[0] + ( 0.5 * this.sliderSize[0]); - var rightTravel = sliderR.getTL()[0] - slider.getTL()[0] - this.sliderSnap[0] ; - } - if (sliderR instanceof Ext.ux.RangeSlider) { - var leftTravel = slider.getTL()[0] - this.el.lowLimit[0]; - var rightTravel = sliderR.getTL()[0] - slider.getBR()[0] - this.sliderSnap[0] ; - } - } - if(slider instanceof Ext.ux.RangeSlider) { - slider.resizable.leftTravel = [leftTravel]; - slider.resizable.rightTravel = [rightTravel]; - } - slider.setConstraint([leftTravel], [rightTravel], this.sliderSnap); - } - } else { - var l = this.sliders.length; - for (var i=0; i< l; i++) { - var slider = this.sliders.get(i); - if (slider instanceof Ext.ux.ThumbSlider ) { - slider.setConstraint([slider.getTL()[0]-this.el.lowLimit[0] + ( 1/2 * this.sliderSize[0]), - slider.getTL()[1]-this.el.lowLimit[1] + ( 1/2 * this.sliderSize[1])], - [this.el.highLimit[0]- (slider.getTL()[0] + this.sliderSize[0]) + ( 1/2 * this.sliderSize[0]), - this.el.highLimit[1]- (slider.getTL()[1] + this.sliderSize[1]) + ( 1/2 * this.sliderSize[1]) ], - this.sliderSnap) - } - if (slider instanceof Ext.ux.RangeSlider) { - slider.setConstraint([slider.getTL()[0] - this.el.lowLimit[0], - slider.getTL()[1] - this.el.lowLimit[1]], - [this.el.highLimit[0] - slider.getBR()[0], - this.el.highLimit[1] - slider.getBR()[1] ], - this.sliderSnap) - } - } - } - }, - - updateValues: function() { - var that = this; - var vals = {}; - this.sliders.each(function(i) { - - if(this.type == 'area') { - if (i instanceof Ext.ux.ThumbSlider) { - i.value = [(i.getTL()[0] + 1/2 * that.sliderSize[0] - that.el.lowLimit[0]) / (that.size[0]) * (that.maxValue[0] - that.minValue[0]) + that.minValue[0], - (i.getTL()[1] + 1/2 * that.sliderSize[1] - that.el.lowLimit[1]) / (that.size[1]) * (that.maxValue[1] - that.minValue[1]) + that.minValue[1]]; - i.percent = [parseFloat((i.getTL()[0] + 1/2 * that.sliderSize[0] - that.el.lowLimit[0]) / (that.size[0]) * 100), - parseFloat((i.getTL()[1] + 1/2 * that.sliderSize[1] - that.el.lowLimit[1]) / (that.size[1]) * 100)]; - } - if (i instanceof Ext.ux.RangeSlider) { - i.value = [[ - (i.getTL()[0] - that.el.lowLimit[0]) / (that.size[0]) * (that.maxValue[0] - that.minValue[0]) + that.minValue[0], - (i.getBR()[0] - that.el.lowLimit[0]) / (that.size[0]) * (that.maxValue[0] - that.minValue[0]) + that.minValue[0] - - - ],[ - (i.getTL()[1] - that.el.lowLimit[1]) / (that.size[1]) * (that.maxValue[1] - that.minValue[1]) + that.minValue[1], - (i.getBR()[1] - that.el.lowLimit[1]) / (that.size[1]) * (that.maxValue[1] - that.minValue[1]) + that.minValue[1] - ]]; - i.percent = [[ - parseFloat((i.getTL()[0] - that.el.lowLimit[0]) / (that.size[0]) * 100).toFixed(2), - parseFloat((i.getBR()[0] - that.el.lowLimit[0]) / (that.size[0]) * 100).toFixed(2) - ],[ - parseFloat((i.getTL()[1] - that.el.lowLimit[1]) / (that.size[1]) * 100).toFixed(2), - parseFloat((i.getBR()[1] - that.el.lowLimit[1]) / (that.size[1]) * 100).toFixed(2) - ]]; - } - } else { - if (i instanceof Ext.ux.ThumbSlider) { - i.value = (i.getTL()[0] + 1/2 * that.sliderSize[0] - that.el.lowLimit[0]) / (that.size[0]) * (that.maxValue[0] - that.minValue[0]) + that.minValue[0]; - i.percent = parseFloat((i.getTL()[0] + 1/2 * that.sliderSize[0] - that.el.lowLimit[0]) / (that.size[0]) * 100); - } - if (i instanceof Ext.ux.RangeSlider) { - i.value = [(i.getTL()[0] - that.el.lowLimit[0]) / (that.size[0]) * (that.maxValue[0] - that.minValue[0]) + that.minValue[0], - (i.getBR()[0] - that.el.lowLimit[0]) / (that.size[0]) * (that.maxValue[0] - that.minValue[0]) + that.minValue[0]]; - i.percent = [ parseFloat((i.getTL()[0] - that.el.lowLimit[0]) / (that.size[0]) * 100), - parseFloat((i.getBR()[0] - that.el.lowLimit[0]) / (that.size[0]) * 100)]; - } - } - vals[this.name] = this.value; - }); - - this.value = vals; - }, - - initSliderPosition: function(slider) { - /* Sets a sliders's initial position within the slide zone. - * If slideZone has a sliderSnap set, the slider - * is positioned at a multiple of the sliderSnap value that is - * closest where the slider's value would otherwise position it. - * After positioning, the slider's actual value will be modified - * in Ext.ux.SlideZone.updateValues() - * to jibe with the actual position in the slide zone given the - * sliderSnap constraint. - */ - var initialPosition = [0,0]; - slider.repositionDelta = [0,0]; - var l = this.type == 'area' ? 2 : 1; - for(var i=0; i < l; i++ ) { - /* Make sure initial value is in slider bar range, - if it's outside, set to closest limit. - The slider value is modified if it's out of range. */ - if(slider.value instanceof Array) { - if (slider instanceof Ext.ux.ThumbSlider) { - - slider.value[i] = Number(slider.value[i]).constrain(this.minValue[i], this.maxValue[i]); - initialPosition[i] = parseInt((slider.value[i] - this.minValue[i]) / (this.maxValue[i] - this.minValue[i]) * this.size[i] + this.el.lowLimit[i]); - } - if (slider instanceof Ext.ux.RangeSlider) { - switch (this.type) { - case 'horizontal': - case 'vertical': - slider.value[i] = Number(slider.value[i]).constrain(this.minValue[i], this.maxValue[i]); - initialPosition[i] = parseInt((slider.value[i] - this.minValue[i]) / (this.maxValue[i] - this.minValue[i]) * this.size[i] + this.el.lowLimit[i]); - break; - - case 'area': - slider.value[i][0] = Number(slider.value[i][0]).constrain(this.minValue[i], this.maxValue[i]); - slider.value[i][1] = Number(slider.value[i][1]).constrain(this.minValue[i], this.maxValue[i]); - - initialPosition[i] = parseInt((slider.value[i][0] - this.minValue[i]) / (this.maxValue[i] - this.minValue[i]) * this.size[i] + this.el.lowLimit[i]); - - break; - } - } - } else { - slider.value = Number(slider.value).constrain(this.minValue[i], this.maxValue[i]); - initialPosition[i] = parseInt((slider.value - this.minValue[i]) / (this.maxValue[i] - this.minValue[i]) * this.size[i] + this.el.lowLimit[i]); - } - - /* Calculate slider value versus closest snap-to location, - and calculate an offset value to apply when positioning it. */ - if (this.sliderSnap[i] > 1) { - var positionToSnapDiff = [0,0]; - positionToSnapDiff[i] = (initialPosition[i] - this.el.lowLimit[i]) % this.sliderSnap[i]; - if (positionToSnapDiff[i]) { - if(positionToSnapDiff[i] < 1/2 * this.sliderSnap[i]) { - slider.repositionDelta[i] = -positionToSnapDiff[i]; - } else { - slider.repositionDelta[i] = this.sliderSnap[i] - positionToSnapDiff[i]; - } - } - } - } - - if (slider instanceof Ext.ux.ThumbSlider) { - slider.setPosition([initialPosition[0] + slider.repositionDelta[0] - (0.5 * this.sliderSize[0]), - initialPosition[1] + slider.repositionDelta[1] - (0.5 * this.sliderSize[1])]); - } - if (slider instanceof Ext.ux.RangeSlider) { - - slider.setPosition([initialPosition[0] + slider.repositionDelta[0], - initialPosition[1] + slider.repositionDelta[1]]); - } - }, - - initSlider: function(slider) { - slider.init(this); - this.initSliderPosition(slider); - } + }, + + + updateConstraints: function() { + if(!this.allowSliderCrossing && this.sliders.length > 1 && this.type != 'area') { + // multiple sliders exists and sliders can't cross, + // so we have to take into account the + // positions of all sliders + sortFN = function(a,b){ + var v1 = a.value instanceof Array ? a.value[0] : a.value; + var v2 = b.value instanceof Array ? b.value[0] : b.value; + return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0); + }; + this.sliders.sort('asc',sortFN);//put in order by their value + + var l = this.sliders.length; + for (var i=0; i< l; i++) { //forloop required, as we have to get -1 and +1 slider positions + var leftTravel = 0, rightTravel = 0; + var sliderL = this.sliders.get(i-1); + var slider = this.sliders.get(i); + var sliderR = this.sliders.get(i+1); + + + if (sliderL && sliderR) { + if (sliderL instanceof Ext.ux.ThumbSlider) { + var leftTravel = slider.getTL()[0] - sliderL.getTL()[0] - this.sliderSnap[0]; + } + if (sliderL instanceof Ext.ux.RangeSlider) { + var leftTravel = slider.getTL()[0] - sliderL.getBR()[0] - this.sliderSnap[0]; + } + if (sliderR instanceof Ext.ux.ThumbSlider) { + var rightTravel = sliderR.getTL()[0] - slider.getTL()[0] - this.sliderSnap[0]; + } + if (sliderR instanceof Ext.ux.RangeSlider) { + var rightTravel = sliderR.getTL()[0] - slider.getBR()[0] - this.sliderSnap[0] ; + } + } else if(sliderL) { + if (sliderL instanceof Ext.ux.ThumbSlider) { + var rightTravel = this.el.highLimit[0] - slider.getTL()[0] - ( 0.5 * this.sliderSize[0]) ; + var leftTravel = slider.getTL()[0] - sliderL.getTL()[0] - this.sliderSnap[0]; + } + if (sliderL instanceof Ext.ux.RangeSlider) { + var rightTravel = this.el.highLimit[0] - slider.getBR()[0]; + var leftTravel = slider.getTL()[0] - sliderL.getBR()[0] - this.sliderSnap[0]; + } + } else if(sliderR) { + if (sliderR instanceof Ext.ux.ThumbSlider) { + var leftTravel = slider.getTL()[0] - this.el.lowLimit[0] + ( 0.5 * this.sliderSize[0]); + var rightTravel = sliderR.getTL()[0] - slider.getTL()[0] - this.sliderSnap[0] ; + } + if (sliderR instanceof Ext.ux.RangeSlider) { + var leftTravel = slider.getTL()[0] - this.el.lowLimit[0]; + var rightTravel = sliderR.getTL()[0] - slider.getBR()[0] - this.sliderSnap[0] ; + } + } + if(slider instanceof Ext.ux.RangeSlider) { + slider.resizable.leftTravel = [leftTravel]; + slider.resizable.rightTravel = [rightTravel]; + } + slider.setConstraint([leftTravel], [rightTravel], this.sliderSnap); + } + } else { + var l = this.sliders.length; + for (var i=0; i< l; i++) { + var slider = this.sliders.get(i); + if (slider instanceof Ext.ux.ThumbSlider ) { + slider.setConstraint([slider.getTL()[0]-this.el.lowLimit[0] + ( 1/2 * this.sliderSize[0]), + slider.getTL()[1]-this.el.lowLimit[1] + ( 1/2 * this.sliderSize[1])], + [this.el.highLimit[0]- (slider.getTL()[0] + this.sliderSize[0]) + ( 1/2 * this.sliderSize[0]), + this.el.highLimit[1]- (slider.getTL()[1] + this.sliderSize[1]) + ( 1/2 * this.sliderSize[1]) ], + this.sliderSnap); + } + if (slider instanceof Ext.ux.RangeSlider) { + slider.setConstraint([slider.getTL()[0] - this.el.lowLimit[0], + slider.getTL()[1] - this.el.lowLimit[1]], + [this.el.highLimit[0] - slider.getBR()[0], + this.el.highLimit[1] - slider.getBR()[1] ], + this.sliderSnap); + } + } + } + }, + + updateValues: function() { + var that = this; + var vals = {}; + this.sliders.each(function(i) { + + if(this.type == 'area') { + if (i instanceof Ext.ux.ThumbSlider) { + i.value = [(i.getTL()[0] + 1/2 * that.sliderSize[0] - that.el.lowLimit[0]) / (that.size[0]) * (that.maxValue[0] - that.minValue[0]) + that.minValue[0], + (i.getTL()[1] + 1/2 * that.sliderSize[1] - that.el.lowLimit[1]) / (that.size[1]) * (that.maxValue[1] - that.minValue[1]) + that.minValue[1]]; + i.percent = [parseFloat((i.getTL()[0] + 1/2 * that.sliderSize[0] - that.el.lowLimit[0]) / (that.size[0]) * 100), + parseFloat((i.getTL()[1] + 1/2 * that.sliderSize[1] - that.el.lowLimit[1]) / (that.size[1]) * 100)]; + } + if (i instanceof Ext.ux.RangeSlider) { + i.value = [[ + (i.getTL()[0] - that.el.lowLimit[0]) / (that.size[0]) * (that.maxValue[0] - that.minValue[0]) + that.minValue[0], + (i.getBR()[0] - that.el.lowLimit[0]) / (that.size[0]) * (that.maxValue[0] - that.minValue[0]) + that.minValue[0] + + + ],[ + (i.getTL()[1] - that.el.lowLimit[1]) / (that.size[1]) * (that.maxValue[1] - that.minValue[1]) + that.minValue[1], + (i.getBR()[1] - that.el.lowLimit[1]) / (that.size[1]) * (that.maxValue[1] - that.minValue[1]) + that.minValue[1] + ]]; + i.percent = [[ + parseFloat((i.getTL()[0] - that.el.lowLimit[0]) / (that.size[0]) * 100).toFixed(2), + parseFloat((i.getBR()[0] - that.el.lowLimit[0]) / (that.size[0]) * 100).toFixed(2) + ],[ + parseFloat((i.getTL()[1] - that.el.lowLimit[1]) / (that.size[1]) * 100).toFixed(2), + parseFloat((i.getBR()[1] - that.el.lowLimit[1]) / (that.size[1]) * 100).toFixed(2) + ]]; + } + } else { + if (i instanceof Ext.ux.ThumbSlider) { + i.value = (i.getTL()[0] + 1/2 * that.sliderSize[0] - that.el.lowLimit[0]) / (that.size[0]) * (that.maxValue[0] - that.minValue[0]) + that.minValue[0]; + i.percent = parseFloat((i.getTL()[0] + 1/2 * that.sliderSize[0] - that.el.lowLimit[0]) / (that.size[0]) * 100); + } + if (i instanceof Ext.ux.RangeSlider) { + i.value = [(i.getTL()[0] - that.el.lowLimit[0]) / (that.size[0]) * (that.maxValue[0] - that.minValue[0]) + that.minValue[0], + (i.getBR()[0] - that.el.lowLimit[0]) / (that.size[0]) * (that.maxValue[0] - that.minValue[0]) + that.minValue[0]]; + i.percent = [ parseFloat((i.getTL()[0] - that.el.lowLimit[0]) / (that.size[0]) * 100), + parseFloat((i.getBR()[0] - that.el.lowLimit[0]) / (that.size[0]) * 100)]; + } + } + vals[this.name] = this.value; + }); + + this.value = vals; + }, + + initSliderPosition: function(slider) { + /* Sets a sliders's initial position within the slide zone. + * If slideZone has a sliderSnap set, the slider + * is positioned at a multiple of the sliderSnap value that is + * closest where the slider's value would otherwise position it. + * After positioning, the slider's actual value will be modified + * in Ext.ux.SlideZone.updateValues() + * to jibe with the actual position in the slide zone given the + * sliderSnap constraint. + */ + var initialPosition = [0,0]; + slider.repositionDelta = [0,0]; + var l = this.type == 'area' ? 2 : 1; + for(var i=0; i < l; i++ ) { + /* Make sure initial value is in slider bar range, + if it's outside, set to closest limit. + The slider value is modified if it's out of range. */ + if(slider.value instanceof Array) { + if (slider instanceof Ext.ux.ThumbSlider) { + + slider.value[i] = Number(slider.value[i]).constrain(this.minValue[i], this.maxValue[i]); + initialPosition[i] = parseInt((slider.value[i] - this.minValue[i]) / (this.maxValue[i] - this.minValue[i]) * this.size[i] + this.el.lowLimit[i],10); + } + if (slider instanceof Ext.ux.RangeSlider) { + switch (this.type) { + case 'horizontal': + case 'vertical': + slider.value[i] = Number(slider.value[i]).constrain(this.minValue[i], this.maxValue[i]); + initialPosition[i] = parseInt((slider.value[i] - this.minValue[i]) / (this.maxValue[i] - this.minValue[i]) * this.size[i] + this.el.lowLimit[i],10); + break; + + case 'area': + slider.value[i][0] = Number(slider.value[i][0]).constrain(this.minValue[i], this.maxValue[i]); + slider.value[i][1] = Number(slider.value[i][1]).constrain(this.minValue[i], this.maxValue[i]); + + initialPosition[i] = parseInt((slider.value[i][0] - this.minValue[i]) / (this.maxValue[i] - this.minValue[i]) * this.size[i] + this.el.lowLimit[i],10); + + break; + } + } + } else { + slider.value = Number(slider.value).constrain(this.minValue[i], this.maxValue[i]); + initialPosition[i] = parseInt((slider.value - this.minValue[i]) / (this.maxValue[i] - this.minValue[i]) * this.size[i] + this.el.lowLimit[i],10); + } + + /* Calculate slider value versus closest snap-to location, + and calculate an offset value to apply when positioning it. */ + if (this.sliderSnap[i] > 1) { + var positionToSnapDiff = [0,0]; + positionToSnapDiff[i] = (initialPosition[i] - this.el.lowLimit[i]) % this.sliderSnap[i]; + if (positionToSnapDiff[i]) { + if(positionToSnapDiff[i] < 1/2 * this.sliderSnap[i]) { + slider.repositionDelta[i] = -positionToSnapDiff[i]; + } else { + slider.repositionDelta[i] = this.sliderSnap[i] - positionToSnapDiff[i]; + } + } + } + } + + if (slider instanceof Ext.ux.ThumbSlider) { + slider.setPosition([initialPosition[0] + slider.repositionDelta[0] - (0.5 * this.sliderSize[0]), + initialPosition[1] + slider.repositionDelta[1] - (0.5 * this.sliderSize[1])]); + } + if (slider instanceof Ext.ux.RangeSlider) { + + slider.setPosition([initialPosition[0] + slider.repositionDelta[0], + initialPosition[1] + slider.repositionDelta[1]]); + } + }, + + initSlider: function(slider) { + slider.init(this); + this.initSliderPosition(slider); + } }); Ext.ux.Slider = function(config) { - Ext.apply(this, config); - - this.addEvents( { - "dragstart" : true, - "dragend" : true, - "drag" : true, - "mouseover":true, - "mouseout":true - }); -} + Ext.apply(this, config); + + this.addEvents( { + "dragstart" : true, + "dragend" : true, + "drag" : true, + "mouseover":true, + "mouseout":true + }); +}; Ext.extend(Ext.ux.Slider, Ext.BoxComponent, { - value: 0, - ddEl: null, - name: null, - cls: null, - allowMove:true, - - init: function() { - //Do nothing - }, - - getTL: function() { - switch(this.type) { - case 'horizontal': - return [this.el.getX()]; - - case 'vertical': - return [this.el.getY()]; - - case 'area': - return this.el.getXY(); - } + value: 0, + ddEl: null, + name: null, + cls: null, + allowMove:true, + + init: function() { + //Do nothing + }, + + getTL: function() { + switch(this.type) { + case 'horizontal': + return [this.el.getX()]; + + case 'vertical': + return [this.el.getY()]; + + case 'area': + return this.el.getXY(); + } return null; - }, - - getBR: function() { - switch(this.type) { - case 'horizontal': - return [this.el.getRight()]; - - case 'vertical': - return [this.el.getBottom()]; - - case 'area': - return [this.el.getRight(), this.el.getBottom()]; - } + }, + + getBR: function() { + switch(this.type) { + case 'horizontal': + return [this.el.getRight()]; + + case 'vertical': + return [this.el.getBottom()]; + + case 'area': + return [this.el.getRight(), this.el.getBottom()]; + } return null; - }, - - setPosition: function(position) { - var i,l = position.length; - for (i=0; i<l; i++) { - position[i] = parseInt(position[i]); - } - - switch(this.type) { - case 'horizontal': - this.el.setX(position[0]); - break; - - case 'vertical': - this.el.setY(position[0]); - break; - - case 'area': - this.el.setX(position[0]); - this.el.setY(position[1]); - break; - } - }, - - setConstraint: function(low, high, snap) { + }, + + setPosition: function(position) { + var i,l = position.length; + for (i=0; i<l; i++) { + position[i] = parseInt(position[i],10); + } + + switch(this.type) { + case 'horizontal': + this.el.setX(position[0]); + break; + + case 'vertical': + this.el.setY(position[0]); + break; + + case 'area': + this.el.setX(position[0]); + this.el.setY(position[1]); + break; + } + }, + + setConstraint: function(low, high, snap) { if(this.allowMove) { - var i,l = low.length; - for (i=0; i<l; i++) { - low[i] = parseInt(low[i] = low[i] < 0 ? 0 : low[i]); - high[i] = parseInt(high[i] = high[i] < 0 ? 0 : high[i]); - } - - - switch(this.type) { - case 'horizontal': - this.ddEl.setXConstraint(low[0], high[0], snap[0]); - this.ddEl.setYConstraint(0, 0); - break; - - case 'vertical': - this.ddEl.clearConstraints(); - this.ddEl.setXConstraint(0, 0); - this.ddEl.setYConstraint(low[0], high[0], snap[0]); - break; - - case 'area': - this.ddEl.setXConstraint(low[0], high[0], snap[0]); - this.ddEl.setYConstraint(low[1], high[1], snap[1]); - break; - } - this.ddEl.resetConstraints(true); + var i,l = low.length; + for (i=0; i<l; i++) { + low[i] = parseInt(low[i] = low[i] < 0 ? 0 : low[i],10); + high[i] = parseInt(high[i] = high[i] < 0 ? 0 : high[i],10); + } + + + switch(this.type) { + case 'horizontal': + this.ddEl.setXConstraint(low[0], high[0], snap[0]); + this.ddEl.setYConstraint(0, 0); + break; + + case 'vertical': + this.ddEl.clearConstraints(); + this.ddEl.setXConstraint(0, 0); + this.ddEl.setYConstraint(low[0], high[0], snap[0]); + break; + + case 'area': + this.ddEl.setXConstraint(low[0], high[0], snap[0]); + this.ddEl.setYConstraint(low[1], high[1], snap[1]); + break; + } + this.ddEl.resetConstraints(true); } - } - + } + }); Ext.ux.ThumbSlider = function(config) { - Ext.ux.ThumbSlider.superclass.constructor.call(this, config); + Ext.ux.ThumbSlider.superclass.constructor.call(this, config); }; Ext.ux.RangeSlider = function(config) { - Ext.ux.RangeSlider.superclass.constructor.call(this, config); + Ext.ux.RangeSlider.superclass.constructor.call(this, config); }; Ext.extend(Ext.ux.ThumbSlider, Ext.ux.Slider, { - //init must be passed an instance of a SliderZon e - init: function(parentSlideZone) { - this.type = parentSlideZone.type; - - this.pointer = 'move'; - - this.el = Ext.DomHelper.append(parentSlideZone.el, { - tag: 'div', - id: Ext.id(), - style: 'position:absolute;'+ - 'overflow: hidden;' - }, true); - this.el.addClass('x-thumb-slider-' + this.type); - this.el.addClass(parentSlideZone.cls); + //init must be passed an instance of a SliderZon e + init: function(parentSlideZone) { + this.type = parentSlideZone.type; + + this.pointer = 'move'; + + this.el = Ext.DomHelper.append(parentSlideZone.el, { + tag: 'div', + id: Ext.id(), + style: 'position:absolute;'+ + 'overflow: hidden;' + }, true); + this.el.addClass('x-thumb-slider-' + this.type); + this.el.addClass(parentSlideZone.cls); if(this.allowMove) { - this.ddEl = new Ext.dd.DD(this.el); - - var sliderInstance = this; - var slideZoneInstance = parentSlideZone; - - this.el.on('mouseover', function() { - sliderInstance.fireEvent('mouseover', sliderInstance); - sliderInstance.el.setStyle('cursor', sliderInstance.pointer); - }); - this.el.on('mouseout', function() { - sliderInstance.fireEvent('mouseout', sliderInstance); - sliderInstance.el.setStyle('cursor', 'default'); - }); - this.ddEl.onMouseDown = function(x, y) { - sliderInstance.fireEvent('dragstart', sliderInstance); - }; - this.ddEl.onMouseUp = function(x, y) { - slideZoneInstance.updateConstraints(); - slideZoneInstance.updateValues(); - sliderInstance.fireEvent('dragend', sliderInstance) - }; - this.ddEl.onDrag = function(e) { - slideZoneInstance.updateValues(); - sliderInstance.fireEvent('drag', sliderInstance); - }; + this.ddEl = new Ext.dd.DD(this.el); + + var sliderInstance = this; + var slideZoneInstance = parentSlideZone; + + this.el.on('mouseover', function() { + sliderInstance.fireEvent('mouseover', sliderInstance); + sliderInstance.el.setStyle('cursor', sliderInstance.pointer); + }); + this.el.on('mouseout', function() { + sliderInstance.fireEvent('mouseout', sliderInstance); + sliderInstance.el.setStyle('cursor', 'default'); + }); + this.ddEl.onMouseDown = function(x, y) { + sliderInstance.fireEvent('dragstart', sliderInstance); + }; + this.ddEl.onMouseUp = function(x, y) { + slideZoneInstance.updateConstraints(); + slideZoneInstance.updateValues(); + sliderInstance.fireEvent('dragend', sliderInstance); + }; + this.ddEl.onDrag = function(e) { + slideZoneInstance.updateValues(); + sliderInstance.fireEvent('drag', sliderInstance); + }; } - Ext.ux.ThumbSlider.superclass.init.call(parentSlideZone); - } + Ext.ux.ThumbSlider.superclass.init.call(parentSlideZone); + } }); Ext.extend(Ext.ux.RangeSlider, Ext.ux.Slider, { - init: function(parentSlideZone) { - this.type = parentSlideZone.type; - - this.pointer = this.type == 'horizontal' ? 'w-resize' : this.type == 'vertical' ? 'n-resize' : 'move'; - - var el = Ext.DomHelper.append(parentSlideZone.el, { - tag: 'div', - id: Ext.id(), - style: 'position:absolute;'+ - 'overflow: hidden;' - }, true); - - //this.el.addClass(parentSlideZone.cls); - switch(this.type) { - case 'horizontal': - var w = Math.abs(this.value[0] - this.value[1]) / (parentSlideZone.maxValue - parentSlideZone.minValue) * parentSlideZone.size; - var h = parentSlideZone.sliderHeight; - var handles = 'e,w'; - this.pointer = 'w-resize'; - break; - - case 'vertical': - var w = parentSlideZone.sliderWidth; - var h = Math.abs(this.value[0] - this.value[1]) / (parentSlideZone.maxValue - parentSlideZone.minValue) * parentSlideZone.size; - var handles = 'n,s'; - this.pointer = 'n-resize'; - break; - - case 'area': - var w = Math.abs(this.value[0][0] - this.value[0][1]) / (parentSlideZone.maxValue[0] - parentSlideZone.minValue[0]) * parentSlideZone.size[0]; - var h = Math.abs(this.value[1][0] - this.value[1][1]) / (parentSlideZone.maxValue[1] - parentSlideZone.minValue[1]) * parentSlideZone.size[1]; - var handles = 'all'; - this.pointer = 'move'; - break; - } - - this.resizable = new Ext.Resizable(el, { - wrap:false, - pinned:this.allowMove, - width: w, - height: h, - minWidth: 20, - widthIncrement: parentSlideZone.sliderSnap[0], - heightIncrement: parentSlideZone.sliderSnap[1], - minHeight: 20, - dynamic: true, - handles: handles, - draggable: this.allowMove, - transparent: false, - constrainTo: parentSlideZone.el, - leftTravel: null, - rightTravel: null, + init: function(parentSlideZone) { + this.type = parentSlideZone.type; + + this.pointer = this.type == 'horizontal' ? 'w-resize' : this.type == 'vertical' ? 'n-resize' : 'move'; + + var el = Ext.DomHelper.append(parentSlideZone.el, { + tag: 'div', + id: Ext.id(), + style: 'position:absolute;'+ + 'overflow: hidden;' + }, true); + + //this.el.addClass(parentSlideZone.cls); + switch(this.type) { + case 'horizontal': + var w = Math.abs(this.value[0] - this.value[1]) / (parentSlideZone.maxValue - parentSlideZone.minValue) * parentSlideZone.size; + var h = parentSlideZone.sliderHeight; + var handles = 'e,w'; + this.pointer = 'w-resize'; + break; + + case 'vertical': + var w = parentSlideZone.sliderWidth; + var h = Math.abs(this.value[0] - this.value[1]) / (parentSlideZone.maxValue - parentSlideZone.minValue) * parentSlideZone.size; + var handles = 'n,s'; + this.pointer = 'n-resize'; + break; + + case 'area': + var w = Math.abs(this.value[0][0] - this.value[0][1]) / (parentSlideZone.maxValue[0] - parentSlideZone.minValue[0]) * parentSlideZone.size[0]; + var h = Math.abs(this.value[1][0] - this.value[1][1]) / (parentSlideZone.maxValue[1] - parentSlideZone.minValue[1]) * parentSlideZone.size[1]; + var handles = 'all'; + this.pointer = 'move'; + break; + } + + this.resizable = new Ext.Resizable(el, { + wrap:false, + pinned:this.allowMove, + width: w, + height: h, + minWidth: 20, + widthIncrement: parentSlideZone.sliderSnap[0], + heightIncrement: parentSlideZone.sliderSnap[1], + minHeight: 20, + dynamic: true, + handles: handles, + draggable: this.allowMove, + transparent: false, + constrainTo: parentSlideZone.el, + leftTravel: null, + rightTravel: null, enabled: this.allowMove - }); - var sliderInstance = this; - var slideZoneInstance = parentSlideZone; - - this.el = this.resizable.el; - this.el.addClass('x-range-slider-' + this.type); - this.el.addClass(this.cls); + }); + var sliderInstance = this; + var slideZoneInstance = parentSlideZone; + + this.el = this.resizable.el; + this.el.addClass('x-range-slider-' + this.type); + this.el.addClass(this.cls); if(this.allowMove) { - this.ddEl = this.resizable.dd; - - - this.resizable.on('beforeresize', function() { - sliderInstance.fireEvent('dragstart', sliderInstance); - }) - - /* Parts of this.resizable.onMouseMove handler taken from: - * http://extjs.com/forum/showthread.php?p=23122&highlight=resizable+constrainto#post23122 - */ - this.resizable.onMouseMove = function( e ) { - var box = this.constrainTo.getRegion(), tgt = e.getXY(); - //redefine the constraining box if slider crossing resrictions - if(!parentSlideZone.allowSliderCrossing) { - if( parentSlideZone.type == 'vertical') { - box = {left: box.left, right: box.right, - top: this.startBox.y - this.leftTravel[0], - bottom: this.startBox.y + this.startBox.height + this.rightTravel[0] } - } - if( parentSlideZone.type == 'horizontal') { - box = {left: this.startBox.x - this.leftTravel[0], - right: this.startBox.x + this.startBox.width + this.rightTravel[0], - top: box.top, bottom: box.bottom } - } - } - - e.xy = [ - tgt[0] - box.left < 0 ? box.left - this.startBox.x + this.startPoint[0] : tgt[0] - box.right > 0 ? box.right - this.startBox.right + this.startPoint[0] : tgt[0], - tgt[1] - box.top < 0 ? box.top - this.startBox.y + this.startPoint[1] : tgt[1] - box.bottom > 0 ? box.bottom - this.startBox.bottom + this.startPoint[1] : tgt[1] - ]; - - Ext.Resizable.prototype.onMouseMove.call(this, e); - slideZoneInstance.updateValues(); - sliderInstance.fireEvent('drag', sliderInstance); - }; - - this.resizable.on('resize', function(width, height) { - slideZoneInstance.updateConstraints(); - slideZoneInstance.updateValues(); - sliderInstance.fireEvent('dragend', sliderInstance); - }) - - this.el.on('mouseover', function() { - sliderInstance.fireEvent('mouseover', sliderInstance); - sliderInstance.el.setStyle('cursor', sliderInstance.pointer); - }); - this.el.on('mouseout', function() { - sliderInstance.fireEvent('mouseout', sliderInstance); - sliderInstance.el.setStyle('cursor', 'default'); - }); - this.ddEl.onMouseDown = function(x, y) { - sliderInstance.fireEvent('dragstart', sliderInstance); - }; - this.ddEl.onMouseUp = function(x, y) { - slideZoneInstance.updateConstraints(); - slideZoneInstance.updateValues(); - sliderInstance.fireEvent('dragend', sliderInstance) - }; - this.ddEl.onDrag = function(e) { - slideZoneInstance.updateValues(); - sliderInstance.fireEvent('drag', sliderInstance); - }; + this.ddEl = this.resizable.dd; + + + this.resizable.on('beforeresize', function() { + sliderInstance.fireEvent('dragstart', sliderInstance); + }); + + /* Parts of this.resizable.onMouseMove handler taken from: + * http://extjs.com/forum/showthread.php?p=23122&highlight=resizable+constrainto#post23122 + */ + this.resizable.onMouseMove = function( e ) { + var box = this.constrainTo.getRegion(), tgt = e.getXY(); + //redefine the constraining box if slider crossing resrictions + if(!parentSlideZone.allowSliderCrossing) { + if( parentSlideZone.type == 'vertical') { + box = {left: box.left, right: box.right, + top: this.startBox.y - this.leftTravel[0], + bottom: this.startBox.y + this.startBox.height + this.rightTravel[0] }; + } + if( parentSlideZone.type == 'horizontal') { + box = {left: this.startBox.x - this.leftTravel[0], + right: this.startBox.x + this.startBox.width + this.rightTravel[0], + top: box.top, bottom: box.bottom }; + } + } + + e.xy = [ + tgt[0] - box.left < 0 ? box.left - this.startBox.x + this.startPoint[0] : tgt[0] - box.right > 0 ? box.right - this.startBox.right + this.startPoint[0] : tgt[0], + tgt[1] - box.top < 0 ? box.top - this.startBox.y + this.startPoint[1] : tgt[1] - box.bottom > 0 ? box.bottom - this.startBox.bottom + this.startPoint[1] : tgt[1] + ]; + + Ext.Resizable.prototype.onMouseMove.call(this, e); + slideZoneInstance.updateValues(); + sliderInstance.fireEvent('drag', sliderInstance); + }; + + this.resizable.on('resize', function(width, height) { + slideZoneInstance.updateConstraints(); + slideZoneInstance.updateValues(); + sliderInstance.fireEvent('dragend', sliderInstance); + }); + + this.el.on('mouseover', function() { + sliderInstance.fireEvent('mouseover', sliderInstance); + sliderInstance.el.setStyle('cursor', sliderInstance.pointer); + }); + this.el.on('mouseout', function() { + sliderInstance.fireEvent('mouseout', sliderInstance); + sliderInstance.el.setStyle('cursor', 'default'); + }); + this.ddEl.onMouseDown = function(x, y) { + sliderInstance.fireEvent('dragstart', sliderInstance); + }; + this.ddEl.onMouseUp = function(x, y) { + slideZoneInstance.updateConstraints(); + slideZoneInstance.updateValues(); + sliderInstance.fireEvent('dragend', sliderInstance); + }; + this.ddEl.onDrag = function(e) { + slideZoneInstance.updateValues(); + sliderInstance.fireEvent('drag', sliderInstance); + }; } - Ext.ux.ThumbSlider.superclass.init.call(parentSlideZone); + Ext.ux.ThumbSlider.superclass.init.call(parentSlideZone); - } + } }); diff --git a/skins/jason/ux/TabCloseMenu.js b/skins/jason/ux/TabCloseMenu.js index 803e2fe..703538a 100644 --- a/skins/jason/ux/TabCloseMenu.js +++ b/skins/jason/ux/TabCloseMenu.js @@ -14,7 +14,7 @@ Ext.ux.TabCloseMenu = function(){ this.init = function(tp){
tabs = tp;
tabs.on('contextmenu', onContextMenu);
- }
+ };
function onContextMenu(ts, item, e){
if(!menu){ // create context menu on first right click
@@ -47,6 +47,6 @@ Ext.ux.TabCloseMenu = function(){ }
});
items.get(tabs.id + '-close-others').setDisabled(disableOthers);
- menu.showAt(e.getPoint()); + menu.showAt(e.getPoint());
}
-}; +};
diff --git a/skins/jason/vdr.js b/skins/jason/vdr.js index f8c95db..dd4c7f9 100644 --- a/skins/jason/vdr.js +++ b/skins/jason/vdr.js @@ -1,6 +1,6 @@ /* * jason - Javascript based skin for xxv - * Copyright(c) 2008-2009, anbr + * Copyright(c) 2008-2010, anbr * * http://xxv.berlios.de/ * @@ -194,12 +194,12 @@ Ext.extend(Ext.xxv.vdrGrid, Ext.grid.EditorGridPanel, { } } ,formatTitle: function(value, p, record) { - var style = ""; - if((record.data.active & 1) == 0) { - style = " deactive"; - } else if(record.data.primary) { - style = " running"; - } + var style = ""; + if((record.data.active & 1) == 0) { + style = " deactive"; + } else if(record.data.primary) { + style = " running"; + } return String.format( '<div class="topic{1}">{0}</div>', @@ -219,7 +219,7 @@ Ext.extend(Ext.xxv.vdrGrid, Ext.grid.EditorGridPanel, { new Ext.xxv.MessageBox().msgSuccess(this.szDeleteSuccess, o.data); var gsm = this.getSelectionModel(); - var sel = options.params.data.split(","); + var sel = options.params.data.split(","); sel.reverse(); for(var i = 0, len = sel.length; i < len; i++){ if(gsm.isIdSelected(sel[i])) { @@ -252,16 +252,16 @@ Ext.extend(Ext.xxv.vdrGrid, Ext.grid.EditorGridPanel, { this.loadMask.show(); var gsm = this.getSelectionModel(); - var sel = gsm.getSelections() + var sel = gsm.getSelections(); if(sel.length <= 0) { gsm.selectRecords([record]); sel.push(record); } var todel = ""; for(var i = 0, len = sel.length; i < len; i++){ - if(i != 0) - todel += ','; - todel += sel[i].data.id; + if(i) + todel += ','; + todel += sel[i].data.id; } Ext.Ajax.request({ scope: this @@ -278,7 +278,7 @@ Ext.extend(Ext.xxv.vdrGrid, Ext.grid.EditorGridPanel, { this.stopEditing(); var item; - if(record != null) { + if(record) { var gsmTimer = this.getSelectionModel(); gsmTimer.selectRecords([record]); |
