All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scripts.sonar-panel.js Maven / Gradle / Ivy

There is a newer version: 4.0.0
Show newest version
/*
 * Licensed to Marvelution under one or more contributor license 
 * agreements.  See the NOTICE file distributed with this work 
 * for additional information regarding copyright ownership.
 * Marvelution licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

AJS.$.namespace("AJS.sonar.panel");

/**
 * Base object containing all the options for the panel
 */
AJS.sonar.panel.config = {};

/**
 * Initiate the Sonar panel
 * 
 * @param panel the configuration object for the panel
 */
AJS.sonar.panel.initPanel = function(panel) {
	AJS.sonar.panel.config = panel;
	var panelContainer = AJS.$(AJS.sonar.panel.config.panelContainer);
	for (var columnId in AJS.sonar.panel.config.layout) {
		AJS.$('
').attr({id: columnId}).addClass(AJS.sonar.panel.config.columnClass).appendTo(panelContainer); AJS.$(AJS.sonar.panel.config.layout[columnId]).each(function(index, gadgetId) { AJS.sonar.panel.addGadgetToColumn(columnId, gadgetId); }); } } /** * Add a gadget to a column in the panel * * @param columnId the columnId to add the gadget to * @param gadgetId the id of the gadget to add */ AJS.sonar.panel.addGadgetToColumn = function(columnId, gadgetId) { var gadget = AJS.sonar.panel.createGadgetBox(gadgetId); AJS.$('#' + columnId).prepend(gadget); } /** * Helper method to create the gadget draggable box * * @param gadgetId the id of the gadget * @return the jQuery wrapped div */ AJS.sonar.panel.createGadgetBox = function(gadgetId) { var header = AJS.$('
').addClass('dragbox-header').append( AJS.$('

').text(AJS.sonar.panel.config.gadgets[gadgetId].title) ).attr({gadget: gadgetId}); return AJS.$('
').attr({id: gadgetId}).addClass('dragbox').append(header).append( AJS.$('
').addClass('dragbox-content').append(AJS.$('