Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | 1x 3x 1x 1x 163x 1x 61x 61x 1x 19x 19x 19x 19x 19x 19x 19x 19x 19x 1x 19x 19x 19x 19x 19x 1x 74x 74x 74x 1x 34x 34x 34x 1x | /*! * VisualEditor user interface FragmentWindow class. * * @copyright See AUTHORS.txt */ /** * Mixin for window for working with fragments of content. * * @class * @abstract * * @constructor * @param {Object} [config] Configuration options */ ve.ui.FragmentWindow = function VeUiFragmentWindow() { // Properties this.fragment = null; }; /* Inheritance */ OO.initClass( ve.ui.FragmentWindow ); /* Methods */ /** * Get the surface fragment the window is for. * * @return {ve.dm.SurfaceFragment|null} Surface fragment the window is for, null if the * window is closed */ ve.ui.FragmentWindow.prototype.getFragment = function () { return this.fragment; }; /** * @inheritdoc OO.ui.Dialog */ ve.ui.FragmentWindow.prototype.getActionWidgetConfig = function ( config ) { Iif ( config.action === 'done' && OO.ui.isMobile() ) { // Use label-less check icon on mobile (T228230) config = ve.extendObject( { icon: 'check', invisibleLabel: true }, config ); } return config; }; /** * @inheritdoc OO.ui.Window * @throws {Error} If fragment was not provided through data parameter */ ve.ui.FragmentWindow.prototype.getSetupProcess = function ( data, process ) { data = data || {}; return process.first( function () { Iif ( !( data.fragment instanceof ve.dm.SurfaceFragment ) ) { throw new Error( 'Cannot open dialog: opening data must contain a fragment' ); } this.fragment = data.fragment; this.initialFragment = data.fragment; this.selectFragmentOnClose = data.selectFragmentOnClose !== false; // Prefer this.initialFragment.getSelection() to this.previousSelection this.previousSelection = this.fragment.getSelection(); }, this ).next( function () { // Don't allow windows to be opened for insertion in readonly mode Iif ( !this.isEditing() && this.isReadOnly() ) { return ve.createDeferred().reject().promise(); } this.actions.setMode( this.getMode() ); }, this ); }; /** * @inheritdoc OO.ui.Window */ ve.ui.FragmentWindow.prototype.getTeardownProcess = function ( data, process ) { ve.track( 'activity.' + this.constructor.static.name, { action: 'dialog-' + ( data && data.action || 'abort' ) } ); return process.next( function () { this.fragment = null; this.initialFragment = null; this.previousSelection = null; }, this ); }; /** * Check if the fragment's surface is readOnly * * @return {boolean} Fragment's surface is readOnly */ ve.ui.FragmentWindow.prototype.isReadOnly = function () { var fragment = this.getFragment(), surface = fragment && fragment.getSurface(); return surface && surface.isReadOnly(); }; /** * Get a symbolic mode name. * * By default will return 'edit' if #isEditing is true, and 'insert' otherwise. * * If the surface model is in read-only mode, will return 'readonly'. * * @return {string} Symbolic mode name */ ve.ui.FragmentWindow.prototype.getMode = function () { Iif ( this.isReadOnly() ) { return 'readonly'; } Eif ( this.getFragment() ) { return this.isEditing() ? 'edit' : 'insert'; } return ''; }; /** * Check if the current fragment is editable by this window. * * @localdoc Returns true if the fragment being edited selects at least one model, * * @return {boolean} Fragment is editable by this window */ ve.ui.FragmentWindow.prototype.isEditing = function () { return !!this.fragment.getSelectedModels().length; }; |