
scales.scales.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mojarra-scales Show documentation
Show all versions of mojarra-scales Show documentation
This is the core for Mojarra Scales. It has everything that Scales offers minus the multi-file upload component dependencies due to their size.
The newest version!
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can obtain
* a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
* or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
* Sun designates this particular file as subject to the "Classpath" exception
* as provided by Sun in the GPL Version 2 section of the License file that
* accompanied this code. If applicable, add the following below the License
* Header, with the fields enclosed by brackets [] replaced by your own
* identifying information: "Portions Copyrighted [year]
* [name of copyright owner]"
*
* Contributor(s):
*
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
if (typeof YAHOO == "undefined") {
var YAHOO = {};
}
if (typeof scales == "undefined") {
var scales = {
scalesPanels: new Array(),
scalesLayouts: new Array(),
currentMaxZ: 1,
createPanel: function(clientId, config) {
YAHOO.util.Dom.setStyle(clientId, 'visibility', 'visible');
var panel = new YAHOO.widget.Panel(clientId, config);
panel.render();
scales.scalesPanels[clientId] = panel;
if (config.flat != true) {
YAHOO.util.Event.addListener(clientId, "mousedown", scales.bringToFront);
} else {
node = YAHOO.util.Dom.get(clientId);
YAHOO.util.Dom.setStyle(node.parentNode.parentNode, 'height', node.clientHeight + 'px');
}
scales.currentMaxZ++;
},
setZToMax: function (target) {
YAHOO.util.Dom.setStyle(target, 'z-index', ++scales.currentMaxZ);
},
bringToFront: function (event) {
scales.setZToMax(event.target.parentNode.parentNode);
},
showPanel: function(id) {
panel = scales.scalesPanels[id];
scales.scalesPanels[id].show();
scales.setZToMax(scales.scalesPanels[id].element);
},
hidePanel: function(id) {
scales.scalesPanels[id].hide();
},
resizeTabView: function(id, maxHeight) {
var tabs = YAHOO.util.Dom.getChildren(YAHOO.util.Dom.getElementsByClassName("yui-content", "div", YAHOO.util.Dom.get(id))[0]);
var tallestTab = 0;
for (i = 0; i != tabs.length; i++) {
var height = tabs[i].clientHeight;
tallestTab = (height > tallestTab) ? height : tallestTab;
}
maxHeight = maxHeight.replace("px", "");
if (maxHeight == "auto") {
maxHeight = tallestTab;
} else {
if (tallestTab > maxHeight) {
maxHeight = maxHeight;
}
}
maxHeight = maxHeight + "px";
for (i = 0; i != tabs.length; i++) {
YAHOO.util.Dom.setStyle(tabs[i], "height", maxHeight);
}
},
createEditor: function(config) {
var full = false,defaults = {};
YAHOO.widget.Toolbar.prototype.STR_COLLAPSE = 'Full Screen Mode';
var editor = new YAHOO.widget.Editor(config.clientId, {height: config.height, width: config.width, dompath: config.domPath, handleSubmit: true, animate: config.animate});
editor.on('toolbarLoaded', function() {
editor.toolbar.on('toolbarCollapsed', function() {
//Cancel the default action
YAHOO.util.Dom.setStyle(this.toolbar.get('cont'), 'display', 'block');
if (full === false) {
full = true; //Make it full screen
this.get('element_cont').setStyle('zIndex', '99999'); //For Safari
this.get('element_cont').setStyle('position', 'absolute');
this.get('element_cont').setStyle('top', '0');
this.get('element_cont').setStyle('left', '0');
this.get('element_cont').setStyle('width', YAHOO.util.Dom.getClientWidth() + 'px');
this.get('element_cont').setStyle('height', YAHOO.util.Dom.getClientHeight() + 'px');
YAHOO.util.Dom.setStyle(this.get('iframe').get('parentNode'), 'height', '100%');
YAHOO.util.Dom.setStyle(this.get('element_cont').get('firstChild'), 'height', '89%');
} else {
full = false; //Make it normal again
this.get('element_cont').setStyle('position', 'static');
this.get('element_cont').setStyle('top', '');
this.get('element_cont').setStyle('left', '');
this.get('element_cont').setStyle('width', defaults.width);
this.get('element_cont').setStyle('height', '');
YAHOO.util.Dom.setStyle(this.get('iframe').get('parentNode'), 'height', defaults.height);
YAHOO.util.Dom.setStyle(this.get('element_cont').get('firstChild'), 'height', '');
}
}, editor, true);
});
editor.on('afterRender', function() {
defaults.height = editor.get('height');
defaults.width = editor.get('width');
});
editor.render();
},
createLayoutManager: function(clientId, fullPage, units) {
var layout = null;
console.time('createLayoutManager');
if (fullPage === true) {
layout = new YAHOO.widget.Layout({units: units});
} else {
layout = new YAHOO.widget.Layout(clientId, {units: units});
}
layout.render();
scales.scalesLayouts[clientId] = layout;
YAHOO.util.Dom.setStyle(clientId, "visibility", "visible");
for (var index = 0 ; index < units.length ; index++) {
YAHOO.util.Dom.setStyle(units[index].body, "visibility", "visible");
}
console.timeEnd('createLayoutManager');
},
createTree: function(clientId, expandAll) {
var tree = new YAHOO.widget.TreeView(clientId);
tree.render();
if (expandAll) {
tree.expandAll();
}
},
createMenu: function(clientId, menuWidth, autoShow) {
var menu = new YAHOO.widget.Menu(clientId,{clicktohide: false, width: menuWidth, autosubmenudisplay: autoShow});
menu.render();
menu.show();
YAHOO.util.Dom.setStyle(clientId, 'position', 'relative');
},
createContextMenu: function(clientId, parentClientId, menuWidth, autoShow) {
var menu = new YAHOO.widget.ContextMenu(clientId, {width: menuWidth, autosubmenudisplay: autoShow,
trigger: parentClientId, clicktohide: true, visible: false});
menu.render(YAHOO.util.Dom.get(parentClientId));
},
createMenuBar: function(clientId, menuWidth, autoShow) {
var menuBar = new YAHOO.widget.MenuBar(clientId, {width: menuWidth, autosubmenudisplay: autoShow, clicktohide: true, visible: true});
menuBar.render();
menuBar.show();
},
createCarousel: function(clientId, config) {
var carousel = new YAHOO.widget.Carousel(clientId, config);
carousel.render();
if (config.width !== "") {
YAHOO.util.Dom.setStyle(clientId, "width", config.width);
YAHOO.util.Dom.getElementsByClassName("yui-carousel-element", "ol", clientId,
function(el) { YAHOO.util.Dom.setStyle(el, "width", config.width); });
}
carousel.show();
},
createDateSelector: function(clientId, config) {
YAHOO.util.Dom.get(clientId).readOnly = (config.enableManualInput == 'false');
return new Scales.DateSelector(config);
},
createColorPicker: function(clientId, config) {
var picker = new YAHOO.widget.ColorPicker(clientId, config);
picker.setValue([config.picker_red, config.picker_green, config.picker_blue], false);
picker.syncUI(false);
},
createChart: function(clientId, type, config, data, schema) {
var dataSource = new YAHOO.util.DataSource(data);
dataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
dataSource.responseSchema = { fields: schema };
if (type == "line") {
return new YAHOO.widget.LineChart(clientId, dataSource, config);
} else if (type == "bar") {
return new YAHOO.widget.BarChart(clientId, dataSource, config);
} else if (type == "column") {
return new YAHOO.widget.ColumnChart(clientId, dataSource, config);
} else if (type == "pie") {
return new YAHOO.widget.PieChart(clientId, dataSource, config);
} else if (type == "stackedbar") {
return new YAHOO.widget.StackedBarChart(clientId, dataSource, config);
} else if (type == "stackedcolumn") {
return new YAHOO.widget.StackedColumnChart(clientId, dataSource, config);
} else {
document.getElementById(clientId).innerHTML = "Chart type '" + type + "' was not recognized";
return null;
}
},
createSlider: function(clientId, config) {
var slider;
if (config.orientation == "horizontal") {
slider = YAHOO.widget.Slider.getHorizSlider(clientId+"_slider", clientId+"_sliderthumb", config.min, config.max, config.tick);
} else {
slider = YAHOO.widget.Slider.getVertSlider(clientId+"_slider", clientId+"_sliderthumb", config.min, config.max, config.tick);
}
slider.getRealValue = function() {
return Math.round(this.getValue() * config.scaleFactor);
};
// Subscribe to the onChange event to capture the new value from the slider
slider.subscribe("change", function(offsetFromStart) {
YAHOO.util.Dom.get(clientId).value = this.getRealValue(); // update hidden field
YAHOO.util.Dom.get(clientId+"_slider").title = this.getRealValue(); // Update the slider's div's title
// Update any input fields that might be tied to this slider
var elem = YAHOO.util.Dom.get(this.update);
if (elem !== null) {
elem.value = this.getRealValue();
}
}, slider, true);
slider.setValue(config.value);
slider.update = config.update;
},
createTabView: function(clientId, maxHeight) {
scales.resizeTabView(clientId, maxHeight);
var tabView = new YAHOO.widget.TabView(clientId);
YAHOO.util.Event.onContentReady(clientId, function() {
resizeTabView(clientId, maxHeight);
});
},
getLayout: function(id) {
return scales.scalesLayouts[id];
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy