diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2014-04-15 09:15:54 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2014-04-15 09:15:54 +0200 |
commit | 76c78bb2a346090f55438be08c4169af2232a9eb (patch) | |
tree | 8bfe5110d5f9393f94a6482efe7bb0bee33559ff | |
parent | cd5220ff68856f8e17835595c1f91b0c58214310 (diff) | |
parent | 6fe7583a6677e7d4333d7854dd8d3f22e02f823a (diff) | |
download | couchdb-76c78bb2a346090f55438be08c4169af2232a9eb.tar.gz |
Merge remote-tracking branch 'origin/master' into 1.6.x
24 files changed, 1220 insertions, 124 deletions
diff --git a/.gitignore b/.gitignore index 5e4d22006..4b12bf780 100644 --- a/.gitignore +++ b/.gitignore @@ -111,6 +111,7 @@ src/fauxton/app/addons/* src/fauxton/settings.json* !src/fauxton/settings.json.default !src/fauxton/settings.json.dev +!src/fauxton/assets/js/plugins/zeroclipboard/ZeroClipboard.swf src/ibrowse/ibrowse.app src/ibrowse/ibrowse.app src/mochiweb/mochiweb.app diff --git a/license.skip b/license.skip index 56b48bdbd..45558d1ab 100644 --- a/license.skip +++ b/license.skip @@ -131,6 +131,7 @@ ^src/fauxton/assets/js/libs/ace/.*.js ^src/fauxton/assets/js/libs/ace/snippets/.*.js ^src/fauxton/assets/js/plugins/.*.js +^src/fauxton/assets/js/plugins/zeroclipboard/ZeroClipboard.swf ^src/fauxton/assets/less/bootstrap/.*.less ^src/fauxton/assets/less/bootstrap/tests/css-tests.css ^src/fauxton/assets/less/bootstrap/tests/buttons.html diff --git a/src/Makefile.am b/src/Makefile.am index 07ee5e150..c574c6e17 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -84,7 +84,8 @@ FAUXTON_FILES = \ fauxton/app/addons/logs/templates/dashboard.html \ fauxton/app/addons/logs/templates/filterItem.html \ fauxton/app/addons/logs/templates/sidebar.html \ - fauxton/app/addons/logs/tests/logSpec.js \ + fauxton/app/addons/logs/tests/baseSpec.js \ + fauxton/app/addons/logs/tests/resourcesSpec.js \ fauxton/app/addons/permissions/assets/less/permissions.less \ fauxton/app/addons/permissions/base.js \ fauxton/app/addons/permissions/resources.js \ @@ -162,6 +163,7 @@ FAUXTON_FILES = \ fauxton/app/addons/pouchdb/base.js \ fauxton/app/addons/pouchdb/pouch.collate.js \ fauxton/app/addons/pouchdb/pouchdb.mapreduce.js \ + fauxton/app/addons/documents/assets/less/documents.less \ fauxton/app/addons/databases/templates/item.html \ fauxton/app/addons/databases/templates/list.html \ fauxton/app/addons/databases/templates/newdatabase.html \ @@ -186,7 +188,6 @@ FAUXTON_FILES = \ fauxton/app/addons/documents/templates/jumpdoc.html \ fauxton/app/addons/documents/templates/search.html \ fauxton/app/addons/documents/templates/sidebar.html \ - fauxton/app/addons/documents/templates/tabs.html \ fauxton/app/addons/documents/templates/upload_modal.html \ fauxton/app/addons/documents/templates/view_editor.html \ fauxton/app/addons/documents/tests/resourcesSpec.js \ @@ -260,7 +261,9 @@ FAUXTON_FILES = \ fauxton/assets/js/plugins/cloudant.pagingcollection.js \ fauxton/assets/js/plugins/jquery.form.js \ fauxton/assets/js/plugins/prettify.js \ - fauxton/assets/js/plugins/beautify.js\ + fauxton/assets/js/plugins/beautify.js \ + fauxton/assets/js/plugins/zeroclipboard/ZeroClipboard.js \ + fauxton/assets/js/plugins/zeroclipboard/ZeroClipboard.swf \ fauxton/assets/less/bootstrap/accordion.less \ fauxton/assets/less/bootstrap/alerts.less \ fauxton/assets/less/bootstrap/bootstrap.less \ diff --git a/src/couchdb/priv/Makefile.am b/src/couchdb/priv/Makefile.am index 9a24222f1..a7973ba13 100644 --- a/src/couchdb/priv/Makefile.am +++ b/src/couchdb/priv/Makefile.am @@ -10,6 +10,8 @@ ## License for the specific language governing permissions and limitations under ## the License. +AUTOMAKE_OPTIONS = subdir-objects + MAKE_SAFE = $(MAKE) couchlibdir = $(localerlanglibdir)/couch-$(version) diff --git a/src/ejson/Makefile.am b/src/ejson/Makefile.am index c1e07db27..60dacc26d 100644 --- a/src/ejson/Makefile.am +++ b/src/ejson/Makefile.am @@ -10,6 +10,8 @@ ## License for the specific language governing permissions and limitations under ## the License. +AUTOMAKE_OPTIONS = subdir-objects + ejsonebindir = $(localerlanglibdir)/ejson-0.1.0/ebin ejsonprivdir = $(localerlanglibdir)/ejson-0.1.0/priv diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js index 29111ebac..c650b9fac 100644 --- a/src/fauxton/Gruntfile.js +++ b/src/fauxton/Gruntfile.js @@ -147,16 +147,6 @@ module.exports = function(grunt) { watch: cleanableAddons }, - // The lint task will run the build configuration and the application - // JavaScript through JSHint and report any errors. You can change the - // options for this task, by reading this: - // https://github.com/cowboy/grunt/blob/master/docs/task_lint.md - lint: { - files: [ - "build/config.js", "app/**/*.js" - ] - }, - less: { compile: { options: { diff --git a/src/fauxton/app/addons/documents/assets/less/documents.less b/src/fauxton/app/addons/documents/assets/less/documents.less index 36429ff81..e49720b33 100644 --- a/src/fauxton/app/addons/documents/assets/less/documents.less +++ b/src/fauxton/app/addons/documents/assets/less/documents.less @@ -35,7 +35,7 @@ button.beautify { #select-per-page { margin-top: 10px; } - + } @@ -80,14 +80,30 @@ button.beautify { } /** used in changes.html **/ -#changes-table { +.change-box { + margin: 0 20px 20px 20px; +} - #changes { - width: 50%; +.change-wrapper { + margin-top: 57px; + border-bottom: 1px solid #dddddd; + &:last-child { + border-bottom: none; } - - #seq, #deleted { - width: 5%; + .row-fluid { + padding: 4px 0 4px 0; + } + .row-fluid:first { + padding: 0px 0 4px 0; + } + a:hover.js-copy { + text-decoration: none; + } + .js-json-container { + display: none; + } + .span2 { + font-weight: bold; } } @@ -111,5 +127,8 @@ button.beautify { display: inline-block; } +.change-sequence { + word-wrap: break-word; +} diff --git a/src/fauxton/app/addons/documents/routes.js b/src/fauxton/app/addons/documents/routes.js index 5e8834ff8..5497a3039 100644 --- a/src/fauxton/app/addons/documents/routes.js +++ b/src/fauxton/app/addons/documents/routes.js @@ -340,8 +340,6 @@ function(app, FauxtonAPI, Documents, Databases) { {"name": this.data.database.id, "link": Databases.databaseUrl(this.data.database)}, ]; }; - - Documents.paginate.reset(); }, updateAllDocsFromView: function (event) { @@ -353,8 +351,8 @@ function(app, FauxtonAPI, Documents, Databases) { pageSize, collection; - docParams.limit = pageSize = this.getDocPerPageLimit(urlParams, this.documentsView.perPage()); - this.documentsView.forceRender(); + var defaultPageSize = _.isUndefined(this.documentsView) ? 20 : this.documentsView.perPage(); + docParams.limit = pageSize = this.getDocPerPageLimit(urlParams, defaultPageSize); if (event.allDocs) { this.eventAllDocs = true; // this is horrible. But I cannot get the trigger not to fire the route! @@ -388,6 +386,7 @@ function(app, FauxtonAPI, Documents, Databases) { this.documentsView.setCollection(collection); this.documentsView.setParams(docParams, urlParams); + this.documentsView.forceRender(); this.apiUrl = [collection.urlRef("apiurl", urlParams), "docs"]; }, @@ -486,12 +485,6 @@ function(app, FauxtonAPI, Documents, Databases) { var docParams = app.getParams(); this.database.buildChanges(docParams); - - this.setView("#tabs", new Documents.Views.Tabs({ - collection: this.designDocs, - database: this.database, - active_id: 'changes' - })); }, changes: function (event) { diff --git a/src/fauxton/app/addons/documents/templates/changes.html b/src/fauxton/app/addons/documents/templates/changes.html index 9408979a2..5978e839e 100644 --- a/src/fauxton/app/addons/documents/templates/changes.html +++ b/src/fauxton/app/addons/documents/templates/changes.html @@ -12,27 +12,57 @@ License for the specific language governing permissions and limitations under the License. --> -<table id="changes-table" class="table"> - <thead> - <th id="seq"> seq </th> - <th> id </th> - <th id="changes"> changes </th> - <th id="deleted"> deleted? </th> - </thead> - <tbody> - <% _.each(changes, function (change) { %> - <tr> - <td> <%= change.seq %> </td> - <% if (change.deleted) { %> - <td> <%= change.id %> </td> - <% } else { %> - <td> <a href="#<%= database.url('app') %>/<%= change.id %>"><%= change.id %></a> </td> - <% } %> - <td> - <pre class="prettyprint"> <%- JSON.stringify({changes: change.changes, doc: change.doc}, null, " ") %> </pre> - </td> - <td><%= change.deleted ? "true" : "false" %></td> - </tr> - <% }); %> - </tbody> -</table> +<% _.each(changes, function (change) { %> + <div class="change-wrapper"> + <div class="change-box"> + <div class="row-fluid"> + <div class="span2"> + seq + </div> + <div class="span8 change-sequence"> + <%= change.seq %> + </div> + <div class="span2 text-right"> + <a class="js-copy" data-clipboard-text="<%= change.seq %>" data-bypass="true" href="#"> + <i class="icon-share"></i> + </a> + </div> + </div> + <div class="row-fluid"> + <div class="span2"> + id + </div> + <div class="span8"> + <% if (change.deleted) { %> + <%= change.id %> + <% } else { %> + <a href="#<%= database.url('app') %>/<%= safeURL(change.id) %>"><%= change.id %></a> + <% } %> </div> + <div class="span2 text-right"> + <a class="js-copy" data-clipboard-text="<%= change.id %>" data-bypass="true" href="#"> + <i class="icon-share"></i> + </a> + </div> + </div> + <div class="row-fluid"> + <div class="span2"> + changes + </div> + <div class="span10"> + <button class="js-toggle-json btn btn-small btn-primary" type="button">View JSON</button> + </div> + </div> + <div class="js-json-container"> + <pre class="prettyprint"><%- JSON.stringify({changes: change.changes, doc: change.doc}, null, " ") %></pre> + </div> + <div class="row-fluid"> + <div class="span2"> + deleted + </div> + <div class="span10"> + <%= change.deleted ? "True" : "False" %> + </div> + </div> + </div> + </div> +<% }); %> diff --git a/src/fauxton/app/addons/documents/templates/tabs.html b/src/fauxton/app/addons/documents/templates/tabs.html deleted file mode 100644 index f8b0c4b44..000000000 --- a/src/fauxton/app/addons/documents/templates/tabs.html +++ /dev/null @@ -1,18 +0,0 @@ -<!-- -Licensed 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. ---> - -<ul class="nav nav-tabs"> - <li class="active"><a href="<%= db_url %>">Docs</a></li> - <li id="changes"><a href="<%= changes_url %>">Changes</a></li> -</ul> diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js index 351b2b0e2..bae49c0cd 100644 --- a/src/fauxton/app/addons/documents/views.js +++ b/src/fauxton/app/addons/documents/views.js @@ -26,40 +26,14 @@ define([ // Plugins "plugins/beautify", "plugins/prettify", + // this should be never global available: + // https://github.com/zeroclipboard/zeroclipboard/blob/master/docs/security.md + "plugins/zeroclipboard/ZeroClipboard" ], -function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColumns, beautify) { +function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, + resizeColumns, beautify, prettify, ZeroClipboard) { var Views = {}; - Views.Tabs = FauxtonAPI.View.extend({ - template: "addons/documents/templates/tabs", - initialize: function(options){ - this.collection = options.collection; - this.database = options.database; - this.active_id = options.active_id; - }, - - serialize: function () { - return { - // TODO make this not hard coded here - changes_url: '#' + this.database.url('changes'), - db_url: '#' + this.database.url('index') + '?limit=' + Databases.DocLimit, - }; - }, - - beforeRender: function(manage) { - this.insertView("#search", new Views.SearchBox({ - collection: this.collection, - database: this.database.id - })); - }, - - afterRender: function () { - if (this.active_id) { - this.$('.active').removeClass('active'); - this.$('#'+this.active_id).addClass('active'); - } - } - }); Views.SearchBox = FauxtonAPI.View.extend({ template: "addons/documents/templates/search", @@ -1934,6 +1908,30 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum this.listenTo( this.model.changes, 'cachesync', this.render); }, + events: { + "click button.js-toggle-json": "toggleJson" + }, + + toggleJson: function(event) { + event.preventDefault(); + + var $button = this.$(event.target), + $container = $button.closest('.change-box').find(".js-json-container"); + + if (!$container.is(":visible")) { + $button + .text("Close JSON") + .addClass("btn-secondary") + .removeClass("btn-primary"); + } else { + $button.text("View JSON") + .addClass("btn-primary") + .removeClass("btn-secondary"); + } + + $container.slideToggle(); + }, + establish: function() { return [ this.model.changes.fetchOnce({prefill: true})]; }, @@ -1947,6 +1945,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum afterRender: function(){ prettyPrint(); + ZeroClipboard.config({ moviePath: "/assets/js/plugins/zeroclipboard/ZeroClipboard.swf" }); + var client = new ZeroClipboard(this.$(".js-copy")); } }); diff --git a/src/fauxton/app/addons/fauxton/base.js b/src/fauxton/app/addons/fauxton/base.js index 7c5021132..29925e828 100644 --- a/src/fauxton/app/addons/fauxton/base.js +++ b/src/fauxton/app/addons/fauxton/base.js @@ -145,7 +145,7 @@ function(app, FauxtonAPI, resizeColumns) { initialize: function () { _.bindAll(this); //resizeAnimation - this.resizeColumns = new resizeColumns({}); + app.resizeColumns = this.resizeColumns = new resizeColumns({}); this.resizeColumns.onResizeHandler(); FauxtonAPI.extensions.on('add:navbar:addHeaderLink', this.addLink); diff --git a/src/fauxton/app/addons/fauxton/resizeColumns.js b/src/fauxton/app/addons/fauxton/resizeColumns.js index abfcd2f63..b08158020 100644 --- a/src/fauxton/app/addons/fauxton/resizeColumns.js +++ b/src/fauxton/app/addons/fauxton/resizeColumns.js @@ -75,6 +75,7 @@ function(FauxtonAPI) { } $(this.options.selectorElements).innerWidth(panelWidth); + } //if there is a callback, run that if(this.options.callback) { diff --git a/src/fauxton/app/addons/fauxton/tests/paginateSpec.js b/src/fauxton/app/addons/fauxton/tests/paginateSpec.js index 8fc409a5d..d336ea8da 100644 --- a/src/fauxton/app/addons/fauxton/tests/paginateSpec.js +++ b/src/fauxton/app/addons/fauxton/tests/paginateSpec.js @@ -31,7 +31,7 @@ define([ id:'myId2', doc: 'num2' }], { - database: {id: 'databaseId'}, + database: {id: 'databaseId', safeID: function () { return this.id;}}, design: '_design/myDoc' }); diff --git a/src/fauxton/app/addons/logs/resources.js b/src/fauxton/app/addons/logs/resources.js index 3a47b9261..c285395be 100644 --- a/src/fauxton/app/addons/logs/resources.js +++ b/src/fauxton/app/addons/logs/resources.js @@ -13,22 +13,21 @@ define([ "app", "api", - "backbone" + "backbone", + "d3" ], -function (app, FauxtonAPI, Backbone) { +function (app, FauxtonAPI, Backbone, d3) { var Log = FauxtonAPI.addon(); Log.Model = Backbone.Model.extend({ date: function () { - var date = new Date(this.get('date')); + var date = new Date(this.get('date')), + formatter = d3.time.format("%b %e %H:%M%:%S"); - var formatted_time = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); - var formatted_date = date.toDateString().slice(4, 10); - - return formatted_date + ' ' + formatted_time; + return formatter(date); }, logLevel: function () { @@ -51,11 +50,11 @@ function (app, FauxtonAPI, Backbone) { initialize: function (options) { this.params = {bytes: 5000}; }, - + documentation: "log", url: function () { - query = "?" + $.param(this.params); + var query = "?" + $.param(this.params); return app.host + '/_log' + query; }, diff --git a/src/fauxton/app/addons/logs/tests/logSpec.js b/src/fauxton/app/addons/logs/tests/baseSpec.js index 621cc9b18..621cc9b18 100644 --- a/src/fauxton/app/addons/logs/tests/logSpec.js +++ b/src/fauxton/app/addons/logs/tests/baseSpec.js diff --git a/src/fauxton/app/addons/logs/tests/resourcesSpec.js b/src/fauxton/app/addons/logs/tests/resourcesSpec.js new file mode 100644 index 000000000..d67c67718 --- /dev/null +++ b/src/fauxton/app/addons/logs/tests/resourcesSpec.js @@ -0,0 +1,38 @@ +// Licensed 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. + +define([ + 'addons/logs/resources', + 'testUtils' +], function (Log, testUtils) { + var assert = testUtils.assert; + + describe('Log Resources', function () { + + describe('Date Formatter', function () { + it('adds leading zeros to minutes', function () { + var model; + + model = new Log.Model({ + date: 'Sat, 12 Apr 2014 15:04:01 GMT', + log_level: 'info', + pid: '123', + args: 'ente ente' + }); + // timezones with daylightsaving in JS are hard + // and we use the current local time here + // so do not test for hours and the exact day + assert.ok(/Apr \d\d \d\d:04:01/.test(model.date())); + }); + }); + }); +}); diff --git a/src/fauxton/app/addons/stats/assets/less/stats.less b/src/fauxton/app/addons/stats/assets/less/stats.less index 43ddb3b69..95020b54a 100644 --- a/src/fauxton/app/addons/stats/assets/less/stats.less +++ b/src/fauxton/app/addons/stats/assets/less/stats.less @@ -12,9 +12,9 @@ .datatypes { padding: 0 15px; -} -.span5 { - height:450px; - min-width: 450px; -}
\ No newline at end of file + .span5 svg { + height:450px; + min-width: 450px; + } +} diff --git a/src/fauxton/app/addons/stats/views.js b/src/fauxton/app/addons/stats/views.js index c8374adb3..4bd24d88e 100644 --- a/src/fauxton/app/addons/stats/views.js +++ b/src/fauxton/app/addons/stats/views.js @@ -20,7 +20,8 @@ define([ ], -function(app, FauxtonAPI,Stats) { +function(app, FauxtonAPI,Stats, d3, nv) { + console.log(nv); Views = {}; datatypeEventer = {}; diff --git a/src/fauxton/assets/js/libs/nv.d3.js b/src/fauxton/assets/js/libs/nv.d3.js index 409dc65e7..983b901fc 100755 --- a/src/fauxton/assets/js/libs/nv.d3.js +++ b/src/fauxton/assets/js/libs/nv.d3.js @@ -1,8 +1,9 @@ //this is a hacky fix because nv.d3 doesn't support requirejs -define("nvd3", ["d3"], function (d3) { +define("nv.d3", ["d3"], function (d3) { + var nv; (function(){ -var nv = window.nv || {}; + nv = window.nv || {}; nv.version = '1.1.15b'; @@ -14369,6 +14370,5 @@ nv.models.stackedAreaChart = function() { return chart; } })(); - -return window.nv; +return nv; }); diff --git a/src/fauxton/assets/js/plugins/zeroclipboard/ZeroClipboard.js b/src/fauxton/assets/js/plugins/zeroclipboard/ZeroClipboard.js new file mode 100755 index 000000000..136e4a980 --- /dev/null +++ b/src/fauxton/assets/js/plugins/zeroclipboard/ZeroClipboard.js @@ -0,0 +1,1031 @@ +/*! +* ZeroClipboard +* The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface. +* Copyright (c) 2014 Jon Rohan, James M. Greene +* Licensed MIT +* http://zeroclipboard.org/ +* v1.3.5 +*/ +(function(window) { + "use strict"; + var currentElement; + var flashState = { + bridge: null, + version: "0.0.0", + disabled: null, + outdated: null, + ready: null + }; + var _clipData = {}; + var clientIdCounter = 0; + var _clientMeta = {}; + var elementIdCounter = 0; + var _elementMeta = {}; + var _amdModuleId = null; + var _cjsModuleId = null; + var _swfPath = function() { + var i, jsDir, tmpJsPath, jsPath, swfPath = "ZeroClipboard.swf"; + if (document.currentScript && (jsPath = document.currentScript.src)) {} else { + var scripts = document.getElementsByTagName("script"); + if ("readyState" in scripts[0]) { + for (i = scripts.length; i--; ) { + if (scripts[i].readyState === "interactive" && (jsPath = scripts[i].src)) { + break; + } + } + } else if (document.readyState === "loading") { + jsPath = scripts[scripts.length - 1].src; + } else { + for (i = scripts.length; i--; ) { + tmpJsPath = scripts[i].src; + if (!tmpJsPath) { + jsDir = null; + break; + } + tmpJsPath = tmpJsPath.split("#")[0].split("?")[0]; + tmpJsPath = tmpJsPath.slice(0, tmpJsPath.lastIndexOf("/") + 1); + if (jsDir == null) { + jsDir = tmpJsPath; + } else if (jsDir !== tmpJsPath) { + jsDir = null; + break; + } + } + if (jsDir !== null) { + jsPath = jsDir; + } + } + } + if (jsPath) { + jsPath = jsPath.split("#")[0].split("?")[0]; + swfPath = jsPath.slice(0, jsPath.lastIndexOf("/") + 1) + swfPath; + } + return swfPath; + }(); + var _camelizeCssPropName = function() { + var matcherRegex = /\-([a-z])/g, replacerFn = function(match, group) { + return group.toUpperCase(); + }; + return function(prop) { + return prop.replace(matcherRegex, replacerFn); + }; + }(); + var _getStyle = function(el, prop) { + var value, camelProp, tagName, possiblePointers, i, len; + if (window.getComputedStyle) { + value = window.getComputedStyle(el, null).getPropertyValue(prop); + } else { + camelProp = _camelizeCssPropName(prop); + if (el.currentStyle) { + value = el.currentStyle[camelProp]; + } else { + value = el.style[camelProp]; + } + } + if (prop === "cursor") { + if (!value || value === "auto") { + tagName = el.tagName.toLowerCase(); + if (tagName === "a") { + return "pointer"; + } + } + } + return value; + }; + var _elementMouseOver = function(event) { + if (!event) { + event = window.event; + } + var target; + if (this !== window) { + target = this; + } else if (event.target) { + target = event.target; + } else if (event.srcElement) { + target = event.srcElement; + } + ZeroClipboard.activate(target); + }; + var _addEventHandler = function(element, method, func) { + if (!element || element.nodeType !== 1) { + return; + } + if (element.addEventListener) { + element.addEventListener(method, func, false); + } else if (element.attachEvent) { + element.attachEvent("on" + method, func); + } + }; + var _removeEventHandler = function(element, method, func) { + if (!element || element.nodeType !== 1) { + return; + } + if (element.removeEventListener) { + element.removeEventListener(method, func, false); + } else if (element.detachEvent) { + element.detachEvent("on" + method, func); + } + }; + var _addClass = function(element, value) { + if (!element || element.nodeType !== 1) { + return element; + } + if (element.classList) { + if (!element.classList.contains(value)) { + element.classList.add(value); + } + return element; + } + if (value && typeof value === "string") { + var classNames = (value || "").split(/\s+/); + if (element.nodeType === 1) { + if (!element.className) { + element.className = value; + } else { + var className = " " + element.className + " ", setClass = element.className; + for (var c = 0, cl = classNames.length; c < cl; c++) { + if (className.indexOf(" " + classNames[c] + " ") < 0) { + setClass += " " + classNames[c]; + } + } + element.className = setClass.replace(/^\s+|\s+$/g, ""); + } + } + } + return element; + }; + var _removeClass = function(element, value) { + if (!element || element.nodeType !== 1) { + return element; + } + if (element.classList) { + if (element.classList.contains(value)) { + element.classList.remove(value); + } + return element; + } + if (value && typeof value === "string" || value === undefined) { + var classNames = (value || "").split(/\s+/); + if (element.nodeType === 1 && element.className) { + if (value) { + var className = (" " + element.className + " ").replace(/[\n\t]/g, " "); + for (var c = 0, cl = classNames.length; c < cl; c++) { + className = className.replace(" " + classNames[c] + " ", " "); + } + element.className = className.replace(/^\s+|\s+$/g, ""); + } else { + element.className = ""; + } + } + } + return element; + }; + var _getZoomFactor = function() { + var rect, physicalWidth, logicalWidth, zoomFactor = 1; + if (typeof document.body.getBoundingClientRect === "function") { + rect = document.body.getBoundingClientRect(); + physicalWidth = rect.right - rect.left; + logicalWidth = document.body.offsetWidth; + zoomFactor = Math.round(physicalWidth / logicalWidth * 100) / 100; + } + return zoomFactor; + }; + var _getDOMObjectPosition = function(obj, defaultZIndex) { + var info = { + left: 0, + top: 0, + width: 0, + height: 0, + zIndex: _getSafeZIndex(defaultZIndex) - 1 + }; + if (obj.getBoundingClientRect) { + var rect = obj.getBoundingClientRect(); + var pageXOffset, pageYOffset, zoomFactor; + if ("pageXOffset" in window && "pageYOffset" in window) { + pageXOffset = window.pageXOffset; + pageYOffset = window.pageYOffset; + } else { + zoomFactor = _getZoomFactor(); + pageXOffset = Math.round(document.documentElement.scrollLeft / zoomFactor); + pageYOffset = Math.round(document.documentElement.scrollTop / zoomFactor); + } + var leftBorderWidth = document.documentElement.clientLeft || 0; + var topBorderWidth = document.documentElement.clientTop || 0; + info.left = rect.left + pageXOffset - leftBorderWidth; + info.top = rect.top + pageYOffset - topBorderWidth; + info.width = "width" in rect ? rect.width : rect.right - rect.left; + info.height = "height" in rect ? rect.height : rect.bottom - rect.top; + } + return info; + }; + var _cacheBust = function(path, options) { + var cacheBust = options == null || options && options.cacheBust === true && options.useNoCache === true; + if (cacheBust) { + return (path.indexOf("?") === -1 ? "?" : "&") + "noCache=" + new Date().getTime(); + } else { + return ""; + } + }; + var _vars = function(options) { + var i, len, domain, str = [], domains = [], trustedOriginsExpanded = []; + if (options.trustedOrigins) { + if (typeof options.trustedOrigins === "string") { + domains.push(options.trustedOrigins); + } else if (typeof options.trustedOrigins === "object" && "length" in options.trustedOrigins) { + domains = domains.concat(options.trustedOrigins); + } + } + if (options.trustedDomains) { + if (typeof options.trustedDomains === "string") { + domains.push(options.trustedDomains); + } else if (typeof options.trustedDomains === "object" && "length" in options.trustedDomains) { + domains = domains.concat(options.trustedDomains); + } + } + if (domains.length) { + for (i = 0, len = domains.length; i < len; i++) { + if (domains.hasOwnProperty(i) && domains[i] && typeof domains[i] === "string") { + domain = _extractDomain(domains[i]); + if (!domain) { + continue; + } + if (domain === "*") { + trustedOriginsExpanded = [ domain ]; + break; + } + trustedOriginsExpanded.push.apply(trustedOriginsExpanded, [ domain, "//" + domain, window.location.protocol + "//" + domain ]); + } + } + } + if (trustedOriginsExpanded.length) { + str.push("trustedOrigins=" + encodeURIComponent(trustedOriginsExpanded.join(","))); + } + if (typeof options.jsModuleId === "string" && options.jsModuleId) { + str.push("jsModuleId=" + encodeURIComponent(options.jsModuleId)); + } + return str.join("&"); + }; + var _inArray = function(elem, array, fromIndex) { + if (typeof array.indexOf === "function") { + return array.indexOf(elem, fromIndex); + } + var i, len = array.length; + if (typeof fromIndex === "undefined") { + fromIndex = 0; + } else if (fromIndex < 0) { + fromIndex = len + fromIndex; + } + for (i = fromIndex; i < len; i++) { + if (array.hasOwnProperty(i) && array[i] === elem) { + return i; + } + } + return -1; + }; + var _prepClip = function(elements) { + if (typeof elements === "string") throw new TypeError("ZeroClipboard doesn't accept query strings."); + if (!elements.length) return [ elements ]; + return elements; + }; + var _dispatchCallback = function(func, context, args, async) { + if (async) { + window.setTimeout(function() { + func.apply(context, args); + }, 0); + } else { + func.apply(context, args); + } + }; + var _getSafeZIndex = function(val) { + var zIndex, tmp; + if (val) { + if (typeof val === "number" && val > 0) { + zIndex = val; + } else if (typeof val === "string" && (tmp = parseInt(val, 10)) && !isNaN(tmp) && tmp > 0) { + zIndex = tmp; + } + } + if (!zIndex) { + if (typeof _globalConfig.zIndex === "number" && _globalConfig.zIndex > 0) { + zIndex = _globalConfig.zIndex; + } else if (typeof _globalConfig.zIndex === "string" && (tmp = parseInt(_globalConfig.zIndex, 10)) && !isNaN(tmp) && tmp > 0) { + zIndex = tmp; + } + } + return zIndex || 0; + }; + var _deprecationWarning = function(deprecatedApiName, debugEnabled) { + if (deprecatedApiName && debugEnabled !== false && typeof console !== "undefined" && console && (console.warn || console.log)) { + var deprecationWarning = "`" + deprecatedApiName + "` is deprecated. See docs for more info:\n" + " https://github.com/zeroclipboard/zeroclipboard/blob/master/docs/instructions.md#deprecations"; + if (console.warn) { + console.warn(deprecationWarning); + } else { + console.log(deprecationWarning); + } + } + }; + var _extend = function() { + var i, len, arg, prop, src, copy, target = arguments[0] || {}; + for (i = 1, len = arguments.length; i < len; i++) { + if ((arg = arguments[i]) != null) { + for (prop in arg) { + if (arg.hasOwnProperty(prop)) { + src = target[prop]; + copy = arg[prop]; + if (target === copy) { + continue; + } + if (copy !== undefined) { + target[prop] = copy; + } + } + } + } + } + return target; + }; + var _extractDomain = function(originOrUrl) { + if (originOrUrl == null || originOrUrl === "") { + return null; + } + originOrUrl = originOrUrl.replace(/^\s+|\s+$/g, ""); + if (originOrUrl === "") { + return null; + } + var protocolIndex = originOrUrl.indexOf("//"); + originOrUrl = protocolIndex === -1 ? originOrUrl : originOrUrl.slice(protocolIndex + 2); + var pathIndex = originOrUrl.indexOf("/"); + originOrUrl = pathIndex === -1 ? originOrUrl : protocolIndex === -1 || pathIndex === 0 ? null : originOrUrl.slice(0, pathIndex); + if (originOrUrl && originOrUrl.slice(-4).toLowerCase() === ".swf") { + return null; + } + return originOrUrl || null; + }; + var _determineScriptAccess = function() { + var _extractAllDomains = function(origins, resultsArray) { + var i, len, tmp; + if (origins != null && resultsArray[0] !== "*") { + if (typeof origins === "string") { + origins = [ origins ]; + } + if (typeof origins === "object" && "length" in origins) { + for (i = 0, len = origins.length; i < len; i++) { + if (origins.hasOwnProperty(i)) { + tmp = _extractDomain(origins[i]); + if (tmp) { + if (tmp === "*") { + resultsArray.length = 0; + resultsArray.push("*"); + break; + } + if (_inArray(tmp, resultsArray) === -1) { + resultsArray.push(tmp); + } + } + } + } + } + } + }; + var _accessLevelLookup = { + always: "always", + samedomain: "sameDomain", + never: "never" + }; + return function(currentDomain, configOptions) { + var asaLower, allowScriptAccess = configOptions.allowScriptAccess; + if (typeof allowScriptAccess === "string" && (asaLower = allowScriptAccess.toLowerCase()) && /^always|samedomain|never$/.test(asaLower)) { + return _accessLevelLookup[asaLower]; + } + var swfDomain = _extractDomain(configOptions.moviePath); + if (swfDomain === null) { + swfDomain = currentDomain; + } + var trustedDomains = []; + _extractAllDomains(configOptions.trustedOrigins, trustedDomains); + _extractAllDomains(configOptions.trustedDomains, trustedDomains); + var len = trustedDomains.length; + if (len > 0) { + if (len === 1 && trustedDomains[0] === "*") { + return "always"; + } + if (_inArray(currentDomain, trustedDomains) !== -1) { + if (len === 1 && currentDomain === swfDomain) { + return "sameDomain"; + } + return "always"; + } + } + return "never"; + }; + }(); + var _objectKeys = function(obj) { + if (obj == null) { + return []; + } + if (Object.keys) { + return Object.keys(obj); + } + var keys = []; + for (var prop in obj) { + if (obj.hasOwnProperty(prop)) { + keys.push(prop); + } + } + return keys; + }; + var _deleteOwnProperties = function(obj) { + if (obj) { + for (var prop in obj) { + if (obj.hasOwnProperty(prop)) { + delete obj[prop]; + } + } + } + return obj; + }; + var _safeActiveElement = function() { + try { + return document.activeElement; + } catch (err) {} + return null; + }; + var _detectFlashSupport = function() { + var hasFlash = false; + if (typeof flashState.disabled === "boolean") { + hasFlash = flashState.disabled === false; + } else { + if (typeof ActiveXObject === "function") { + try { + if (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) { + hasFlash = true; + } + } catch (error) {} + } + if (!hasFlash && navigator.mimeTypes["application/x-shockwave-flash"]) { + hasFlash = true; + } + } + return hasFlash; + }; + function _parseFlashVersion(flashVersion) { + return flashVersion.replace(/,/g, ".").replace(/[^0-9\.]/g, ""); + } + function _isFlashVersionSupported(flashVersion) { + return parseFloat(_parseFlashVersion(flashVersion)) >= 10; + } + var ZeroClipboard = function(elements, options) { + if (!(this instanceof ZeroClipboard)) { + return new ZeroClipboard(elements, options); + } + this.id = "" + clientIdCounter++; + _clientMeta[this.id] = { + instance: this, + elements: [], + handlers: {} + }; + if (elements) { + this.clip(elements); + } + if (typeof options !== "undefined") { + _deprecationWarning("new ZeroClipboard(elements, options)", _globalConfig.debug); + ZeroClipboard.config(options); + } + this.options = ZeroClipboard.config(); + if (typeof flashState.disabled !== "boolean") { + flashState.disabled = !_detectFlashSupport(); + } + if (flashState.disabled === false && flashState.outdated !== true) { + if (flashState.bridge === null) { + flashState.outdated = false; + flashState.ready = false; + _bridge(); + } + } + }; + ZeroClipboard.prototype.setText = function(newText) { + if (newText && newText !== "") { + _clipData["text/plain"] = newText; + if (flashState.ready === true && flashState.bridge && typeof flashState.bridge.setText === "function") { + flashState.bridge.setText(newText); + } else { + flashState.ready = false; + } + } + return this; + }; + ZeroClipboard.prototype.setSize = function(width, height) { + if (flashState.ready === true && flashState.bridge && typeof flashState.bridge.setSize === "function") { + flashState.bridge.setSize(width, height); + } else { + flashState.ready = false; + } + return this; + }; + var _setHandCursor = function(enabled) { + if (flashState.ready === true && flashState.bridge && typeof flashState.bridge.setHandCursor === "function") { + flashState.bridge.setHandCursor(enabled); + } else { + flashState.ready = false; + } + }; + ZeroClipboard.prototype.destroy = function() { + this.unclip(); + this.off(); + delete _clientMeta[this.id]; + }; + var _getAllClients = function() { + var i, len, client, clients = [], clientIds = _objectKeys(_clientMeta); + for (i = 0, len = clientIds.length; i < len; i++) { + client = _clientMeta[clientIds[i]].instance; + if (client && client instanceof ZeroClipboard) { + clients.push(client); + } + } + return clients; + }; + ZeroClipboard.version = "1.3.5"; + var _globalConfig = { + swfPath: _swfPath, + trustedDomains: window.location.host ? [ window.location.host ] : [], + cacheBust: true, + forceHandCursor: false, + zIndex: 999999999, + debug: true, + title: null, + autoActivate: true + }; + ZeroClipboard.config = function(options) { + if (typeof options === "object" && options !== null) { + _extend(_globalConfig, options); + } + if (typeof options === "string" && options) { + if (_globalConfig.hasOwnProperty(options)) { + return _globalConfig[options]; + } + return; + } + var copy = {}; + for (var prop in _globalConfig) { + if (_globalConfig.hasOwnProperty(prop)) { + if (typeof _globalConfig[prop] === "object" && _globalConfig[prop] !== null) { + if ("length" in _globalConfig[prop]) { + copy[prop] = _globalConfig[prop].slice(0); + } else { + copy[prop] = _extend({}, _globalConfig[prop]); + } + } else { + copy[prop] = _globalConfig[prop]; + } + } + } + return copy; + }; + ZeroClipboard.destroy = function() { + ZeroClipboard.deactivate(); + for (var clientId in _clientMeta) { + if (_clientMeta.hasOwnProperty(clientId) && _clientMeta[clientId]) { + var client = _clientMeta[clientId].instance; + if (client && typeof client.destroy === "function") { + client.destroy(); + } + } + } + var htmlBridge = _getHtmlBridge(flashState.bridge); + if (htmlBridge && htmlBridge.parentNode) { + htmlBridge.parentNode.removeChild(htmlBridge); + flashState.ready = null; + flashState.bridge = null; + } + }; + ZeroClipboard.activate = function(element) { + if (currentElement) { + _removeClass(currentElement, _globalConfig.hoverClass); + _removeClass(currentElement, _globalConfig.activeClass); + } + currentElement = element; + _addClass(element, _globalConfig.hoverClass); + _reposition(); + var newTitle = _globalConfig.title || element.getAttribute("title"); + if (newTitle) { + var htmlBridge = _getHtmlBridge(flashState.bridge); + if (htmlBridge) { + htmlBridge.setAttribute("title", newTitle); + } + } + var useHandCursor = _globalConfig.forceHandCursor === true || _getStyle(element, "cursor") === "pointer"; + _setHandCursor(useHandCursor); + }; + ZeroClipboard.deactivate = function() { + var htmlBridge = _getHtmlBridge(flashState.bridge); + if (htmlBridge) { + htmlBridge.style.left = "0px"; + htmlBridge.style.top = "-9999px"; + htmlBridge.removeAttribute("title"); + } + if (currentElement) { + _removeClass(currentElement, _globalConfig.hoverClass); + _removeClass(currentElement, _globalConfig.activeClass); + currentElement = null; + } + }; + var _bridge = function() { + var flashBridge, len; + var container = document.getElementById("global-zeroclipboard-html-bridge"); + if (!container) { + var opts = ZeroClipboard.config(); + opts.jsModuleId = typeof _amdModuleId === "string" && _amdModuleId || typeof _cjsModuleId === "string" && _cjsModuleId || null; + var allowScriptAccess = _determineScriptAccess(window.location.host, _globalConfig); + var flashvars = _vars(opts); + var swfUrl = _globalConfig.moviePath + _cacheBust(_globalConfig.moviePath, _globalConfig); + var html = ' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="global-zeroclipboard-flash-bridge" width="100%" height="100%"> <param name="movie" value="' + swfUrl + '"/> <param name="allowScriptAccess" value="' + allowScriptAccess + '"/> <param name="scale" value="exactfit"/> <param name="loop" value="false"/> <param name="menu" value="false"/> <param name="quality" value="best" /> <param name="bgcolor" value="#ffffff"/> <param name="wmode" value="transparent"/> <param name="flashvars" value="' + flashvars + '"/> <embed src="' + swfUrl + '" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="100%" height="100%" name="global-zeroclipboard-flash-bridge" allowScriptAccess="' + allowScriptAccess + '" allowFullScreen="false" type="application/x-shockwave-flash" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="' + flashvars + '" scale="exactfit"> </embed> </object>'; + container = document.createElement("div"); + container.id = "global-zeroclipboard-html-bridge"; + container.setAttribute("class", "global-zeroclipboard-container"); + container.style.position = "absolute"; + container.style.left = "0px"; + container.style.top = "-9999px"; + container.style.width = "15px"; + container.style.height = "15px"; + container.style.zIndex = "" + _getSafeZIndex(_globalConfig.zIndex); + document.body.appendChild(container); + container.innerHTML = html; + } + flashBridge = document["global-zeroclipboard-flash-bridge"]; + if (flashBridge && (len = flashBridge.length)) { + flashBridge = flashBridge[len - 1]; + } + flashState.bridge = flashBridge || container.children[0].lastElementChild; + }; + var _getHtmlBridge = function(flashBridge) { + var isFlashElement = /^OBJECT|EMBED$/; + var htmlBridge = flashBridge && flashBridge.parentNode; + while (htmlBridge && isFlashElement.test(htmlBridge.nodeName) && htmlBridge.parentNode) { + htmlBridge = htmlBridge.parentNode; + } + return htmlBridge || null; + }; + var _reposition = function() { + if (currentElement) { + var pos = _getDOMObjectPosition(currentElement, _globalConfig.zIndex); + var htmlBridge = _getHtmlBridge(flashState.bridge); + if (htmlBridge) { + htmlBridge.style.top = pos.top + "px"; + htmlBridge.style.left = pos.left + "px"; + htmlBridge.style.width = pos.width + "px"; + htmlBridge.style.height = pos.height + "px"; + htmlBridge.style.zIndex = pos.zIndex + 1; + } + if (flashState.ready === true && flashState.bridge && typeof flashState.bridge.setSize === "function") { + flashState.bridge.setSize(pos.width, pos.height); + } else { + flashState.ready = false; + } + } + return this; + }; + ZeroClipboard.prototype.on = function(eventName, func) { + var i, len, events, added = {}, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers; + if (typeof eventName === "string" && eventName) { + events = eventName.toLowerCase().split(/\s+/); + } else if (typeof eventName === "object" && eventName && typeof func === "undefined") { + for (i in eventName) { + if (eventName.hasOwnProperty(i) && typeof i === "string" && i && typeof eventName[i] === "function") { + this.on(i, eventName[i]); + } + } + } + if (events && events.length) { + for (i = 0, len = events.length; i < len; i++) { + eventName = events[i].replace(/^on/, ""); + added[eventName] = true; + if (!handlers[eventName]) { + handlers[eventName] = []; + } + handlers[eventName].push(func); + } + if (added.noflash && flashState.disabled) { + _receiveEvent.call(this, "noflash", {}); + } + if (added.wrongflash && flashState.outdated) { + _receiveEvent.call(this, "wrongflash", { + flashVersion: flashState.version + }); + } + if (added.load && flashState.ready) { + _receiveEvent.call(this, "load", { + flashVersion: flashState.version + }); + } + } + return this; + }; + ZeroClipboard.prototype.off = function(eventName, func) { + var i, len, foundIndex, events, perEventHandlers, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers; + if (arguments.length === 0) { + events = _objectKeys(handlers); + } else if (typeof eventName === "string" && eventName) { + events = eventName.split(/\s+/); + } else if (typeof eventName === "object" && eventName && typeof func === "undefined") { + for (i in eventName) { + if (eventName.hasOwnProperty(i) && typeof i === "string" && i && typeof eventName[i] === "function") { + this.off(i, eventName[i]); + } + } + } + if (events && events.length) { + for (i = 0, len = events.length; i < len; i++) { + eventName = events[i].toLowerCase().replace(/^on/, ""); + perEventHandlers = handlers[eventName]; + if (perEventHandlers && perEventHandlers.length) { + if (func) { + foundIndex = _inArray(func, perEventHandlers); + while (foundIndex !== -1) { + perEventHandlers.splice(foundIndex, 1); + foundIndex = _inArray(func, perEventHandlers, foundIndex); + } + } else { + handlers[eventName].length = 0; + } + } + } + } + return this; + }; + ZeroClipboard.prototype.handlers = function(eventName) { + var prop, copy = null, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers; + if (handlers) { + if (typeof eventName === "string" && eventName) { + return handlers[eventName] ? handlers[eventName].slice(0) : null; + } + copy = {}; + for (prop in handlers) { + if (handlers.hasOwnProperty(prop) && handlers[prop]) { + copy[prop] = handlers[prop].slice(0); + } + } + } + return copy; + }; + var _dispatchClientCallbacks = function(eventName, context, args, async) { + var handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers[eventName]; + if (handlers && handlers.length) { + var i, len, func, originalContext = context || this; + for (i = 0, len = handlers.length; i < len; i++) { + func = handlers[i]; + context = originalContext; + if (typeof func === "string" && typeof window[func] === "function") { + func = window[func]; + } + if (typeof func === "object" && func && typeof func.handleEvent === "function") { + context = func; + func = func.handleEvent; + } + if (typeof func === "function") { + _dispatchCallback(func, context, args, async); + } + } + } + return this; + }; + ZeroClipboard.prototype.clip = function(elements) { + elements = _prepClip(elements); + for (var i = 0; i < elements.length; i++) { + if (elements.hasOwnProperty(i) && elements[i] && elements[i].nodeType === 1) { + if (!elements[i].zcClippingId) { + elements[i].zcClippingId = "zcClippingId_" + elementIdCounter++; + _elementMeta[elements[i].zcClippingId] = [ this.id ]; + if (_globalConfig.autoActivate === true) { + _addEventHandler(elements[i], "mouseover", _elementMouseOver); + } + } else if (_inArray(this.id, _elementMeta[elements[i].zcClippingId]) === -1) { + _elementMeta[elements[i].zcClippingId].push(this.id); + } + var clippedElements = _clientMeta[this.id].elements; + if (_inArray(elements[i], clippedElements) === -1) { + clippedElements.push(elements[i]); + } + } + } + return this; + }; + ZeroClipboard.prototype.unclip = function(elements) { + var meta = _clientMeta[this.id]; + if (meta) { + var clippedElements = meta.elements; + var arrayIndex; + if (typeof elements === "undefined") { + elements = clippedElements.slice(0); + } else { + elements = _prepClip(elements); + } + for (var i = elements.length; i--; ) { + if (elements.hasOwnProperty(i) && elements[i] && elements[i].nodeType === 1) { + arrayIndex = 0; + while ((arrayIndex = _inArray(elements[i], clippedElements, arrayIndex)) !== -1) { + clippedElements.splice(arrayIndex, 1); + } + var clientIds = _elementMeta[elements[i].zcClippingId]; + if (clientIds) { + arrayIndex = 0; + while ((arrayIndex = _inArray(this.id, clientIds, arrayIndex)) !== -1) { + clientIds.splice(arrayIndex, 1); + } + if (clientIds.length === 0) { + if (_globalConfig.autoActivate === true) { + _removeEventHandler(elements[i], "mouseover", _elementMouseOver); + } + delete elements[i].zcClippingId; + } + } + } + } + } + return this; + }; + ZeroClipboard.prototype.elements = function() { + var meta = _clientMeta[this.id]; + return meta && meta.elements ? meta.elements.slice(0) : []; + }; + var _getAllClientsClippedToElement = function(element) { + var elementMetaId, clientIds, i, len, client, clients = []; + if (element && element.nodeType === 1 && (elementMetaId = element.zcClippingId) && _elementMeta.hasOwnProperty(elementMetaId)) { + clientIds = _elementMeta[elementMetaId]; + if (clientIds && clientIds.length) { + for (i = 0, len = clientIds.length; i < len; i++) { + client = _clientMeta[clientIds[i]].instance; + if (client && client instanceof ZeroClipboard) { + clients.push(client); + } + } + } + } + return clients; + }; + _globalConfig.hoverClass = "zeroclipboard-is-hover"; + _globalConfig.activeClass = "zeroclipboard-is-active"; + _globalConfig.trustedOrigins = null; + _globalConfig.allowScriptAccess = null; + _globalConfig.useNoCache = true; + _globalConfig.moviePath = "ZeroClipboard.swf"; + ZeroClipboard.detectFlashSupport = function() { + _deprecationWarning("ZeroClipboard.detectFlashSupport", _globalConfig.debug); + return _detectFlashSupport(); + }; + ZeroClipboard.dispatch = function(eventName, args) { + if (typeof eventName === "string" && eventName) { + var cleanEventName = eventName.toLowerCase().replace(/^on/, ""); + if (cleanEventName) { + var clients = currentElement && _globalConfig.autoActivate === true ? _getAllClientsClippedToElement(currentElement) : _getAllClients(); + for (var i = 0, len = clients.length; i < len; i++) { + _receiveEvent.call(clients[i], cleanEventName, args); + } + } + } + }; + ZeroClipboard.prototype.setHandCursor = function(enabled) { + _deprecationWarning("ZeroClipboard.prototype.setHandCursor", _globalConfig.debug); + enabled = typeof enabled === "boolean" ? enabled : !!enabled; + _setHandCursor(enabled); + _globalConfig.forceHandCursor = enabled; + return this; + }; + ZeroClipboard.prototype.reposition = function() { + _deprecationWarning("ZeroClipboard.prototype.reposition", _globalConfig.debug); + return _reposition(); + }; + ZeroClipboard.prototype.receiveEvent = function(eventName, args) { + _deprecationWarning("ZeroClipboard.prototype.receiveEvent", _globalConfig.debug); + if (typeof eventName === "string" && eventName) { + var cleanEventName = eventName.toLowerCase().replace(/^on/, ""); + if (cleanEventName) { + _receiveEvent.call(this, cleanEventName, args); + } + } + }; + ZeroClipboard.prototype.setCurrent = function(element) { + _deprecationWarning("ZeroClipboard.prototype.setCurrent", _globalConfig.debug); + ZeroClipboard.activate(element); + return this; + }; + ZeroClipboard.prototype.resetBridge = function() { + _deprecationWarning("ZeroClipboard.prototype.resetBridge", _globalConfig.debug); + ZeroClipboard.deactivate(); + return this; + }; + ZeroClipboard.prototype.setTitle = function(newTitle) { + _deprecationWarning("ZeroClipboard.prototype.setTitle", _globalConfig.debug); + newTitle = newTitle || _globalConfig.title || currentElement && currentElement.getAttribute("title"); + if (newTitle) { + var htmlBridge = _getHtmlBridge(flashState.bridge); + if (htmlBridge) { + htmlBridge.setAttribute("title", newTitle); + } + } + return this; + }; + ZeroClipboard.setDefaults = function(options) { + _deprecationWarning("ZeroClipboard.setDefaults", _globalConfig.debug); + ZeroClipboard.config(options); + }; + ZeroClipboard.prototype.addEventListener = function(eventName, func) { + _deprecationWarning("ZeroClipboard.prototype.addEventListener", _globalConfig.debug); + return this.on(eventName, func); + }; + ZeroClipboard.prototype.removeEventListener = function(eventName, func) { + _deprecationWarning("ZeroClipboard.prototype.removeEventListener", _globalConfig.debug); + return this.off(eventName, func); + }; + ZeroClipboard.prototype.ready = function() { + _deprecationWarning("ZeroClipboard.prototype.ready", _globalConfig.debug); + return flashState.ready === true; + }; + var _receiveEvent = function(eventName, args) { + eventName = eventName.toLowerCase().replace(/^on/, ""); + var cleanVersion = args && args.flashVersion && _parseFlashVersion(args.flashVersion) || null; + var element = currentElement; + var performCallbackAsync = true; + switch (eventName) { + case "load": + if (cleanVersion) { + if (!_isFlashVersionSupported(cleanVersion)) { + _receiveEvent.call(this, "onWrongFlash", { + flashVersion: cleanVersion + }); + return; + } + flashState.outdated = false; + flashState.ready = true; + flashState.version = cleanVersion; + } + break; + + case "wrongflash": + if (cleanVersion && !_isFlashVersionSupported(cleanVersion)) { + flashState.outdated = true; + flashState.ready = false; + flashState.version = cleanVersion; + } + break; + + case "mouseover": + _addClass(element, _globalConfig.hoverClass); + break; + + case "mouseout": + if (_globalConfig.autoActivate === true) { + ZeroClipboard.deactivate(); + } + break; + + case "mousedown": + _addClass(element, _globalConfig.activeClass); + break; + + case "mouseup": + _removeClass(element, _globalConfig.activeClass); + break; + + case "datarequested": + if (element) { + var targetId = element.getAttribute("data-clipboard-target"), targetEl = !targetId ? null : document.getElementById(targetId); + if (targetEl) { + var textContent = targetEl.value || targetEl.textContent || targetEl.innerText; + if (textContent) { + this.setText(textContent); + } + } else { + var defaultText = element.getAttribute("data-clipboard-text"); + if (defaultText) { + this.setText(defaultText); + } + } + } + performCallbackAsync = false; + break; + + case "complete": + _deleteOwnProperties(_clipData); + if (element && element !== _safeActiveElement() && element.focus) { + element.focus(); + } + break; + } + var context = element; + var eventArgs = [ this, args ]; + return _dispatchClientCallbacks.call(this, eventName, context, eventArgs, performCallbackAsync); + }; + if (typeof define === "function" && define.amd) { + define([ "require", "exports", "module" ], function(require, exports, module) { + _amdModuleId = module && module.id || null; + return ZeroClipboard; + }); + } else if (typeof module === "object" && module && typeof module.exports === "object" && module.exports && typeof window.require === "function") { + _cjsModuleId = module.id || null; + module.exports = ZeroClipboard; + } else { + window.ZeroClipboard = ZeroClipboard; + } +})(function() { + return this; +}());
\ No newline at end of file diff --git a/src/fauxton/assets/js/plugins/zeroclipboard/ZeroClipboard.swf b/src/fauxton/assets/js/plugins/zeroclipboard/ZeroClipboard.swf Binary files differnew file mode 100755 index 000000000..55ccf9608 --- /dev/null +++ b/src/fauxton/assets/js/plugins/zeroclipboard/ZeroClipboard.swf diff --git a/src/fauxton/tasks/couchserver.js b/src/fauxton/tasks/couchserver.js index 95b05e860..e1f18f919 100644 --- a/src/fauxton/tasks/couchserver.js +++ b/src/fauxton/tasks/couchserver.js @@ -51,6 +51,7 @@ module.exports = function (grunt) { filePath = path.join(app_dir, url.replace('/_utils/fauxton/','')); } else if (!!url.match(/assets/)) { // serve any javascript or css files from here assets dir + url = url.replace(/\?.*/, ''); filePath = path.join('./',url); } else if (!!url.match(/mocha|\/test\/core\/|test\.config/)) { filePath = path.join('./test', url.replace('/test/','')); diff --git a/src/snappy/Makefile.am b/src/snappy/Makefile.am index ff75f0705..4bcfaead0 100644 --- a/src/snappy/Makefile.am +++ b/src/snappy/Makefile.am @@ -10,6 +10,8 @@ ## License for the specific language governing permissions and limitations under ## the License. +AUTOMAKE_OPTIONS = subdir-objects + snappyebindir = $(localerlanglibdir)/snappy-1.0.5/ebin snappyprivdir = $(localerlanglibdir)/snappy-1.0.5/priv |