PluginProbe ʕ •ᴥ•ʔ
Starter Sites & Templates by Neve / 1.4.1
Starter Sites & Templates by Neve v1.4.1
1.4.1 1.4.0 1.3.0 1.2.29 1.2.28 1.2.6 1.2.7 1.2.8 1.2.9 trunk 1.0.10 1.0.11 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 1.1.20 1.1.21 1.1.22 1.1.23 1.1.24 1.1.25 1.1.26 1.1.27 1.1.28 1.1.29 1.1.3 1.1.30 1.1.31 1.1.32 1.1.33 1.1.34 1.1.35 1.1.36 1.1.37 1.1.38 1.1.39 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.3 1.2.4 1.2.5
templates-patterns-collection / elementor / src / data / store / index.js
templates-patterns-collection / elementor / src / data / store Last commit date
index.js 1 year ago
index.js
145 lines
1 import { registerStore } from '@wordpress/data';
2
3 const DEFAULT_STATE = {
4 isFetching: true,
5 isPreview: false,
6 tab: 'library',
7 templates: [],
8 library: {
9 items: [],
10 currentPage: 0,
11 totalPages: 0,
12 },
13 preview: {},
14 };
15
16 registerStore( 'tpc/elementor', {
17 reducer( state = DEFAULT_STATE, action ) {
18 if ( 'SET_FETCHING' === action.type ) {
19 return {
20 ...state,
21 isFetching: action.isFetching,
22 };
23 }
24
25 if ( 'TOGGLE_PREVIEW' === action.type ) {
26 return {
27 ...state,
28 isPreview: ! state.isPreview,
29 };
30 }
31
32 if ( 'UPDATE_CURRENT_TAB' === action.type ) {
33 return {
34 ...state,
35 tab: action.tab,
36 };
37 }
38
39 if ( 'UPDATE_TEMPLATES' === action.type ) {
40 return {
41 ...state,
42 templates: {
43 items: action.items,
44 currentPage: Number( action.currentPage ),
45 totalPages: Number( action.totalPages ),
46 },
47 };
48 }
49
50 if ( 'UPDATE_LIBRARY' === action.type ) {
51 return {
52 ...state,
53 library: {
54 items: action.items,
55 currentPage: Number( action.currentPage ),
56 totalPages: Number( action.totalPages ),
57 },
58 };
59 }
60
61 if ( 'SET_PREVIEW_DATA' === action.type ) {
62 return {
63 ...state,
64 preview: action.preview,
65 };
66 }
67
68 return state;
69 },
70
71 selectors: {
72 isFetching( state ) {
73 return state.isFetching;
74 },
75
76 isPreview( state ) {
77 return state.isPreview;
78 },
79
80 getCurrentTab( state ) {
81 return state.tab;
82 },
83
84 getTemplates( state ) {
85 return state.templates;
86 },
87
88 getLibrary( state ) {
89 return state.library;
90 },
91
92 getPreview( state ) {
93 return state.preview;
94 },
95 },
96
97 actions: {
98 setFetching( isFetching ) {
99 return {
100 type: 'SET_FETCHING',
101 isFetching,
102 };
103 },
104
105 togglePreview( isPreview ) {
106 return {
107 type: 'TOGGLE_PREVIEW',
108 isPreview,
109 };
110 },
111
112 updateCurrentTab( tab ) {
113 return {
114 type: 'UPDATE_CURRENT_TAB',
115 tab,
116 };
117 },
118
119 updateTemplates( items, currentPage, totalPages ) {
120 return {
121 type: 'UPDATE_TEMPLATES',
122 items,
123 currentPage,
124 totalPages,
125 };
126 },
127
128 updateLibrary( items, currentPage, totalPages ) {
129 return {
130 type: 'UPDATE_LIBRARY',
131 items,
132 currentPage,
133 totalPages,
134 };
135 },
136
137 setPreviewData( preview ) {
138 return {
139 type: 'SET_PREVIEW_DATA',
140 preview,
141 };
142 },
143 },
144 } );
145