ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject ambari git commit: AMBARI-16244. Show the connect string with the HiveServer instance. (Jaimin)
Date Wed, 04 May 2016 23:36:44 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 264111afc -> 111cc827d


AMBARI-16244. Show the connect string with the HiveServer instance. (Jaimin)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/111cc827
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/111cc827
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/111cc827

Branch: refs/heads/trunk
Commit: 111cc827d0983c31a879f0bdcad31237c8aa2583
Parents: 264111a
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Wed May 4 16:35:50 2016 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Wed May 4 16:35:50 2016 -0700

----------------------------------------------------------------------
 LICENSE.txt                                     | 30 ++++++++
 ambari-web/app/assets/img/clippy.svg            |  3 +
 .../global/configuration_controller.js          |  2 +-
 .../controllers/main/service/info/summary.js    | 65 ++++++++++++++++
 ambari-web/app/messages.js                      |  2 +
 .../templates/main/service/services/hive.hbs    | 37 ++++-----
 .../app/views/main/service/info/summary.js      |  3 +-
 .../app/views/main/service/services/hive.js     | 80 ++++++++++++++++++--
 .../views/main/service/services/hive_test.js    | 16 ----
 ambari-web/vendor/scripts/clipboard.min.js      |  7 ++
 10 files changed, 204 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/111cc827/LICENSE.txt
----------------------------------------------------------------------
diff --git a/LICENSE.txt b/LICENSE.txt
index f92b489..906c059 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -738,6 +738,35 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 
+For clipboard.js 1.5.10 (ambari/ambari-web/vendor/scripts/clipboard.min.js):
+
+clipboard.js v1.5.10
+https://clipboardjs.com/
+Copyright 2016 Zeno Rocha <hi@zenorocha.com>
+Clipboard may be freely distributed under the MIT license.
+
+MIT license selected:
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
 For MockJax 1.6.0 (contrib/views/slider/src/main/resources/ui/app/assets/javascripts/jquery.mockjax.js,
 /contrib/views/files/src/main/resources/ui/app/assets/javascripts/jquery.mockjax.js,
 /contrib/views/pig/src/main/resources/ui/pig-web/app/assets/static/javascripts/jquery.mockjax.js):
@@ -892,4 +921,5 @@ This license is Copyright (C) 2003-2004 Lawrence E. Rosen. All rights
reserved.
 
 This product uses software based on SIL Open Font License (OFL)
 * Font-Awesome (SIL OFL 1.1) [http://fortawesome.github.io/Font-Awesome/]
+* Image clippy.svg from Octicon project (SIL OFL 1.1)  [https://octicons.github.com/]
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/111cc827/ambari-web/app/assets/img/clippy.svg
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/img/clippy.svg b/ambari-web/app/assets/img/clippy.svg
new file mode 100644
index 0000000..854761d
--- /dev/null
+++ b/ambari-web/app/assets/img/clippy.svg
@@ -0,0 +1,3 @@
+<svg height="16" width="14" xmlns="http://www.w3.org/2000/svg">
+  <path d="M2 12h4v1H2v-1z m5-6H2v1h5v-1z m2 3V7L6 10l3 3V11h5V9H9z m-4.5-1H2v1h2.5v-1zM2
11h2.5v-1H2v1z m9 1h1v2c-0.02 0.28-0.11 0.52-0.3 0.7s-0.42 0.28-0.7 0.3H1c-0.55 0-1-0.45-1-1V3c0-0.55
0.45-1 1-1h3C4 0.89 4.89 0 6 0s2 0.89 2 2h3c0.55 0 1 0.45 1 1v5h-1V5H1v9h10V12zM2 4h8c0-0.55-0.45-1-1-1h-1c-0.55
0-1-0.45-1-1s-0.45-1-1-1-1 0.45-1 1-0.45 1-1 1h-1c-0.55 0-1 0.45-1 1z" />
+</svg>

http://git-wip-us.apache.org/repos/asf/ambari/blob/111cc827/ambari-web/app/controllers/global/configuration_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/configuration_controller.js b/ambari-web/app/controllers/global/configuration_controller.js
index 1f5675f..43afc0f 100644
--- a/ambari-web/app/controllers/global/configuration_controller.js
+++ b/ambari-web/app/controllers/global/configuration_controller.js
@@ -56,7 +56,7 @@ App.ConfigurationController = Em.Controller.extend({
     var i = 0;
     while (i < tags.length && !isDifferent) {
       var storedTag = storedTags.findProperty('siteName', tags[i].siteName);
-      isDifferent = (!storedTag || storedTag.tagName !== tags[i].tagName);
+      isDifferent = (!storedTag || !tags[i].tagName || storedTag.tagName !== tags[i].tagName);
       i++;
     }
     return isDifferent;

http://git-wip-us.apache.org/repos/asf/ambari/blob/111cc827/ambari-web/app/controllers/main/service/info/summary.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/summary.js b/ambari-web/app/controllers/main/service/info/summary.js
index f1740a7..3a71cb3 100644
--- a/ambari-web/app/controllers/main/service/info/summary.js
+++ b/ambari-web/app/controllers/main/service/info/summary.js
@@ -45,6 +45,12 @@ App.MainServiceInfoSummaryController = Em.Controller.extend(App.WidgetSectionMix
   sectionNameSuffix: "_SUMMARY",
 
   /**
+   * HiveServer2 JDBC connection endpoint data
+   * @type {array}
+   */
+  hiveServerEndPoints: [],
+
+  /**
    * Ranger plugins data
    * @type {array}
    */
@@ -223,6 +229,65 @@ App.MainServiceInfoSummaryController = Em.Controller.extend(App.WidgetSectionMix
   },
 
   /**
+   * This method is invoked when hive view is rendered to fetch and display
+   * information for JDBC connect string for HiveServer2 instances
+   * @method  setHiveEndPointsValue
+   * @public
+   */
+  setHiveEndPointsValue: function() {
+    var self = this;
+    var tags = [
+      {
+        siteName: 'hive-site'
+      },
+      {
+        siteName: 'hive-interactive-site'
+      }
+    ];
+
+    var siteToComponentMap = {
+      'hive-site': 'HIVE_SERVER',
+      'hive-interactive-site': 'HIVE_SERVER_INTERACTIVE'
+    };
+
+    App.router.get('configurationController').getConfigsByTags(tags).done(function (configs)
{
+
+      var hiveSiteIndex =  configs.map(function(item){
+        return item.type;
+      }).indexOf('hive-site');
+
+      // if hive-site is not first item then rotate the array to make it first
+      if (!!hiveSiteIndex) {
+        configs.push(configs.shift());
+      }
+
+      var hiveSiteDynamicDiscovery = configs[0].properties['hive.server2.support.dynamic.service.discovery'];
+      var hiveSiteZkNameSpace =  configs[0].properties['hive.server2.zookeeper.namespace'];
+      var hiveSiteZkQuorom =  configs[0].properties['hive.zookeeper.quorum'];
+
+
+      configs.forEach(function(_config) {
+        var masterComponent = App.MasterComponent.find().findProperty('componentName', siteToComponentMap[_config.type]);
+        if (_config.type === 'hive-interactive-site') {
+          hiveSiteDynamicDiscovery =  _config.properties['hive.server2.support.dynamic.service.discovery']
|| hiveSiteDynamicDiscovery;
+          hiveSiteZkQuorom =  _config.properties['hive.zookeeper.quorum'] || hiveSiteZkQuorom;
+          hiveSiteZkNameSpace =  _config.properties['hive.server2.zookeeper.namespace'] ||
hiveSiteZkNameSpace;
+        }
+        if (masterComponent && !!masterComponent.get('totalCount')) {
+          var hiveEndPoint = {
+            isVisible: hiveSiteDynamicDiscovery,
+            componentName: masterComponent.get('componentName'),
+            label: masterComponent.get('displayName') + ' Endpoint',
+            value: Em.I18n.t('services.service.summary.hiveserver2.endpoint.value').format(hiveSiteZkQuorom,
hiveSiteZkNameSpace),
+            tooltipText: Em.I18n.t('services.service.summary.hiveserver2.endpoint.tooltip.text').format(masterComponent.get('displayName'))
+          };
+          self.get('hiveServerEndPoints').pushObject(Em.Object.create(hiveEndPoint));
+        }
+      });
+    });
+  },
+
+  /**
    * Send start command for selected Flume Agent
    * @method startFlumeAgent
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/111cc827/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index d08d96f..e388526 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1756,6 +1756,8 @@ Em.I18n.translations = {
   'services.service.summary.moreStats':'more stats here',
   'services.service.summary.clientCount': '{0} Client Hosts',
   'services.service.summary.historyServer': 'History Server Web UI',
+  'services.service.summary.hiveserver2.endpoint.tooltip.text':'JDBC connection string for
{0}',
+  'services.service.summary.hiveserver2.endpoint.value':'jdbc:hive2://{0}/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace={1}',
   'services.service.actions.downloadClientConfigs':'Download Client Configs',
   'services.service.actions.downloadClientConfigs.fail.noConfigFile':'No configuration files
defined for the component',
   'services.service.actions.downloadClientConfigs.fail.popup.header':'{0} Configs',

http://git-wip-us.apache.org/repos/asf/ambari/blob/111cc827/ambari-web/app/templates/main/service/services/hive.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/services/hive.hbs b/ambari-web/app/templates/main/service/services/hive.hbs
index 617f6ce..23a2347 100644
--- a/ambari-web/app/templates/main/service/services/hive.hbs
+++ b/ambari-web/app/templates/main/service/services/hive.hbs
@@ -16,22 +16,23 @@
 * limitations under the License.
 }}
 
-<div class="clearfix">
-  <div class="name span2">
-    <i class="pull-left icon-empty"></i>
-    {{view App.MainDashboardServiceHealthView serviceBinding="view.service"}}
-    <a {{action selectService view.service href=true}}>{{view.service.displayName}}</a>
-    {{#if view.alertsCount}}
-      <a href="#" class="label label-important" {{action "showAlertsPopup" view.service
target="view.parentView"}}>
-        {{view.alertsCount}}
-      </a>
-    {{/if}}
-  </div>
-  <div class="summary span">
-    {{#each component in view.titleMasters}}
-      <a href="#" {{action showDetails component.host}}>{{component.displayName}}</a>,
-    {{/each}}
+{{view App.SummaryMasterComponentsView mastersCompBinding="view.parentView.mastersObj"}}
+{{view App.SummaryClientComponentsView clientsObjBinding="view.parentView.clientObj"}}
 
-    <a href="#" {{action filterHosts view.clients.component}}>{{view.clients.title}}</a>
-  </div>
-</div>
\ No newline at end of file
+<tr class="hidden"><td></td></tr>
+
+{{#each endpoint in hiveServerEndPoints}}
+  {{#if endpoint.isVisible}}
+   <tr {{bindAttr class=":component endpoint.componentName"}}>
+     <td class="summary-label">{{endpoint.label}}</td>
+     <td class="summary-value" >
+       {{#view view.summaryValueView titleBinding="endpoint.tooltipText" data-toggle="tooltip"}}
+         {{endpoint.value}}
+       {{/view}}
+       {{#view view.clipBoardView data-clipboard-action= "copy" data-clipboard-textBinding="endpoint.value"}}
+         <img src="/img/clippy.svg" alt="Copy" rel="clipboard-tooltip" data-toggle="tooltip"
data-placement="bottom" title="Copied!"/>
+       {{/view}}
+     </td>
+   </tr>
+  {{/if}}
+{{/each}}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/111cc827/ambari-web/app/views/main/service/info/summary.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/info/summary.js b/ambari-web/app/views/main/service/info/summary.js
index 7e0d0bb..6191e6a 100644
--- a/ambari-web/app/views/main/service/info/summary.js
+++ b/ambari-web/app/views/main/service/info/summary.js
@@ -72,7 +72,8 @@ App.MainServiceInfoSummaryView = Em.View.extend(App.UserPref, App.TimeRangeMixin
       STORM: App.MainDashboardServiceStormView,
       YARN: App.MainDashboardServiceYARNView,
       RANGER: App.MainDashboardServiceRangerView,
-      FLUME: App.MainDashboardServiceFlumeView
+      FLUME: App.MainDashboardServiceFlumeView,
+      HIVE:  App.MainDashboardServiceHiveView
     }
   }.property('serviceName'),
   /** @property collapsedMetrics {object[]} - metrics list for collapsed section

http://git-wip-us.apache.org/repos/asf/ambari/blob/111cc827/ambari-web/app/views/main/service/services/hive.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/services/hive.js b/ambari-web/app/views/main/service/services/hive.js
index c1a0f58..d306433 100644
--- a/ambari-web/app/views/main/service/services/hive.js
+++ b/ambari-web/app/views/main/service/services/hive.js
@@ -20,10 +20,80 @@ var App = require('app');
 
 App.MainDashboardServiceHiveView = App.MainDashboardServiceView.extend({
   templateName: require('templates/main/service/services/hive'),
-  serviceName: 'hive',
+  serviceName: 'HIVE',
+  
+  didInsertElement: function () {
+    var controller = this.get('controller');
+    this._super();
+    App.router.get('mainController').isLoading.call(App.router.get('clusterController'),
'isComponentsStateLoaded').done(function () {
+      controller.setHiveEndPointsValue();
+    });
+  },
 
-  titleMasters: function () {
-    var masters = this.get('masters');
-    return [masters.findProperty('componentName', 'HIVE_SERVER'), masters.findProperty('componentName',
'HIVE_METASTORE')];
-  }.property('masters')
+  willDestroyElement: function () {
+    this.get('controller.hiveServerEndPoints').clear();
+  },
+
+  /**
+   * view for JDBC connection String
+   */
+  summaryValueView: Em.View.extend({
+    tagName: 'span',
+    attributeBindings: ['title'],
+
+    didInsertElement: function() {
+      this.setEllipsis();
+      this.setTooltip();
+    },
+
+    /**
+     * sets the Hive JDBC connection text with ellipsis
+     */
+    setEllipsis: function() {
+      var $ = this.$();
+      var text =  $.text();
+      var MAX_LENGTH = 32;
+      var ellipsis = '...';
+      var length = MAX_LENGTH > text.length ? text.length : MAX_LENGTH;
+      var start = Math.max(length - ellipsis.length, ellipsis.length);
+      text = text.slice(0, start);
+      text += ellipsis;
+      $.text(text);
+    },
+
+    /**
+     * sets the tooltip for Hive JDBC connection string
+     */
+    setTooltip: function() {
+      var $ = this.$();
+      Em.run.next(function () {
+        $.tooltip();
+      });
+    }
+  }),
+
+  /**
+   * View for clipboard image that copies JDBC connection string
+   */
+  clipBoardView: Em.View.extend({
+    tagName: 'a',
+    href: "javascript:void(null)",
+    attributeBindings: ['data-clipboard-text', 'data-clipboard-action', "href"],
+    didInsertElement: function() {
+      var $this =  this.$();
+      var id = "#" + $this.attr('id');
+      var clipboard = new Clipboard(id);
+      var options = {
+        trigger: "click"
+      };
+      Em.run.next(function () {
+        $("[rel=clipboard-tooltip]").tooltip(options);
+      });
+    },
+    mouseLeave: function() {
+      Em.run.next(function () {
+        $("[rel=clipboard-tooltip]").tooltip("hide");
+      });
+    }
+  })
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/111cc827/ambari-web/test/views/main/service/services/hive_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/service/services/hive_test.js b/ambari-web/test/views/main/service/services/hive_test.js
index a31ba62..ba987a0 100644
--- a/ambari-web/test/views/main/service/services/hive_test.js
+++ b/ambari-web/test/views/main/service/services/hive_test.js
@@ -25,20 +25,4 @@ describe('App.MainDashboardServiceHiveView', function () {
   beforeEach(function() {
     view = App.MainDashboardServiceHiveView.create();
   });
-
-  describe("#titleMasters", function () {
-
-    it("should pass components", function () {
-      view.set('masters', [
-        Em.Object.create({
-          componentName: 'HIVE_SERVER'
-        }),
-        Em.Object.create({
-          componentName: 'HIVE_METASTORE'
-        })
-      ]);
-      view.propertyDidChange('titleMasters');
-      expect(view.get('titleMasters')).to.be.eql([view.get('masters')[0], view.get('masters')[1]]);
-    });
-  });
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/111cc827/ambari-web/vendor/scripts/clipboard.min.js
----------------------------------------------------------------------
diff --git a/ambari-web/vendor/scripts/clipboard.min.js b/ambari-web/vendor/scripts/clipboard.min.js
new file mode 100755
index 0000000..e4f7310
--- /dev/null
+++ b/ambari-web/vendor/scripts/clipboard.min.js
@@ -0,0 +1,7 @@
+/*!
+ * clipboard.js v1.5.10
+ * https://zenorocha.github.io/clipboard.js
+ *
+ * Licensed MIT © Zeno Rocha
+ */
+!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else
if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof
window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Clipboard=t()}}(function(){var
t,e,n;return function t(e,n,o){function i(c,a){if(!n[c]){if(!e[c]){var s="function"==typeof
require&&require;if(!a&&s)return s(c,!0);if(r)return r(c,!0);var l=new Error("Cannot
find module '"+c+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[c]={exports:{}};e[c][0].call(u.exports,function(t){var
n=e[c][1][t];return i(n?n:t)},u,u.exports,t,e,n,o)}return n[c].exports}for(var r="function"==typeof
require&&require,c=0;c<o.length;c++)i(o[c]);return i}({1:[function(t,e,n){var o=t("matches-selector");e.exports=function(t,e,n){for(var
i=n?t:t.parentNode;i&&i!==document;){if(o(i,e))return i;i=i.parentNode}}},{"matches-selector":5}],2:[function(t,e,n){function
o(t,e,n,o,r){var c=i.apply(this,arguments);
 return t.addEventListener(n,c,r),{destroy:function(){t.removeEventListener(n,c,r)}}}function
i(t,e,n,o){return function(n){n.delegateTarget=r(n.target,e,!0),n.delegateTarget&&o.call(t,n)}}var
r=t("closest");e.exports=o},{closest:1}],3:[function(t,e,n){n.node=function(t){return void
0!==t&&t instanceof HTMLElement&&1===t.nodeType},n.nodeList=function(t){var
e=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===e||"[object
HTMLCollection]"===e)&&"length"in t&&(0===t.length||n.node(t[0]))},n.string=function(t){return"string"==typeof
t||t instanceof String},n.fn=function(t){var e=Object.prototype.toString.call(t);return"[object
Function]"===e}},{}],4:[function(t,e,n){function o(t,e,n){if(!t&&!e&&!n)throw
new Error("Missing required arguments");if(!a.string(e))throw new TypeError("Second argument
must be a String");if(!a.fn(n))throw new TypeError("Third argument must be a Function");if(a.node(t))return
i(t,e,n);if(a.nodeList(t))return r(t,e,n);if(a.string(t))retur
 n c(t,e,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection,
or NodeList")}function i(t,e,n){return t.addEventListener(e,n),{destroy:function(){t.removeEventListener(e,n)}}}function
r(t,e,n){return Array.prototype.forEach.call(t,function(t){t.addEventListener(e,n)}),{destroy:function(){Array.prototype.forEach.call(t,function(t){t.removeEventListener(e,n)})}}}function
c(t,e,n){return s(document.body,t,e,n)}var a=t("./is"),s=t("delegate");e.exports=o},{"./is":3,delegate:2}],5:[function(t,e,n){function
o(t,e){if(r)return r.call(t,e);for(var n=t.parentNode.querySelectorAll(e),o=0;o<n.length;++o)if(n[o]==t)return!0;return!1}var
i=Element.prototype,r=i.matchesSelector||i.webkitMatchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector;e.exports=o},{}],6:[function(t,e,n){function
o(t){var e;if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName)t.focus(),t.setSelectionRange(0,t.value.length),e=t.value;else{t.hasAttribute("contenteditable")&&t.
 focus();var n=window.getSelection(),o=document.createRange();o.selectNodeContents(t),n.removeAllRanges(),n.addRange(o),e=n.toString()}return
e}e.exports=o},{}],7:[function(t,e,n){function o(){}o.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){function
o(){i.off(t,o),e.apply(n,arguments)}var i=this;return o._=e,this.on(t,o,n)},emit:function(t){var
e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,i=n.length;for(o;i>o;o++)n[o].fn.apply(n[o].ctx,e);return
this},off:function(t,e){var n=this.e||(this.e={}),o=n[t],i=[];if(o&&e)for(var r=0,c=o.length;c>r;r++)o[r].fn!==e&&o[r].fn._!==e&&i.push(o[r]);return
i.length?n[t]=i:delete n[t],this}},e.exports=o},{}],8:[function(e,n,o){!function(i,r){if("function"==typeof
t&&t.amd)t(["module","select"],r);else if("undefined"!=typeof o)r(n,e("select"));else{var
c={exports:{}};r(c,i.select),i.clipboardAction=c.exports}}(this,function(t,e){"use strict";
 function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof
e))throw new TypeError("Cannot call a class as a function")}var i=n(e),r="function"==typeof
Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return
t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},c=function(){function
t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in
o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return
n&&t(e.prototype,n),o&&t(e,o),e}}(),a=function(){function t(e){o(this,t),this.resolveOptions(e),this.initSelection()}return
t.prototype.resolveOptions=function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.action=e.action,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""},t.prototype.initSelection=function
t(){this.text?this.selectFake():this.target&&this.selectT
 arget()},t.prototype.selectFake=function t(){var e=this,n="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandler=document.body.addEventListener("click",function(){return
e.removeFake()}),this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="fixed",this.fakeElem.style[n?"right":"left"]="-9999px",this.fakeElem.style.top=(window.pageYOffset||document.documentElement.scrollTop)+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,document.body.appendChild(this.fakeElem),this.selectedText=(0,i.default)(this.fakeElem),this.copyText()},t.prototype.removeFake=function
t(){this.fakeHandler&&(document.body.removeEventListener("click"),this.fakeHandler=null),this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)},t.prototype.selectTarget=function
t(){this.selectedT
 ext=(0,i.default)(this.target),this.copyText()},t.prototype.copyText=function t(){var e=void
0;try{e=document.execCommand(this.action)}catch(n){e=!1}this.handleResult(e)},t.prototype.handleResult=function
t(e){e?this.emitter.emit("success",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)}):this.emitter.emit("error",{action:this.action,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})},t.prototype.clearSelection=function
t(){this.target&&this.target.blur(),window.getSelection().removeAllRanges()},t.prototype.destroy=function
t(){this.removeFake()},c(t,[{key:"action",set:function t(){var e=arguments.length<=0||void
0===arguments[0]?"copy":arguments[0];if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw
new Error('Invalid "action" value, use either "copy" or "cut"')},get:function t(){return this._action}},{key:"target",set:function
t(e){if(void 0!==e){if(!e||"object"!==("undefined"==typeof e
 ?"undefined":r(e))||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&e.hasAttribute("disabled"))throw
new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw
new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or
"disabled" attributes');this._target=e}},get:function t(){return this._target}}]),t}();t.exports=a})},{select:6}],9:[function(e,n,o){!function(i,r){if("function"==typeof
t&&t.amd)t(["module","./clipboard-action","tiny-emitter","good-listener"],r);else
if("undefined"!=typeof o)r(n,e("./clipboard-action"),e("tiny-emitter"),e("good-listener"));else{var
c={exports:{}};r(c,i.clipboardAction,i.tinyEmitter,i.goodListener),i.clipboard=c.exports}}(this,function(t,e,n,o){"use
strict";function i(t){return t&&t.__esModule?t:{"default":t}}function r(t,e){if(!(t
instanceof e
 ))throw new TypeError("Cannot call a class as a function")}function c(t,e){if(!t)throw new
ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof
e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw
new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function
s(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}var l=i(e),u=i(n),f=i(o),d=function(t){function
e(n,o){r(this,e);var i=c(this,t.call(this));return i.resolveOptions(o),i.listenClick(n),i}return
a(e,t),e.prototype.resolveOptions=function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.action="function"==typeof
e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.targe
 t:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText},e.prototype.listenClick=function
t(e){var n=this;this.listener=(0,f.default)(e,"click",function(t){return n.onClick(t)})},e.prototype.onClick=function
t(e){var n=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new
l.default({action:this.action(n),target:this.target(n),text:this.text(n),trigger:n,emitter:this})},e.prototype.defaultAction=function
t(e){return s("action",e)},e.prototype.defaultTarget=function t(e){var n=s("target",e);return
n?document.querySelector(n):void 0},e.prototype.defaultText=function t(e){return s("text",e)},e.prototype.destroy=function
t(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)},e}(u.default);t.exports=d})},{"./clipboard-action":8,"good-listener":4,"tiny-emitter":7}]},{},[9])(9)});
\ No newline at end of file


Mime
View raw message