-
Notifications
You must be signed in to change notification settings - Fork 160
Move authoring UI inline JS handlers to data attributes #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,13 +143,13 @@ We used to call them Bookmarks and Folders, now we call them Blogroll links and | |
|
|
||
| <td align="center"> | ||
|
|
||
| <a href="#" onclick="editBookmark( | ||
| '<s:property value="#bookmark.id"/>', | ||
| '<s:property value="#bookmark.name"/>', | ||
| '<s:property value="#bookmark.url"/>', | ||
| '<s:property value="#bookmark.feedUrl"/>', | ||
| '<s:property value="#bookmark.description"/>', | ||
| '<s:property value="#bookmark.image"/>' )"> | ||
| <a href="#" class="bookmark-edit-link" | ||
| data-bookmark-id="<s:property value="#bookmark.id"/>" | ||
| data-bookmark-name="<s:property value="#bookmark.name"/>" | ||
| data-bookmark-url="<s:property value="#bookmark.url"/>" | ||
| data-bookmark-feed-url="<s:property value="#bookmark.feedUrl"/>" | ||
| data-bookmark-description="<s:property value="#bookmark.description"/>" | ||
| data-bookmark-image="<s:property value="#bookmark.image"/>"> | ||
| <span class="glyphicon glyphicon-edit"></span> | ||
| </a> | ||
|
|
||
|
|
@@ -338,7 +338,7 @@ We used to call them Bookmarks and Folders, now we call them Blogroll links and | |
|
|
||
| function confirmDeleteFolder() { | ||
| $('#boomarks_delete_folder_folderId').val($('#bookmarks_folderId:first').val()); | ||
| $('#deleteBlogrollName').html('<s:property value="%{folder.name}"/>'); | ||
| $('#deleteBlogrollName').text('<s:property value="%{folder.name}"/>'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| $('#delete-blogroll-modal').modal({show: true}); | ||
| } | ||
|
|
||
|
|
@@ -700,12 +700,23 @@ We used to call them Bookmarks and Folders, now we call them Blogroll links and | |
| $('#bookmarkEdit_bean_image:first').val(''); | ||
| $('#bookmarkEdit_bean_feedUrl:first').val(''); | ||
|
|
||
| $('#subtitle_folder_name:first').html(originalName); | ||
| $('#subtitle_folder_name:first').text(originalName); | ||
|
|
||
| $('#addedit-bookmark-modal').modal({show: true}); | ||
| } | ||
|
|
||
|
|
||
| // Values come from data-* attributes and are bound via delegated listeners. | ||
| $(document).on('click', '.bookmark-edit-link', function (event) { | ||
| event.preventDefault(); | ||
| editBookmark($(this).attr('data-bookmark-id'), | ||
| $(this).attr('data-bookmark-name'), | ||
| $(this).attr('data-bookmark-url'), | ||
| $(this).attr('data-bookmark-feed-url'), | ||
| $(this).attr('data-bookmark-description'), | ||
| $(this).attr('data-bookmark-image')); | ||
| }); | ||
|
|
||
| function editBookmark(id, name, url, feedUrl, description, image) { | ||
|
|
||
| var saveBookmarkButton = $('#save_bookmark:first'); | ||
|
|
@@ -725,7 +736,7 @@ We used to call them Bookmarks and Folders, now we call them Blogroll links and | |
| $('#bookmarkEdit_bean_description:first').val(description); | ||
| $('#bookmarkEdit_bean_image:first').val(image); | ||
|
|
||
| $('#subtitle_folder_name:first').html(originalName); | ||
| $('#subtitle_folder_name:first').text(originalName); | ||
|
|
||
| $('#addedit-bookmark-modal').modal({show: true}); | ||
| } | ||
|
|
@@ -770,7 +781,7 @@ We used to call them Bookmarks and Folders, now we call them Blogroll links and | |
| elem.removeClass("alert-info"); | ||
| elem.removeClass("alert-danger"); | ||
| elem.addClass("alert-success"); | ||
| elem.html(message); | ||
| elem.text(message); | ||
|
|
||
| } else { | ||
| saveBookmarkButton.attr("disabled", true); | ||
|
|
@@ -789,7 +800,7 @@ We used to call them Bookmarks and Folders, now we call them Blogroll links and | |
| elem.removeClass("alert-info"); | ||
| elem.removeClass("alert-success"); | ||
| elem.addClass("alert-danger"); | ||
| elem.html(message); | ||
| elem.text(message); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,11 +55,11 @@ | |
| <s:set var="categoryName" value="#category.name" /> | ||
| <s:set var="categoryDesc" value="#category.description" /> | ||
| <s:set var="categoryImage" value="#category.image" /> | ||
| <a href="#" onclick="showCategoryEditModal( | ||
| '<s:property value="categoryId" />', | ||
| '<s:property value="categoryName"/>', | ||
| '<s:property value="categoryDesc"/>', | ||
| '<s:property value="categoryImage"/>' )"> | ||
| <a href="#" class="category-edit-link" | ||
| data-category-id="<s:property value="categoryId" />" | ||
| data-category-name="<s:property value="categoryName"/>" | ||
| data-category-desc="<s:property value="categoryDesc"/>" | ||
| data-category-image="<s:property value="categoryImage"/>"> | ||
| <span class="glyphicon glyphicon-edit"></span> | ||
| </a> | ||
|
|
||
|
|
@@ -71,10 +71,10 @@ | |
| <s:set var="categoryId" value="#category.id" /> | ||
| <s:set var="categoryName" value="#category.name" /> | ||
| <s:set var="categoryInUse" value="#category.inUse.toString()" /> | ||
| <a href="#" onclick="showCategoryDeleteModal( | ||
| '<s:property value="categoryId" />', | ||
| '<s:property value="categoryName" />', | ||
| <s:property value="categoryInUse"/> )" > | ||
| <a href="#" class="category-delete-link" | ||
| data-category-id="<s:property value="categoryId" />" | ||
| data-category-name="<s:property value="categoryName" />" | ||
| data-category-in-use="<s:property value="categoryInUse"/>"> | ||
| <span class="glyphicon glyphicon-trash"></span> | ||
| </a> | ||
|
|
||
|
|
@@ -288,7 +288,7 @@ | |
| function showCategoryDeleteModal( id, name, inUse ) { | ||
| $('#categoryRemove_removeId').val(id); | ||
| $('#categoryEdit_bean_name').val(name); | ||
| $('#category-name').html(name); | ||
| $('#category-name').text(name); | ||
| if ( inUse ) { | ||
| $('#category-in-use').css('display','block'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pre-existing, but since this function is being reworked: lines 294/297 toggle |
||
| $('#category-emtpy').css('display', 'none'); | ||
|
|
@@ -301,14 +301,15 @@ | |
| } | ||
|
|
||
| function populateCategorySelect(removeId) { | ||
| const allCategories = []; | ||
|
|
||
| <s:iterator value="allCategories" var="category"> | ||
| allCategories.push({ | ||
| id: '<s:property value="#category.id"/>', | ||
| name: '<s:property value="#category.name"/>' | ||
| }); | ||
| </s:iterator> | ||
| // Category names are author-supplied. They are rendered into data | ||
| // attributes below and read back as text here, so no name is ever | ||
| // parsed as JavaScript. | ||
| const allCategories = $('#category-option-data .category-option').map(function () { | ||
| return { | ||
| id: $(this).attr('data-category-id'), | ||
| name: $(this).attr('data-category-name') | ||
| }; | ||
| }).get(); | ||
|
|
||
| const select = $('#categoryRemove_targetCategoryId'); | ||
| select.empty(); | ||
|
|
@@ -319,4 +320,30 @@ | |
| }); | ||
| } | ||
|
|
||
| // Values come from data-* attributes and are bound via delegated listeners. | ||
| $(document).on('click', '.category-edit-link', function (event) { | ||
| event.preventDefault(); | ||
| showCategoryEditModal($(this).attr('data-category-id'), | ||
| $(this).attr('data-category-name'), | ||
| $(this).attr('data-category-desc'), | ||
| $(this).attr('data-category-image')); | ||
| }); | ||
|
|
||
| $(document).on('click', '.category-delete-link', function (event) { | ||
| event.preventDefault(); | ||
| showCategoryDeleteModal($(this).attr('data-category-id'), | ||
| $(this).attr('data-category-name'), | ||
| $(this).attr('data-category-in-use') === 'true'); | ||
| }); | ||
|
|
||
| </script> | ||
|
|
||
| <%-- Source data for the "move entries to" select, carried as escaped | ||
| attributes rather than generated JavaScript literals. --%> | ||
| <div id="category-option-data" style="display:none"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: the |
||
| <s:iterator value="allCategories" var="category"> | ||
| <span class="category-option" | ||
| data-category-id="<s:property value="#category.id"/>" | ||
| data-category-name="<s:property value="#category.name"/>"></span> | ||
| </s:iterator> | ||
| </div> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CreateWeblog.jsp:118consumes this same field with$('#themedescription').html(data.description), so a theme description is inert on Theme Edit but still rendered as markup on Create Weblog. Worth switching that call to.text()in this PR, since the audit test only scansjsps/editorand won't notice it.