Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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;
// Build the initial panel layout
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);
});
}
if (!AJS.sonar.panel.config.readOnly) {
// Initialise the drag and drop panel
AJS.$(AJS.sonar.panel.config.columnSelector).sortable({
connectWith: AJS.sonar.panel.config.columnSelector,
handle: AJS.sonar.panel.config.handle,
cursor: AJS.sonar.panel.config.cursor,
placeholder: AJS.sonar.panel.config.placeHolder,
forcePlaceholderSize: true,
opacity: 0.4,
stop: AJS.sonar.panel.config.changeCallback
}).disableSelection();
AJS.$(AJS.sonar.panel.config.columnClass).sortable('refresh');
// Register the on-click event for the add gadget button
if (AJS.sonar.panel.config.addGadgetButton != '') {
AJS.$(AJS.sonar.panel.config.addGadgetButton).click(function(event) {
var popup = new AJS.Dialog(650, 500);
popup.addHeader(AJS.sonar.panel.config.addGadgetHeader);
popup.addPanel("Panel 1", "panel1");
var configuredGadgets = new Array();
AJS.$(AJS.sonar.panel.config.columnSelector).each(function() {
configuredGadgets = configuredGadgets.concat(AJS.$(this).sortable('toArray'));
});
var gadgetList = AJS.$('').addClass('gadgetList');
for (var gadgetId in AJS.sonar.panel.config.gadgets) {
var gadgetOption = AJS.$('');
AJS.$('').attr({
src: contextPath + "/download/resources/com.marvelution.jira.plugins.sonar/images/gadgets/sonar-" + gadgetId + "-thumb.png",
width: 120,
height: 60
}).appendTo(gadgetOption);
var buttons = AJS.$('').addClass('buttons');
if (configuredGadgets.indexOf(gadgetId) == -1) {
AJS.$('').attr({
id: 'add_' + gadgetId,
type: 'button',
value: AJS.sonar.panel.config.addButton
}).click(AJS.sonar.panel.handleGadgetAddRemoveEvent).appendTo(buttons);
} else {
AJS.$('').attr({
id: 'remove_' + gadgetId,
type: 'button',
value: AJS.sonar.panel.config.removeButton
}).click(AJS.sonar.panel.handleGadgetAddRemoveEvent).appendTo(buttons);
}
gadgetOption.append(buttons);
gadgetOption.append(AJS.$('').text(AJS.sonar.panel.config.gadgets[gadgetId].title));
gadgetOption.append(AJS.$('').text(AJS.sonar.panel.config.gadgets[gadgetId].description));
gadgetOption.hover(function() {
AJS.$(this).addClass('hover');
}, function() {
AJS.$(this).removeClass('hover');
});
gadgetList.append(gadgetOption);
}
popup.getCurrentPanel().body.append(gadgetList);
popup.addButton(AJS.sonar.panel.config.closeButton, function(dialog) {
dialog.hide();
});
popup.gotoPage(0);
popup.gotoPanel(0);
popup.show();
});
}
}
}
/**
* Event handler for adding or removing a gadget from the panel
*
* @param event the event that was triggered
*/
AJS.sonar.panel.handleGadgetAddRemoveEvent = function(event) {
var params = AJS.$(this).attr('id').split('_');
if (params[0] == 'add') {
AJS.sonar.panel.addGadgetToColumn(AJS.sonar.panel.config.defaultColumn, params[1]);
AJS.$(this).attr({id: 'remove_' + params[1], value: AJS.sonar.panel.config.removeButton});
} else {
AJS.$('#' + params[1]).remove();
AJS.$(this).attr({id: 'add_' + params[1], value: AJS.sonar.panel.config.addButton});
}
AJS.$(AJS.sonar.panel.config.columnSelector).sortable('refresh');
AJS.sonar.panel.config.changeCallback(event, null);
}
/**
* 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);
if (!AJS.sonar.panel.config.readOnly) {
gadget.hover(function() {
AJS.$(this).find('.menu').show();
}, function() {
AJS.$(this).find('.menu').hide();
});
}
AJS.$('#' + columnId).prepend(gadget);
AJS.$.ajax({
type: "GET",
url: contextPath + "/rest/sonar/1.0/gadgets/generateHtml",
dataType: 'html',
data: ({
projectId: AJS.sonar.panel.config.projectId,
gadgetId: gadgetId
}),
success: function(html) {
gadget.find('.dragbox-content').html(html);
},
error: function() {
alert('Something whent wrong when getting the HTML code for gadget ' + gadgetId);
}
});
}
/**
* 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)
).append(
AJS.$('').addClass('menu').append(
AJS.$('