19 with "mandatory","'warn'"; |
19 with "mandatory","'warn'"; |
20 content; |
20 content; |
21 } |
21 } |
22 }; |
22 }; |
23 |
23 |
|
24 decl _activable(*level) alias - { |
|
25 | activable_sub:{ |
|
26 const "activity" labels("/active /inactive") { |
|
27 with "mandatory"{text *level}; |
|
28 content; |
|
29 } |
|
30 value "$activity"; |
|
31 const "has_activity","string-length($activity)>0"; |
|
32 | }, |
|
33 }; |
|
34 |
24 decl activable() alias - { |
35 decl activable() alias - { |
25 | activable_sub:{ |
36 _activable("warn") |
26 warning_labels("/active /inactive") { |
37 }; |
27 content; |
38 decl optional_activable() alias - { |
28 } |
39 _activable("no") |
29 | } |
40 }; |
30 }; |
41 |
31 decl activable_labels(*ptr) alias - { |
42 decl activable_labels(*ptr) alias - { |
32 optional_labels(*ptr) { |
43 optional_labels(*ptr) { |
33 with "subelements","'active inactive'"; |
44 with "subelements","'active inactive'"; |
34 content; |
45 content; |
35 } |
46 } |
254 this.element = id(elt_id); |
269 this.element = id(elt_id); |
255 this.args = args; |
270 this.args = args; |
256 [this.indexes, this.variables_options] = (variables.length>0) ? zip(...variables) : [[],[]]; |
271 [this.indexes, this.variables_options] = (variables.length>0) ? zip(...variables) : [[],[]]; |
257 this.indexes_length = this.indexes.length; |
272 this.indexes_length = this.indexes.length; |
258 this.enable_expr = enable_expr; |
273 this.enable_expr = enable_expr; |
|
274 this.enable_state = true; |
|
275 this.enable_displayed_state = true; |
|
276 this.enabled_elts = []; |
|
277 |
259 Object.keys(members).forEach(prop => this[prop]=members[prop]); |
278 Object.keys(members).forEach(prop => this[prop]=members[prop]); |
260 this.lastapply = this.indexes.map(() => undefined); |
279 this.lastapply = this.indexes.map(() => undefined); |
261 this.inhibit = this.indexes.map(() => undefined); |
280 this.inhibit = this.indexes.map(() => undefined); |
262 this.pending = this.indexes.map(() => undefined); |
281 this.pending = this.indexes.map(() => undefined); |
263 this.bound_uninhibit = this.uninhibit.bind(this); |
282 this.bound_uninhibit = this.uninhibit.bind(this); |
299 console.log(err); |
318 console.log(err); |
300 } |
319 } |
301 } |
320 } |
302 |
321 |
303 if(this.enable_expr){ |
322 if(this.enable_expr){ |
304 this.disabled_elt = null; |
|
305 this.enabled_elts = []; |
|
306 this.enable_state = false; |
323 this.enable_state = false; |
307 this.enable_displayed_state = false; |
324 this.enable_displayed_state = false; |
308 for(let child of Array.from(this.element.children)){ |
325 for(let child of Array.from(this.element.children)){ |
309 if(child.getAttribute("inkscape:label")=="disabled"){ |
326 let label = child.getAttribute("inkscape:label"); |
310 this.disabled_elt = child; |
327 if(label!="disabled"){ |
311 }else{ |
|
312 this.enabled_elts.push(child); |
328 this.enabled_elts.push(child); |
313 this.element.removeChild(child); |
329 this.element.removeChild(child); |
314 } |
330 } |
315 } |
331 } |
316 } |
332 } |
317 } |
333 } |
318 |
334 |
319 unsub(){ |
335 unsub(){ |
320 /* remove subsribers */ |
336 /* remove subsribers */ |
321 if(!this.unsubscribable) |
337 for(let i = 0; i < this.indexes_length; i++) { |
322 for(let i = 0; i < this.indexes_length; i++) { |
338 /* flush updates pending because of inhibition */ |
323 /* flush updates pending because of inhibition */ |
339 let inhibition = this.inhibit[i]; |
324 let inhibition = this.inhibit[i]; |
340 if(inhibition != undefined){ |
325 if(inhibition != undefined){ |
341 clearTimeout(inhibition); |
326 clearTimeout(inhibition); |
342 this.lastapply[i] = undefined; |
327 this.lastapply[i] = undefined; |
343 this.uninhibit(i); |
328 this.uninhibit(i); |
344 } |
329 } |
345 let deafened = this.deafen[i]; |
330 let deafened = this.deafen[i]; |
346 if(deafened != undefined){ |
331 if(deafened != undefined){ |
347 clearTimeout(deafened); |
332 clearTimeout(deafened); |
348 this.lastdispatch[i] = undefined; |
333 this.lastdispatch[i] = undefined; |
349 this.undeafen(i); |
334 this.undeafen(i); |
350 } |
335 } |
351 let index = this.indexes[i]; |
336 let index = this.indexes[i]; |
352 if(this.relativeness[i]) |
337 if(this.relativeness[i]) |
353 index += this.offset; |
338 index += this.offset; |
354 subscribers(index).delete(this); |
339 subscribers(index).delete(this); |
355 } |
340 } |
|
341 this.offset = 0; |
356 this.offset = 0; |
342 this.relativeness = undefined; |
357 this.relativeness = undefined; |
343 } |
358 } |
344 |
359 |
345 sub(new_offset=0, relativeness, container_id){ |
360 sub(new_offset=0, relativeness, container_id){ |
346 this.offset = new_offset; |
361 this.offset = new_offset; |
347 this.relativeness = relativeness; |
362 this.relativeness = relativeness; |
348 this.container_id = container_id ; |
363 this.container_id = container_id ; |
349 /* add this's subsribers */ |
364 /* add this's subsribers */ |
350 if(!this.unsubscribable) |
365 for(let i = 0; i < this.indexes_length; i++) { |
351 for(let i = 0; i < this.indexes_length; i++) { |
366 let index = this.get_variable_index(i); |
352 let index = this.get_variable_index(i); |
367 if(index == undefined) continue; |
353 if(index == undefined) continue; |
368 subscribers(index).add(this); |
354 subscribers(index).add(this); |
369 } |
355 } |
|
356 need_cache_apply.push(this); |
370 need_cache_apply.push(this); |
357 } |
371 } |
358 |
372 |
359 apply_cache() { |
373 apply_cache() { |
360 if(!this.unsubscribable) for(let index in this.indexes){ |
374 for(let index in this.indexes){ |
361 /* dispatch current cache in newly opened page widgets */ |
375 /* dispatch current cache in newly opened page widgets */ |
362 let realindex = this.get_variable_index(index); |
376 let realindex = this.get_variable_index(index); |
363 if(realindex == undefined) continue; |
377 if(realindex == undefined) continue; |
364 let cached_val = cache[realindex]; |
378 let cached_val = cache[realindex]; |
365 if(cached_val != undefined) |
379 if(cached_val != undefined) |