Changeset 27479
- Timestamp:
- 03/09/2014 06:04:29 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/media-views.js
r27478 r27479 2698 2698 2699 2699 /** 2700 * wp.media.view.MediaFrame. AudioDetails2700 * wp.media.view.MediaFrame.MediaDetails 2701 2701 * 2702 2702 * @constructor … … 2709 2709 * @mixes wp.media.controller.StateMachine 2710 2710 */ 2711 media.view.MediaFrame. AudioDetails = media.view.MediaFrame.Select.extend({2711 media.view.MediaFrame.MediaDetails = media.view.MediaFrame.Select.extend({ 2712 2712 defaults: { 2713 id: ' audio',2713 id: 'media', 2714 2714 url: '', 2715 menu: ' audio-details',2716 content: ' audio-details',2717 toolbar: ' audio-details',2715 menu: 'media-details', 2716 content: 'media-details', 2717 toolbar: 'media-details', 2718 2718 type: 'link', 2719 title: l10n.audioDetailsTitle,2720 2719 priority: 120 2721 2720 }, 2722 2721 2723 2722 initialize: function( options ) { 2723 this.DetailsView = options.DetailsView; 2724 this.cancelText = options.cancelText; 2725 this.addText = options.addText; 2726 2724 2727 this.media = new media.model.PostMedia( options.metadata ); 2725 2728 this.options.selection = new media.model.Selection( this.media.attachment, { multiple: false } ); … … 2728 2731 2729 2732 bindHandlers: function() { 2733 var menu = this.defaults.menu; 2734 2730 2735 media.view.MediaFrame.Select.prototype.bindHandlers.apply( this, arguments ); 2731 this.on( 'menu:create:audio-details', this.createMenu, this ); 2732 this.on( 'content:render:audio-details', this.renderAudioDetailsContent, this ); 2733 this.on( 'menu:render:audio-details', this.renderMenu, this ); 2734 this.on( 'toolbar:render:audio-details', this.renderAudioDetailsToolbar, this ); 2735 // override the select toolbar 2736 this.on( 'toolbar:render:replace-audio', this.renderReplaceAudioToolbar, this ); 2737 this.on( 'toolbar:render:add-audio-source', this.renderAddAudioSourceToolbar, this ); 2738 }, 2739 2740 createStates: function() { 2741 this.states.add([ 2742 new media.controller.AudioDetails( { 2743 media: this.media, 2744 editable: false, 2745 menu: 'audio-details' 2746 } ), 2747 2748 new media.controller.MediaLibrary( { 2749 type: 'audio', 2750 id: 'replace-audio', 2751 title: l10n.audioReplaceTitle, 2752 toolbar: 'replace-audio', 2753 media: this.media, 2754 menu: 'audio-details' 2755 } ), 2756 2757 2758 new media.controller.MediaLibrary( { 2759 type: 'audio', 2760 id: 'add-audio-source', 2761 title: l10n.audioAddSourceTitle, 2762 toolbar: 'add-audio-source', 2763 media: this.media, 2764 menu: 'audio-details' 2765 } ) 2766 ]); 2767 }, 2768 2769 renderAudioDetailsContent: function() { 2770 var view = new media.view.AudioDetails({ 2736 2737 this.on( 'menu:create:' + menu, this.createMenu, this ); 2738 this.on( 'content:render:' + menu, this.renderDetailsContent, this ); 2739 this.on( 'menu:render:' + menu, this.renderMenu, this ); 2740 this.on( 'toolbar:render:' + menu, this.renderDetailsToolbar, this ); 2741 }, 2742 2743 renderDetailsContent: function() { 2744 var view = new this.DetailsView({ 2771 2745 controller: this, 2772 2746 model: this.state().media, … … 2784 2758 view.set({ 2785 2759 cancel: { 2786 text: l10n.audioDetailsCancel,2760 text: this.cancelText, 2787 2761 priority: 20, 2788 2762 click: function() { … … 2802 2776 }, 2803 2777 2804 render AudioDetailsToolbar: function() {2778 renderDetailsToolbar: function() { 2805 2779 this.toolbar.set( new media.view.Toolbar({ 2806 2780 controller: this, … … 2828 2802 }, 2829 2803 2830 renderReplace AudioToolbar: function() {2804 renderReplaceToolbar: function() { 2831 2805 this.toolbar.set( new media.view.Toolbar({ 2832 2806 controller: this, … … 2845 2819 controller.media.changeAttachment( attachment, state.display( attachment ) ); 2846 2820 2847 // not sure if we want to use wp.media.string.image which will create a shortcode or2848 // perhaps wp.html.string to at least to build the <img />2849 2821 state.trigger( 'replace', controller.media.toJSON() ); 2850 2822 … … 2858 2830 }, 2859 2831 2860 renderAdd AudioSourceToolbar: function() {2832 renderAddSourceToolbar: function() { 2861 2833 this.toolbar.set( new media.view.Toolbar({ 2862 2834 controller: this, … … 2864 2836 replace: { 2865 2837 style: 'primary', 2866 text: l10n.audioAddSourceTitle,2838 text: this.addText, 2867 2839 priority: 80, 2868 2840 … … 2888 2860 2889 2861 /** 2890 * wp.media.view.MediaFrame. VideoDetails2862 * wp.media.view.MediaFrame.AudioDetails 2891 2863 * 2892 2864 * @constructor 2865 * @augments wp.media.view.MediaFrame.MediaDetails 2893 2866 * @augments wp.media.view.MediaFrame.Select 2894 2867 * @augments wp.media.view.MediaFrame … … 2899 2872 * @mixes wp.media.controller.StateMachine 2900 2873 */ 2901 media.view.MediaFrame.VideoDetails = media.view.MediaFrame.Select.extend({ 2874 media.view.MediaFrame.AudioDetails = media.view.MediaFrame.MediaDetails.extend({ 2875 defaults: { 2876 id: 'audio', 2877 url: '', 2878 menu: 'audio-details', 2879 content: 'audio-details', 2880 toolbar: 'audio-details', 2881 type: 'link', 2882 title: l10n.audioDetailsTitle, 2883 priority: 120 2884 }, 2885 2886 initialize: function( options ) { 2887 options.DetailsView = media.view.AudioDetails; 2888 options.cancelText = l10n.audioDetailsCancel; 2889 options.addText = l10n.audioAddSourceTitle; 2890 2891 media.view.MediaFrame.MediaDetails.prototype.initialize.call( this, options ); 2892 }, 2893 2894 bindHandlers: function() { 2895 media.view.MediaFrame.MediaDetails.prototype.bindHandlers.apply( this, arguments ); 2896 2897 this.on( 'toolbar:render:replace-audio', this.renderReplaceToolbar, this ); 2898 this.on( 'toolbar:render:add-audio-source', this.renderAddSourceToolbar, this ); 2899 }, 2900 2901 createStates: function() { 2902 this.states.add([ 2903 new media.controller.AudioDetails( { 2904 media: this.media, 2905 editable: false, 2906 menu: 'audio-details' 2907 } ), 2908 2909 new media.controller.MediaLibrary( { 2910 type: 'audio', 2911 id: 'replace-audio', 2912 title: l10n.audioReplaceTitle, 2913 toolbar: 'replace-audio', 2914 media: this.media, 2915 menu: 'audio-details' 2916 } ), 2917 2918 2919 new media.controller.MediaLibrary( { 2920 type: 'audio', 2921 id: 'add-audio-source', 2922 title: l10n.audioAddSourceTitle, 2923 toolbar: 'add-audio-source', 2924 media: this.media, 2925 menu: 'audio-details' 2926 } ) 2927 ]); 2928 } 2929 }); 2930 2931 /** 2932 * wp.media.view.MediaFrame.VideoDetails 2933 * 2934 * @constructor 2935 * @augments wp.media.view.MediaFrame.MediaDetails 2936 * @augments wp.media.view.MediaFrame.Select 2937 * @augments wp.media.view.MediaFrame 2938 * @augments wp.media.view.Frame 2939 * @augments wp.media.View 2940 * @augments wp.Backbone.View 2941 * @augments Backbone.View 2942 * @mixes wp.media.controller.StateMachine 2943 */ 2944 media.view.MediaFrame.VideoDetails = media.view.MediaFrame.MediaDetails.extend({ 2902 2945 defaults: { 2903 2946 id: 'video', … … 2912 2955 2913 2956 initialize: function( options ) { 2914 this.media = new media.model.PostMedia( options.metadata ); 2915 this.options.selection = new media.model.Selection( this.media.attachment, { multiple: false } ); 2916 media.view.MediaFrame.Select.prototype.initialize.apply( this, arguments ); 2957 options.DetailsView = media.view.VideoDetails; 2958 options.cancelText = l10n.videoDetailsCancel; 2959 options.addText = l10n.videoAddSourceTitle; 2960 2961 media.view.MediaFrame.MediaDetails.prototype.initialize.call( this, options ); 2917 2962 }, 2918 2963 2919 2964 bindHandlers: function() { 2920 media.view.MediaFrame.Select.prototype.bindHandlers.apply( this, arguments ); 2921 this.on( 'menu:create:video-details', this.createMenu, this ); 2922 this.on( 'content:render:video-details', this.renderVideoDetailsContent, this ); 2923 this.on( 'menu:render:video-details', this.renderMenu, this ); 2924 this.on( 'toolbar:render:video-details', this.renderVideoDetailsToolbar, this ); 2925 // override the select toolbar 2926 this.on( 'toolbar:render:replace-video', this.renderReplaceVideoToolbar, this ); 2927 this.on( 'toolbar:render:add-video-source', this.renderAddVideoSourceToolbar, this ); 2965 media.view.MediaFrame.MediaDetails.prototype.bindHandlers.apply( this, arguments ); 2966 2967 this.on( 'toolbar:render:replace-video', this.renderReplaceToolbar, this ); 2968 this.on( 'toolbar:render:add-video-source', this.renderAddSourceToolbar, this ); 2928 2969 this.on( 'toolbar:render:select-poster-image', this.renderSelectPosterImageToolbar, this ); 2929 2970 }, … … 2964 3005 } ) 2965 3006 ]); 2966 },2967 2968 renderVideoDetailsContent: function() {2969 var view = new media.view.VideoDetails({2970 controller: this,2971 model: this.state().media,2972 attachment: this.state().media.attachment2973 }).render();2974 2975 this.content.set( view );2976 },2977 2978 renderMenu: function( view ) {2979 var lastState = this.lastState(),2980 previous = lastState && lastState.id,2981 frame = this;2982 2983 view.set({2984 cancel: {2985 text: l10n.videoDetailsCancel,2986 priority: 20,2987 click: function() {2988 if ( previous ) {2989 frame.setState( previous );2990 } else {2991 frame.close();2992 }2993 }2994 },2995 separateCancel: new media.View({2996 className: 'separator',2997 priority: 402998 })2999 });3000 3001 },3002 3003 renderVideoDetailsToolbar: function() {3004 this.toolbar.set( new media.view.Toolbar({3005 controller: this,3006 items: {3007 select: {3008 style: 'primary',3009 text: l10n.update,3010 priority: 80,3011 3012 click: function() {3013 var controller = this.controller,3014 state = controller.state();3015 3016 controller.close();3017 3018 // not sure if we want to use wp.media.string.image which will create a shortcode or3019 // perhaps wp.html.string to at least to build the <img />3020 state.trigger( 'update', controller.media.toJSON() );3021 3022 // Restore and reset the default state.3023 controller.setState( controller.options.state );3024 controller.reset();3025 }3026 }3027 }3028 }) );3029 },3030 3031 renderReplaceVideoToolbar: function() {3032 this.toolbar.set( new media.view.Toolbar({3033 controller: this,3034 items: {3035 replace: {3036 style: 'primary',3037 text: l10n.replace,3038 priority: 80,3039 3040 click: function() {3041 var controller = this.controller,3042 state = controller.state(),3043 selection = state.get( 'selection' ),3044 attachment = selection.single();3045 3046 controller.media.changeAttachment( attachment, state.display( attachment ) );3047 3048 state.trigger( 'replace', controller.media.toJSON() );3049 3050 // Restore and reset the default state.3051 controller.setState( controller.options.state );3052 controller.reset();3053 }3054 }3055 }3056 }) );3057 },3058 3059 renderAddVideoSourceToolbar: function() {3060 this.toolbar.set( new media.view.Toolbar({3061 controller: this,3062 items: {3063 replace: {3064 style: 'primary',3065 text: l10n.videoAddSourceTitle,3066 priority: 80,3067 3068 click: function() {3069 var controller = this.controller,3070 state = controller.state(),3071 selection = state.get( 'selection' ),3072 attachment = selection.single();3073 3074 controller.media.setSource( attachment, state.display( attachment ) );3075 3076 state.trigger( 'add-source', controller.media.toJSON() );3077 3078 // Restore and reset the default state.3079 controller.setState( controller.options.state );3080 controller.reset();3081 }3082 }3083 }3084 }) );3085 3007 }, 3086 3008
Note: See TracChangeset
for help on using the changeset viewer.