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 11:37:15 +00:00
parent 2778b48273
commit 15bc2f3ade
2 changed files with 15 additions and 11 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

@ -236,10 +236,7 @@ var et2_tabbox = et2_valueWidget.extend([et2_IInput],
// We can do this and not wind up with 2 because child is a template,
// which has special handling
// disabling immediate direct call for selected tab seems to have no recognisable impact and
// some widgets, eg. color-picker have problems with calling doLoadingFinished twice
// (color input gets re-rendered second time after hitting [Apply], if color-picker is in a tab)
//this._children[0].loadingFinished(promises);
this._children[0].loadingFinished(promises);
// Defer parsing & loading of other tabs until later
window.setTimeout(function() {