Skip to content
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

Remove items from area if there's ten more than max. #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions assets/js/customizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@
settings = [ {} ];
}

// Remove items larger than 50.
settings = settings.slice(0, 50);
// Remove items if there's ten more than max.
settings = settings.slice(0, max + 10);

const items = [];
settings.forEach(item => {
Expand Down Expand Up @@ -315,7 +315,7 @@
this.nestedSortables = [];

// Set featured area globals.
max = featuredAreaList.dataset.max;
max = parseInt( featuredAreaList.dataset.max );
type = featuredAreaList.dataset.type;
subtype = featuredAreaList.dataset.subtype.split(',');

Expand All @@ -342,8 +342,8 @@
settings = [ {} ];
}

// Remove items larger than 50.
settings = settings.slice(0, 50);
// Remove items if there's ten more than max.
settings = settings.slice(0, max + 10);

// Add items from settings to the DOM.
settings.forEach(item => {
Expand Down
6 changes: 3 additions & 3 deletions dist/js/customizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ this.search("")
document.getElementById("featured-items-search-input").addEventListener("keyup",(event=>this.onInputChange(event)))
document.addEventListener("click",(event=>{event.target.classList.contains("add-featured-item")||isChildOf(event.target,"featured-item-container")||this.close()}))
document.querySelector("#featured-items-search-panel .customize-section-back").addEventListener("click",(event=>this.close()))}setItems(settings){try{settings=JSON.parse(settings)}catch(e){console.log(e)
settings=[{}]}settings=settings.slice(0,50)
settings=[{}]}settings=settings.slice(0,max+10)
const items=[]
settings.forEach((item=>{null!=item&&items.push(parseInt(item.id))}))
this.featuredAreaItems=items}open(settings){document.querySelector("body").classList.add("adding-featured-items")
Expand All @@ -61,13 +61,13 @@ body.classList.add("searching")
var search_item_tpl=this.searchResult.querySelectorAll(".featured-item-tpl");[].forEach.call(search_item_tpl,(function(item){item.remove()}))
window.fetch(wpApiSettings.root+wpFeaturedContentApiSettings.base+"posts",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","X-WP-Nonce":wpApiSettings.nonce},body:JSON.stringify({s:search,type:type,subtype:subtype,list:this.featuredArea,items:this.featuredAreaItems}),credentials:"same-origin"}).then((data=>data.json())).then((data=>{body.classList.remove("searching")
data.forEach(((obj,index)=>{new FeaturedItem(obj,this.searchResult)}))}))}),500)}}}featuredArea=new class{constructor(){this.nestedSortables=[]
max=featuredAreaList.dataset.max
max=parseInt(featuredAreaList.dataset.max)
type=featuredAreaList.dataset.type
subtype=featuredAreaList.dataset.subtype.split(",")
addItemButtons.forEach((button=>{button.addEventListener("click",(event=>this.toggleSearchPanel(event)))}))
clearOverflowButton.addEventListener("click",(event=>this.clearOverflow(event)))}loadSettings(){let settings=control.setting.get()
try{settings=JSON.parse(settings)}catch(e){console.log(e)
settings=[{}]}settings=settings.slice(0,50)
settings=[{}]}settings=settings.slice(0,max+10)
settings.forEach((item=>{null!=item&&new FeaturedItem(item,featuredAreaList)}))
this.toggleClearOverflow()
this.initSortables()}getDataAttributes(dataset){return Object.keys(dataset).reduce((function(object,key){object[key]=dataset[key]
Expand Down