fixed color-picker shown twice if used in a tab-widget after apply, backport of

r48992: disabling immediate direct call to loadingFinished() for selected tab seems to have no recognisable impact
and some widgets, eg. color-picker have problems with calling doLoadingFinished twice
r49047: change tab loading again to initialise visible tab immediatly and gard et2_color / jPicker against being initialised twice
This commit is contained in:
Ralf Becker 2014-10-17 12:14:44 +00:00
parent 8ef066f283
commit b1f48200e6
2 changed files with 17 additions and 9 deletions

View File

@ -99,7 +99,11 @@ var et2_color = et2_inputWidget.extend(
this._super.call(this, arguments);
},
doLoadingFinished: function() {
doLoadingFinished: function()
{
// as tabs can cause a double loading, we check here if jPicker is already initialised
if (this.get_jPicker()) return;
this._super.apply(this, arguments);
var self = this;
@ -130,7 +134,7 @@ var et2_color = et2_inputWidget.extend(
setTimeout(function() {
//Regex to exclude invalid charachters from class identifier name, to be able to address the class name with jquery selector later.
var regExClassName = /[\[\]']+/g;
// Make the buttons look like all the others
jQuery("div.jPicker :button").addClass("et2_button et2_button_text");
@ -163,14 +167,17 @@ var et2_color = et2_inputWidget.extend(
/**
* Get the jPicker object for this widget, so further things can be done to it
*
* Id of jPicker node is either our id+'_jPicker' or our dom_id (no idea why).
*/
get_jPicker: function() {
if(jQuery.jPicker.List.length)
for(var i=0; i < jQuery.jPicker.List.length; ++i)
{
var self = this;
return jQuery(jQuery.jPicker.List.filter(function(elem,index) {
return (elem && elem.id == self.id + "_jPicker");
}))[0];
var node = jQuery.jPicker.List[i];
if (node && (node.id == this.id+'_jPicker' || node.id == this.dom_id))
{
return node;
}
}
return null;
},

View File

@ -242,6 +242,7 @@ var et2_tabbox = et2_valueWidget.extend([et2_IInput],
window.setTimeout(function() {
for (var i = 0; i < tabs.tabData.length; i++)
{
if (i == tabs.selected_index) continue;
tabs._loadTab(i,promises);
}
jQuery.when.apply(jQuery,promises).then(function() {
@ -343,7 +344,7 @@ var et2_tabbox = et2_valueWidget.extend([et2_IInput],
/**
* Gets the index of the currently active tab
*
*
* @returns {number}
*/
get_active_tab: function() {
@ -352,7 +353,7 @@ var et2_tabbox = et2_valueWidget.extend([et2_IInput],
/**
* Sets the currently active tab by index
*
*
* @param {number} _idx
*/
setActiveTab: function(_idx) {