From 5236e415a484f264b3e288fd5d4aa7dc6f335cc5 Mon Sep 17 00:00:00 2001 From: Stefan Date: Wed, 30 Sep 2015 10:08:12 +0200 Subject: [PATCH 1/6] Renamed functions (asset related) --- js/AH5Communicator.js | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/js/AH5Communicator.js b/js/AH5Communicator.js index c7e2c2b..2f54b75 100644 --- a/js/AH5Communicator.js +++ b/js/AH5Communicator.js @@ -336,6 +336,7 @@ PluginAPI.Editor = (function () { }, callback); }; + /** * Initialize pre registered menus * @@ -350,45 +351,11 @@ PluginAPI.Editor = (function () { }, callback); }; - AH5Communicator.prototype.updateAssetMedia = function(data, callback) { + AH5Communicator.prototype.updateAssetData = function(data, callback) { PluginAPI.request('update-asset-media', data, callback); }; - - AH5Communicator.prototype.insertEmbeddedMedia = function(markup, data, callback) { - var insert = function(dpArticleId, callback) { - data.internalId = dpArticleId; - var element = $('
'); - element.attr('id', 'asset-' + dpArticleId); - element.attr('data-internal-id', dpArticleId); - element.attr('data-external-id', data.externalId); - element.addClass(data.assetClass); - var customMarkup = $(markup); - element.append(customMarkup); - this.insertElement(element, { select: true} , callback) - }.bind(this); - - var cb = function(callback) { - PluginAPI.request('update-embedded-asset', data, callback); - }; - - if (PluginAPI.selectedPluginElement) { - var dpArticleId = PluginAPI.selectedPluginElement.dpArticleId; - if (!dpArticleId) { - throw "Selected plugin element: expected dpArticleId not found (tried reading from attribute 'data-internal-id')"; - } - insert(dpArticleId, cb); - } else { - PluginAPI.createEmbeddedObject( - data.embeddedTypeId, - function(dpArticleId) { - insert(dpArticleId, cb); - } - ); - } - }; - - AH5Communicator.prototype.insertEmbeddedMedia = function(markup, data, callback) { + AH5Communicator.prototype.insertEmbeddedAsset = function(markup, data, callback) { var replaceElement = false; if (PluginAPI.selectedPluginElement) { if (data.assetSource !== PluginAPI.getAppName()) { From 1436bba3a8297e99726e021adefc9987781df332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ketil=20=C3=98vreb=C3=B8?= Date: Wed, 28 Oct 2015 10:18:33 +0100 Subject: [PATCH 2/6] Fix style issues and tests --- js/AH5Communicator.js | 25 +++++++++++-------------- js/ArticleCommunicator.js | 3 +-- karma.conf.js | 2 +- package.json | 3 ++- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/js/AH5Communicator.js b/js/AH5Communicator.js index 2f54b75..5e98ecb 100644 --- a/js/AH5Communicator.js +++ b/js/AH5Communicator.js @@ -1,11 +1,9 @@ /* global PluginAPI: true */ +/* jshint maxstatements:30 */ PluginAPI.Editor = (function () { "use strict"; - - - /** * This will be used by editor apps to communicate with the editor * @@ -19,16 +17,13 @@ PluginAPI.Editor = (function () { */ var AH5Communicator = function() { - var selectedPluginElement = null; - - var pluginElementSelected = function(element) { - PluginAPI.selectedPluginElement = element - } + PluginAPI.selectedPluginElement = element; + }; var pluginElementDeselected = function() { PluginAPI.selectedPluginElement = null; - } + }; this.DEBUG = false; @@ -39,10 +34,8 @@ PluginAPI.Editor = (function () { }; - AH5Communicator.prototype.selectedPluginElement = null; - /** * Get name of current active editor * @@ -389,18 +382,22 @@ PluginAPI.Editor = (function () { var updateEmbeddedAssetRequest = function(callback) { PluginAPI.request('update-embedded-asset', data, callback); }; - + if (PluginAPI.selectedPluginElement) { var dpArticleId = PluginAPI.selectedPluginElement.dpArticleId; if (!dpArticleId) { throw "Selected plugin element: expected dpArticleId not found (tried reading from attribute 'data-internal-id')"; } - insert(dpArticleId, function() {updateEmbeddedAssetRequest(callback)}); + insert(dpArticleId, function() { + updateEmbeddedAssetRequest(callback); + }); } else { PluginAPI.createEmbeddedObject( data.embeddedTypeId, function(dpArticleId) { - insert(dpArticleId, function() {updateEmbeddedAssetRequest(callback)}); + insert(dpArticleId, function() { + updateEmbeddedAssetRequest(callback); + }); } ); } diff --git a/js/ArticleCommunicator.js b/js/ArticleCommunicator.js index 89fc046..7813a4f 100644 --- a/js/ArticleCommunicator.js +++ b/js/ArticleCommunicator.js @@ -1,7 +1,6 @@ /* global PluginAPI: true */ -/* jshint maxstatements:44 */ - +/* jshint maxstatements:50 */ PluginAPI.Article = (function() { "use strict"; diff --git a/karma.conf.js b/karma.conf.js index ba0ace1..15644da 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ - 'js/vendor/jquery/dist/jquery.js', + 'node_modules/jquery/dist/jquery.js', 'js/vendors/*.js', 'js/Listeners.js', 'js/PluginAPI.js', diff --git a/package.json b/package.json index 9e21ebb..9f3f54d 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "karma-jasmine": "~0.2.0", "grunt-contrib-watch": "~0.6.1", "time-grunt": "~0.4.0", - "grunt-jsdoc": "~0.5.7" + "grunt-jsdoc": "~0.5.7", + "jquery": "~2.1.4" } } From 8b4836642bd07ef5001cf9176a26ce946d0f2337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ketil=20=C3=98vreb=C3=B8?= Date: Wed, 28 Oct 2015 10:19:57 +0100 Subject: [PATCH 3/6] Added method for opening plugin editors --- js/AH5Communicator.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/AH5Communicator.js b/js/AH5Communicator.js index 5e98ecb..d853839 100644 --- a/js/AH5Communicator.js +++ b/js/AH5Communicator.js @@ -344,6 +344,17 @@ PluginAPI.Editor = (function () { }, callback); }; + /** + * Opens the plugin editor for a given element. + * + * @param {String} id Plugin element ID + */ + AH5Communicator.prototype.openPluginElementEditor = function (id) { + PluginAPI.request('open-element-editor', { + id: id + }); + }; + AH5Communicator.prototype.updateAssetData = function(data, callback) { PluginAPI.request('update-asset-media', data, callback); }; From 9de20328409dcac5ba83b05baa0e2a6cfefd21d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ketil=20=C3=98vreb=C3=B8?= Date: Tue, 9 Feb 2016 13:06:18 +0100 Subject: [PATCH 4/6] Add API methods for retrieving the word/char counts from the open article --- js/AH5Communicator.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js/AH5Communicator.js b/js/AH5Communicator.js index d853839..fbb64dc 100644 --- a/js/AH5Communicator.js +++ b/js/AH5Communicator.js @@ -355,6 +355,24 @@ PluginAPI.Editor = (function () { }); }; + /** + * Returns the total number of words in the currently open article. + * + * @param {Function} callback Receives the total word count as its single parameter + */ + AH5Communicator.prototype.getTotalWordCount = function (callback) { + PluginAPI.request('total-word-count', null, callback); + }; + + /** + * Returns the total number of characters in the currently open article. + * + * @param {Function} callback Receives the total character count as its single parameter + */ + AH5Communicator.prototype.getTotalCharCount = function (callback) { + PluginAPI.request('total-char-count', null, callback); + }; + AH5Communicator.prototype.updateAssetData = function(data, callback) { PluginAPI.request('update-asset-media', data, callback); }; From 02546105363a578bc924da447bc5a2dde128831c Mon Sep 17 00:00:00 2001 From: arasix Date: Mon, 18 Apr 2016 14:46:58 +0200 Subject: [PATCH 5/6] Added option for getting DrPublish config --- js/PluginAPI.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/js/PluginAPI.js b/js/PluginAPI.js index cbefe7b..e499bac 100644 --- a/js/PluginAPI.js +++ b/js/PluginAPI.js @@ -382,6 +382,15 @@ var PluginAPI = (function() { this.request('get-configuration', null, callback); }; + /** + * Get DrPublish configuratin + * + * @param {Function} callback function(Object) + */ + Api.prototype.getDrPublishConfiguration = function (callback) { + this.request('get-drpublish-configuration', null, callback); + }; + /** * Set configuration information about the app * From f954c08266d63e55d96a974627b7e4b857fa3195 Mon Sep 17 00:00:00 2001 From: arasix Date: Thu, 28 Apr 2016 08:23:15 +0200 Subject: [PATCH 6/6] JWT auth - work in progress --- js/PluginAPI.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/PluginAPI.js b/js/PluginAPI.js index e499bac..aa544f9 100644 --- a/js/PluginAPI.js +++ b/js/PluginAPI.js @@ -634,5 +634,11 @@ var PluginAPI = (function() { this.request('get-custom-modal-inputs', null, callback); }; + Api.prototype.confirmAuthenticated = function() { + this.request("confirm-authenticated", { + pluginName: this.appName + }); + }; + return new Api(); })();