Edit File by line
/home/barbar84/www/wp-admin/js
File: theme-plugin-editor.js
/**
[0] Fix | Delete
* @output wp-admin/js/theme-plugin-editor.js
[1] Fix | Delete
*/
[2] Fix | Delete
[3] Fix | Delete
/* eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1] }] */
[4] Fix | Delete
[5] Fix | Delete
if ( ! window.wp ) {
[6] Fix | Delete
window.wp = {};
[7] Fix | Delete
}
[8] Fix | Delete
[9] Fix | Delete
wp.themePluginEditor = (function( $ ) {
[10] Fix | Delete
'use strict';
[11] Fix | Delete
var component, TreeLinks,
[12] Fix | Delete
__ = wp.i18n.__, _n = wp.i18n._n, sprintf = wp.i18n.sprintf;
[13] Fix | Delete
[14] Fix | Delete
component = {
[15] Fix | Delete
codeEditor: {},
[16] Fix | Delete
instance: null,
[17] Fix | Delete
noticeElements: {},
[18] Fix | Delete
dirty: false,
[19] Fix | Delete
lintErrors: []
[20] Fix | Delete
};
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Initialize component.
[24] Fix | Delete
*
[25] Fix | Delete
* @since 4.9.0
[26] Fix | Delete
*
[27] Fix | Delete
* @param {jQuery} form - Form element.
[28] Fix | Delete
* @param {Object} settings - Settings.
[29] Fix | Delete
* @param {Object|boolean} settings.codeEditor - Code editor settings (or `false` if syntax highlighting is disabled).
[30] Fix | Delete
* @return {void}
[31] Fix | Delete
*/
[32] Fix | Delete
component.init = function init( form, settings ) {
[33] Fix | Delete
[34] Fix | Delete
component.form = form;
[35] Fix | Delete
if ( settings ) {
[36] Fix | Delete
$.extend( component, settings );
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
component.noticeTemplate = wp.template( 'wp-file-editor-notice' );
[40] Fix | Delete
component.noticesContainer = component.form.find( '.editor-notices' );
[41] Fix | Delete
component.submitButton = component.form.find( ':input[name=submit]' );
[42] Fix | Delete
component.spinner = component.form.find( '.submit .spinner' );
[43] Fix | Delete
component.form.on( 'submit', component.submit );
[44] Fix | Delete
component.textarea = component.form.find( '#newcontent' );
[45] Fix | Delete
component.textarea.on( 'change', component.onChange );
[46] Fix | Delete
component.warning = $( '.file-editor-warning' );
[47] Fix | Delete
component.docsLookUpButton = component.form.find( '#docs-lookup' );
[48] Fix | Delete
component.docsLookUpList = component.form.find( '#docs-list' );
[49] Fix | Delete
[50] Fix | Delete
if ( component.warning.length > 0 ) {
[51] Fix | Delete
component.showWarning();
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
if ( false !== component.codeEditor ) {
[55] Fix | Delete
/*
[56] Fix | Delete
* Defer adding notices until after DOM ready as workaround for WP Admin injecting
[57] Fix | Delete
* its own managed dismiss buttons and also to prevent the editor from showing a notice
[58] Fix | Delete
* when the file had linting errors to begin with.
[59] Fix | Delete
*/
[60] Fix | Delete
_.defer( function() {
[61] Fix | Delete
component.initCodeEditor();
[62] Fix | Delete
} );
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
$( component.initFileBrowser );
[66] Fix | Delete
[67] Fix | Delete
$( window ).on( 'beforeunload', function() {
[68] Fix | Delete
if ( component.dirty ) {
[69] Fix | Delete
return __( 'The changes you made will be lost if you navigate away from this page.' );
[70] Fix | Delete
}
[71] Fix | Delete
return undefined;
[72] Fix | Delete
} );
[73] Fix | Delete
[74] Fix | Delete
component.docsLookUpList.on( 'change', function() {
[75] Fix | Delete
var option = $( this ).val();
[76] Fix | Delete
if ( '' === option ) {
[77] Fix | Delete
component.docsLookUpButton.prop( 'disabled', true );
[78] Fix | Delete
} else {
[79] Fix | Delete
component.docsLookUpButton.prop( 'disabled', false );
[80] Fix | Delete
}
[81] Fix | Delete
} );
[82] Fix | Delete
};
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Set up and display the warning modal.
[86] Fix | Delete
*
[87] Fix | Delete
* @since 4.9.0
[88] Fix | Delete
* @return {void}
[89] Fix | Delete
*/
[90] Fix | Delete
component.showWarning = function() {
[91] Fix | Delete
// Get the text within the modal.
[92] Fix | Delete
var rawMessage = component.warning.find( '.file-editor-warning-message' ).text();
[93] Fix | Delete
// Hide all the #wpwrap content from assistive technologies.
[94] Fix | Delete
$( '#wpwrap' ).attr( 'aria-hidden', 'true' );
[95] Fix | Delete
// Detach the warning modal from its position and append it to the body.
[96] Fix | Delete
$( document.body )
[97] Fix | Delete
.addClass( 'modal-open' )
[98] Fix | Delete
.append( component.warning.detach() );
[99] Fix | Delete
// Reveal the modal and set focus on the go back button.
[100] Fix | Delete
component.warning
[101] Fix | Delete
.removeClass( 'hidden' )
[102] Fix | Delete
.find( '.file-editor-warning-go-back' ).trigger( 'focus' );
[103] Fix | Delete
// Get the links and buttons within the modal.
[104] Fix | Delete
component.warningTabbables = component.warning.find( 'a, button' );
[105] Fix | Delete
// Attach event handlers.
[106] Fix | Delete
component.warningTabbables.on( 'keydown', component.constrainTabbing );
[107] Fix | Delete
component.warning.on( 'click', '.file-editor-warning-dismiss', component.dismissWarning );
[108] Fix | Delete
// Make screen readers announce the warning message after a short delay (necessary for some screen readers).
[109] Fix | Delete
setTimeout( function() {
[110] Fix | Delete
wp.a11y.speak( wp.sanitize.stripTags( rawMessage.replace( /\s+/g, ' ' ) ), 'assertive' );
[111] Fix | Delete
}, 1000 );
[112] Fix | Delete
};
[113] Fix | Delete
[114] Fix | Delete
/**
[115] Fix | Delete
* Constrain tabbing within the warning modal.
[116] Fix | Delete
*
[117] Fix | Delete
* @since 4.9.0
[118] Fix | Delete
* @param {Object} event jQuery event object.
[119] Fix | Delete
* @return {void}
[120] Fix | Delete
*/
[121] Fix | Delete
component.constrainTabbing = function( event ) {
[122] Fix | Delete
var firstTabbable, lastTabbable;
[123] Fix | Delete
[124] Fix | Delete
if ( 9 !== event.which ) {
[125] Fix | Delete
return;
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
firstTabbable = component.warningTabbables.first()[0];
[129] Fix | Delete
lastTabbable = component.warningTabbables.last()[0];
[130] Fix | Delete
[131] Fix | Delete
if ( lastTabbable === event.target && ! event.shiftKey ) {
[132] Fix | Delete
firstTabbable.focus();
[133] Fix | Delete
event.preventDefault();
[134] Fix | Delete
} else if ( firstTabbable === event.target && event.shiftKey ) {
[135] Fix | Delete
lastTabbable.focus();
[136] Fix | Delete
event.preventDefault();
[137] Fix | Delete
}
[138] Fix | Delete
};
[139] Fix | Delete
[140] Fix | Delete
/**
[141] Fix | Delete
* Dismiss the warning modal.
[142] Fix | Delete
*
[143] Fix | Delete
* @since 4.9.0
[144] Fix | Delete
* @return {void}
[145] Fix | Delete
*/
[146] Fix | Delete
component.dismissWarning = function() {
[147] Fix | Delete
[148] Fix | Delete
wp.ajax.post( 'dismiss-wp-pointer', {
[149] Fix | Delete
pointer: component.themeOrPlugin + '_editor_notice'
[150] Fix | Delete
});
[151] Fix | Delete
[152] Fix | Delete
// Hide modal.
[153] Fix | Delete
component.warning.remove();
[154] Fix | Delete
$( '#wpwrap' ).removeAttr( 'aria-hidden' );
[155] Fix | Delete
$( 'body' ).removeClass( 'modal-open' );
[156] Fix | Delete
};
[157] Fix | Delete
[158] Fix | Delete
/**
[159] Fix | Delete
* Callback for when a change happens.
[160] Fix | Delete
*
[161] Fix | Delete
* @since 4.9.0
[162] Fix | Delete
* @return {void}
[163] Fix | Delete
*/
[164] Fix | Delete
component.onChange = function() {
[165] Fix | Delete
component.dirty = true;
[166] Fix | Delete
component.removeNotice( 'file_saved' );
[167] Fix | Delete
};
[168] Fix | Delete
[169] Fix | Delete
/**
[170] Fix | Delete
* Submit file via Ajax.
[171] Fix | Delete
*
[172] Fix | Delete
* @since 4.9.0
[173] Fix | Delete
* @param {jQuery.Event} event - Event.
[174] Fix | Delete
* @return {void}
[175] Fix | Delete
*/
[176] Fix | Delete
component.submit = function( event ) {
[177] Fix | Delete
var data = {}, request;
[178] Fix | Delete
event.preventDefault(); // Prevent form submission in favor of Ajax below.
[179] Fix | Delete
$.each( component.form.serializeArray(), function() {
[180] Fix | Delete
data[ this.name ] = this.value;
[181] Fix | Delete
} );
[182] Fix | Delete
[183] Fix | Delete
// Use value from codemirror if present.
[184] Fix | Delete
if ( component.instance ) {
[185] Fix | Delete
data.newcontent = component.instance.codemirror.getValue();
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
if ( component.isSaving ) {
[189] Fix | Delete
return;
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
// Scroll ot the line that has the error.
[193] Fix | Delete
if ( component.lintErrors.length ) {
[194] Fix | Delete
component.instance.codemirror.setCursor( component.lintErrors[0].from.line );
[195] Fix | Delete
return;
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
component.isSaving = true;
[199] Fix | Delete
component.textarea.prop( 'readonly', true );
[200] Fix | Delete
if ( component.instance ) {
[201] Fix | Delete
component.instance.codemirror.setOption( 'readOnly', true );
[202] Fix | Delete
}
[203] Fix | Delete
[204] Fix | Delete
component.spinner.addClass( 'is-active' );
[205] Fix | Delete
request = wp.ajax.post( 'edit-theme-plugin-file', data );
[206] Fix | Delete
[207] Fix | Delete
// Remove previous save notice before saving.
[208] Fix | Delete
if ( component.lastSaveNoticeCode ) {
[209] Fix | Delete
component.removeNotice( component.lastSaveNoticeCode );
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
request.done( function( response ) {
[213] Fix | Delete
component.lastSaveNoticeCode = 'file_saved';
[214] Fix | Delete
component.addNotice({
[215] Fix | Delete
code: component.lastSaveNoticeCode,
[216] Fix | Delete
type: 'success',
[217] Fix | Delete
message: response.message,
[218] Fix | Delete
dismissible: true
[219] Fix | Delete
});
[220] Fix | Delete
component.dirty = false;
[221] Fix | Delete
} );
[222] Fix | Delete
[223] Fix | Delete
request.fail( function( response ) {
[224] Fix | Delete
var notice = $.extend(
[225] Fix | Delete
{
[226] Fix | Delete
code: 'save_error',
[227] Fix | Delete
message: __( 'Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP.' )
[228] Fix | Delete
},
[229] Fix | Delete
response,
[230] Fix | Delete
{
[231] Fix | Delete
type: 'error',
[232] Fix | Delete
dismissible: true
[233] Fix | Delete
}
[234] Fix | Delete
);
[235] Fix | Delete
component.lastSaveNoticeCode = notice.code;
[236] Fix | Delete
component.addNotice( notice );
[237] Fix | Delete
} );
[238] Fix | Delete
[239] Fix | Delete
request.always( function() {
[240] Fix | Delete
component.spinner.removeClass( 'is-active' );
[241] Fix | Delete
component.isSaving = false;
[242] Fix | Delete
[243] Fix | Delete
component.textarea.prop( 'readonly', false );
[244] Fix | Delete
if ( component.instance ) {
[245] Fix | Delete
component.instance.codemirror.setOption( 'readOnly', false );
[246] Fix | Delete
}
[247] Fix | Delete
} );
[248] Fix | Delete
};
[249] Fix | Delete
[250] Fix | Delete
/**
[251] Fix | Delete
* Add notice.
[252] Fix | Delete
*
[253] Fix | Delete
* @since 4.9.0
[254] Fix | Delete
*
[255] Fix | Delete
* @param {Object} notice - Notice.
[256] Fix | Delete
* @param {string} notice.code - Code.
[257] Fix | Delete
* @param {string} notice.type - Type.
[258] Fix | Delete
* @param {string} notice.message - Message.
[259] Fix | Delete
* @param {boolean} [notice.dismissible=false] - Dismissible.
[260] Fix | Delete
* @param {Function} [notice.onDismiss] - Callback for when a user dismisses the notice.
[261] Fix | Delete
* @return {jQuery} Notice element.
[262] Fix | Delete
*/
[263] Fix | Delete
component.addNotice = function( notice ) {
[264] Fix | Delete
var noticeElement;
[265] Fix | Delete
[266] Fix | Delete
if ( ! notice.code ) {
[267] Fix | Delete
throw new Error( 'Missing code.' );
[268] Fix | Delete
}
[269] Fix | Delete
[270] Fix | Delete
// Only let one notice of a given type be displayed at a time.
[271] Fix | Delete
component.removeNotice( notice.code );
[272] Fix | Delete
[273] Fix | Delete
noticeElement = $( component.noticeTemplate( notice ) );
[274] Fix | Delete
noticeElement.hide();
[275] Fix | Delete
[276] Fix | Delete
noticeElement.find( '.notice-dismiss' ).on( 'click', function() {
[277] Fix | Delete
component.removeNotice( notice.code );
[278] Fix | Delete
if ( notice.onDismiss ) {
[279] Fix | Delete
notice.onDismiss( notice );
[280] Fix | Delete
}
[281] Fix | Delete
} );
[282] Fix | Delete
[283] Fix | Delete
wp.a11y.speak( notice.message );
[284] Fix | Delete
[285] Fix | Delete
component.noticesContainer.append( noticeElement );
[286] Fix | Delete
noticeElement.slideDown( 'fast' );
[287] Fix | Delete
component.noticeElements[ notice.code ] = noticeElement;
[288] Fix | Delete
return noticeElement;
[289] Fix | Delete
};
[290] Fix | Delete
[291] Fix | Delete
/**
[292] Fix | Delete
* Remove notice.
[293] Fix | Delete
*
[294] Fix | Delete
* @since 4.9.0
[295] Fix | Delete
*
[296] Fix | Delete
* @param {string} code - Notice code.
[297] Fix | Delete
* @return {boolean} Whether a notice was removed.
[298] Fix | Delete
*/
[299] Fix | Delete
component.removeNotice = function( code ) {
[300] Fix | Delete
if ( component.noticeElements[ code ] ) {
[301] Fix | Delete
component.noticeElements[ code ].slideUp( 'fast', function() {
[302] Fix | Delete
$( this ).remove();
[303] Fix | Delete
} );
[304] Fix | Delete
delete component.noticeElements[ code ];
[305] Fix | Delete
return true;
[306] Fix | Delete
}
[307] Fix | Delete
return false;
[308] Fix | Delete
};
[309] Fix | Delete
[310] Fix | Delete
/**
[311] Fix | Delete
* Initialize code editor.
[312] Fix | Delete
*
[313] Fix | Delete
* @since 4.9.0
[314] Fix | Delete
* @return {void}
[315] Fix | Delete
*/
[316] Fix | Delete
component.initCodeEditor = function initCodeEditor() {
[317] Fix | Delete
var codeEditorSettings, editor;
[318] Fix | Delete
[319] Fix | Delete
codeEditorSettings = $.extend( {}, component.codeEditor );
[320] Fix | Delete
[321] Fix | Delete
/**
[322] Fix | Delete
* Handle tabbing to the field before the editor.
[323] Fix | Delete
*
[324] Fix | Delete
* @since 4.9.0
[325] Fix | Delete
*
[326] Fix | Delete
* @return {void}
[327] Fix | Delete
*/
[328] Fix | Delete
codeEditorSettings.onTabPrevious = function() {
[329] Fix | Delete
$( '#templateside' ).find( ':tabbable' ).last().focus();
[330] Fix | Delete
};
[331] Fix | Delete
[332] Fix | Delete
/**
[333] Fix | Delete
* Handle tabbing to the field after the editor.
[334] Fix | Delete
*
[335] Fix | Delete
* @since 4.9.0
[336] Fix | Delete
*
[337] Fix | Delete
* @return {void}
[338] Fix | Delete
*/
[339] Fix | Delete
codeEditorSettings.onTabNext = function() {
[340] Fix | Delete
$( '#template' ).find( ':tabbable:not(.CodeMirror-code)' ).first().focus();
[341] Fix | Delete
};
[342] Fix | Delete
[343] Fix | Delete
/**
[344] Fix | Delete
* Handle change to the linting errors.
[345] Fix | Delete
*
[346] Fix | Delete
* @since 4.9.0
[347] Fix | Delete
*
[348] Fix | Delete
* @param {Array} errors - List of linting errors.
[349] Fix | Delete
* @return {void}
[350] Fix | Delete
*/
[351] Fix | Delete
codeEditorSettings.onChangeLintingErrors = function( errors ) {
[352] Fix | Delete
component.lintErrors = errors;
[353] Fix | Delete
[354] Fix | Delete
// Only disable the button in onUpdateErrorNotice when there are errors so users can still feel they can click the button.
[355] Fix | Delete
if ( 0 === errors.length ) {
[356] Fix | Delete
component.submitButton.toggleClass( 'disabled', false );
[357] Fix | Delete
}
[358] Fix | Delete
};
[359] Fix | Delete
[360] Fix | Delete
/**
[361] Fix | Delete
* Update error notice.
[362] Fix | Delete
*
[363] Fix | Delete
* @since 4.9.0
[364] Fix | Delete
*
[365] Fix | Delete
* @param {Array} errorAnnotations - Error annotations.
[366] Fix | Delete
* @return {void}
[367] Fix | Delete
*/
[368] Fix | Delete
codeEditorSettings.onUpdateErrorNotice = function onUpdateErrorNotice( errorAnnotations ) {
[369] Fix | Delete
var noticeElement;
[370] Fix | Delete
[371] Fix | Delete
component.submitButton.toggleClass( 'disabled', errorAnnotations.length > 0 );
[372] Fix | Delete
[373] Fix | Delete
if ( 0 !== errorAnnotations.length ) {
[374] Fix | Delete
noticeElement = component.addNotice({
[375] Fix | Delete
code: 'lint_errors',
[376] Fix | Delete
type: 'error',
[377] Fix | Delete
message: sprintf(
[378] Fix | Delete
/* translators: %s: Error count. */
[379] Fix | Delete
_n(
[380] Fix | Delete
'There is %s error which must be fixed before you can update this file.',
[381] Fix | Delete
'There are %s errors which must be fixed before you can update this file.',
[382] Fix | Delete
errorAnnotations.length
[383] Fix | Delete
),
[384] Fix | Delete
String( errorAnnotations.length )
[385] Fix | Delete
),
[386] Fix | Delete
dismissible: false
[387] Fix | Delete
});
[388] Fix | Delete
noticeElement.find( 'input[type=checkbox]' ).on( 'click', function() {
[389] Fix | Delete
codeEditorSettings.onChangeLintingErrors( [] );
[390] Fix | Delete
component.removeNotice( 'lint_errors' );
[391] Fix | Delete
} );
[392] Fix | Delete
} else {
[393] Fix | Delete
component.removeNotice( 'lint_errors' );
[394] Fix | Delete
}
[395] Fix | Delete
};
[396] Fix | Delete
[397] Fix | Delete
editor = wp.codeEditor.initialize( $( '#newcontent' ), codeEditorSettings );
[398] Fix | Delete
editor.codemirror.on( 'change', component.onChange );
[399] Fix | Delete
[400] Fix | Delete
// Improve the editor accessibility.
[401] Fix | Delete
$( editor.codemirror.display.lineDiv )
[402] Fix | Delete
.attr({
[403] Fix | Delete
role: 'textbox',
[404] Fix | Delete
'aria-multiline': 'true',
[405] Fix | Delete
'aria-labelledby': 'theme-plugin-editor-label',
[406] Fix | Delete
'aria-describedby': 'editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4'
[407] Fix | Delete
});
[408] Fix | Delete
[409] Fix | Delete
// Focus the editor when clicking on its label.
[410] Fix | Delete
$( '#theme-plugin-editor-label' ).on( 'click', function() {
[411] Fix | Delete
editor.codemirror.focus();
[412] Fix | Delete
});
[413] Fix | Delete
[414] Fix | Delete
component.instance = editor;
[415] Fix | Delete
};
[416] Fix | Delete
[417] Fix | Delete
/**
[418] Fix | Delete
* Initialization of the file browser's folder states.
[419] Fix | Delete
*
[420] Fix | Delete
* @since 4.9.0
[421] Fix | Delete
* @return {void}
[422] Fix | Delete
*/
[423] Fix | Delete
component.initFileBrowser = function initFileBrowser() {
[424] Fix | Delete
[425] Fix | Delete
var $templateside = $( '#templateside' );
[426] Fix | Delete
[427] Fix | Delete
// Collapse all folders.
[428] Fix | Delete
$templateside.find( '[role="group"]' ).parent().attr( 'aria-expanded', false );
[429] Fix | Delete
[430] Fix | Delete
// Expand ancestors to the current file.
[431] Fix | Delete
$templateside.find( '.notice' ).parents( '[aria-expanded]' ).attr( 'aria-expanded', true );
[432] Fix | Delete
[433] Fix | Delete
// Find Tree elements and enhance them.
[434] Fix | Delete
$templateside.find( '[role="tree"]' ).each( function() {
[435] Fix | Delete
var treeLinks = new TreeLinks( this );
[436] Fix | Delete
treeLinks.init();
[437] Fix | Delete
} );
[438] Fix | Delete
[439] Fix | Delete
// Scroll the current file into view.
[440] Fix | Delete
$templateside.find( '.current-file:first' ).each( function() {
[441] Fix | Delete
if ( this.scrollIntoViewIfNeeded ) {
[442] Fix | Delete
this.scrollIntoViewIfNeeded();
[443] Fix | Delete
} else {
[444] Fix | Delete
this.scrollIntoView( false );
[445] Fix | Delete
}
[446] Fix | Delete
} );
[447] Fix | Delete
};
[448] Fix | Delete
[449] Fix | Delete
/* jshint ignore:start */
[450] Fix | Delete
/* jscs:disable */
[451] Fix | Delete
/* eslint-disable */
[452] Fix | Delete
[453] Fix | Delete
/**
[454] Fix | Delete
* Creates a new TreeitemLink.
[455] Fix | Delete
*
[456] Fix | Delete
* @since 4.9.0
[457] Fix | Delete
* @class
[458] Fix | Delete
* @private
[459] Fix | Delete
* @see {@link https://www.w3.org/TR/wai-aria-practices-1.1/examples/treeview/treeview-2/treeview-2b.html|W3C Treeview Example}
[460] Fix | Delete
* @license W3C-20150513
[461] Fix | Delete
*/
[462] Fix | Delete
var TreeitemLink = (function () {
[463] Fix | Delete
/**
[464] Fix | Delete
* This content is licensed according to the W3C Software License at
[465] Fix | Delete
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
[466] Fix | Delete
*
[467] Fix | Delete
* File: TreeitemLink.js
[468] Fix | Delete
*
[469] Fix | Delete
* Desc: Treeitem widget that implements ARIA Authoring Practices
[470] Fix | Delete
* for a tree being used as a file viewer
[471] Fix | Delete
*
[472] Fix | Delete
* Author: Jon Gunderson, Ku Ja Eun and Nicholas Hoyt
[473] Fix | Delete
*/
[474] Fix | Delete
[475] Fix | Delete
/**
[476] Fix | Delete
* @constructor
[477] Fix | Delete
*
[478] Fix | Delete
* @desc
[479] Fix | Delete
* Treeitem object for representing the state and user interactions for a
[480] Fix | Delete
* treeItem widget
[481] Fix | Delete
*
[482] Fix | Delete
* @param node
[483] Fix | Delete
* An element with the role=tree attribute
[484] Fix | Delete
*/
[485] Fix | Delete
[486] Fix | Delete
var TreeitemLink = function (node, treeObj, group) {
[487] Fix | Delete
[488] Fix | Delete
// Check whether node is a DOM element.
[489] Fix | Delete
if (typeof node !== 'object') {
[490] Fix | Delete
return;
[491] Fix | Delete
}
[492] Fix | Delete
[493] Fix | Delete
node.tabIndex = -1;
[494] Fix | Delete
this.tree = treeObj;
[495] Fix | Delete
this.groupTreeitem = group;
[496] Fix | Delete
this.domNode = node;
[497] Fix | Delete
this.label = node.textContent.trim();
[498] Fix | Delete
this.stopDefaultClick = false;
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function