-fix widget linking (see previous commit) and stateSet function (set all widgets without triggering the sync event)
-fix widget purging : now triggered at each edit, but purging tabs only when needed
This commit is contained in:
parent
9747397f59
commit
71be04b8fe
4 changed files with 26 additions and 25 deletions
|
|
@ -71,9 +71,8 @@ module.exports = {
|
|||
setTimeout(function(){
|
||||
if (WIDGETS[data[0]]!=undefined) {
|
||||
for (var i=WIDGETS[data[0]].length-1;i>=0;i--) {
|
||||
if (WIDGETS[data[0]][i].setValue && WIDGETS[data[0]][i].getValue) {
|
||||
WIDGETS[data[0]][i].setValue(data[1],send,true)
|
||||
break
|
||||
if (WIDGETS[data[0]][i].setValue) {
|
||||
WIDGETS[data[0]][i].setValue(data[1],send,false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ var updateDom = function(container,data) {
|
|||
// save state
|
||||
var scroll = $('#sidepanel').scrollTop(),
|
||||
state = actions.stateGet(),
|
||||
hadChildren = data.widgets||data.tabs||data.matrix||data.strips
|
||||
purgetabs = data.tabs?true:false
|
||||
|
||||
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ var updateDom = function(container,data) {
|
|||
newContainer.find('[data-tab]:first-child').click()
|
||||
|
||||
|
||||
if (container.attr('id')=='container' || container.hasClass('tab') || hadChildren) purgeStores()
|
||||
purgeStores(purgetabs)
|
||||
|
||||
// restore state
|
||||
actions.stateSet(state,false)
|
||||
|
|
|
|||
|
|
@ -1,29 +1,31 @@
|
|||
module.exports = function() {
|
||||
module.exports = function(purgetabs) {
|
||||
|
||||
// prune tabs store
|
||||
var count, newcount, formerBuffuredTabs, bufferedTabs
|
||||
|
||||
while (true) {
|
||||
// we need to do that several times since tabs are referenced in each of their parents
|
||||
if (purgetabs) {
|
||||
while (true) {
|
||||
// we need to do that several times since tabs are referenced in each of their parents
|
||||
|
||||
// get all buffered tabs
|
||||
formerBuffuredTabs = []
|
||||
for (i in TABS) {
|
||||
formerBuffuredTabs.push(TABS[i].tab[0])
|
||||
}
|
||||
|
||||
// remove deleted tabs that are not referenced (have no navigation link pointing to them)
|
||||
var $f = $(formerBuffuredTabs)
|
||||
for (i in TABS) {
|
||||
if (!($f.find(`[data-tab="${i}"]`).length || i== '#container')) {
|
||||
delete TABS[i]
|
||||
// get all buffered tabs
|
||||
formerBuffuredTabs = []
|
||||
for (i in TABS) {
|
||||
formerBuffuredTabs.push(TABS[i].tab[0])
|
||||
}
|
||||
|
||||
// remove deleted tabs that are not referenced (have no navigation link pointing to them)
|
||||
var $f = $(formerBuffuredTabs)
|
||||
for (i in TABS) {
|
||||
if (!($f.find(`[data-tab="${i}"]`).length || i== '#container')) {
|
||||
delete TABS[i]
|
||||
}
|
||||
}
|
||||
|
||||
newcount = Object.keys(TABS).length
|
||||
if (count == newcount) break
|
||||
count = newcount
|
||||
|
||||
}
|
||||
|
||||
newcount = Object.keys(TABS).length
|
||||
if (count == newcount) break
|
||||
count = newcount
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ module.exports.sync = function() {
|
|||
if (WIDGETS_LINKED[linkId] && WIDGETS_LINKED[linkId].length>1) {
|
||||
var v = widget.getValue()
|
||||
for (i in WIDGETS_LINKED[linkId]) {
|
||||
if (WIDGETS_LINKED[linkId][i]!=widget && WIDGETS_LINKED[linkId][i].setValue) {
|
||||
if (!WIDGETS_LINKED[linkId][i].is(widget) && WIDGETS_LINKED[linkId][i].setValue) {
|
||||
WIDGETS_LINKED[linkId][i].setValue(v,true,false)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue