r72891 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72890‎ | r72891 | r72892 >
Date:05:40, 13 September 2010
Author:dale
Status:deferred
Tags:
Comment:
stubs for transition edit support
Modified paths:
  • /branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/remotes/mw.MediaWikiRemoteSequencer.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php
@@ -52,8 +52,8 @@
5353
5454 'mwe-sequencer-tools-transitions' => 'Transitions',
5555 'mwe-sequencer-tools-transitions-desc' => 'Set in and out Transitions',
56 - 'mwe-sequencer-clip-transin' => 'Transition in',
57 - 'mwe-sequencer-clip-transout' => 'Transition out',
 56+ 'mwe-sequencer-tools-transitions-transIn' => 'Transition in',
 57+ 'mwe-sequencer-tools-transitions-transOut' => 'Transition out',
5858
5959 'mwe-sequencer-clip-cancel-edit' => 'Cancel clip edit',
6060 'mwe-sequencer-preview' => 'Preview',
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js
@@ -2,7 +2,7 @@
33 * Handles the "tools" window top level component driver
44 */
55
6 -//Wrap in mw closure to avoid global leakage
 6+// Wrap in mw closure to avoid global leakage
77 ( function( mw ) {
88
99 mw.SequencerTools = function( sequencer ) {
@@ -38,13 +38,13 @@
3939 'contentTypes': [ 'img'], // xxx todo add video support
4040 'animate' : 'true'
4141 },
42 - 'templateedit':{
43 - 'editWidgets' : ['edittemplate'],
 42+ 'templateedit' : {
 43+ 'editWidgets' : ['editTemplate'],
4444 'editableAttributes' : [ 'apititlekey' ],
4545 'contentTypes' : ['mwtemplate']
4646 },
47 - 'transitions' : {
48 - 'editableAttributes' : [ 'transIn', 'transOut' ],
 47+ 'transitions' : {
 48+ 'editWidgets' : ['editTransitions'],
4949 'contentTypes': ['video', 'img', 'mwtemplate' ]
5050 }
5151 },
@@ -68,14 +68,6 @@
6969 'inputSize' : 30,
7070 'title' : gM('mwe-sequencer-template-name' )
7171 },
72 - 'transIn' : {
73 - 'type' : 'select',
74 - 'selectValues' : [ 'fadeFromColor' ]
75 - },
76 - 'transOut' : {
77 - 'type' : 'select',
78 - 'selectValues' : [ 'fadeFromColor', 'crossfade' ]
79 - },
8072 // Special child node type
8173 'param' : {
8274 'type' : 'childParam',
@@ -166,8 +158,8 @@
167159 $j( clickButton )
168160 .attr({
169161 'href': _this.sequencer.getServer().getAssetViewUrl(
170 - $j(smilElement).find("param[name='apiTitleKey']").attr('value')
171 - )
 162+ _this.sequencer.getSmil().getTitleKey( smilElement )
 163+ )
172164 ,
173165 'target' : '_new'
174166 })
@@ -252,7 +244,167 @@
253245 }
254246 },
255247 editWidgets: {
256 - 'edittemplate':{
 248+ 'editTransitions' : {
 249+ 'transitionTypes' : {
 250+ 'fade':{
 251+ 'type' : {
 252+ 'value' : 'fade',
 253+ 'editType' : 'hidden'
 254+ },
 255+ 'dur' : {
 256+ 'value' : '2s',
 257+ 'editType' : 'time'
 258+ },
 259+ },
 260+ 'fadeColor':{
 261+ 'extends':'fade',
 262+ 'fadeColor' : {
 263+ 'value' : '#000',
 264+ 'editType' : 'color'
 265+ }
 266+ },
 267+ // Set high level select attribute default
 268+ 'fadeFromColor' : {
 269+ 'extends': 'fadeColor',
 270+ 'selectable' : ['transIn'],
 271+ 'subtype' : {
 272+ 'value' : 'fadeFromColor',
 273+ 'editType' : 'hidden'
 274+ }
 275+ },
 276+ 'fadeToColor' : {
 277+ 'extends': 'fadeColor',
 278+ 'selectable' : ['transOut'],
 279+ 'subtype' : {
 280+ 'value' : 'fadeToColor',
 281+ 'editType' : 'hidden'
 282+ }
 283+ },
 284+ 'crossfade' : {
 285+ 'extends': 'fade',
 286+ 'selectable' : ['transIn', 'transOut'],
 287+ 'subtype' : {
 288+ 'value' : 'crossfade',
 289+ 'editType' : 'hidden'
 290+ }
 291+ }
 292+ },
 293+ buildAttributeSet: function( transitionType ){
 294+ var attributes = {};
 295+ for( var i in this.transitionTypes[ transitionType ] ){
 296+ if( i == 'extends' ){
 297+ $j.extend( attributes, this.buildAttributeSet( i ) );
 298+ } else {
 299+ attributes[ i ] = this.transitionTypes[ transitionType ][i];
 300+ }
 301+ }
 302+ return attributes;
 303+ },
 304+
 305+ getTransitionId: function( smilElement, transitionType ){
 306+ // Transition name is packed from attributeValue via striping the smilElement id
 307+ // This is a consequence of smil's strange transition dom placement in the head of the
 308+ // document instead of as child nodes. The idea with smil is the transition can be 'reused'
 309+ // but in the sequencer context we want unique transitions so that each can be customized
 310+ // independently.
 311+ return $j( smilElement ).attr('id') + '_' + transitionType;
 312+ },
 313+
 314+ getSelectedTransitionType: function(smilElement, transitionDirection ){
 315+ var attributeValue = $j( smilElement ).attr( transitionDirection );
 316+ if( !attributeValue )
 317+ return '';
 318+ return attributeValue.replace( $j( smilElement ).attr('id') + '_', '' );
 319+ },
 320+
 321+ getBindedTranstionEdit: function( _this, smilElement, transitionType ){
 322+ var $smilDom = _this.sequencer.getSmil().$dom;
 323+ var $editTransitionsSet = $j('<span />');
 324+ // Get the smil transition element
 325+ var $smilTransitionElement = $smilDom.find( '#' + this.getTransitionId( smilElement, transitionType ) );
 326+ // Get all the editable attributes for transitionName
 327+ var attributeSet = this.buildAttributeSet( transitionType );
 328+ for( var i in attributeSet ){
 329+ var transitionAttribute = attributeSet[i];
 330+ // Skip setup attributes
 331+ if( i == 'extends' || i == 'selectable' ){
 332+ continue;
 333+ }
 334+ if( transitionAttribute.editType == 'time' ){
 335+ $editTransitionsSet.append(
 336+ $j('<input />')
 337+ .attr('size', 5)
 338+ .change(function(){
 339+ var timeValue = mw.pa$j(this).val();
 340+ })
 341+ )
 342+ }
 343+
 344+
 345+ }
 346+ },
 347+
 348+ 'onChange': function( _this, smilElement, target ){
 349+
 350+ },
 351+ 'draw': function( _this, target, smilElement ){
 352+ // draw the two attribute types
 353+ $transitionWidget = $j('<div />');
 354+
 355+ var transitionDirections = ['transIn', 'transOut'];
 356+ for( var i in transitionDirections ){
 357+ var transitionDirection = transitionTypes[i];
 358+ $transitionWidget.append(
 359+ $j('<h3 />').text( gM('mwe-sequencer-tools-transitions-' + transitionDirection ))
 360+ )
 361+ // Output the top level empty select
 362+ $transSelect = $j('<select />').append(
 363+ $j('<option />')
 364+ .attr('value', '')
 365+ );
 366+ var selectedTransitionType = this.getSelectedTransitionType(smilElement, transitionDirection);
 367+ for( var j in this.transitionTypes ){
 368+ if( this.transitionTypes[j].selectable
 369+ &&
 370+ $j.inArray( transitionType, this.transitionTypes[j].selectable ) !== -1 )
 371+ {
 372+ // output the item if its selecteable for the current transitionType
 373+ var $option = $j("<option />")
 374+ .attr('value', this.transitionTypes[j])
 375+ .text( this.transitionTypes[j] )
 376+ // Add selected attribute if selected:
 377+ if( selectedTransitionType == this.transitionTypes[j] ){
 378+ $option.attr('selected', 'true');
 379+ }
 380+ $transSelect.append( $option );
 381+ }
 382+ }
 383+ // add the select
 384+ $transitionWidget.append( $transSelect );
 385+
 386+ // Set up the transConfig container:
 387+ var $transConfig = $j('<span />')
 388+ .addClass('transConfig');
 389+ // If a given transition type is selected output is editable attributes
 390+ if( selectedTransitionType != '' ) {
 391+ $transConfig.append(
 392+ this.getBindedTranstionEdit(
 393+ smilElement, selectedTransitionType
 394+ )
 395+ )
 396+ }
 397+
 398+ $transitionWidget.append( $transConfig );
 399+ }
 400+
 401+ return $transitionWidget;
 402+ },
 403+ 'drawTransitionType':function( attributeType ){
 404+
 405+ }
 406+
 407+ },
 408+ 'editTemplate':{
257409 'onChange' : function( _this, smilElement, target ){
258410 // Clear the smilElement template cache:
259411 $j( smilElement ).data('templateHtmlCache', null);
@@ -282,7 +434,7 @@
283435 return ;
284436 }
285437 $j( target ).empty().append(
286 - $j('<h3 />').text( gM('mwe-sequencer-edittemplate-params') )
 438+ $j('<h3 />').text( gM('mwe-sequencer-editTemplate-params') )
287439 )
288440
289441 // This is not supposed to be perfect ..
@@ -306,14 +458,14 @@
307459 $j( target ).append(
308460 _this.getEditableAttribute(
309461 smilElement,
310 - 'edittemplate',
 462+ 'editTemplate',
311463 'param',
312464 paramName
313465 )
314466 .find('input')
315467 // Bind the change event:
316468 .change(function(){
317 - _this.editWidgets.edittemplate.onChange(
 469+ _this.editWidgets.editTemplate.onChange(
318470 _this,
319471 smilElement,
320472 target
@@ -848,6 +1000,8 @@
8491001 mw.log("Error: editableAttributes : " + attributeName + ' not found');
8501002 return;
8511003 }
 1004+
 1005+
8521006 var _this = this;
8531007 var editAttribute = this.editableAttributes[ attributeName ];
8541008 var editType = editAttribute.type;
@@ -855,6 +1009,7 @@
8561010 mw.log(" Error: No editableTypes interface for " + editType);
8571011 return ;
8581012 }
 1013+
8591014 // Set the update key to the paramName if provided:
8601015 var updateKey = ( paramName ) ? paramName : attributeName;
8611016
@@ -870,41 +1025,50 @@
8711026 // Set paramName based attributes:
8721027 var attributeTitle = ( editAttribute.title ) ? editAttribute.title : paramName + ':';
8731028
874 - return $j( '<div />' )
875 - .css({
876 - 'float': 'left',
877 - 'font-size': '12px',
878 - 'border': 'solid thin #999',
879 - 'background-color': '#EEE',
880 - 'padding' : '2px',
881 - 'margin' : '5px'
 1029+ return _this.getInputBox({
 1030+ 'title' : attributeTitle,
 1031+ 'inputId' : _this.getEditToolInputId( toolId, updateKey ),
 1032+ 'inputSize': inputSize,
 1033+ 'initialValue' : initialValue,
 1034+ 'inputChange': function(){
 1035+ // Run the editableType update function:
 1036+ _this.editableTypes[ editType ].update(
 1037+ _this,
 1038+ smilElement,
 1039+ updateKey,
 1040+ $j( this ).val()
 1041+ );
 1042+ }
 1043+ })
 1044+ },
 1045+ getInputBox: function( config ){
 1046+ var _this = this;
 1047+ return $j( '<div />' )
 1048+ .css({
 1049+ 'float': 'left',
 1050+ 'font-size': '12px',
 1051+ 'border': 'solid thin #999',
 1052+ 'background-color': '#EEE',
 1053+ 'padding' : '2px',
 1054+ 'margin' : '5px'
 1055+ })
 1056+ .addClass('ui-corner-all')
 1057+ .append(
 1058+ $j('<span />')
 1059+ .css('margin', '5px')
 1060+ .text( config.title ),
 1061+
 1062+ $j('<input />')
 1063+ .attr( {
 1064+ 'id' : config.inputId ,
 1065+ 'size': config.inputSize
8821066 })
883 - .addClass('ui-corner-all')
884 - .append(
885 - $j('<span />')
886 - .css('margin', '5px')
887 - .text( attributeTitle ),
888 -
889 - $j('<input />')
890 - .attr( {
891 - 'id' : _this.getEditToolInputId( toolId, updateKey ),
892 - 'size': inputSize
893 - })
894 - .data('initialValue', initialValue )
895 - .sequencerInput( _this.sequencer )
896 - .val( initialValue )
897 - .change(function(){
898 - // Run the editableType update function:
899 - _this.editableTypes[ editType ].update(
900 - _this,
901 - smilElement,
902 - updateKey,
903 - $j( this ).val()
904 - );
905 - // widgets can bind directly to this change action.
906 - })
907 - );
908 - }
 1067+ .data('initialValue', config.initialValue )
 1068+ .sequencerInput( _this.sequencer )
 1069+ .val( config.initialValue )
 1070+ .change( options.inputChange )
 1071+ );
 1072+ }
9091073 }
9101074
9111075 } )( window.mw );
\ No newline at end of file
Index: branches/MwEmbedStandAlone/modules/Sequencer/remotes/mw.MediaWikiRemoteSequencer.js
@@ -108,12 +108,14 @@
109109 seqTitle = seqTitle.substr(0, seqTitle.length -4 );
110110 // not ideal details page builder but 'should work' ::
111111 editLink = mw.getApiProviderURL( embedPlayer.apiProvider ).replace( 'api.php', 'index.php' );
112 - editLink = mw.replaceUrlParams( editLink,
113 - {
114 - 'title' : seqTitle,
115 - 'action' : 'edit'
116 - }
117 - );
 112+ editLink = mw.getRemoteSequencerLink (
 113+ mw.replaceUrlParams( editLink,
 114+ {
 115+ 'title' : seqTitle,
 116+ 'action' : 'edit'
 117+ }
 118+ )
 119+ );
118120 }
119121 var kalturaLinkAttr = {
120122 'href': 'http://kaltura.com',

Status & tagging log