// create namespace
Ext.namespace('com.evoca.players', 'com.evoca.players.util');
var userID;
/**
* PlayerViewPanel
*/
com.evoca.players.renderPlayerGrid = function(divID, userIDParam) {
// Initialize quicktips
Ext.QuickTips.init();
Ext.apply(Ext.QuickTips.getQuickTip(), {
maxWidth: 200,
minWidth: 100,
showDelay: 50,
trackMouse: true
});
userID = userIDParam;
var playerUtils = new com.evoca.players.PlayerUtils();
this.playerStore = new Ext.data.Store({
url: '../Request?action=getPlayers&userID=1581',
autoLoad: true,
reader: new com.evoca.players.PlayerListXMLReader({
record : 'player',
totalRecords: 'totalPlayers'
}, playerUtils.createPlayerRecord())
});
var deleteColumn = new com.evoca.players.DeleteColumn({
id: 'delete',
width: 40,
header: "Delete"
});
var configureColumn = new com.evoca.players.ConfigureColumn({
id: 'config',
width: 27,
scope: this,
header: 'Edit'
});
var showHTMLColumn = new com.evoca.players.ShowHTMLColumn({
id: 'showhtml',
header: 'Get HTML Code',
width: 85,
scope: this
});
var cm = new Ext.grid.ColumnModel([
configureColumn,
{
id:'name',
header: "Player Name",
dataIndex: 'name',
width: 200
},{
id: 'type',
header: 'Type',
dataIndex: 'type',
renderer: function(v,params,record){
var retVal = 'Unknown Type';
switch(v) {
case 'DEFAULT':
retVal = 'Default Single Player';
break;
case 'CUSTOM':
retVal = 'Custom Single Player';
break;
case 'HYBRID_DEFAULT':
retVal = 'Default Playlist Player';
break;
case 'HYBRID_CUSTOMIZED':
retVal = 'Custom Playlist Player';
break;
default:
retVal = 'Unknown Type';
}
return retVal;
}
},
showHTMLColumn,
deleteColumn,
{
hidden : true,
dataIndex: 'playerParams'
},{
dataIndex: 'swfFilename',
hidden : true
},{
dataIndex: 'swfHeight',
hidden : true
},{
dataIndex: 'swfWidth',
hidden : true
}
]);
var playerGrid = new Ext.grid.GridPanel({
region:'center',
ds: this.playerStore,
cm: cm,
stripeRows: true,
autoExpandColumn: 'type',
autoHeight: true,
width: 800,
title: 'Players',
// config options for stateful behavior
stateful: false,
stateId: 'playergrid',
scope: this,
tbar: [{
text: 'Create Player',
handler: function() {
var createWin = new com.evoca.players.CreateWindow(null, this);
createWin.show();
},
iconCls: 'add-icon',
scope: this
}]
});
function cellClick(grid, rowIndex, columnIndex, e, parent) {
var columnObj = grid.getColumnModel().config[columnIndex];
if(columnObj.handleClick)
columnObj.handleClick(grid, rowIndex, columnIndex, e, this);
}
playerGrid.on('cellclick', cellClick);
playerGrid.render(divID);
};
//Ext.extend(com.evoca.players.PlayerViewPanel, Ext.grid.GridPanel, {});
/**
* ConfigureColumn
*/
com.evoca.players.ConfigureColumn = function(config){
Ext.apply(this, config);
if(!this.id){
this.id = Ext.id();
}
};
com.evoca.players.ConfigureColumn.prototype ={
renderer : function(v, p, record){
p.css += ' configure-column';
return ' ';
},
handleClick : function(grid, rowIndex, columnIndex, e, parent) {
var record = grid.getStore().getAt(rowIndex); // Get the Record for the row
var createWin = new com.evoca.players.CreateWindow(record, parent);
createWin.show();
}
};
/**
* ShowHTMLColumn
*/
com.evoca.players.ShowHTMLColumn = function(config){
Ext.apply(this, config);
if(!this.id){
this.id = Ext.id();
}
};
com.evoca.players.ShowHTMLColumn.prototype ={
renderer : function(v, p, record){
p.css += ' showhtml-column';
return ' ';
},
handleClick : function(grid, rowIndex, columnIndex, e) {
var record = grid.getStore().getAt(rowIndex); // Get the Record for the row
var showHTMLWin = new com.evoca.players.ShowHTMLWindow(record, parent);
showHTMLWin.show();
}
};
/**
* DeleteColumn
*/
com.evoca.players.DeleteColumn = function(config){
Ext.apply(this, config);
if(!this.id){
this.id = Ext.id();
}
};
com.evoca.players.DeleteColumn.prototype ={
renderer : function(v, p, record){
var playerUtils = new com.evoca.players.PlayerUtils();
if(record != null && playerUtils.isDefaultPlayer(record))
p.css += ' delete-column-disabled';
else
p.css += ' delete-column';
return ' ';
},
handleClick : function(grid, rowIndex, columnIndex, e) {
var record = grid.getStore().getAt(rowIndex); // Get the Record for the row
var data = record.get('name');
var type = record.get('type');
var playerUtils = new com.evoca.players.PlayerUtils();
if(!playerUtils.isDefaultPlayer(record)) {
Ext.Msg.show({
title: 'Delete',
buttonAlign: 'center',
buttons: Ext.Msg.YESNO,
msg: 'Are you sure you want to delete the player: ' + data + '?',
fn: function(btn, text) {
if(btn == 'yes') {
Ext.Ajax.request({
url: 'data/deletePlayer/' + data,
success: function(response) {
Ext.Msg.show({
title: 'Success',
buttonAlign: 'center',
buttons: Ext.Msg.OK,
msg: response.responseText,//'The player has been deleted.',
fn: function() {
//window.location.reload();
},
scope: this
});
grid.store.remove(record);
},
failure: function(){
Ext.Msg.show({
title: 'Failure',
buttonAlign: 'center',
buttons: Ext.Msg.OK,
msg: 'The player could not be deleted.',
fn: function() {
this.hide();
window.location.reload();
},
scope: this
});
},
scope: this
});
}
},
scope: this
});
}
}
};
/**
* ShowHTMLWindow
*/
com.evoca.players.ShowHTMLWindow = function(record, parent) {
this.record = record;
this.parent = parent;
this.disableParent();
this.feedRecord =
Ext.data.Record.create([
{name: 'name'}
]);
var feedXMLReader = new Ext.data.XmlReader({
totalRecords: "totalRecordCount",
record: "feed"
}, this.feedRecord
);
var feedStore = new Ext.data.Store({
autoLoad: true,
url: 'data/feeds/',
reader: feedXMLReader
});
this.feedsPicker = new Ext.form.ComboBox({
name: 'feedsPicker',
id: 'feedsPicker',
fieldLabel: 'Choose a Feed',
store: feedStore,
displayField:'name',
valueField: 'name',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
selectOnFocus:true,
resizable:true,
forceSelection: true,
editable: false,
emptyText: 'Please select a feed'
});
this.feedsForm = new Ext.form.FormPanel({
onSubmit: Ext.emptyFn,
items: this.feedsPicker,
bodyStyle:'background:transparent',
border: false,
submit: function() {
this.getForm().getEl().dom.submit();
}
});
this.infoPanel = new Ext.Panel({
html: 'Generating the HTML snippet for a player requires that you pick a playlist feed for your player.
If no feeds appear in the dropdown box then you can create a playlist feed by navigating the menu to the Feeds Configuration page: Configuration-->Feeds
',
bodyStyle:'background:transparent',
border: false
});
this.feedsPicker.on ( 'select', function() {
var feedName = this.feedsForm.getForm().findField('feedsPicker').getValue();
var playerName = this.record.get('name');
var enableShareButton = this.record.get('enableShareButton');
var shareButtonTheme = this.record.get('shareButtonTheme');
var localResourceStr = 'data/players/audio/flash/' + playerName + '/feeds/' + feedName + '?resourceExpires=2147483647';
var beginHTMLStr = '
';
Ext.Ajax.request({
url: localResourceStr,
disableCaching: false,
success: function(response) {
var text = response.responseText.replace(/\r|\n|\r\n/g, "");
var displayText = response.responseText;
if(!Ext.isIE) {
displayText = displayText.replace(/wmode/g, 'wmodefake');
}
if(enableShareButton == 'true') {
displayText = 'Preview shows only first page of share feature. Not for use in posting player.
' + displayText;
var shareButton3 = "";
shareButton3 += '';
displayText += shareButton3;
}
displayText = '' + displayText + '
';
Ext.Msg.show({
title: 'HTML Player and Copy-n-Paste Code',
buttonAlign: 'center',
buttons: Ext.Msg.OK,
width: 700,
msg: displayText + '- 1. Test the player to make sure that it is the player that you want.
- 2. Click on the Copy-n-Paste HTML Code to select it.
- 3. Copy this code to the webpage where you want this player to be displayed.
Copy-n-Paste HTML Code
' + beginHTMLStr + text + endHTMLStr + '
*Note: If you are seeing a spining image but see no player then you may have a problem with the feed. Please check the following:
1.Verify that the "Enable playlist" checkbox is checked for this feed.
2.Verify that there are recordings in the feed. If there are no recordings in the feed then the player will not display properly.
',
fn: function() {
//window.location.reload();
},
scope: this
});
},
failure: function(){
Ext.Msg.show({
title: 'Failure',
buttonAlign: 'center',
buttons: Ext.Msg.OK,
msg: 'The player HTML code could not be fetched.',
fn: function() {
this.hide();
window.location.reload();
},
scope: this
});
},
scope: this
});
},this);
com.evoca.players.ShowHTMLWindow.superclass.constructor.call(this, {
title: 'Show Player HTML Code',
id: 'ev-showhtml-window',
autoHeight: true,
width: 310,
resizable: false,
plain:true,
modal: true,
autoScroll: true,
stateful: false,
closeAction: 'close',
closable: true,
//labelWidth: 110, // label settings here cascade unless overridden
scope: this,
items: [this.infoPanel, this.feedsForm]
});
}
Ext.extend(com.evoca.players.ShowHTMLWindow, Ext.Window, {
close : function() {
this.destroy();
this.enableParent();
},
disableParent : function() {
if(this.parent) {
//this.parent.disable();
}
},
enableParent : function() {
if(this.parent) {
//this.parent.enable();
}
}
});
com.evoca.players.hideDisplayWidget = function(embedCodeID, embedToID, themeNumber) {
if($(embedToID)) {
Element.hide(embedToID);
}
if($('previewShareLink')) {
$('previewShareLink').href = "javascript:com.evoca.players.displayEmbedWidget('" + embedCodeID + "', '" + embedToID + "', '" + themeNumber + "');";
}
}
com.evoca.players.displayEmbedWidget = function(embedCodeID, embedToID, themeNumber) {
if($(embedToID) && $(embedToID).innerHTML != '') {
Element.show(embedToID);
}
else {
var lightColor = '';
var oceanBlue = ''
var redAndBlack = '';
var pinkAndRed = '';
var earchTones = '';
var skyBlue = '';
var color = lightColor;
switch(themeNumber) {
case '1':
color = oceanBlue;
break;
case '2':
color = redAndBlack;
break;
case '3':
color = pinkAndRed;
break;
case '4':
color = earchTones;
break;
case '5':
color = skyBlue;
break;
case '6':
color = lightColor;
break;
default:
color = lightColor;
}
var pconf={
defaultContent: embedCodeID,
widgetTitle: 'Evoca Recording',
UIConfig: '' + color + ''
};
var partner = '597482';
Wildfire.initPost(partner, embedToID, 400, 300, pconf);
}
if($('previewShareLink')) {
$('previewShareLink').href = "javascript:com.evoca.players.hideDisplayWidget('" + embedCodeID + "', '" + embedToID + "', '" + themeNumber + "');";
}
}
/**
* CreateWindow
*/
com.evoca.players.CreateWindow = function(record, parent) {
//parent.disable(true);
this.record = record;
this.parent = parent;
this.disableParent();
var shareButtonThemeData = [
['light', '6'],
['ocean', '1'],
['redAndBlack', '2'],
['pinkAndRed', '3'],
['earthTones', '4'],
['skyBlue', '5']
];
var nameValueReader = new Ext.data.ArrayReader({}, [
{name: 'name'},
{name: 'value'}
]);
var shareButtonThemeStore = new Ext.data.Store({
reader: nameValueReader,
data: shareButtonThemeData
});
this.orientationDefaults = {defaultImage:'',swfFilename:'playlistDefault',type:'HYBRID_CUSTOMIZED',file:'static/config/players/xml/playlist.xml',swfheight:0,swfwidth:0,frontcolor:'0x000000',backcolor:'0xffffff',lightcolor:'0x000000',screencolor:'0x000000',width:'', height:'', location:'static/config/players/swf/ev-pl-4x.swf',logo:'',stretching:'uniform',displayclick:'play',autostart:'false',repeat:'false',shuffle:true,volume:80, skin:'evoca-rounded-skin.swf'};
this.orientations = {
defaults:{},
normal:{swfFilename:'playlistDefault', type:'HYBRID_CUSTOMIZED',file:'static/config/players/xml/playlist.xml',swfheight:'140',swfwidth:'320', playlist:'right', playlistsize:'320'},
below:{swfFilename:'playlistDefault', type:'HYBRID_CUSTOMIZED',file:'static/config/players/xml/playlist.xml',swfheight:'140',swfwidth:'320', playlist:'bottom', playlistsize:'120'},
line:{swfFilename:'playlistDefault', type:'HYBRID_CUSTOMIZED',file:'static/config/players/audio/MTVHotline3.mp3',swfheight:'20',swfwidth:'320', playlist:'none'},
rightlist:{swfFilename:'playlistDefault', type:'HYBRID_CUSTOMIZED',file:'static/config/players/xml/playlist.xml',swfheight:'140',swfwidth:'320', width:'120', height: '120', playlist:'right', playlistsize:'200'},
abovebelow:{swfFilename:'playlistDefault', type:'HYBRID_CUSTOMIZED',file:'static/config/players/xml/playlist.xml',swfheight:'240',swfwidth:'320', width:'320', height: '120', playlist:'bottom', playlistsize: '100'}
}
this.trueFalseStore = new Ext.data.SimpleStore({
fields: ['value', 'text'],
data : [['false', 'false'],
['true', 'true']]
});
this.skinStore = new Ext.data.SimpleStore({
fields: ['value', 'text'],
data : [['evoca-rounded-skin.swf', 'Rounded skin'],
['jw-default-skin.swf', 'Square skin']]
});
this.skin = new Ext.form.ComboBox({
id: 'skin',
name: 'skin',
fieldLabel: 'Skin',
autoWidth: true,
store: this.skinStore,
displayField:'text',
valueField: 'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Choose an skin below:',
selectOnFocus:true,
resizable:true,
forceSelection: true,
editable: false,
value: this.skinStore.getAt(0).get('value')
});
// FORM FIELDS
this.store = new Ext.data.SimpleStore({
fields: ['value', 'text'],
data : [['normal', 'No display, playlist above'],
['below', 'No display, playlist below'],
['line', 'A line with single recording'],
['rightlist', 'Display to the left, playlist to the right'],
['abovebelow', 'Display above, and playlist on the bottom']]
});
this.picker = new Ext.form.ComboBox({
id: 'picker',
name: 'picker',
height: 400,
width: 343,
store: this.store,
hideLabel: true,
displayField:'text',
valueField: 'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Choose an orientation below:',
selectOnFocus:true,
resizable:true,
forceSelection: true,
editable: false
});
this.picker.on ( 'select', function() {
var fieldValue = this.form.getForm().findField('picker').getValue();
var orientationName;
for(var i = this.store.getCount() - 1; i >= 0; i--) {
if(this.store.getAt(i).get('value') == fieldValue) {
orientationName = this.store.getAt(i).get('value');
break;
}
}
this.loadOrientation(orientationName);
},this);
this.swfheight = new Ext.form.TextField({
id: 'swfheight',
name: 'swfheight',
fieldLabel: 'Height of the player',
inputType: 'text',
validateOnBlur: false,
allowBlank: false,
style: {height: '22px'},
width: 164,
value: 0,
vtype: 'wholenum',
maxLength: 100,
maxLengthText: 'The height can only be 100 characters long'
});
this.swfwidth = new Ext.form.TextField({
id: 'swfwidth',
name: 'swfwidth',
fieldLabel: 'Width of the player',
inputType: 'text',
validateOnBlur: false,
allowBlank: false,
style: {height: '22px'},
width: 164,
value: 0,
vtype: 'wholenum',
maxLength: 100,
maxLengthText: 'The width can only be 100 characters long'
});
this.backcolor = new Ext.form.TextField({
id: 'backcolor',
name: 'backcolor',
fieldLabel: 'Background color: (pick)',
labelSeparator: '',
inputType: 'text',
validateOnBlur: false,
allowBlank: false,
style: {height: '22px'},
width: 164,
value: '0xffffff',
maxLength: 8,
maxLengthText: 'This field may only contain 8 characters',
vtype: 'hexnum'
});
this.frontcolor = new Ext.form.TextField({
id: 'frontcolor',
name: 'frontcolor',
fieldLabel: 'Foreground color: (pick)',
labelSeparator: '',
inputType: 'text',
validateOnBlur: false,
allowBlank: false,
style: {height: '22px'},
width: 164,
value: '0x000000',
maxLength: 8,
maxLengthText: 'This field may only contain 8 characters',
vtype: 'hexnum'
});
this.lightcolor = new Ext.form.TextField({
id: 'lightcolor',
name: 'lightcolor',
fieldLabel: 'Highlight color: (pick)',
labelSeparator: '',
inputType: 'text',
validateOnBlur: false,
allowBlank: false,
style: {height: '22px'},
width: 164,
value: '0x000000',
maxLength: 8,
maxLengthText: 'This field may only contain 8 characters',
vtype: 'hexnum'
});
this.screencolor = new Ext.form.TextField({
id: 'screencolor',
name: 'screencolor',
fieldLabel: 'Screen color: (pick)',
labelSeparator: '',
inputType: 'text',
validateOnBlur: false,
allowBlank: false,
style: {height: '22px'},
width: 164,
value: '0x000000',
maxLength: 8,
maxLengthText: 'This field may only contain 8 characters',
vtype: 'hexnum'
});
this.displaywidth = new Ext.form.TextField({
id: 'width',
name: 'width',
fieldLabel: 'Display width',
inputType: 'text',
validateOnBlur: false,
allowBlank: true,
style: {height: '22px'},
width: 164,
vtype: 'wholenum',
maxLength: 100,
maxLengthText: 'The display width can only be 100 characters long'
});
this.displayheight = new Ext.form.TextField({
id: 'height',
name: 'height',
fieldLabel: 'Display height',
inputType: 'text',
validateOnBlur: false,
allowBlank: true,
style: {height: '22px'},
width: 164,
vtype: 'wholenum',
maxLength: 100,
maxLengthText: 'The display height can only be 100 characters long'
});
// On displaywidth blur, update the playlistsize
this.displaywidth.on ( 'blur', function() {
var playlistLocation = this.form.getForm().findField('playlist').getValue();
var width = this.form.getForm().findField('width').getValue();
var height = this.form.getForm().findField('height').getValue();
var swfwidth = this.form.getForm().findField('swfwidth').getValue();
var swfheight = this.form.getForm().findField('swfheight').getValue();
this.form.getForm().findField('playlistsize').setValue(
com.evoca.players.util.calculatePlaylistSize(playlistLocation, swfwidth, swfheight, width, height)
);
},this);
// On displaywidth blur, update the playlistsize
this.displayheight.on ( 'blur', function() {
var playlistLocation = this.form.getForm().findField('playlist').getValue();
var width = this.form.getForm().findField('width').getValue();
var height = this.form.getForm().findField('height').getValue();
var swfwidth = this.form.getForm().findField('swfwidth').getValue();
var swfheight = this.form.getForm().findField('swfheight').getValue();
this.form.getForm().findField('playlistsize').setValue(
com.evoca.players.util.calculatePlaylistSize(playlistLocation, swfwidth, swfheight, width, height)
);
},this);
this.logo = new Ext.form.TextField({
id: 'logo',
name: 'logo',
fieldLabel: 'Logo to put over the display',
inputType: 'text',
validateOnBlur: false,
allowBlank: true,
style: {height: '22px'},
width: 164,
vtype: 'url'
});
this.defaultImage = new Ext.form.TextField({
id: 'defaultImage',
name: 'defaultImage',
fieldLabel: 'Default image',
inputType: 'text',
validateOnBlur: false,
allowBlank: true,
style: {height: '22px'},
width: 164,
vtype: 'url'
});
this.stretchingstore = new Ext.data.SimpleStore({
fields: ['value', 'text'],
data : [['uniform', 'to fit the display'],
['fill', 'to fill the display'],
['exactfit', 'disproportionally to fit'],
['none', 'don\'t stretch at all']]
});
this.stretching = new Ext.form.ComboBox({
id: 'stretching',
name: 'stretching',
fieldLabel: 'Stretch movies/images',
autoWidth: true,
store: this.stretchingstore,
displayField:'text',
valueField: 'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Choose an example below:',
selectOnFocus:true,
resizable:true,
forceSelection: true,
editable: false,
value: this.stretchingstore.getAt(0).get('value')
});
this.displayclickStore = new Ext.data.SimpleStore({
fields: ['value', 'text'],
data : [['play', 'play/pause the recording'],
['link', 'follow a recording link'],
['none', 'show nothing'],
['mute', 'mute the player'],
['next', 'advance to the next recording']]
});
this.displayclick = new Ext.form.ComboBox({
id: 'displayclick',
name: 'displayclick',
fieldLabel: 'Display click behavior',
autoWidth: true,
store: this.displayclickStore,
displayField:'text',
valueField: 'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
selectOnFocus:true,
resizable:true,
forceSelection: true,
editable: false,
value: this.displayclickStore.getAt(0).get('value')
});
this.autostartStore = new Ext.data.SimpleStore({
fields: ['value', 'text'],
data : [['false', 'false'],
['true', 'true'],
['muted', 'muted']]
});
this.autostart = new Ext.form.ComboBox({
id: 'autostart',
name: 'autostart',
fieldLabel: 'Automatically start playing',
autoWidth: true,
store: this.autostartStore,
displayField:'text',
valueField: 'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Choose an example below:',
selectOnFocus:true,
resizable:true,
forceSelection: true,
editable: false,
value: this.autostartStore.getAt(0).get('value')
});
this.repeatStore = new Ext.data.SimpleStore({
fields: ['value', 'text'],
data : [['false', 'false'],
['true', 'true'],
['list', 'list']]
});
this.repeat = new Ext.form.ComboBox({
id: 'repeat',
name: 'repeat',
fieldLabel: 'Repeat playing',
autoWidth: true,
store: this.repeatStore,
displayField:'text',
valueField: 'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Choose an example below:',
selectOnFocus:true,
resizable:true,
forceSelection: true,
editable: false,
value: this.repeatStore.getAt(0).get('value')
});
this.shuffle = new Ext.form.ComboBox({
id: 'shuffle',
name: 'shuffle',
fieldLabel: 'Shuffle playback',
autoWidth: true,
store: this.trueFalseStore,
displayField:'text',
valueField: 'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
selectOnFocus:true,
resizable:true,
forceSelection: true,
editable: false,
value: this.trueFalseStore.getAt(1).get('value')
});
this.volume = new Ext.form.TextField({
id: 'volume',
name: 'volume',
fieldLabel: 'Volume at startup',
inputType: 'text',
validateOnBlur: false,
allowBlank: false,
style: {height: '22px'},
width: 164,
value: 80,
vtype: 'wholenum',
maxLength: 100,
maxLengthText: 'The volume can only be 100 characters long'
});
this.playerName = new Ext.form.TextField({
id: 'playerName',
name: 'playerName',
fieldLabel: 'Name ',
inputType: 'text',
validateOnBlur: false,
allowBlank: false,
autoCreate: {tag: "input", type: "text", maxLength: "30"},
style: {height: '22px'},
width: 164,
minLength: 1,
minLengthText: 'The name of the player must be at least 1 character long.',
regex: /^[0-9a-zA-Z_]+$/,
validator: (function(curValue) {
var retVal = true;
var msg = 'Name must be unique. A player already exists called \'' + curValue + '\'.';
var regexStr = '/^(' + curValue + '){1}$/i';
var regex = eval(regexStr);
var tmprec = this.parent.store.find('name', regex);
if(tmprec > -1 && record != null) {
if(record.get('index') != tmprec)
retVal = msg;
else
retVal = true;
}
else if(tmprec > -1) {
retVal = msg;
}
else {
retVal = true;
}
return retVal;
}).createDelegate(this),
scope: this
});
var htmlHeader = new Ext.form.TextArea({
id: 'htmlHeader',
fieldLabel: 'HTML Header',
width: 260
});
var htmlFooter = new Ext.form.TextArea({
id: 'htmlFooter',
fieldLabel: 'HTML Footer',
width: 260
});
this.shareButtonTheme = new Ext.form.ComboBox({
id: 'shareButtonTheme',
name: 'shareButtonTheme',
fieldLabel: 'Theme',
autoWidth: true,
store: shareButtonThemeStore,
displayField:'name',
valueField: 'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Choose a theme:',
selectOnFocus:true,
resizable:true,
forceSelection: true,
editable: false,
value: (this.record == null) ? shareButtonThemeStore.getAt(0).get('value') : this.record.get('shareButtonTheme')
});
this.enableShareButton = new Ext.form.Checkbox({
name: 'enableShareButton',
id: 'enableShareButton',
fieldLabel: 'Show share button',
checked: (this.record == null) ? false : (this.record.get('enableShareButton') + '') == 'true'
});
var formParent = this;
// FIELD LISTENERS
htmlHeader.on('render', function(){
this.trigger = new Ext.form.TriggerField({
id: 'htmlHeaderWrapper',
triggerClass: 'configure-column',
scope: this
});
this.trigger.onTriggerClick = function(){
var headerValue = htmlHeader.getValue();
var htmlEditor = new com.evoca.players.HtmlWizard(headerValue, formParent, 'htmlHeader', 'Edit HTML Header');
htmlEditor.show();
htmlEditor.on('destroy', function(){
this.preview.enable();
this.preview.removeClass('x-item-disabled');
this.preview.syncSize();
});
};
this.trigger.applyToMarkup('htmlHeader');
})
this.enableShareButton.on('check', function() {
if(this.enableShareButton.checked) {
this.showField(this.shareButtonTheme);
}
else {
this.hideField(this.shareButtonTheme);
}
this.syncSize();
},
this);
htmlFooter.on('render', function(){
this.trigger = new Ext.form.TriggerField({
id: 'htmlFooterWrapper',
triggerClass: 'configure-column',
scope: this
});
this.trigger.onTriggerClick = function(){
var footerValue = htmlFooter.getValue();
var htmlEditor = new com.evoca.players.HtmlWizard(footerValue, formParent, 'htmlFooter', 'Edit HTML Footer');
htmlEditor.show();
};
this.trigger.applyToMarkup('htmlFooter');
})
// FIELD SETS
this.htmlHeaderFooter = new Ext.form.FieldSet({
title: 'Header and Footer HTML',
autoWidth: true,
autoHeight: true,
labelWidth: 79,
items: [htmlHeader, htmlFooter]
});
this.orientationSetup = new Ext.form.FieldSet({
title: 'Orientation',
autoWidth: true,
autoHeight: true,
items: [this.picker]
});
this.basicOptions = new Ext.form.FieldSet({
title: 'Basic Options',
autoWidth: true,
autoHeight: true,
items: [this.playerName, this.swfwidth, this.swfheight, this.displaywidth, this.displayheight, this.skin, this.enableShareButton, this.shareButtonTheme]
});
this.colorOptions = new Ext.form.FieldSet({
title: 'Color Options',
autoWidth: true,
autoHeight: true,
items: [this.backcolor, this.frontcolor, this.lightcolor, this.screencolor]
});
this.displayOptions = new Ext.form.FieldSet({
title: 'Display appearance',
autoWidth: true,
autoHeight: true,
items: [this.logo,
this.defaultImage,
this.stretching,
this.displayclick]
});
this.playbackBehaviorOptions = new Ext.form.FieldSet({
title: 'Playback behaviour',
autoWidth: true,
autoHeight: true,
items: [this.autostart, this.repeat, this.shuffle, this.volume]
});
// HIDDEN FORM FIELDS
this.file = new Ext.form.Hidden({
id: 'file',
name: 'file'
});
this.location = new Ext.form.Hidden({
id: 'location',
name: 'location'
});
this.flashVars = new Ext.form.Hidden({
id: 'flashVars',
name: 'flashVars',
value: record == null ? '' : record.get('playerParams')
});
this.swfFilename = new Ext.form.Hidden({
id: 'swfFilename',
name: 'swfFilename',
value: record == null ? '' : record.get('swfFilename')
});
this.oldPlayerName = new Ext.form.Hidden({
id: 'oldPlayerName',
name: 'oldPlayerName',
value: record == null ? '' : record.get('name')
});
this.type = new Ext.form.Hidden({
id: 'type',
name: 'type',
value: record == null ? '' : record.get('type')
});
this.fileField = new Ext.form.TextField({
fieldLabel: 'File to Upload',
inputType: 'file',
validateOnBlur: false,
name: 'userfile',
allowBlank: false,
style: {height: '22px'},
width: 260
});
this.playlistsize = new Ext.form.Hidden({
id: 'playlistsize',
name: 'playlistsize',
value: record == null ? '' : record.get('playlistsize')
});
this.playlist = new Ext.form.Hidden({
id: 'playlist',
name: 'playlist',
value: record == null ? '' : record.get('playlist')
});
this.version = new Ext.form.Hidden({
id: 'v',
name: 'v',
value: '4'
});
this.pluginsField = new Ext.form.Hidden({
id: 'plugins',
name: 'plugins',
value: 'ems-plugin.swf'
});
// Quick Tips
var autoHide = true;
var dismissDelay = 60000;
this.pickerTip = 'Choose an orientation for the display, controlbar, and playlist.';
this.heightTip = 'height (320): Sets the overall height of the player.';
this.widthTip = 'width (260): Sets the overall width of the player.';
this.backcolorTip = 'backcolor (0xFFFFFF): Backgroundcolor of the controls, in HEX format.';
this.frontcolorTip = 'frontcolor (0x000000): Texts & buttons color of the controls, in HEX format.';
this.lightcolorTip = 'lightcolor (0x000000): Rollover color of the controls, in HEX format.';
this.screencolorTip = 'screencolor (0x000000): Color of the display area, in HEX format.';
this.displaywidthTip = 'displaywidth (260): Controls the width of the image display.';
this.displayheightTip = 'displayheight (260): Controls the height of the image display.';
this.logoTip = 'logo (undefined): Set this to the URL of an image that can be put as a watermark logo in the top right corner of the display. Transparent PNG files give the best results.';
this.defaultImageTip = 'defaultImage (undefined): Set this to the URL of an image to be used as the default image for the display window.';
this.stretchingTip = 'stretching (to fit the display): Sets how to stretch images/movies to make them fit the display. The default stretches to fit the display.';
this.displayclickTip = 'displayclick (play): Controls what happens when a user clicks in the middle of the display.';
this.autostartTip = 'autostart (false): Set this to true in the player to automatically start playing when the page loads.';
this.repeatTip = 'repeat (false): Set this to true to automatically repeat playback of all files. Set this to list to playback an entire playlist once.';
this.shuffleTip = 'shuffle (true): Set this to false to playback a playlist sequentially (first to last) instead of shuffled.';
this.volumeTip = 'volume (80): sets the startup volume for playback of audiotracks.';
this.playerNameTip = 'name (undefined): The name of the player.';
this.htmlHeaderTip = 'htmlHeader: The HTML header that is viewable above the player.';
this.htmlFooterTip = 'htmlFooter: The HTML footer that is viewable below the player.';
this.shareTip = "With a share button, offer options for online visitors to post player to 70+ destinations including Facebook, WordPress, and email and bookmark it";
// Register the tips for the fields
Ext.QuickTips.register({text:this.pickerTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.picker});
Ext.QuickTips.register({text:this.heightTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.swfheight});
Ext.QuickTips.register({text:this.widthTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.swfwidth});
Ext.QuickTips.register({text:this.backcolorTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.backcolor});
Ext.QuickTips.register({text:this.frontcolorTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.frontcolor});
Ext.QuickTips.register({text:this.lightcolorTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.lightcolor});
Ext.QuickTips.register({text:this.screencolorTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.screencolor});
Ext.QuickTips.register({text:this.displaywidthTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.displaywidth});
Ext.QuickTips.register({text:this.displayheightTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.displayheight});
Ext.QuickTips.register({text:this.logoTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.logo});
Ext.QuickTips.register({text:this.defaultImageTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.defaultImage});
Ext.QuickTips.register({text:this.stretchingTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.stretching});
Ext.QuickTips.register({text:this.displayclickTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.displayclick});
Ext.QuickTips.register({text:this.autostartTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.autostart});
Ext.QuickTips.register({text:this.repeatTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.repeat});
Ext.QuickTips.register({text:this.shuffleTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.shuffle});
Ext.QuickTips.register({text:this.volumeTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.volume});
//Ext.QuickTips.register({text:this.playerNameTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.playerName});
Ext.QuickTips.register({text:this.htmlHeaderTip,dismissDelay:dismissDelay,autoHide:autoHide,target:htmlHeader});
Ext.QuickTips.register({text:this.htmlFooterTip,dismissDelay:dismissDelay,autoHide:autoHide,target:htmlFooter});
Ext.QuickTips.register({text:this.shareTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.shareButtonTheme});
Ext.QuickTips.register({text:this.shareTip,dismissDelay:dismissDelay,autoHide:autoHide,target:this.enableShareButton});
this.form = new Ext.FormPanel({
plugins: new Ext.ux.OOSubmit(),
autoWidth: true,
stateful: false,
height: 400,
autoScroll: true,
labelWidth: 175,
labelAlign: 'right',
id:'createForm',
url: 'data/createOrUpdatePlayer',
fileUpload: false,
items: [
this.file, this.location, this.flashVars, this.swfFilename, this.oldPlayerName, this.type, this.playlist, this.playlistsize, this.version, this.pluginsField, // hidden fields
this.orientationSetup,
this.basicOptions,
this.htmlHeaderFooter,
this.colorOptions,
this.displayOptions,
this.playbackBehaviorOptions
],
border: false,
bodyStyle:'position:relative;background:transparent;padding:10px;',
errorReader: new Ext.data.XmlReader({
record: 'error',
success: '@success'
},
['detail'])
});
var operation = 'create';
if(record != null)
operation = 'edit';
com.evoca.players.CreateWindow.superclass.constructor.call(this, {
title: (operation == 'create') ? 'Create Player' : 'Edit Player',
id: 'ev-create-window',
autoHeight: true,
width: 450,
maskDisabled: false,
bodyStyle: 'position:relative',
resizable: true,
titleBar: true,
plain:true,
modal: false,
autoScroll: true,
closable: true,
labelWidth: 110, // label settings here cascade unless overridden
buttons:[{
text: 'Reload',
scope: this,
handler: function(){
this.refreshPreview();
}
},{
text: (operation == 'create') ? 'Create' : 'Save',
scope: this,
handler: function(){
if (this.form.getForm().isValid()) {
this.calculateFlashvars(this);
this.preview.disable();
this.form.getForm().submit({
waitMsg: (operation == 'create') ? 'Creating...' : 'Saving...',
style: 'position:absolute',
success: function(form, action) {
Ext.Msg.show({
title: 'Success',
buttonAlign: 'center',
buttons: Ext.Msg.OK,
msg: (operation == 'create') ? 'Player was successfully created.' : 'Player was successfully edited.',
fn: function() {
this.hide();
this.preview.hide();
window.location.reload();
},
scope: this
});
},
failure: function(form, action) {
// show the error dialog
var errorsText = '';
var errorsLength = (action.result.errors) ? action.result.errors.length : 0;
if(errorsLength > 0) {
errorsText = (errorsLength > 1) ? '
Reasons:
' : '
Reason: ';
var i = 1;
action.result.errors.each(
function(error) {
errorsText += (((errorsLength > 1) ? (i + ') ') : '') + error.detail + '
');
i++;
}
);
}
Ext.Msg.show({
title: 'Error',
buttons: Ext.Msg.OK,
msg: (operation == 'create') ? 'Player was not created.' + errorsText : 'Player was not edited.' + errorsText,
scope:this,
fn: function() {
this.preview.enable();
}
});
},
scope: this
});
}
},
scope: this
},{
text: 'Cancel',
handler: function() {
this.destroy();
this.preview.destroy();
this.enableParent();
},
scope: this
}],
items: [this.form],
scope: this
});
}
Ext.extend(com.evoca.players.CreateWindow, Ext.Window, {
show : function(){
if(this.rendered){
this.form.getForm().reset();
}
var type = this.record == null ? null : this.record.get('type');
var nonEditable = false;
if(type == 'HYBRID_DEFAULT' || type == 'DEFAULT')
nonEditable = true;
// Create the preview window
var showCloseButton = false;
if(nonEditable)
showCloseButton = true;
this.preview = new com.evoca.players.PreviewWindow(showCloseButton, this.parent, this.record, {scope:this});
if(nonEditable != true) {
com.evoca.players.CreateWindow.superclass.show.apply(this, arguments);
this.setPosition(30, 80);
this.preview.show();
this.preview.anchorTo('ev-create-window', 'tr');
this.preview.enable();
if(this.record != null) {
this.loadPlayer(this.record);
}
else
this.loadOrientation('defaults');
if(!this.enableShareButton.checked)
this.hideField(this.shareButtonTheme);
}
else {
this.preview.show();
this.preview.loadPlayer(this.record);
this.preview.setPosition(30, 80);
}
},
close : function() {
this.destroy();
this.preview.destroy();
this.enableParent();
},
disableParent : function() {
if(this.parent) {
this.parent.addClass('x-item-disabled');
}
},
enableParent : function() {
if(this.parent)
this.parent.removeClass('x-item-disabled');
},
loadOrientation: function(orientationName) {
// Reset form to defaults
var field;
for(var prm in this.orientationDefaults) {
field = this.form.getForm().findField(prm);
if(field.getValue() == null || field.getValue() == '') {
field.setValue(this.orientationDefaults[prm]);
}
}
// Load the example into the form fields
if(orientationName) {
for(var prm in this.orientations[orientationName]) {
field = this.form.getForm().findField(prm);
if(field.getValue() == null)
field.setValue(this.orientations[orientationName][prm]);
}
this.updateOrientationValues();
// Load the player
if(orientationName != 'defaults') {
this.refreshPreview();
}
}
},
updateOrientationValues: function(doc) {
if(!doc)
doc = this;
var playerUtils = new com.evoca.players.PlayerUtils();
var playlistlocation = doc.form.getForm().findField('playlist').getValue();
var playlistsize = doc.form.getForm().findField('playlistsize').getValue();
var orientation = doc.form.getForm().findField('picker').getValue();
var displaywidth = doc.form.getForm().findField('width').getValue();
var displayheight = doc.form.getForm().findField('height').getValue();
var swfWidth = doc.form.getForm().findField('swfwidth').getValue();
var swfHeight = doc.form.getForm().findField('swfheight').getValue();
// Put the player into the correct orientation
if(orientation != null) {
if(orientation == 'normal') {
if(swfHeight <= 20)
doc.form.getForm().findField('swfheight').setValue('140');
if(swfWidth == 0)
doc.form.getForm().findField('swfwidth').setValue('320');
doc.form.getForm().findField('playlist').setValue('right');
doc.form.getForm().findField('playlistsize').setValue(doc.form.getForm().findField('swfwidth').getValue());
}
else if(orientation == 'below') {
if(swfHeight <= 20)
doc.form.getForm().findField('swfheight').setValue('140');
if(swfWidth == 0)
doc.form.getForm().findField('swfwidth').setValue('320');
doc.form.getForm().findField('playlist').setValue('bottom');
doc.form.getForm().findField('playlistsize').setValue(eval(doc.form.getForm().findField('swfheight').getValue()) - 20);
}
else if(orientation == 'line') {
doc.form.getForm().findField('swfheight').setValue('20');
if(swfWidth == 0)
doc.form.getForm().findField('swfwidth').setValue('320');
doc.form.getForm().findField('playlist').setValue('right');
doc.form.getForm().findField('playlistsize').setValue('0');
}
else if(orientation == 'rightlist') {
doc.form.getForm().findField('playlist').setValue('right');
if(swfHeight <= 20)
doc.form.getForm().findField('swfheight').setValue('140');
if(swfWidth == 0)
doc.form.getForm().findField('swfwidth').setValue('320');
if(playlistsize == 0 || playlistsize == swfWidth)
doc.form.getForm().findField('playlistsize').setValue('120');
}
else if(orientation == 'abovebelow') {
doc.form.getForm().findField('playlist').setValue('bottom');
if(swfHeight <= 20) {
doc.form.getForm().findField('swfheight').setValue('240');
doc.form.getForm().findField('playlistsize').setValue('100');
}
else
doc.form.getForm().findField('playlistsize').setValue((swfHeight / 2) - 20);
if(swfWidth == 0)
doc.form.getForm().findField('swfwidth').setValue('320');
}
this.form.getForm().findField('width').setValue(com.evoca.players.util.calculateDisplaywidthSize(orientation, swfWidth, doc.form.getForm().findField('playlistsize').getValue()));
this.form.getForm().findField('height').setValue(com.evoca.players.util.calculateDisplayheightSize(orientation, swfHeight, doc.form.getForm().findField('playlistsize').getValue()));
}
},
loadPlayer : function(record) {
if(record != null) {
this.loadForm(record);
this.preview.loadPlayer(record);
}
},
refreshPreview : function(doc) {
if(!doc)
doc = this;
var playerUtils = new com.evoca.players.PlayerUtils();
var record = playerUtils.createPlayerRecord();
var orientation = doc.form.getForm().findField('picker').getValue();
var w = doc.form.getForm().findField('width').getValue();
var h = doc.form.getForm().findField('height').getValue();
var l = doc.form.getForm().findField('location').getValue();
var playerName = doc.form.getForm().findField('playerName').getValue();
var swfWidth = doc.form.getForm().findField('swfwidth').getValue();
var swfHeight = doc.form.getForm().findField('swfheight').getValue();
var type = doc.form.getForm().findField('type').getValue();
var swfFilename = doc.form.getForm().findField('swfFilename').getValue();
var htmlHeader = doc.form.getForm().findField('htmlHeader').getValue();
var htmlFooter = doc.form.getForm().findField('htmlFooter').getValue();
var playlistLocation = this.form.getForm().findField('playlist').getValue();
var playlistsize = this.form.getForm().findField('playlistsize').getValue();
var enableShareButton = this.form.getForm().findField('enableShareButton').getValue();
var shareButtonTheme = this.form.getForm().findField('shareButtonTheme').getValue();
// Adjust the size of the display
this.form.getForm().findField('width').setValue(com.evoca.players.util.calculateDisplaywidthSize(orientation, swfWidth, playlistsize));
this.form.getForm().findField('height').setValue(com.evoca.players.util.calculateDisplayheightSize(orientation, swfHeight, playlistsize));
var so = new SWFObject(l,'mpl',swfWidth,swfHeight,'9');
this.calculateFlashvars(doc);
var playerRecord = new record({
name: playerName,
htmlHeader: htmlHeader,
htmlFooter: htmlFooter,
swfFilename: swfFilename,
swfHeight: swfHeight,
swfWidth: swfWidth,
type: type,
playerParams: doc.form.getForm().findField('flashVars').getValue(),
enableShareButton: enableShareButton,
shareButtonTheme: shareButtonTheme
});
this.preview.loadPlayer(playerRecord);
},
calculateFlashvars : function(doc) {
var flashVars = '';
for(var prm in doc.form.getForm().getValues()) {
if( prm != 'picker' &&
prm != 'flashVars' &&
prm != 'type' &&
prm != 'swfFilename' &&
prm != 'oldPlayerName' &&
prm != 'playerName' &&
prm != 'htmlHeader' &&
prm != 'htmlFooter' &&
prm != 'swfwidth' &&
prm != 'swfheight' &&
prm != 'width' &&
prm != 'height' &&
prm != 'location' &&
prm != 'enableShareButton' &&
prm != 'shareButtonTheme') {
if(prm != 'file') {
flashVars += ',' + prm + '=' + doc.form.getForm().findField(prm).getValue();
}
}
}
doc.form.getForm().findField('flashVars').setValue(flashVars);
},
loadForm : function(record) {
if(record != null) {
// Reset form to defaults
for(var prm in this.orientationDefaults) {
this.form.getForm().findField(prm).setValue(this.orientationDefaults[prm])
}
this.form.getForm().findField('playerName').setValue(record.get('name'));
var swfWidth = null
var swfHeight = null;
if(record.get('htmlHeader') != null && record.get('htmlHeader') != 'null')
this.form.getForm().findField('htmlHeader').setValue(record.get('htmlHeader'));
if(record.get('htmlFooter') != null && record.get('htmlFooter') != 'null')
this.form.getForm().findField('htmlFooter').setValue(record.get('htmlFooter'));
if(record.get('swfWidth') != null && record.get('swfWidth') != 'null') {
swfWidth = record.get('swfWidth');
this.form.getForm().findField('swfwidth').setValue(swfWidth);
}
if(record.get('swfHeight') != null && record.get('swfHeight') != 'null') {
swfHeight = record.get('swfHeight');
this.form.getForm().findField('swfheight').setValue(swfHeight);
}
var flashVars = record.get('playerParams') == null ? '' : record.get('playerParams');
var flashParts = flashVars.split(',');
alert(flashVars + '\n\n' + flashParts);
var partt;
var part;
var playlistLocation = null;//, swfWidth, swfHeight, width
var playlistsize = null;
for(var i = 0; i < flashParts.size(); i++) {
partt = flashParts[i];
if(partt != null && partt != '') {
part = partt.split('=');
this.form.getForm().findField(part[0]).setValue(part[1]);
if(part[0] == 'playlistsize')
playlistsize = part[1];
else if(part[0] == 'playlist')
playlistLocation = part[1];
}
}
var orientation = com.evoca.players.util.calculateOrientation(playlistLocation, swfWidth, playlistsize)
this.form.getForm().findField('picker').setValue(orientation);
this.form.getForm().findField('width').setValue(com.evoca.players.util.calculateDisplaywidthSize(orientation, swfWidth, playlistsize));
this.form.getForm().findField('height').setValue(com.evoca.players.util.calculateDisplayheightSize(orientation, swfHeight, playlistsize));
// Default version to 4
var version = this.form.getForm().findField('v').getValue();
if(version == null || version == '') {
this.form.getForm().findField('v').setValue('4');
}
}
},
/*
* hideField
*/
hideField : function(field) {
if(field) {
var labelEl = field.getEl();
if(labelEl && labelEl.up('.x-form-item')) {
field.disable();
field.hide();
labelEl.up('.x-form-item').setDisplayed(false);
}
}
},
/*
* showField
*/
showField : function(field) {
if(field) {
var labelEl = field.getEl();
if(labelEl && labelEl.up('.x-form-item')) {
field.enable();
field.show();
labelEl.up('.x-form-item').setDisplayed(true);
}
}
}
});
com.evoca.players.HtmlWizard = function(rawHtml, parent, formFieldID, title) {
///parent.preview.disable();
this.preview = parent.preview;
this.playerCode = $('flashPlayerCode').innerHTML;
$('flashPlayerCode').innerHTML = '';
this.parent = parent;
this.htmlEditor = new Ext.form.HtmlEditor({
id: 'htmlEditor',
width: 570,
height: 350,
hideLabel: true,
enableLists: false,
value: rawHtml
});
this.form = new Ext.FormPanel({
border: false,
labelAlign:'right',
bodyStyle:'background:transparent;padding:10px;',
items: [this.htmlEditor]
});
if(title == null)
title = 'HTML Editor';
com.evoca.players.HtmlWizard.superclass.constructor.call(this, {
title: title,
id: 'ev-html-window',
height: 450,
width: 610,
bodyStyle: 'background:transparent;position:relative',
resizable: false,
stateful: false,
titleBar: true,
//plain:true,
modal: true,
closable: true,
items: [this.form],
scope: this,
closeAction: 'close',
buttons:[{
text: 'Save',
scope: this,
handler: function(){
if (this.form.getForm().isValid()) {
$('flashPlayerCode').innerHtml = this.playerCode;
parent.form.getForm().findField(formFieldID).setValue(this.form.getForm().findField('htmlEditor').getValue());
//parent.removeClass('x-item-disabled');
//parent.preview.removeClass('x-item-disabled');
parent.refreshPreview();
this.destroy();
}
}
},{
text: 'Cancel',
handler: this.close.createDelegate(this, [])
}]
});
}
Ext.extend(com.evoca.players.HtmlWizard, Ext.Window, {
show : function(){
if(this.rendered){
this.form.getForm().reset();
}
com.evoca.players.HtmlWizard.superclass.show.apply(this, arguments);
},
close : function(){
$('flashPlayerCode').innerHtml = this.playerCode;
//this.parent.removeClass('x-item-disabled');
//this.parent.preview.removeClass('x-item-disabled');
this.destroy();
}
});
/**
* PreviewWindow
*/
com.evoca.players.PreviewWindow = function(showCloseButton, parent, record, playerStore, selectedRecording) {
this.parent = parent;
this.record = record;
this.showCloseButton = showCloseButton;
var closable = false;
var width = 50;
if(record != null && record.get('swfWidth') != null)
width += eval(record.get('swfWidth'));
var closeButton = new Ext.Button({
text: 'Close',
scope: this,
handler: function(){
this.close();
}
});
if(showCloseButton && record != null && record.get('swfWidth') != null) {
width = 400;
closable = true;
}
else {
closable = false;
closeButton.hide();
}
var copyid = 'playerClipButton' + selectedRecording.get('recordingID');
log('copyid: ' + copyid);
var copyButton = 'Copy
';
//var createWindow = new com.evoca.players.CreateWindow(record, this);
//createWindow.show();
var headerPanel = new Ext.Panel({
id: 'headerPanel',
border: false,
html: '',
bodyStyle: 'position:relative;background:transparent;padding:10px;',
scope: this
});
var playerGrid = new Ext.grid.GridPanel({
store: new Ext.data.Store({
autoDestroy: true,
reader: new Ext.data.ArrayReader({}, [
{name: 'player'},
{name: 'width'},
{name: 'height'}
]),
data: [
['Mini', 'Extends to 290', '24'],
['Small', '126', '20'],
['Medium', '223', '20'],
['Large', '320', '20']
]
}),
colModel: new Ext.grid.ColumnModel({
defaults: {
width: 120,
sortable: true
},
columns: [
{id: 'player', header: 'Player', width: 50, sortable: true, dataIndex: 'player'},
{id: 'width', header: 'Width', css: 'text-align: center;', width: 90, sortable: true, dataIndex: 'width'},
{id: 'height', header: 'Height', css: 'text-align: center;', width: 50, sortable: true, dataIndex: 'height'}
]
}),
autoHeight: true,
autoHeight: true,
frame: false,
title: 'Player dimensions',
iconCls: 'icon-grid'
});
var playerTypePanel = new Ext.Panel({
id: 'playerTypePanel',
border: false,
bodyStyle: 'background:transparent;margin-left: 110px;',
scope: this,
width: 302,
items: [playerGrid]
});
var footerPanel = new Ext.Panel({
id: 'footerPanel',
border: false,
html: 'Save code to embed. Code is deleted when this window is closed.',
bodyStyle: 'position:relative;background:transparent;padding:10px;',
scope: this
});
var playerPanel = new Ext.Panel({
id: 'playerPanel',
border: false,
html: '',
bodyStyle: 'position:relative;background:transparent;padding:10px;',
scope: this
});
var playerBox = new Ext.form.ComboBox({
store: playerStore,
//fieldLabel: 'Copy-n-Paste Code',
fieldLabel: 'Copy-n-Paste Code',
displayField: 'name',
mode: 'local',
selectOnFocus: false,
editable: false,
triggerAction: 'all',
xtype: 'combo',
forceSelection: true,
scope: this,
value: record.get('name'),
listeners:{
scope: this,
'select': function(combo, record, index) {
this.loadPlayer(record, selectedRecording);
this.loadHtmlHeader(record);
}
}
});
var copyAndPastCode = new Ext.form.TextArea({
id: 'copyAndPasteCode',
//fieldLabel: 'Copy-n-Paste Code',
hideLabel: true,
width: width - 15,
height: 100,
scope: this,
readOnly: true,
selectOnFocus: true,
listeners: {
render: function() {
this.selectText();
}
/*
focus: function(sm) {
this.selectText();
},
keypress: function(sm) {
this.selectText();
},
keyup: function(sm) {
this.selectText();
}
*/
}
});
var codePanel = new Ext.form.FormPanel({
id: 'codePanel',
border: false,
autoHeight: true,
bodyStyle: 'position:relative;background:transparent;padding:10px;',
scope: this,
labelWidth: 214,
labelAlign: 'right',
html: copyButton,
items: [playerBox, copyAndPastCode]
});
com.evoca.players.PreviewWindow.superclass.constructor.call(this, {
title: 'Preview',
id: 'ev-preview-window',
plain: false,
autoHeight: true,
width: width,
modal: true,
stateful: false,
closable: closable,
frame: true,
bodyStyle: 'position:relative;background:transparent;padding:10px;',
buttons:[closeButton],
buttonAlign: 'right',
items: [headerPanel, playerPanel, codePanel, footerPanel, playerTypePanel]
});
this.on('render', function(){
this.loadPlayer(record, selectedRecording);
});
this.on('afterlayout', function(){
this.loadCopyButton(selectedRecording);
});
this.on('move', function(){
this.loadCopyButton(selectedRecording);
});
}
Ext.extend(com.evoca.players.PreviewWindow, Ext.Window, {
loadHtmlHeader : function(player) {
if($('prefHtmlHeader')) {
//alert('foo');
$('prefHtmlHeader').innerHTML = this.getHtmlHeader(player);
}
},
getHtmlHeader : function(player) {
if(player != null) {
var extraText = '';
if(player.get("type") == 'HYBRID_WP')
extraText = 'expanded to ';
var htmlHeader = '';
htmlHeader += 'This preview shows the working player that is';
htmlHeader += ' ' + extraText + player.get('swfWidth') + ' pixels wide';
htmlHeader += ' x ' + player.get('swfHeight') + ' pixels high.';
htmlHeader += ' The ?share button? destination sites (e.g. Facebook, ';
htmlHeader += ' LinkedIn, etc.) shown when you click on it are for';
htmlHeader += ' illustration only. It is active when embedded.';
htmlHeader += '';
return htmlHeader;
}
},
loadCopyButton : function(recording) {
var copyid = 'playerClipButton' + selectedRecording.get('recordingID');
//log('copyID: ' + copyid);
var clip = getClipObject(copyid, 'copyAndPasteCode', root);
log('clip: ' + clip);
},
show : function(){
com.evoca.players.PreviewWindow.superclass.show.apply(this, arguments);
},
close: function() {
this.destroy();
},
getPlayerCode: function(player, recording) {
if(player != null && recording != null) {
var shareURL = recording.get('shareURL');
var hostParts = shareURL.split('everyone_recording');
var host = '';
if(hostParts != null && hostParts.length >= 1)
host = hostParts[0];
var filename = player.get('swfFilename');
var w = player.get('swfWidth');
var h = player.get('swfHeight');
var enableShareButton = player.get('enableShareButton');
var shareButtonTheme = player.get('shareButtonTheme');
var l = host + 'evocaPlayer/';
var htmlHeader = (player.get('htmlHeader')) ? player.get('htmlHeader') : '';
var htmlFooter = (player.get('htmlFooter')) ? player.get('htmlFooter') : '';
if(filename == null || filename == '' || filename == 'playlistDefault')
l += 'ev-pl-4x.swf';
else
l += filename;
var src = l; // object param=movie, embed src
var allowfullscreen = true;
var object = '\r\n\t\t<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0" width="' + w + '" height="' + h + '">';
object += '\r\n\t\t\t<param name="movie" value="' + l + '">';
object += '\r\n\t\t\t<param name="quality" value="high"/>';
object += '\r\n\t\t\t<param name="allowScriptAccess" value="always"/>';
if(player.get('transparent'))
object += '\r\n\t\t\t<param name="wmode" value="transparent">';
var embed = '\r\n\t\t\t<embed src="' + l + '" width="' + w + '" height="' + h + '" allowfullscreen="true" allowscriptaccess="always" ';
if(player.get('transparent'))
embed += ' wmode="transparent" ';
embed += ' flashvars="';
var flashVars = player.get('playerParams') == null ? '' : player.get('playerParams');
var flashParts = flashVars.split(',');
var partt;
var part;
var flashVarsToUse = '';
var count = 0;
for(var i = 0; i < flashParts.length; i++) {
partt = flashParts[i];
if(partt != null && partt != '') {
part = partt.split('=');
if(part[0] == 'skin' || part[0] == 'plugins')
part[1] = host + 'evocaPlayer/' + part[1];
if(count > 0)
flashVarsToUse += '&';
flashVarsToUse += part[0] + '=' + part[1];
count++;
}
}
var type = player.get('type');
if(type && type == 'HYBRID_WP') {
var title = recording.get('title');
if(!title)
title = "";
log("title before: " + title);
title = title.replace(/"/g, "%22");
log("title after: " + title);
flashVarsToUse += '&titles=' + title;
flashVarsToUse += '&rid=' + recording.get('recordingID');
flashVarsToUse += '&soundFile=' + recording.get('directURL');
flashVarsToUse += '&host=' + host;
}
flashVarsToUse += '&listenURL=' + host + 'lc.jsp?rid=' + recording.get('recordingID');
flashVarsToUse += '&file=' + recording.get('directURL');
object += '\r\n\t\t\t<param name="flashVars" value="' + flashVarsToUse + '" />';
embed += flashVarsToUse + '"></embed>';
object = object + embed + '\r\n\t\t</object>';
var code = '';
code += '<div style="width:' + w + ';" id="flashPlayerHTML-' + player.get('name') + '">';
code += '\r\n\t<div id="playerHeader">' + htmlHeader + '</div>';
code += '\r\n\t<div class="evocaFlashPlayer" id="playerCode">' + object + '\r\n\t</div>';
code += '\r\n\t<div id="playerFooter">' + htmlFooter + '</div>';
// add gigya player
code += '\r\n</div>';
if(enableShareButton != null && (enableShareButton == 'true' || enableShareButton == true)) {
var textAreaName = 'codeInfo' + player.get('name');
var gigaycodestart = '\r\n<textarea style="display:none" id="' + textAreaName + '">';
var gigaycodeend = '\r\n</textarea>';
var gigaycodeScript = "<script src='http://cdn.gigya.com/wildfire/JS/WFButton.js?defaultContent=" + textAreaName + "&module=post&widgetTitle=Evoca%20Recording&partner=597482&cid=codefield&theme=6&b=click&btnurl=http%3A%2F%2Fwww.evoca.com%2Fimages%2Fshare-button.jpg'></script>";
}
var fullCode = code + gigaycodestart + '\r\n' + code + gigaycodeend + gigaycodeScript;
//return "<a href=''>foo</a>";
return fullCode;
}
},
loadPlayer : function(player, recording) {
if(player != null) {
var shareURL = recording.get('shareURL');
var hostParts = shareURL.split('everyone_recording');
var host = '';
if(hostParts != null && hostParts.length >= 1)
host = hostParts[0];
var playerUtils = new com.evoca.players.PlayerUtils();
//playerUtils.isPlaylistPlayer(player);
var filename = player.get('swfFilename');
var w = player.get('swfWidth');
var h = player.get('swfHeight');
var enableShareButton = player.get('enableShareButton');
var shareButtonTheme = player.get('shareButtonTheme');
var windowWidth = eval(w) + 50;
var minShareButtonWidth = 440;
if((enableShareButton == "true" || enableShareButton == true) && windowWidth < minShareButtonWidth)
windowWidth = minShareButtonWidth;
this.setWidth(windowWidth);
this.doLayout();
var l = host + 'evocaPlayer/';
if(filename == null || filename == '' || filename == 'playlistDefault')
l += 'ev-pl-4x.swf';
else
l += filename;
var so = new SWFObject(l,'embeddedPlayer',w,h,'9');
so.addParam('allowfullscreen',true);
if(player.get('transparent')) {
so.addParam('wmode', 'transparent');
}
so.addVariable('file', recording.get('directURL'));
so.addVariable('allowScriptAccess', "always");
var flashVars = player.get('playerParams') == null ? '' : player.get('playerParams');
var flashParts = flashVars.split(',');
var partt;
var part;
for(var i = 0; i < flashParts.length; i++) {
partt = flashParts[i];
if(partt != null && partt != '') {
part = partt.split('=');
if(part[0] == 'skin' || part[0] == 'plugins')
part[1] = host + 'evocaPlayer/' + part[1];
so.addVariable(part[0], part[1]);
}
}
var type = player.get('type');
if(type && type == 'HYBRID_WP') {
var title = recording.get('title');
if(!title)
title = "";
log("title before: " + title);
title = title.replace(/"/g, "%22");
log("title after: " + title);
so.addVariable('titles', title);
so.addVariable('rid', recording.get('recordingID'));
so.addVariable('soundFile', recording.get('directURL'));
}
so.write('flashPlayerCode');
if(player.get('htmlHeader') != null && player.get('htmlHeader') != 'null')
$('prevHeader').innerHTML = player.get('htmlHeader');
if(player.get('htmlFooter') != null && player.get('htmlFooter') != 'null')
$('prevFooter').innerHTML = player.get('htmlFooter');
// TODO: Make sure we're using the correct gigya widget
$('hiddenTextArea').innerHTML = "";
$('prevShareButton').innerHTML = "";
if(enableShareButton != null && (enableShareButton == 'true' || enableShareButton == true)) {
var shareButton3 = "";
shareButton3 += '';
var textAreaStart = "";
var textArea = textAreaStart + $('preview').innerHTML + textAreaEnd;
$('hiddenTextArea').innerHTML = textArea;
$('prevShareButton').innerHTML = shareButton3;
}
if($('copyAndPasteCode'))
$('copyAndPasteCode').innerHTML = this.getPlayerCode(player, recording);
}
}
});
Ext.apply(Ext.form.VTypes, {
'hexnum': function(){
var re = /0\x[a-fA-F\d]{6}/;
return function(v){
return re.test(v);
}
}(),
'hexnumText' : 'The format is wrong, ie: 0xFFFFFF'
});
Ext.apply(Ext.form.VTypes, {
'wholenum': function() {
var whole = /^[0-9]+$/;
return function(v){
return whole.test(v);
}
}(),
'wholenumText': 'The field must be a valid whole number'
});
com.evoca.players.PlayerUtils = function() {
/**
* Returns a player list object based off xml string
*/
this.createPlayerRecord = function() {
var playerRecord = Ext.data.Record.create([
{name: 'name', mapping: '@name', type:'string'},
{name: 'swfFilename'},
{name: 'swfHeight'},
{name: 'swfWidth'},
{name: 'transparent'},
{name: 'type'},
{name: 'playerParams'},
{name: 'index'},
{name: 'htmlHeader'},
{name: 'htmlFooter'},
{name: 'enableShareButton'},
{name: 'shareButtonTheme'}
]);
return playerRecord;
},
this.getPlayerArrayReader = function() {
var reader = new Ext.data.ArrayReader({}, [
{name: 'name'},
{name: 'swfFilename'},
{name: 'swfHeight'},
{name: 'swfWidth'},
{name: 'transparent'},
{name: 'type'},
{name: 'playerParams'},
{name: 'index'},
{name: 'htmlHeader'},
{name: 'htmlFooter'},
{name: 'enableShareButton'},
{name: 'shareButtonTheme'}
]);
return reader;
},
this.getEvocaStandardPlayerRecords = function() {
var playerRecord = this.createPlayerRecord();
var hiddenPlayer = new playerRecord({
name: '',
swfHeight: 20,
swfWidth: 126,
//swfWidth: 145,
type: 'HYBRID_DEFAULT',
enableShareButton: true,
shareButtonTheme: '6',
playerParams: 'playlist=none,playlistsize=0,v=4,plugins=ee-plugin.swf,skin=jw-default-skin-no-thumbs-simple.swf,backcolor=0xffffff,frontcolor=0x000000,lightcolor=0x000000,screencolor=0x000000,stretching=uniform,displayclick=play,autostart=false,repeat=false,shuffle=false,volume=80'
});
var miniPlayer = new playerRecord({
name: 'Mini',
swfFilename: 'wpaudioplayer.swf',
swfHeight: 24,
swfWidth: 290,
type: 'HYBRID_WP',
enableShareButton: true,
shareButtonTheme: '6',
transparent: true,
playerParams: 'initialvolume=80'
});
var smallPlayer = new playerRecord({
name: 'Small',
swfHeight: 20,
swfWidth: 126,
//swfWidth: 145,
type: 'HYBRID_DEFAULT',
enableShareButton: true,
shareButtonTheme: '6',
playerParams: 'playlist=none,playlistsize=0,v=4,plugins=ee-plugin.swf,skin=jw-default-skin-no-thumbs-simple.swf,backcolor=0xffffff,frontcolor=0x000000,lightcolor=0x000000,screencolor=0x000000,stretching=uniform,displayclick=play,autostart=false,repeat=false,shuffle=false,volume=80'
});
var mediumPlayer = new playerRecord({
name: 'Medium',
swfHeight: 20,
swfWidth: 223,
type: 'HYBRID_DEFAULT',
enableShareButton: true,
shareButtonTheme: '6',
playerParams: 'showrepeate=false,playlist=none,playlistsize=0,v=4,plugins=ee-plugin.swf,skin=jw-default-skin-no-thumbs.swf,backcolor=0xffffff,frontcolor=0x000000,lightcolor=0x000000,screencolor=0x000000,stretching=uniform,displayclick=play,autostart=false,repeat=false,shuffle=false,volume=80'
});
var largePlayer = new playerRecord({
name: 'Large',
swfHeight: 20,
swfWidth: 320,
type: 'HYBRID_DEFAULT',
enableShareButton: true,
shareButtonTheme: '6',
playerParams: 'showrepeate=false,playlist=none,playlistsize=0,v=4,plugins=ee-plugin.swf,skin=jw-default-skin-no-thumbs.swf,backcolor=0xffffff,frontcolor=0x000000,lightcolor=0x000000,screencolor=0x000000,stretching=uniform,displayclick=play,autostart=false,repeat=false,shuffle=false,volume=80'
});
if(!Ext.isGecko)
return [hiddenPlayer, miniPlayer, smallPlayer, mediumPlayer, largePlayer];
else
return [miniPlayer, smallPlayer, mediumPlayer, largePlayer];
}
this.getPlayerStore = function(root, userID) {
//var url = root + 'Request?action=getAlbums&userID=' + userID;
var store = new Ext.data.Store({});
/*
var store = new Ext.data.Store({
url: url,
autoLoad: true,
sortInfo: {
field: 'albumName',
direction: 'ASC'
},
reader: new Ext.data.XmlReader({
record : 'album',
totalRecords: 'totalAlbums'
}, this.createAlbumRecord())
});
*/
store.add(this.getEvocaStandardPlayerRecords());
return store;
}
this.isPlaylistPlayer = function(record) {
var retVal = false;
if(record != null && record.get('type')) {
var type = record.get('type');
if(type != null && (type == 'HYBRID_DEFAULT' || type == 'HYBRID_CUSTOMIZED'))
retVal = true;
}
return retVal;
}
this.isDefaultPlayer = function(record) {
var retVal = false;
if(record != null && record.get('type')) {
var type = record.get('type');
if(type != null && (type == 'HYBRID_DEFAULT' || type == 'DEFAULT'))
retVal = true;
}
return retVal;
}
};
com.evoca.players.PlayerListXMLReader = function(meta, recordType){
com.evoca.players.PlayerListXMLReader.superclass.constructor.call(this, meta, recordType);
};
Ext.extend(com.evoca.players.PlayerListXMLReader, Ext.data.DataReader, {
/**
* This method is only used by a DataProxy which has retrieved data from a remote server.
* @param {Object} response The XHR object which contains the parsed XML document. The response is expected
* to contain a method called 'responseXML' that returns an XML document object.
* @return {Object} records A data block which is used by an {@link Ext.data.Store} as
* a cache of Ext.data.Records.
*/
read : function(response){
var doc = response.responseXML;
if(!doc) {
throw {message: "XmlReader.read: XML Document not available"};
}
return this.readRecords(doc);
},
/**
* Create a data block containing Ext.data.Records from an XML document.
* @param {Object} doc A parsed XML document.
* @return {Object} records A data block which is used by an {@link Ext.data.Store} as
* a cache of Ext.data.Records.
*/
readRecords : function(doc){
/**
* After any data loads/reads, the raw XML Document is available for further custom processing.
* @type XMLDocument
*/
this.xmlData = doc;
var root = doc.documentElement || doc;
var q = Ext.DomQuery;
var recordType = this.recordType, fields = recordType.prototype.fields;
var sid = this.meta.id;
var totalRecords = 0, success = true;
if(this.meta.totalRecords){
totalRecords = q.selectNumber(this.meta.totalRecords, root, 0);
}
if(this.meta.success){
var sv = q.selectValue(this.meta.success, root, true);
success = sv !== false && sv !== 'false';
}
var records = [];
var ns = q.select(this.meta.record, root);
for(var i = 0, len = ns.length; i < len; i++) {
var n = ns[i];
var values = {};
var id = sid ? q.selectValue(sid, n) : undefined;
for(var j = 0, jlen = fields.length; j < jlen; j++){
var f = fields.items[j];
var v = q.selectValue(f.mapping || f.name, n, f.defaultValue);
v = f.convert(v);
values[f.name] = v;
}
// START CUSTOM
var tmpns = q.select("playerParams/playerParam", n);
var playerparamvalues = '';
for(var k = 0, tmplen = tmpns.length; k < tmplen; k++) {
var playerParam = tmpns[k];
var name = q.selectValue("name", playerParam);
var val = q.selectValue("value", playerParam);
playerparamvalues += ',' + name + '=' + val;
}
values['playerParams'] = playerparamvalues;
values['index'] = records.length;
// END CUSTOM
var record = new recordType(values, id);
record.node = n;
records[records.length] = record;
}
return {
success : success,
records : records,
totalRecords : totalRecords || records.length
};
}
});
com.evoca.players.util.calculatePlaylistSize = function(playlistLocation, swfWidth, swfHeight, width, height) {
var retVal = 0;
if(playlistLocation != null) {
if(playlistLocation == 'right' && swfWidth != null && width != null)
retVal = eval(swfWidth) - eval(width);
else if(playlistLocation == 'bottom' && swfHeight != null && height == null)
retVal = eval(swfHeight) - 20;
else if(playlistLocation == 'bottom' && swfHeight != null && height != null)
retVal = eval(swfHeight) - 20 - eval(height);
}
return retVal;
}
com.evoca.players.util.calculateDisplaywidthSize = function(orientation, swfWidth, playlistsize) {
var retVal = 0;
if(orientation != null) {
if(orientation == 'normal' || orientation == 'below' || orientation == 'line')
retVal = 0
else if(orientation == 'rightlist')
retVal = eval(swfWidth) - playlistsize;
else if(orientation == 'abovebelow')
retVal = eval(swfWidth);
}
return retVal;
}
com.evoca.players.util.calculateDisplayheightSize = function(orientation, swfHeight, playlistsize) {
var retVal = 0;
if(orientation != null) {
if(orientation == 'normal' || orientation == 'below' || orientation == 'line')
retVal = 0
else if(orientation == 'rightlist')
retVal = eval(swfHeight) - 20;
else if(orientation == 'abovebelow')
retVal = eval(swfHeight) - eval(playlistsize) - 20;
}
return retVal;
}
com.evoca.players.util.calculateOrientation = function(playlistLocation, swfWidth, playlistsize) {
var retVal = 'default';
if(playlistLocation != null) {
if(playlistLocation == 'none')
retVal = 'line';
else if(playlistLocation == 'right' && playlistsize == swfWidth)
retVal = 'normal';
else if(playlistLocation == 'bottom' && playlistsize == swfWidth)
retVal = 'bottom';
else if(playlistLocation == 'right' && playlistsize < swfWidth)
retVal = 'rightlist';
else if(playlistLocation == 'bottom')
retVal = 'abovebelow';
}
return retVal;
}
/**
* This submit action is basically the same as the normal submit action,
* only that it uses the fields getSubmitValue() to compose the values to submit,
* instead of looping over the input-tags in the form-tag of the form.
*
* To use it, just use the OOSubmit-plugin on either a FormPanel or a BasicForm,
* or explicitly call form.doAction('oosubmit');
*
* @param {Object} form
* @param {Object} options
*/
Ext.ux.OOSubmitAction = function(form, options){
Ext.ux.OOSubmitAction.superclass.constructor.call(this, form, options);
};
Ext.extend(Ext.ux.OOSubmitAction, Ext.form.Action.Submit, {
/**
* @cfg {boolean} clientValidation Determines whether a Form's fields are validated
* in a final call to {@link Ext.form.BasicForm#isValid isValid} prior to submission.
* Pass false in the Form's submit options to prevent this. If not defined, pre-submission field validation
* is performed.
*/
type : 'oosubmit',
// private
/**
* This is nearly a copy of the original submit action run method
*/
run : function(){
var o = this.options;
var method = this.getMethod();
var isPost = method == 'POST';
//retrieve the forms values and put them into formValues
var formValues = {};
this.form.items.each(function(field) {
//check if the form item provides a specialized getSubmitValue() and use that if available
if (typeof field.getSubmitValue == "function") formValues[field.getName()] = field.getSubmitValue();
else formValues[field.getName()] = field.getValue();
});
if(o.clientValidation === false || this.form.isValid()) {
Ext.Ajax.request(Ext.apply(this.createCallback(o), {
url:this.getUrl(!isPost),
method: method,
params:formValues, //add our values
isUpload: this.form.fileUpload
}));
}
else if (o.clientValidation !== false){ // client validation failed
this.failureType = Ext.form.Action.CLIENT_INVALID;
this.form.afterAction(this, false);
}
}
});
/**
* This plugin can be either used on BasicForm or FormPanel.
* In both cases it changes the behaviour of submit() to use
* the 'oosubmit' action instead of the 'submit' action.
*/
Ext.ux.OOSubmit=function() {
this.init=function(_object) {
var form=null;
if (typeof _object.form=="object") {
//we are a formpanel:
form=_object.form;
}
else form=_object;
//Save the old submit method:
form.oldSubmit=form.submit;
//create a new submit method which calls the oosubmit action per default:
form.submit=function(options) {
this.doAction('oosubmit', options);
return this;
};
};
};
Ext.form.Action.ACTION_TYPES['oosubmit'] = Ext.ux.OOSubmitAction;
// end of file