http://git-wip-us.apache.org/repos/asf/nifi/blob/bf3b1640/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group-ports.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group-ports.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group-ports.js index 7c75aa2..f5f44dd 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group-ports.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group-ports.js @@ -15,9 +15,46 @@ * limitations under the License. */ -/* global nf, d3 */ - -nf.RemoteProcessGroupPorts = (function () { +/* global define, module, require, exports */ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery', + 'd3', + 'nf.ErrorHandler', + 'nf.Common', + 'nf.Dialog', + 'nf.Client', + 'nf.CanvasUtils', + 'nf.ng.Bridge', + 'nf.RemoteProcessGroup'], + function ($, d3, errorHandler, common, dialog, client, canvasUtils, angularBridge, nfRemoteProcessGroup) { + return (nf.RemoteProcessGroupPorts = factory($, d3, errorHandler, common, dialog, client, canvasUtils, angularBridge, nfRemoteProcessGroup)); + }); + } else if (typeof exports === 'object' && typeof module === 'object') { + module.exports = (nf.RemoteProcessGroupPorts = + factory(require('jquery'), + require('d3'), + require('nf.ErrorHandler'), + require('nf.Common'), + require('nf.Dialog'), + require('nf.Client'), + require('nf.CanvasUtils'), + require('nf.ng.Bridge'), + require('nf.RemoteProcessGroup'))); + } else { + nf.RemoteProcessGroupPorts = factory(root.$, + root.d3, + root.nf.ErrorHandler, + root.nf.Common, + root.nf.Dialog, + root.nf.Client, + root.nf.CanvasUtils, + root.nf.ng.Bridge, + root.nf.RemoteProcessGroup); + } +}(this, function ($, d3, errorHandler, common, dialog, client, canvasUtils, angularBridge, nfRemoteProcessGroup) { + 'use strict'; /** * Initializes the remote port configuration dialog. @@ -45,7 +82,7 @@ nf.RemoteProcessGroupPorts = (function () { // create the remote process group details var remoteProcessGroupPortEntity = { - 'revision': nf.Client.getRevision(remoteProcessGroupData), + 'revision': client.getRevision(remoteProcessGroupData), 'remoteProcessGroupPort': { id: remotePortId, groupId: remoteProcessGroupId, @@ -92,22 +129,22 @@ nf.RemoteProcessGroupPorts = (function () { if (errors.length === 1) { content = $('<span></span>').text(errors[0]); } else { - content = nf.Common.formatUnorderedList(errors); + content = common.formatUnorderedList(errors); } - nf.Dialog.showOkDialog({ + dialog.showOkDialog({ dialogContent: content, headerText: 'Remote Process Group Ports' }); } else { - nf.ErrorHandler.handleAjaxError(xhr, status, error); + errorHandler.handleAjaxError(xhr, status, error); } }).always(function () { // close the dialog $('#remote-port-configuration').modal('hide'); }); } else { - nf.Dialog.showOkDialog({ + dialog.showOkDialog({ headerText: 'Remote Process Group Ports', dialogContent: 'Concurrent tasks must be an integer value.' }); @@ -165,9 +202,9 @@ nf.RemoteProcessGroupPorts = (function () { var remoteProcessGroupData = remoteProcessGroup.datum(); // if can modify, the over status of this node may have changed - if (nf.CanvasUtils.canModify(remoteProcessGroup)) { + if (canvasUtils.canModify(remoteProcessGroup)) { // reload the remote process group - nf.RemoteProcessGroup.reload(remoteProcessGroupData.id); + nfRemoteProcessGroup.reload(remoteProcessGroupData.id); } // hide the dialog @@ -184,8 +221,8 @@ nf.RemoteProcessGroupPorts = (function () { // clear any tooltips var dialog = $('#remote-process-group-ports'); - nf.Common.cleanUpTooltips(dialog, 'div.remote-port-removed'); - nf.Common.cleanUpTooltips(dialog, 'div.concurrent-tasks-info'); + common.cleanUpTooltips(dialog, 'div.remote-port-removed'); + common.cleanUpTooltips(dialog, 'div.concurrent-tasks-info'); // clear the input and output ports $('#remote-process-group-input-ports-container').empty(); @@ -203,7 +240,7 @@ nf.RemoteProcessGroupPorts = (function () { * @argument {string} portType The type of port */ var createPortOption = function (container, port, portType) { - var portId = nf.Common.escapeHtml(port.id); + var portId = common.escapeHtml(port.id); var portContainer = $('<div class="remote-port-container"></div>').appendTo(container); var portContainerEditContainer = $('<div class="remote-port-edit-container"></div>').appendTo(portContainer); var portContainerDetailsContainer = $('<div class="remote-port-details-container"></div>').appendTo(portContainer); @@ -213,25 +250,25 @@ nf.RemoteProcessGroupPorts = (function () { var remoteProcessGroup = d3.select('#id-' + remoteProcessGroupId); // if can modify, support updating the remote group port - if (nf.CanvasUtils.canModify(remoteProcessGroup)) { + if (canvasUtils.canModify(remoteProcessGroup)) { // show the enabled transmission switch var transmissionSwitch; if (port.connected === true) { if (port.transmitting === true) { - transmissionSwitch = (nf.ng.Bridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary enabled-active-transmission" aria-label="Toggle port transmission"></md-switch>'))(nf.ng.Bridge.rootScope)).appendTo(portContainerEditContainer); + transmissionSwitch = (angularBridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary enabled-active-transmission" aria-label="Toggle port transmission"></md-switch>'))(angularBridge.rootScope)).appendTo(portContainerEditContainer); transmissionSwitch.click(); } else { if (port.exists === true) { - transmissionSwitch = (nf.ng.Bridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary enabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(nf.ng.Bridge.rootScope)).appendTo(portContainerEditContainer); + transmissionSwitch = (angularBridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary enabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(angularBridge.rootScope)).appendTo(portContainerEditContainer); } else { - (nf.ng.Bridge.injector.get('$compile')($('<md-switch ng-disabled="true" style="margin:0px" class="md-primary disabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(nf.ng.Bridge.rootScope)).appendTo(portContainerEditContainer); + (angularBridge.injector.get('$compile')($('<md-switch ng-disabled="true" style="margin:0px" class="md-primary disabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(angularBridge.rootScope)).appendTo(portContainerEditContainer); } } } else { if (port.transmitting === true) { - (nf.ng.Bridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary disabled-active-transmission" aria-label="Toggle port transmission"></md-switch>'))(nf.ng.Bridge.rootScope)).appendTo(portContainerEditContainer); + (angularBridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary disabled-active-transmission" aria-label="Toggle port transmission"></md-switch>'))(angularBridge.rootScope)).appendTo(portContainerEditContainer); } else { - (nf.ng.Bridge.injector.get('$compile')($('<md-switch ng-disabled="true" style="margin:0px" class="md-primary disabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(nf.ng.Bridge.rootScope)).appendTo(portContainerEditContainer); + (angularBridge.injector.get('$compile')($('<md-switch ng-disabled="true" style="margin:0px" class="md-primary disabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(angularBridge.rootScope)).appendTo(portContainerEditContainer); } } @@ -255,14 +292,14 @@ nf.RemoteProcessGroupPorts = (function () { } } else if (port.exists === false) { $('<div class="remote-port-removed"/>').appendTo(portContainerEditContainer).qtip($.extend({}, - nf.Common.config.tooltipConfig, + common.config.tooltipConfig, { content: 'This port has been removed.' })); } // only allow modifications to transmission when the swtich is defined - if (nf.Common.isDefinedAndNotNull(transmissionSwitch)) { + if (common.isDefinedAndNotNull(transmissionSwitch)) { // create toggle for changing transmission state transmissionSwitch.click(function () { // get the component being edited @@ -277,7 +314,7 @@ nf.RemoteProcessGroupPorts = (function () { // create the remote process group details var remoteProcessGroupPortEntity = { - 'revision': nf.Client.getRevision(remoteProcessGroupData), + 'revision': client.getRevision(remoteProcessGroupData), 'remoteProcessGroupPort': { id: port.id, groupId: remoteProcessGroupId, @@ -312,7 +349,7 @@ nf.RemoteProcessGroupPorts = (function () { transmissionSwitch.removeClass('enabled-active-transmission enabled-inactive-transmission').addClass('disabled-inactive-transmission').off('click'); // hide the edit button - if (nf.Common.isDefinedAndNotNull(editRemotePort)) { + if (common.isDefinedAndNotNull(editRemotePort)) { editRemotePort.hide(); } } else { @@ -322,7 +359,7 @@ nf.RemoteProcessGroupPorts = (function () { transmissionSwitch.removeClass('enabled-active-transmission enabled-inactive-transmission').addClass('enabled-active-transmission'); // hide the edit button - if (nf.Common.isDefinedAndNotNull(editRemotePort)) { + if (common.isDefinedAndNotNull(editRemotePort)) { editRemotePort.hide(); } } else { @@ -330,7 +367,7 @@ nf.RemoteProcessGroupPorts = (function () { transmissionSwitch.removeClass('enabled-active-transmission enabled-inactive-transmission').addClass('enabled-inactive-transmission'); // show the edit button - if (nf.Common.isDefinedAndNotNull(editRemotePort)) { + if (common.isDefinedAndNotNull(editRemotePort)) { editRemotePort.show(); } } @@ -343,15 +380,15 @@ nf.RemoteProcessGroupPorts = (function () { if (errors.length === 1) { content = $('<span></span>').text(errors[0]); } else { - content = nf.Common.formatUnorderedList(errors); + content = common.formatUnorderedList(errors); } - nf.Dialog.showOkDialog({ + dialog.showOkDialog({ headerText: 'Remote Process Group Ports', dialogContent: content }); } else { - nf.ErrorHandler.handleAjaxError(xhr, status, error); + errorHandler.handleAjaxError(xhr, status, error); } }); }); @@ -359,9 +396,9 @@ nf.RemoteProcessGroupPorts = (function () { } else { // show the disabled transmission switch if (port.transmitting === true) { - (nf.ng.Bridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary disabled-active-transmission" aria-label="Toggle port transmission"></md-switch>'))(nf.ng.Bridge.rootScope)).appendTo(portContainerEditContainer); + (angularBridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary disabled-active-transmission" aria-label="Toggle port transmission"></md-switch>'))(angularBridge.rootScope)).appendTo(portContainerEditContainer); } else { - (nf.ng.Bridge.injector.get('$compile')($('<md-switch ng-disabled="true" style="margin:0px" class="md-primary disabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(nf.ng.Bridge.rootScope)).appendTo(portContainerEditContainer); + (angularBridge.injector.get('$compile')($('<md-switch ng-disabled="true" style="margin:0px" class="md-primary disabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(angularBridge.rootScope)).appendTo(portContainerEditContainer); } } @@ -373,7 +410,7 @@ nf.RemoteProcessGroupPorts = (function () { $('<div class="clear"></div>').appendTo(portContainerDetailsContainer); // add the comments for this port - if (nf.Common.isBlank(port.comments)) { + if (common.isBlank(port.comments)) { $('<div class="remote-port-description unset">No description specified.</div>').appendTo(portContainerDetailsContainer); } else { $('<div class="remote-port-description"></div>').text(port.comments).appendTo(portContainerDetailsContainer); @@ -394,7 +431,7 @@ nf.RemoteProcessGroupPorts = (function () { '<div class="processor-setting concurrent-tasks-info fa fa-question-circle"></div>' + '</div>' + '</div>').append(concurrentTasks).appendTo(concurrentTasksContainer).find('div.concurrent-tasks-info').qtip($.extend({}, - nf.Common.config.tooltipConfig, + common.config.tooltipConfig, { content: 'The number of tasks that should be concurrently scheduled for this port.' })); @@ -424,7 +461,7 @@ nf.RemoteProcessGroupPorts = (function () { portContainer.find('.ellipsis').ellipsis(); // inform Angular app values have changed - nf.ng.Bridge.digest(); + angularBridge.digest(); }; /** @@ -469,7 +506,7 @@ nf.RemoteProcessGroupPorts = (function () { */ showPorts: function (selection) { // if the specified component is a remote process group, load its properties - if (nf.CanvasUtils.isRemoteProcessGroup(selection)) { + if (canvasUtils.isRemoteProcessGroup(selection)) { var selectionData = selection.datum(); // load the properties for the specified component @@ -481,7 +518,7 @@ nf.RemoteProcessGroupPorts = (function () { var remoteProcessGroup = response.component; // set the model locally - nf.RemoteProcessGroup.set(response); + nfRemoteProcessGroup.set(response); // populate the port settings $('#remote-process-group-ports-id').text(remoteProcessGroup.id); @@ -490,7 +527,7 @@ nf.RemoteProcessGroupPorts = (function () { // get the contents var remoteProcessGroupContents = remoteProcessGroup.contents; - if (nf.Common.isDefinedAndNotNull(remoteProcessGroupContents)) { + if (common.isDefinedAndNotNull(remoteProcessGroupContents)) { var connectedInputPorts = []; var disconnectedInputPorts = []; @@ -514,7 +551,7 @@ nf.RemoteProcessGroupPorts = (function () { createPortOption(inputPortContainer, inputPort, 'input'); }); - if (nf.Common.isEmpty(connectedInputPorts) && nf.Common.isEmpty(disconnectedInputPorts)) { + if (common.isEmpty(connectedInputPorts) && common.isEmpty(disconnectedInputPorts)) { $('<div class="unset"></div>').text("No ports to display").appendTo(inputPortContainer); } @@ -541,15 +578,15 @@ nf.RemoteProcessGroupPorts = (function () { createPortOption(outputPortContainer, outputPort, 'output'); }); - if (nf.Common.isEmpty(connectedOutputPorts) && nf.Common.isEmpty(disconnectedOutputPorts)) { + if (common.isEmpty(connectedOutputPorts) && common.isEmpty(disconnectedOutputPorts)) { $('<div class="unset"></div>').text("No ports to display").appendTo(outputPortContainer); } } // show the details $('#remote-process-group-ports').modal('show'); - }).fail(nf.ErrorHandler.handleAjaxError); + }).fail(errorHandler.handleAjaxError); } } }; -}()); \ No newline at end of file +})); \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/nifi/blob/bf3b1640/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group.js index 1903e44..f487ca4 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group.js @@ -15,9 +15,42 @@ * limitations under the License. */ -/* global nf, d3 */ - -nf.RemoteProcessGroup = (function () { +/* global define, module, require, exports */ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery', + 'd3', + 'nf.Connection', + 'nf.Common', + 'nf.Client', + 'nf.CanvasUtils'], + function ($, d3, connection, common, client, canvasUtils) { + return (nf.RemoteProcessGroup = factory($, d3, connection, common, client, canvasUtils)); + }); + } else if (typeof exports === 'object' && typeof module === 'object') { + module.exports = (nf.RemoteProcessGroup = + factory(require('jquery'), + require('d3'), + require('nf.Connection'), + require('nf.Common'), + require('nf.Client'), + require('nf.CanvasUtils'))); + } else { + nf.RemoteProcessGroup = factory(root.$, + root.d3, + root.nf.Connection, + root.nf.Common, + root.nf.Client, + root.nf.CanvasUtils); + } +}(this, function ($, d3, connection, common, client, canvasUtils) { + 'use strict'; + + var nfConnectable; + var nfDraggable; + var nfSelectable; + var nfContextMenu; var PREVIEW_NAME_LENGTH = 30; @@ -55,7 +88,7 @@ nf.RemoteProcessGroup = (function () { * @param {object} d */ var getProcessGroupComments = function (d) { - if (nf.Common.isBlank(d.component.comments)) { + if (common.isBlank(d.component.comments)) { return 'No comments specified'; } else { return d.component.comments; @@ -90,7 +123,7 @@ nf.RemoteProcessGroup = (function () { 'class': 'remote-process-group component' }) .classed('selected', selected) - .call(nf.CanvasUtils.position); + .call(canvasUtils.position); // ---- // body @@ -145,7 +178,7 @@ nf.RemoteProcessGroup = (function () { }); // always support selection - remoteProcessGroup.call(nf.Selectable.activate).call(nf.ContextMenu.activate); + remoteProcessGroup.call(nfSelectable.activate).call(nfContextMenu.activate); }; // attempt of space between component count and icon for process group contents @@ -178,7 +211,7 @@ nf.RemoteProcessGroup = (function () { var details = remoteProcessGroup.select('g.remote-process-group-details'); // update the component behavior as appropriate - nf.CanvasUtils.editable(remoteProcessGroup); + canvasUtils.editable(remoteProcessGroup, nfConnectable, nfDraggable); // if this processor is visible, render everything if (remoteProcessGroup.classed('visible')) { @@ -499,7 +532,7 @@ nf.RemoteProcessGroup = (function () { remoteProcessGroupUri.text(null).selectAll('title').remove(); // apply ellipsis to the remote process group name as necessary - nf.CanvasUtils.ellipsis(remoteProcessGroupUri, d.component.targetUris); + canvasUtils.ellipsis(remoteProcessGroupUri, d.component.targetUris); }).append('title').text(function (d) { return d.component.name; }); @@ -530,15 +563,15 @@ nf.RemoteProcessGroup = (function () { // update the tip tip.text(function () { - if (d.component.targetSecure === true) { - return 'Site-to-Site is secure.'; - } else { - return 'Site-to-Site is NOT secure.'; - } - }); + if (d.component.targetSecure === true) { + return 'Site-to-Site is secure.'; + } else { + return 'Site-to-Site is NOT secure.'; + } + }); // add the tooltip - nf.CanvasUtils.canvasTooltip(tip, d3.select(this)); + canvasUtils.canvasTooltip(tip, d3.select(this)); }); // --------------- @@ -554,9 +587,9 @@ nf.RemoteProcessGroup = (function () { remoteProcessGroupComments.text(null).selectAll('tspan, title').remove(); // apply ellipsis to the port name as necessary - nf.CanvasUtils.ellipsis(remoteProcessGroupComments, getProcessGroupComments(d)); + canvasUtils.ellipsis(remoteProcessGroupComments, getProcessGroupComments(d)); }).classed('unset', function (d) { - return nf.Common.isBlank(d.component.comments); + return common.isBlank(d.component.comments); }).append('title').text(function (d) { return getProcessGroupComments(d); }); @@ -567,7 +600,7 @@ nf.RemoteProcessGroup = (function () { details.select('text.remote-process-group-last-refresh') .text(function (d) { - if (nf.Common.isDefinedAndNotNull(d.component.flowRefreshed)) { + if (common.isDefinedAndNotNull(d.component.flowRefreshed)) { return d.component.flowRefreshed; } else { return 'Remote flow not current'; @@ -583,7 +616,7 @@ nf.RemoteProcessGroup = (function () { remoteProcessGroupName.text(null).selectAll('title').remove(); // apply ellipsis to the remote process group name as necessary - nf.CanvasUtils.ellipsis(remoteProcessGroupName, d.component.name); + canvasUtils.ellipsis(remoteProcessGroupName, d.component.name); }).append('title').text(function (d) { return d.component.name; }); @@ -647,13 +680,13 @@ nf.RemoteProcessGroup = (function () { // sent count value updated.select('text.remote-process-group-sent tspan.count') .text(function (d) { - return nf.Common.substringBeforeFirst(d.status.aggregateSnapshot.sent, ' '); + return common.substringBeforeFirst(d.status.aggregateSnapshot.sent, ' '); }); // sent size value updated.select('text.remote-process-group-sent tspan.size') .text(function (d) { - return ' ' + nf.Common.substringAfterFirst(d.status.aggregateSnapshot.sent, ' '); + return ' ' + common.substringAfterFirst(d.status.aggregateSnapshot.sent, ' '); }); // sent ports value @@ -671,13 +704,13 @@ nf.RemoteProcessGroup = (function () { // received count value updated.select('text.remote-process-group-received tspan.count') .text(function (d) { - return nf.Common.substringBeforeFirst(d.status.aggregateSnapshot.received, ' '); + return common.substringBeforeFirst(d.status.aggregateSnapshot.received, ' '); }); // received size value updated.select('text.remote-process-group-received tspan.size') .text(function (d) { - return ' ' + nf.Common.substringAfterFirst(d.status.aggregateSnapshot.received, ' '); + return ' ' + common.substringAfterFirst(d.status.aggregateSnapshot.received, ' '); }); // -------------------- @@ -690,7 +723,7 @@ nf.RemoteProcessGroup = (function () { .text(function (d) { var icon = ''; if (d.permissions.canRead) { - if (!nf.Common.isEmpty(d.component.authorizationIssues)) { + if (!common.isEmpty(d.component.authorizationIssues)) { icon = '\uf071'; } else if (d.component.transmitting === true) { icon = '\uf140'; @@ -703,7 +736,7 @@ nf.RemoteProcessGroup = (function () { .attr('font-family', function (d) { var family = ''; if (d.permissions.canRead) { - if (!nf.Common.isEmpty(d.component.authorizationIssues) || d.component.transmitting) { + if (!common.isEmpty(d.component.authorizationIssues) || d.component.transmitting) { family = 'FontAwesome'; } else { family = 'flowfont'; @@ -712,20 +745,20 @@ nf.RemoteProcessGroup = (function () { return family; }) .classed('invalid', function (d) { - return d.permissions.canRead && !nf.Common.isEmpty(d.component.authorizationIssues); + return d.permissions.canRead && !common.isEmpty(d.component.authorizationIssues); }) .classed('transmitting', function (d) { - return d.permissions.canRead && nf.Common.isEmpty(d.component.authorizationIssues) && d.component.transmitting === true; + return d.permissions.canRead && common.isEmpty(d.component.authorizationIssues) && d.component.transmitting === true; }) .classed('not-transmitting', function (d) { - return d.permissions.canRead && nf.Common.isEmpty(d.component.authorizationIssues) && d.component.transmitting === false; + return d.permissions.canRead && common.isEmpty(d.component.authorizationIssues) && d.component.transmitting === false; }) .each(function (d) { // get the tip var tip = d3.select('#authorization-issues-' + d.id); // if there are validation errors generate a tooltip - if (d.permissions.canRead && !nf.Common.isEmpty(d.component.authorizationIssues)) { + if (d.permissions.canRead && !common.isEmpty(d.component.authorizationIssues)) { // create the tip if necessary if (tip.empty()) { tip = d3.select('#remote-process-group-tooltips').append('div') @@ -737,16 +770,16 @@ nf.RemoteProcessGroup = (function () { // update the tip tip.html(function () { - var list = nf.Common.formatUnorderedList(d.component.authorizationIssues); - if (list === null || list.length === 0) { - return ''; - } else { - return $('<div></div>').append(list).html(); - } - }); + var list = common.formatUnorderedList(d.component.authorizationIssues); + if (list === null || list.length === 0) { + return ''; + } else { + return $('<div></div>').append(list).html(); + } + }); // add the tooltip - nf.CanvasUtils.canvasTooltip(tip, d3.select(this)); + canvasUtils.canvasTooltip(tip, d3.select(this)); } else { if (!tip.empty()) { tip.remove(); @@ -762,7 +795,7 @@ nf.RemoteProcessGroup = (function () { // active thread count // ------------------- - nf.CanvasUtils.activeThreadCount(remoteProcessGroup, d, function (off) { + canvasUtils.activeThreadCount(remoteProcessGroup, d, function (off) { offset = off; }); @@ -771,10 +804,10 @@ nf.RemoteProcessGroup = (function () { // --------- remoteProcessGroup.select('rect.bulletin-background').classed('has-bulletins', function () { - return !nf.Common.isEmpty(d.status.aggregateSnapshot.bulletins); + return !common.isEmpty(d.status.aggregateSnapshot.bulletins); }); - nf.CanvasUtils.bulletins(remoteProcessGroup, d, function () { + canvasUtils.bulletins(remoteProcessGroup, d, function () { return d3.select('#remote-process-group-tooltips'); }, offset); }); @@ -807,11 +840,16 @@ nf.RemoteProcessGroup = (function () { }); }; - return { + var nfRemoteProcessGroup = { /** * Initializes of the Process Group handler. */ - init: function () { + init: function (connectable, draggable, selectable, contextMenu) { + nfConnectable = connectable; + nfDraggable = draggable; + nfSelectable = selectable; + nfContextMenu = contextMenu; + remoteProcessGroupMap = d3.map(); removedCache = d3.map(); addedCache = d3.map(); @@ -832,8 +870,8 @@ nf.RemoteProcessGroup = (function () { */ add: function (remoteProcessGroupEntities, options) { var selectAll = false; - if (nf.Common.isDefinedAndNotNull(options)) { - selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll; + if (common.isDefinedAndNotNull(options)) { + selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll; } // get the current time @@ -854,7 +892,7 @@ nf.RemoteProcessGroup = (function () { $.each(remoteProcessGroupEntities, function (_, remoteProcessGroupEntity) { add(remoteProcessGroupEntity); }); - } else if (nf.Common.isDefinedAndNotNull(remoteProcessGroupEntities)) { + } else if (common.isDefinedAndNotNull(remoteProcessGroupEntities)) { add(remoteProcessGroupEntities); } @@ -863,7 +901,7 @@ nf.RemoteProcessGroup = (function () { selection.enter().call(renderRemoteProcessGroups, selectAll); selection.call(updateRemoteProcessGroups); }, - + /** * Populates the graph with the specified remote process groups. * @@ -873,16 +911,16 @@ nf.RemoteProcessGroup = (function () { set: function (remoteProcessGroupEntities, options) { var selectAll = false; var transition = false; - if (nf.Common.isDefinedAndNotNull(options)) { - selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll; - transition = nf.Common.isDefinedAndNotNull(options.transition) ? options.transition : transition; + if (common.isDefinedAndNotNull(options)) { + selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll; + transition = common.isDefinedAndNotNull(options.transition) ? options.transition : transition; } var set = function (proposedRemoteProcessGroupEntity) { var currentRemoteProcessGroupEntity = remoteProcessGroupMap.get(proposedRemoteProcessGroupEntity.id); // set the remote process group if appropriate due to revision and wasn't previously removed - if (nf.Client.isNewerRevision(currentRemoteProcessGroupEntity, proposedRemoteProcessGroupEntity) && !removedCache.has(proposedRemoteProcessGroupEntity.id)) { + if (client.isNewerRevision(currentRemoteProcessGroupEntity, proposedRemoteProcessGroupEntity) && !removedCache.has(proposedRemoteProcessGroupEntity.id)) { remoteProcessGroupMap.set(proposedRemoteProcessGroupEntity.id, $.extend({ type: 'RemoteProcessGroup', dimensions: dimensions @@ -906,14 +944,14 @@ nf.RemoteProcessGroup = (function () { $.each(remoteProcessGroupEntities, function (_, remoteProcessGroupEntity) { set(remoteProcessGroupEntity); }); - } else if (nf.Common.isDefinedAndNotNull(remoteProcessGroupEntities)) { + } else if (common.isDefinedAndNotNull(remoteProcessGroupEntities)) { set(remoteProcessGroupEntities); } // apply the selection and handle all new remote process groups var selection = select(); selection.enter().call(renderRemoteProcessGroups, selectAll); - selection.call(updateRemoteProcessGroups).call(nf.CanvasUtils.position, transition); + selection.call(updateRemoteProcessGroups).call(canvasUtils.position, transition); selection.exit().call(removeRemoteProcessGroups); }, @@ -924,7 +962,7 @@ nf.RemoteProcessGroup = (function () { * @param {string} id */ get: function (id) { - if (nf.Common.isUndefined(id)) { + if (common.isUndefined(id)) { return remoteProcessGroupMap.values(); } else { return remoteProcessGroupMap.get(id); @@ -938,7 +976,7 @@ nf.RemoteProcessGroup = (function () { * @param {string} id Optional */ refresh: function (id) { - if (nf.Common.isDefinedAndNotNull(id)) { + if (common.isDefinedAndNotNull(id)) { d3.select('#id-' + id).call(updateRemoteProcessGroups); } else { d3.selectAll('g.remote-process-group').call(updateRemoteProcessGroups); @@ -966,13 +1004,13 @@ nf.RemoteProcessGroup = (function () { url: remoteProcessGroupEntity.uri, dataType: 'json' }).done(function (response) { - nf.RemoteProcessGroup.set(response); + nfRemoteProcessGroup.set(response); // reload the group's connections - var connections = nf.Connection.getComponentConnections(id); + var connections = connection.getComponentConnections(id); $.each(connections, function (_, connection) { if (connection.permissions.canRead) { - nf.Connection.reload(connection.id); + connection.reload(connection.id); } }); }); @@ -985,7 +1023,7 @@ nf.RemoteProcessGroup = (function () { * @param {string} id The id */ position: function (id) { - d3.select('#id-' + id).call(nf.CanvasUtils.position); + d3.select('#id-' + id).call(canvasUtils.position); }, /** @@ -1014,7 +1052,7 @@ nf.RemoteProcessGroup = (function () { * Removes all remote process groups. */ removeAll: function () { - nf.RemoteProcessGroup.remove(remoteProcessGroupMap.keys()); + nfRemoteProcessGroup.remove(remoteProcessGroupMap.keys()); }, /** @@ -1035,4 +1073,6 @@ nf.RemoteProcessGroup = (function () { expire(removedCache); } }; -}()); \ No newline at end of file + + return nfRemoteProcessGroup; +})); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi/blob/bf3b1640/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js index cf94ba2..88f6fb4 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js @@ -15,9 +15,48 @@ * limitations under the License. */ -/* global nf */ - -nf.ReportingTask = (function () { +/* global define, module, require, exports */ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery', + 'nf.ErrorHandler', + 'nf.Common', + 'nf.Dialog', + 'nf.Client', + 'nf.ControllerService', + 'nf.ControllerServices', + 'nf.UniversalCapture', + 'nf.CustomUi'], + function ($, errorHandler, common, dialog, client, controllerService, controllerServices, universalCapture, customUi) { + return (nf.ReportingTask = factory($, errorHandler, common, dialog, client, controllerService, controllerServices, universalCapture, customUi)); + }); + } else if (typeof exports === 'object' && typeof module === 'object') { + module.exports = (nf.ReportingTask = + factory(require('jquery'), + require('nf.ErrorHandler'), + require('nf.Common'), + require('nf.Dialog'), + require('nf.Client'), + require('nf.ControllerService'), + require('nf.ControllerServices'), + require('nf.UniversalCapture'), + require('nf.CustomUi'))); + } else { + nf.ReportingTask = factory(root.$, + root.nf.ErrorHandler, + root.nf.Common, + root.nf.Dialog, + root.nf.Client, + root.nf.ControllerService, + root.nf.ControllerServices, + root.nf.UniversalCapture, + root.nf.CustomUi); + } +}(this, function ($, errorHandler, common, dialog, client, controllerService, controllerServices, universalCapture, customUi) { + 'use strict'; + + var nfSettings; var config = { edit: 'edit', @@ -38,7 +77,7 @@ nf.ReportingTask = (function () { var getControllerServicesTable = function () { return $('#controller-services-table'); }; - + /** * Handle any expected reporting task configuration errors. * @@ -54,15 +93,15 @@ nf.ReportingTask = (function () { if (errors.length === 1) { content = $('<span></span>').text(errors[0]); } else { - content = nf.Common.formatUnorderedList(errors); + content = common.formatUnorderedList(errors); } - nf.Dialog.showOkDialog({ + dialog.showOkDialog({ dialogContent: content, headerText: 'Reporting Task' }); } else { - nf.ErrorHandler.handleAjaxError(xhr, status, error); + errorHandler.handleAjaxError(xhr, status, error); } }; @@ -102,7 +141,7 @@ nf.ReportingTask = (function () { } // check the scheduling period - if (nf.Common.isDefinedAndNotNull(schedulingPeriod) && schedulingPeriod.val() !== (entity.component['schedulingPeriod'] + '')) { + if (common.isDefinedAndNotNull(schedulingPeriod) && schedulingPeriod.val() !== (entity.component['schedulingPeriod'] + '')) { return true; } @@ -165,13 +204,13 @@ nf.ReportingTask = (function () { var errors = []; var reportingTask = details['component']; - if (nf.Common.isBlank(reportingTask['schedulingPeriod'])) { + if (common.isBlank(reportingTask['schedulingPeriod'])) { errors.push('Run schedule must be specified'); } if (errors.length > 0) { - nf.Dialog.showOkDialog({ - dialogContent: nf.Common.formatUnorderedList(errors), + dialog.showOkDialog({ + dialogContent: common.formatUnorderedList(errors), headerText: 'Reporting Task' }); return false; @@ -202,7 +241,7 @@ nf.ReportingTask = (function () { */ var setRunning = function (reportingTaskEntity, running) { var entity = { - 'revision': nf.Client.getRevision(reportingTaskEntity), + 'revision': client.getRevision(reportingTaskEntity), 'component': { 'id': reportingTaskEntity.id, 'state': running === true ? 'RUNNING' : 'STOPPED' @@ -218,8 +257,8 @@ nf.ReportingTask = (function () { }).done(function (response) { // update the task renderReportingTask(response); - nf.ControllerService.reloadReferencedServices(getControllerServicesTable(), response.component); - }).fail(nf.ErrorHandler.handleAjaxError); + controllerService.reloadReferencedServices(getControllerServicesTable(), response.component); + }).fail(errorHandler.handleAjaxError); }; /** @@ -233,7 +272,7 @@ nf.ReportingTask = (function () { // determine if changes have been made if (isSaveRequired()) { // see if those changes should be saved - nf.Dialog.showYesNoDialog({ + dialog.showYesNoDialog({ headerText: 'Save', dialogContent: 'Save changes before going to this Controller Service?', noHandler: function () { @@ -265,7 +304,7 @@ nf.ReportingTask = (function () { // ensure details are valid as far as we can tell if (validateDetails(updatedReportingTask)) { - updatedReportingTask['revision'] = nf.Client.getRevision(reportingTaskEntity); + updatedReportingTask['revision'] = client.getRevision(reportingTaskEntity); // update the selected component return $.ajax({ @@ -299,14 +338,16 @@ nf.ReportingTask = (function () { propertyName: propertyName }, dataType: 'json' - }).fail(nf.ErrorHandler.handleAjaxError); + }).fail(errorHandler.handleAjaxError); }; - return { + var nfReportingTask = { /** * Initializes the reporting task configuration dialog. */ - init: function () { + init: function (settings) { + nfSettings = settings; + // initialize the configuration dialog tabs $('#reporting-task-configuration-tabs').tabbs({ tabStyle: 'tab', @@ -324,7 +365,7 @@ nf.ReportingTask = (function () { }], select: function () { // remove all property detail dialogs - nf.UniversalCapture.removeAllPropertyDetailDialogs(); + universalCapture.removeAllPropertyDetailDialogs(); // update the property table size in case this is the first time its rendered if ($(this).text() === 'Properties') { @@ -349,13 +390,13 @@ nf.ReportingTask = (function () { $('#reporting-task-properties').propertytable('clear'); // clear the comments - nf.Common.clearField('read-only-reporting-task-comments'); + common.clearField('read-only-reporting-task-comments'); // removed the cached reporting task details $('#reporting-task-configuration').removeData('reportingTaskDetails'); }, open: function () { - nf.Common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0)); + common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0)); } } }); @@ -366,8 +407,8 @@ nf.ReportingTask = (function () { supportsGoTo: true, dialogContainer: '#new-reporting-task-property-container', descriptorDeferred: getReportingTaskPropertyDescriptor, - controllerServiceCreatedDeferred: function(response){ - return nf.ControllerServices.loadControllerServices(controllerServicesUri, $('#controller-services-table')); + controllerServiceCreatedDeferred: function (response) { + return controllerServices.loadControllerServices(controllerServicesUri, $('#controller-services-table')); }, goToServiceDeferred: goToServiceFromProperty }); @@ -391,8 +432,8 @@ nf.ReportingTask = (function () { supportsGoTo: true, dialogContainer: '#new-reporting-task-property-container', descriptorDeferred: getReportingTaskPropertyDescriptor, - controllerServiceCreatedDeferred: function(response){ - return nf.ControllerServices.loadControllerServices(controllerServicesUri, $('#controller-services-table')); + controllerServiceCreatedDeferred: function (response) { + return controllerServices.loadControllerServices(controllerServicesUri, $('#controller-services-table')); }, goToServiceDeferred: goToServiceFromProperty }); @@ -434,8 +475,8 @@ nf.ReportingTask = (function () { } // populate the reporting task settings - nf.Common.populateField('reporting-task-id', reportingTask['id']); - nf.Common.populateField('reporting-task-type', nf.Common.substringAfterLast(reportingTask['type'], '.')); + common.populateField('reporting-task-id', reportingTask['id']); + common.populateField('reporting-task-type', common.substringAfterLast(reportingTask['type'], '.')); $('#reporting-task-name').val(reportingTask['name']); $('#reporting-task-enabled').removeClass('checkbox-unchecked checkbox-checked').addClass(reportingTaskEnableStyle); $('#reporting-task-comments').val(reportingTask['comments']); @@ -489,10 +530,10 @@ nf.ReportingTask = (function () { // close all fields currently being edited $('#reporting-task-properties').propertytable('saveRow'); - // save the reporting task - saveReportingTask(reportingTaskEntity).done(function (response) { - // reload the reporting task - nf.ControllerService.reloadReferencedServices(getControllerServicesTable(), response.component); + // save the reporting task + saveReportingTask(reportingTaskEntity).done(function (response) { + // reload the reporting task + controllerService.reloadReferencedServices(getControllerServicesTable(), response.component); // close the details panel $('#reporting-task-configuration').modal('hide'); @@ -515,7 +556,7 @@ nf.ReportingTask = (function () { }]; // determine if we should show the advanced button - if (nf.Common.isDefinedAndNotNull(reportingTask.customUiUrl) && reportingTask.customUiUrl !== '') { + if (common.isDefinedAndNotNull(reportingTask.customUiUrl) && reportingTask.customUiUrl !== '') { buttons.push({ buttonText: 'Advanced', clazz: 'fa fa-cog button-icon', @@ -534,14 +575,14 @@ nf.ReportingTask = (function () { $('#shell-close-button').click(); // show the custom ui - nf.CustomUi.showCustomUi(reportingTaskEntity, reportingTask.customUiUrl, true).done(function () { + customUi.showCustomUi(reportingTaskEntity, reportingTask.customUiUrl, true).done(function () { // once the custom ui is closed, reload the reporting task - nf.ReportingTask.reload(reportingTaskEntity.id).done(function (response) { - nf.ControllerService.reloadReferencedServices(getControllerServicesTable(), response.reportingTask); + nfReportingTask.reload(reportingTaskEntity.id).done(function (response) { + controllerService.reloadReferencedServices(getControllerServicesTable(), response.reportingTask); }); // show the settings - nf.Settings.showSettings(); + nfSettings.showSettings(); }); }; @@ -551,7 +592,7 @@ nf.ReportingTask = (function () { // determine if changes have been made if (isSaveRequired()) { // see if those changes should be saved - nf.Dialog.showYesNoDialog({ + dialog.showYesNoDialog({ headerText: 'Save', dialogContent: 'Save changes before opening the advanced configuration?', noHandler: openCustomUi, @@ -583,7 +624,7 @@ nf.ReportingTask = (function () { $('#reporting-task-configuration').modal('show'); $('#reporting-task-properties').propertytable('resetTableSize'); - }).fail(nf.ErrorHandler.handleAjaxError); + }).fail(errorHandler.handleAjaxError); }, /** @@ -632,10 +673,10 @@ nf.ReportingTask = (function () { var reportingTaskHistory = historyResponse[0].componentHistory; // populate the reporting task settings - nf.Common.populateField('reporting-task-id', reportingTask['id']); - nf.Common.populateField('reporting-task-type', nf.Common.substringAfterLast(reportingTask['type'], '.')); - nf.Common.populateField('read-only-reporting-task-name', reportingTask['name']); - nf.Common.populateField('read-only-reporting-task-comments', reportingTask['comments']); + common.populateField('reporting-task-id', reportingTask['id']); + common.populateField('reporting-task-type', common.substringAfterLast(reportingTask['type'], '.')); + common.populateField('read-only-reporting-task-name', reportingTask['name']); + common.populateField('read-only-reporting-task-comments', reportingTask['comments']); // make the scheduling strategy human readable var schedulingStrategy = reportingTask['schedulingStrategy']; @@ -644,8 +685,8 @@ nf.ReportingTask = (function () { } else { schedulingStrategy = "Timer driven"; } - nf.Common.populateField('read-only-reporting-task-scheduling-strategy', schedulingStrategy); - nf.Common.populateField('read-only-reporting-task-scheduling-period', reportingTask['schedulingPeriod']); + common.populateField('read-only-reporting-task-scheduling-strategy', schedulingStrategy); + common.populateField('read-only-reporting-task-scheduling-period', reportingTask['schedulingPeriod']); var buttons = [{ buttonText: 'Ok', @@ -663,7 +704,7 @@ nf.ReportingTask = (function () { }]; // determine if we should show the advanced button - if (nf.Common.isDefinedAndNotNull(nf.CustomUi) && nf.Common.isDefinedAndNotNull(reportingTask.customUiUrl) && reportingTask.customUiUrl !== '') { + if (common.isDefinedAndNotNull(customUi) && common.isDefinedAndNotNull(reportingTask.customUiUrl) && reportingTask.customUiUrl !== '') { buttons.push({ buttonText: 'Advanced', clazz: 'fa fa-cog button-icon', @@ -681,8 +722,8 @@ nf.ReportingTask = (function () { $('#shell-close-button').click(); // show the custom ui - nf.CustomUi.showCustomUi(reportingTaskEntity, reportingTask.customUiUrl, false).done(function() { - nf.Settings.showSettings(); + customUi.showCustomUi(reportingTaskEntity, reportingTask.customUiUrl, false).done(function () { + nfSettings.showSettings(); }); } } @@ -736,9 +777,9 @@ nf.ReportingTask = (function () { dataType: 'json' }).done(function (response) { renderReportingTask(response); - }).fail(nf.ErrorHandler.handleAjaxError); + }).fail(errorHandler.handleAjaxError); }, - + /** * Prompts the user before attempting to delete the specified reporting task. * @@ -746,11 +787,11 @@ nf.ReportingTask = (function () { */ promptToDeleteReportingTask: function (reportingTaskEntity) { // prompt for deletion - nf.Dialog.showYesNoDialog({ + dialog.showYesNoDialog({ headerText: 'Delete Reporting Task', - dialogContent: 'Delete reporting task \'' + nf.Common.escapeHtml(reportingTaskEntity.component.name) + '\'?', + dialogContent: 'Delete reporting task \'' + common.escapeHtml(reportingTaskEntity.component.name) + '\'?', yesHandler: function () { - nf.ReportingTask.remove(reportingTaskEntity); + nfReportingTask.remove(reportingTaskEntity); } }); }, @@ -763,7 +804,7 @@ nf.ReportingTask = (function () { remove: function (reportingTaskEntity) { // prompt for removal? - var revision = nf.Client.getRevision(reportingTaskEntity); + var revision = client.getRevision(reportingTaskEntity); $.ajax({ type: 'DELETE', url: reportingTaskEntity.uri + '?' + $.param({ @@ -776,7 +817,9 @@ nf.ReportingTask = (function () { var reportingTaskGrid = $('#reporting-tasks-table').data('gridInstance'); var reportingTaskData = reportingTaskGrid.getData(); reportingTaskData.deleteItem(reportingTaskEntity.id); - }).fail(nf.ErrorHandler.handleAjaxError); + }).fail(errorHandler.handleAjaxError); } }; -}()); + + return nfReportingTask; +})); http://git-wip-us.apache.org/repos/asf/nifi/blob/bf3b1640/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-selectable.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-selectable.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-selectable.js index 13cf3f5..d418b01 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-selectable.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-selectable.js @@ -15,18 +15,34 @@ * limitations under the License. */ -/* global nf, d3 */ +/* global define, module, require, exports */ -nf.Selectable = (function () { +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define(['d3', + 'nf.ng.Bridge', + 'nf.ContextMenu'], + function (d3, angularBridge, contextMenu) { + return (nf.Selectable = factory(d3, angularBridge, contextMenu)); + }); + } else if (typeof exports === 'object' && typeof module === 'object') { + module.exports = (nf.Selectable = + factory(require('d3'), + require('nf.ng.Bridge'), + require('nf.ContextMenu'))); + } else { + nf.Selectable = factory(root.d3, + root.nf.ng.Bridge, + root.nf.ContextMenu); + } +}(this, function (d3, angularBridge, contextMenu) { + 'use strict'; - return { - init: function () { + var nfSelectable = { - }, - select: function (g) { // hide any context menus as necessary - nf.ContextMenu.hide(); + contextMenu.hide(); // only need to update selection if necessary if (!g.classed('selected')) { @@ -44,18 +60,26 @@ nf.Selectable = (function () { } } - // inform Angular app that values have changed - nf.ng.Bridge.digest(); + // inform Angular app that values have changed since the + // enabled operate palette buttons are based off of the selection + angularBridge.digest(); // stop propagation d3.event.stopPropagation(); }, - + + /** + * Activates the select behavior for the components in the specified selection. + * + * @param {selection} components + */ activate: function (components) { components.on('mousedown.selection', function () { // get the clicked component to update selection - nf.Selectable.select(d3.select(this)); + nfSelectable.select(d3.select(this)); }); } }; -}()); \ No newline at end of file + + return nfSelectable; +})); \ No newline at end of file