forked from publiclab/plots2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract code to editorHelper for DRY publiclab#8478
- Loading branch information
Showing
2 changed files
with
20 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// used in editor.js & dragdrop.js | ||
const getEditorParams = (targetDiv) => { | ||
const closestCommentFormWrapper = targetDiv.closest('div.comment-form-wrapper'); // this returns null if there is no match | ||
let params = {}; | ||
// there are no .comment-form-wrappers on /wiki/edit or /wiki/new | ||
// these pages just have a single text-input form. | ||
if (closestCommentFormWrapper) { | ||
params['dSelected'] = $(closestCommentFormWrapper); | ||
// assign the ID of the textarea within the closest comment-form-wrapper | ||
params['textarea'] = closestCommentFormWrapper.querySelector('textarea').id; | ||
} else { | ||
// default to #text-input | ||
// #text-input ID should be unique, and the only comment form on /wiki/new & /wiki/edit | ||
params['textarea'] = 'text-input'; | ||
} | ||
return params; | ||
}; |