Fossil SCM

s/f-post-/f-preview-/.

stephan 2020-05-06 17:37 fileedit-ajaxify
Commit 99bd288bcee68411d7eb85c14e560b8dbd1aafefc0d10d47e7250b6a0f81b969
+3 -3
--- src/fileedit.c
+++ src/fileedit.c
@@ -1603,15 +1603,15 @@
16031603
"data-tab-label='Preview'"
16041604
">");
16051605
16061606
CX("<div class='fileedit-options flex-container row'>");
16071607
CX("<button id='btn-preview-refresh' "
1608
- "data-f-post-from='fileedit-content-editor' "
1608
+ "data-f-preview-from='fileedit-content-editor' "
16091609
/* ^^^ text source elem ID*/
1610
- "data-f-post-via='_postPreview' "
1610
+ "data-f-preview-via='_postPreview' "
16111611
/* ^^^ fossil.page[methodName](content, callback) */
1612
- "data-f-post-to='fileedit-tab-preview-wrapper' "
1612
+ "data-f-preview-to='fileedit-tab-preview-wrapper' "
16131613
/* ^^^ dest elem ID */
16141614
">Refresh</button>");
16151615
/* Default preview rendering mode selection... */
16161616
previewRenderMode = fileedit_render_mode_for_mimetype(zFileMime);
16171617
style_select_list_int("select-preview-mode",
16181618
--- src/fileedit.c
+++ src/fileedit.c
@@ -1603,15 +1603,15 @@
1603 "data-tab-label='Preview'"
1604 ">");
1605
1606 CX("<div class='fileedit-options flex-container row'>");
1607 CX("<button id='btn-preview-refresh' "
1608 "data-f-post-from='fileedit-content-editor' "
1609 /* ^^^ text source elem ID*/
1610 "data-f-post-via='_postPreview' "
1611 /* ^^^ fossil.page[methodName](content, callback) */
1612 "data-f-post-to='fileedit-tab-preview-wrapper' "
1613 /* ^^^ dest elem ID */
1614 ">Refresh</button>");
1615 /* Default preview rendering mode selection... */
1616 previewRenderMode = fileedit_render_mode_for_mimetype(zFileMime);
1617 style_select_list_int("select-preview-mode",
1618
--- src/fileedit.c
+++ src/fileedit.c
@@ -1603,15 +1603,15 @@
1603 "data-tab-label='Preview'"
1604 ">");
1605
1606 CX("<div class='fileedit-options flex-container row'>");
1607 CX("<button id='btn-preview-refresh' "
1608 "data-f-preview-from='fileedit-content-editor' "
1609 /* ^^^ text source elem ID*/
1610 "data-f-preview-via='_postPreview' "
1611 /* ^^^ fossil.page[methodName](content, callback) */
1612 "data-f-preview-to='fileedit-tab-preview-wrapper' "
1613 /* ^^^ dest elem ID */
1614 ">Refresh</button>");
1615 /* Default preview rendering mode selection... */
1616 previewRenderMode = fileedit_render_mode_for_mimetype(zFileMime);
1617 style_select_list_int("select-preview-mode",
1618
--- src/fossil.bootstrap.js
+++ src/fossil.bootstrap.js
@@ -154,41 +154,41 @@
154154
- A CSS selector
155155
156156
Each element in the collection must have the following data
157157
attributes:
158158
159
- - data-f-post-from: the DOM element id of the text source
159
+ - data-f-preview-from: the DOM element id of the text source
160160
element. It must support .value to get the content.
161161
162
- - data-f-post-to: the DOM element id of the target "previewer"
162
+ - data-f-preview-to: the DOM element id of the target "previewer"
163163
element.
164164
165
- - data-f-post-via: the name of a method (see below).
165
+ - data-f-preview-via: the name of a method (see below).
166166
167
- - OPTIONAL data-f-post-as-text: a numeric value. Explained below.
167
+ - OPTIONAL data-f-preview-as-text: a numeric value. Explained below.
168168
169169
Each element gets a click handler added to it which does the
170170
following:
171171
172
- 1) Reads the content from its data-f-post-from element.
172
+ 1) Reads the content from its data-f-preview-from element.
173173
174174
2) Passes the content to
175175
methodNamespace[f-data-post-via](content,callback). f-data-post-via
176176
is responsible for submitting the preview HTTP request, including
177177
any parameters the request might require. When the response
178178
arrives, it must pass the content of the response to its 2nd
179179
argument, an auto-generated callback installed by this mechanism
180180
which...
181181
182
- 3) Assigns the response text to the data-f-post-to element. If
183
- data-f-post-as-text is '0' (the default) then the content
182
+ 3) Assigns the response text to the data-f-preview-to element. If
183
+ data-f-preview-as-text is '0' (the default) then the content
184184
is assigned to the target element's innerHTML property, else
185185
it is assigned to the element's textContent property.
186186
187187
188188
The methodNamespace (2nd argument) defaults to fossil.page, and
189
- data-f-post-via must be a single method name, not a
189
+ data-f-preview-via must be a single method name, not a
190190
property-access-style string. e.g. "myPreview" is legal but
191191
"foo.myPreview" is not (unless, of course, the method is actually
192192
named "foo.myPreview" (which is legal but would be
193193
unconventional)).
194194
@@ -195,16 +195,16 @@
195195
An example...
196196
197197
First an input button:
198198
199199
<button id='test-preview-connector'
200
- data-f-post-from='fileedit-content-editor' // elem ID
201
- data-f-post-via='myPreview' // method name
202
- data-f-post-to='fileedit-tab-preview-wrapper' // elem ID
200
+ data-f-preview-from='fileedit-content-editor' // elem ID
201
+ data-f-preview-via='myPreview' // method name
202
+ data-f-preview-to='fileedit-tab-preview-wrapper' // elem ID
203203
>Preview update</button>
204204
205
- And a sample data-f-post-via method:
205
+ And a sample data-f-preview-via method:
206206
207207
fossil.page.myPreview = function(content,callback){
208208
const fd = new FormData();
209209
fd.append('foo', ...);
210210
fossil.fetch('preview_forumpost',{
@@ -219,12 +219,12 @@
219219
220220
Then connect the parts with:
221221
222222
fossil.connectPagePreviewers('#test-preview-connector');
223223
224
- Note that the data-f-post-from, data-f-post-via, and
225
- data-f-post-to selector are not resolved until the button is
224
+ Note that the data-f-preview-from, data-f-preview-via, and
225
+ data-f-preview-to selector are not resolved until the button is
226226
actually clicked, so they need not exist in the DOM at the
227227
instant when the connection is set up, so long as they can be
228228
resolved when the preview-refreshing element is clicked.
229229
*/
230230
F.connectPagePreviewers = function f(selector,methodNamespace){
@@ -237,15 +237,15 @@
237237
methodNamespace = F.page;
238238
}
239239
selector.forEach(function(e){
240240
e.addEventListener(
241241
'click', function(r){
242
- const eTo = document.querySelector('#'+e.dataset.fPostTo),
243
- eFrom = document.querySelector('#'+e.dataset.fPostFrom),
244
- asText = +(e.dataset.fPostAsText || 0);
242
+ const eTo = document.querySelector('#'+e.dataset.fPreviewTo),
243
+ eFrom = document.querySelector('#'+e.dataset.fPreviewFrom),
244
+ asText = +(e.dataset.fPreviewAsText || 0);
245245
eTo.textContent = "Fetching preview...";
246
- methodNamespace[e.dataset.fPostVia](
246
+ methodNamespace[e.dataset.fPreviewVia](
247247
eFrom.value,
248248
(r)=>eTo[asText ? 'textContent' : 'innerHTML'] = r||''
249249
);
250250
}, false
251251
);
252252
--- src/fossil.bootstrap.js
+++ src/fossil.bootstrap.js
@@ -154,41 +154,41 @@
154 - A CSS selector
155
156 Each element in the collection must have the following data
157 attributes:
158
159 - data-f-post-from: the DOM element id of the text source
160 element. It must support .value to get the content.
161
162 - data-f-post-to: the DOM element id of the target "previewer"
163 element.
164
165 - data-f-post-via: the name of a method (see below).
166
167 - OPTIONAL data-f-post-as-text: a numeric value. Explained below.
168
169 Each element gets a click handler added to it which does the
170 following:
171
172 1) Reads the content from its data-f-post-from element.
173
174 2) Passes the content to
175 methodNamespace[f-data-post-via](content,callback). f-data-post-via
176 is responsible for submitting the preview HTTP request, including
177 any parameters the request might require. When the response
178 arrives, it must pass the content of the response to its 2nd
179 argument, an auto-generated callback installed by this mechanism
180 which...
181
182 3) Assigns the response text to the data-f-post-to element. If
183 data-f-post-as-text is '0' (the default) then the content
184 is assigned to the target element's innerHTML property, else
185 it is assigned to the element's textContent property.
186
187
188 The methodNamespace (2nd argument) defaults to fossil.page, and
189 data-f-post-via must be a single method name, not a
190 property-access-style string. e.g. "myPreview" is legal but
191 "foo.myPreview" is not (unless, of course, the method is actually
192 named "foo.myPreview" (which is legal but would be
193 unconventional)).
194
@@ -195,16 +195,16 @@
195 An example...
196
197 First an input button:
198
199 <button id='test-preview-connector'
200 data-f-post-from='fileedit-content-editor' // elem ID
201 data-f-post-via='myPreview' // method name
202 data-f-post-to='fileedit-tab-preview-wrapper' // elem ID
203 >Preview update</button>
204
205 And a sample data-f-post-via method:
206
207 fossil.page.myPreview = function(content,callback){
208 const fd = new FormData();
209 fd.append('foo', ...);
210 fossil.fetch('preview_forumpost',{
@@ -219,12 +219,12 @@
219
220 Then connect the parts with:
221
222 fossil.connectPagePreviewers('#test-preview-connector');
223
224 Note that the data-f-post-from, data-f-post-via, and
225 data-f-post-to selector are not resolved until the button is
226 actually clicked, so they need not exist in the DOM at the
227 instant when the connection is set up, so long as they can be
228 resolved when the preview-refreshing element is clicked.
229 */
230 F.connectPagePreviewers = function f(selector,methodNamespace){
@@ -237,15 +237,15 @@
237 methodNamespace = F.page;
238 }
239 selector.forEach(function(e){
240 e.addEventListener(
241 'click', function(r){
242 const eTo = document.querySelector('#'+e.dataset.fPostTo),
243 eFrom = document.querySelector('#'+e.dataset.fPostFrom),
244 asText = +(e.dataset.fPostAsText || 0);
245 eTo.textContent = "Fetching preview...";
246 methodNamespace[e.dataset.fPostVia](
247 eFrom.value,
248 (r)=>eTo[asText ? 'textContent' : 'innerHTML'] = r||''
249 );
250 }, false
251 );
252
--- src/fossil.bootstrap.js
+++ src/fossil.bootstrap.js
@@ -154,41 +154,41 @@
154 - A CSS selector
155
156 Each element in the collection must have the following data
157 attributes:
158
159 - data-f-preview-from: the DOM element id of the text source
160 element. It must support .value to get the content.
161
162 - data-f-preview-to: the DOM element id of the target "previewer"
163 element.
164
165 - data-f-preview-via: the name of a method (see below).
166
167 - OPTIONAL data-f-preview-as-text: a numeric value. Explained below.
168
169 Each element gets a click handler added to it which does the
170 following:
171
172 1) Reads the content from its data-f-preview-from element.
173
174 2) Passes the content to
175 methodNamespace[f-data-post-via](content,callback). f-data-post-via
176 is responsible for submitting the preview HTTP request, including
177 any parameters the request might require. When the response
178 arrives, it must pass the content of the response to its 2nd
179 argument, an auto-generated callback installed by this mechanism
180 which...
181
182 3) Assigns the response text to the data-f-preview-to element. If
183 data-f-preview-as-text is '0' (the default) then the content
184 is assigned to the target element's innerHTML property, else
185 it is assigned to the element's textContent property.
186
187
188 The methodNamespace (2nd argument) defaults to fossil.page, and
189 data-f-preview-via must be a single method name, not a
190 property-access-style string. e.g. "myPreview" is legal but
191 "foo.myPreview" is not (unless, of course, the method is actually
192 named "foo.myPreview" (which is legal but would be
193 unconventional)).
194
@@ -195,16 +195,16 @@
195 An example...
196
197 First an input button:
198
199 <button id='test-preview-connector'
200 data-f-preview-from='fileedit-content-editor' // elem ID
201 data-f-preview-via='myPreview' // method name
202 data-f-preview-to='fileedit-tab-preview-wrapper' // elem ID
203 >Preview update</button>
204
205 And a sample data-f-preview-via method:
206
207 fossil.page.myPreview = function(content,callback){
208 const fd = new FormData();
209 fd.append('foo', ...);
210 fossil.fetch('preview_forumpost',{
@@ -219,12 +219,12 @@
219
220 Then connect the parts with:
221
222 fossil.connectPagePreviewers('#test-preview-connector');
223
224 Note that the data-f-preview-from, data-f-preview-via, and
225 data-f-preview-to selector are not resolved until the button is
226 actually clicked, so they need not exist in the DOM at the
227 instant when the connection is set up, so long as they can be
228 resolved when the preview-refreshing element is clicked.
229 */
230 F.connectPagePreviewers = function f(selector,methodNamespace){
@@ -237,15 +237,15 @@
237 methodNamespace = F.page;
238 }
239 selector.forEach(function(e){
240 e.addEventListener(
241 'click', function(r){
242 const eTo = document.querySelector('#'+e.dataset.fPreviewTo),
243 eFrom = document.querySelector('#'+e.dataset.fPreviewFrom),
244 asText = +(e.dataset.fPreviewAsText || 0);
245 eTo.textContent = "Fetching preview...";
246 methodNamespace[e.dataset.fPreviewVia](
247 eFrom.value,
248 (r)=>eTo[asText ? 'textContent' : 'innerHTML'] = r||''
249 );
250 }, false
251 );
252

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button