Last active
May 20, 2021 19:12
-
-
Save ao5357/ed2278b86e6b1f950e726666415efad7 to your computer and use it in GitHub Desktop.
ckeditor patches for nypl D7 classic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 6b72c5388c6457f285cde93edca508187fb40253 Mon Sep 17 00:00:00 2001 | |
From: Brad Czerniak <[email protected]> | |
Date: Thu, 20 May 2021 14:51:09 -0400 | |
Subject: [PATCH] RENO-2169 Include NYPL plugins in ckeditor | |
--- | |
plugins/catalogimage/dialogs/catalogimage.js | 90 ++++++++++ | |
plugins/catalogimage/images/catalogimage.png | Bin 0 -> 471 bytes | |
plugins/catalogimage/plugin.js | 136 +++++++++++++++ | |
plugins/cataloglink/icons/cataloglink.png | Bin 0 -> 1150 bytes | |
plugins/cataloglink/images/cataloglink.png | Bin 0 -> 394 bytes | |
plugins/cataloglink/plugin.js | 159 ++++++++++++++++++ | |
.../dialogs/digitalcollection.js | 91 ++++++++++ | |
.../icons/digitalcollection.png | Bin 0 -> 1150 bytes | |
.../icons/digitalcollectiontest.png | Bin 0 -> 622 bytes | |
.../images/digitalcollection.png | Bin 0 -> 474 bytes | |
plugins/digitalcollection/plugin.js | 137 +++++++++++++++ | |
11 files changed, 613 insertions(+) | |
create mode 100644 plugins/catalogimage/dialogs/catalogimage.js | |
create mode 100644 plugins/catalogimage/images/catalogimage.png | |
create mode 100644 plugins/catalogimage/plugin.js | |
create mode 100644 plugins/cataloglink/icons/cataloglink.png | |
create mode 100644 plugins/cataloglink/images/cataloglink.png | |
create mode 100644 plugins/cataloglink/plugin.js | |
create mode 100644 plugins/digitalcollection/dialogs/digitalcollection.js | |
create mode 100644 plugins/digitalcollection/icons/digitalcollection.png | |
create mode 100755 plugins/digitalcollection/icons/digitalcollectiontest.png | |
create mode 100644 plugins/digitalcollection/images/digitalcollection.png | |
create mode 100644 plugins/digitalcollection/plugin.js | |
diff --git a/plugins/catalogimage/dialogs/catalogimage.js b/plugins/catalogimage/dialogs/catalogimage.js | |
new file mode 100644 | |
index 0000000000000000000000000000000000000000..759ce9d738e56bff53343996aa4f61548eb647fd | |
--- /dev/null | |
+++ b/plugins/catalogimage/dialogs/catalogimage.js | |
@@ -0,0 +1,90 @@ | |
+/*jslint indent: 2, maxlen: 80 */ | |
+/*globals CKEDITOR */ | |
+ | |
+CKEDITOR.dialog.add('catalogimageDialog', function (editor) { | |
+ 'use strict'; | |
+ return { | |
+ title: 'Catalog Image', | |
+ minWidth: 200, | |
+ minHeight: 100, | |
+ contents: [ | |
+ { | |
+ id: 'info', | |
+ elements: [ | |
+ { | |
+ id: 'align', | |
+ type: 'select', | |
+ label: 'Align', | |
+ items: [ | |
+ [ editor.lang.common.notSet, '' ], | |
+ [ editor.lang.common.alignLeft, 'left' ], | |
+ [ editor.lang.common.alignRight, 'right' ], | |
+ [ editor.lang.common.alignCenter, 'center' ] | |
+ ], | |
+ setup: function (widget) { | |
+ this.setValue(widget.data.align); | |
+ }, | |
+ commit: function (widget) { | |
+ widget.setData('align', this.getValue()); | |
+ } | |
+ }, | |
+ { | |
+ id: 'width', | |
+ type: 'text', | |
+ label: 'Width (px)', | |
+ setup: function (widget) { | |
+ this.setValue(widget.data.width); | |
+ }, | |
+ commit: function (widget) { | |
+ widget.setData('width', this.getValue()); | |
+ } | |
+ }, | |
+ { | |
+ id: 'alt', | |
+ type: 'text', | |
+ label: 'Alt Text', | |
+ required: true, | |
+ validate: CKEDITOR.dialog | |
+ .validate.notEmpty("Please fill out the Alternative Text field."), | |
+ setup: function (widget) { | |
+ this.setValue(widget.data.alt); | |
+ }, | |
+ commit: function (widget) { | |
+ widget.setData('alt', this.getValue()); | |
+ } | |
+ }, | |
+ { | |
+ id: 'img_url', | |
+ type: 'text', | |
+ label: 'Image URL', | |
+ required: true, | |
+ validate: CKEDITOR.dialog | |
+ .validate.notEmpty("The Image URL field cannot be empty. " + | |
+ "Please add the URL for the image."), | |
+ setup: function (widget) { | |
+ this.setValue(widget.data.img_url); | |
+ }, | |
+ commit: function (widget) { | |
+ widget.setData('img_url', this.getValue()); | |
+ } | |
+ }, | |
+ { | |
+ id: 'img_link', | |
+ type: 'text', | |
+ label: 'Catalog Link', | |
+ required: true, | |
+ validate: CKEDITOR.dialog | |
+ .validate.notEmpty("The Encore Destination Link field cannot be empty. " + | |
+ "Please add a URL to link the image to."), | |
+ setup: function (widget) { | |
+ this.setValue(widget.data.img_link); | |
+ }, | |
+ commit: function (widget) { | |
+ widget.setData('img_link', this.getValue()); | |
+ } | |
+ } | |
+ ] | |
+ } | |
+ ] | |
+ }; | |
+}); | |
\ No newline at end of file | |
diff --git a/plugins/catalogimage/images/catalogimage.png b/plugins/catalogimage/images/catalogimage.png | |
new file mode 100644 | |
index 0000000000000000000000000000000000000000..878b469f612e2fc9ced4f91220d156b8b88930e2 | |
GIT binary patch | |
literal 471 | |
zcmV;|0Vw{7P)<h;3K|Lk000e1NJLTq000mG000mO1^@s7X!Otb0000PbVXQnQ*UN; | |
zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUzc}YY;RCwBAU;u)M$f*4wn&CeX00a=2 | |
z$I8yJpW*(42mhU2UH=0F5M1iQg$rN-Mz~ri00<yPNokq=_I7q)&Wh#B92uILoBzLm | |
z{~o01Kgcj9kc@zU089r1)5VLI7?1%#0D%!m8^~H1IB@VF*haV!AfO;G&+y>kLxv9@ | |
zJ}|&61pyWi@!`WqxFU1_cDJ#q+5g_2ZVX9RH}?Yo0mKNjM?W|yXac$<*iRq;RDj|@ | |
zWQT&i1+)9&#fuCO_k2Jx3GNGheSL<Fn>L{Y3fu}1fLQ}F8rcf40#H<-+mGS~el%mz | |
z1M0)WhYtmS7)24x(EtGkv*vwLN(xr*qFW7$BOut1?n?nsP{88r0T$bk<M802Lk{4C | |
z2a8K&0E<tsrjH*P^!4<>L5K@5VG{(o02DAF8y`Yb5H7%it`R*|!E6UQ8zpox3|O>y | |
zF#{oR2xtg;j({65XZCEc4Qw2o45R=?Xf(zHDNvFYAVKee-#>pi0swRp3l35y?-&38 | |
N002ovPDHLkV1gpkv+Mu> | |
literal 0 | |
HcmV?d00001 | |
diff --git a/plugins/catalogimage/plugin.js b/plugins/catalogimage/plugin.js | |
new file mode 100644 | |
index 0000000000000000000000000000000000000000..422b3ac584af6f563c5d4e238b00e9402762ff21 | |
--- /dev/null | |
+++ b/plugins/catalogimage/plugin.js | |
@@ -0,0 +1,136 @@ | |
+/*jslint indent: 2, maxlen: 80 */ | |
+/*globals CKEDITOR */ | |
+ | |
+CKEDITOR.plugins.add('catalogimage', { | |
+ requires: 'widget', | |
+ icons: 'catalogimage', | |
+ init: function (editor) { | |
+ 'use strict'; | |
+ | |
+ CKEDITOR.dialog.add( | |
+ 'catalogimageDialog', | |
+ this.path + 'dialogs/catalogimage.js' | |
+ ); | |
+ | |
+ editor.ui.addButton('catalogimage', { | |
+ label: 'Add Catalog Image', | |
+ command: 'catalogimage', | |
+ icon: this.path + 'images/catalogimage.png', | |
+ toolbar: 'nypl' | |
+ }); | |
+ | |
+ // if (editor.contextMenu) { | |
+ // editor.addMenuGroup('catalogImageGroup'); | |
+ // editor.addMenuItem('catalogImageItem', { | |
+ // label: 'Edit Catalog Image', | |
+ // icon: this.path + 'images/catalogimage.png', | |
+ // command: 'catalogimageDialog', | |
+ // group: 'catalogImageGroup' | |
+ // }); | |
+ // editor.contextMenu.addListener(function (element) { | |
+ // var catalogElement = element.getAscendant('figure', true); | |
+ // if (catalogElement && | |
+ // catalogElement.getAttribute('class').indexOf('catalog-image') !== 0) { | |
+ // return { catalogImageItem: CKEDITOR.TRISTATE_OFF }; | |
+ // } | |
+ // }); | |
+ // } | |
+ | |
+ editor.widgets.add('catalogimage', { | |
+ dialog: 'catalogimageDialog', | |
+ init: function () { | |
+ var img = this.element.find('img').getItem(0), | |
+ link = this.element.find('a').getItem(0), | |
+ alt = img.getAttribute('alt'), | |
+ width = img.getAttribute('width'), | |
+ img_url = img.getAttribute('src'), | |
+ img_link = link.getAttribute('href'); | |
+ | |
+ if (alt && alt !== undefined) { | |
+ this.setData('alt', alt); | |
+ } | |
+ if (width) { | |
+ this.setData('width', width); | |
+ } | |
+ if (img_url) { | |
+ this.setData('img_url', img_url); | |
+ } | |
+ if (img_link) { | |
+ this.setData('img_link', img_link); | |
+ } | |
+ | |
+ if (this.element.hasClass('align-left')) { | |
+ this.setData('align', 'left'); | |
+ } | |
+ if (this.element.hasClass('align-right')) { | |
+ this.setData('align', 'right'); | |
+ } | |
+ if (this.element.hasClass('align-center')) { | |
+ this.setData('align', 'center'); | |
+ } | |
+ }, | |
+ data: function () { | |
+ var img = this.element.find('img').getItem(0), | |
+ link = this.element.find('a').getItem(0); | |
+ | |
+ if (this.data.alt === '') { | |
+ img.setAttribute('alt', ''); | |
+ } else { | |
+ img.setAttribute('alt', this.data.alt); | |
+ } | |
+ | |
+ if (this.data.width === '') { | |
+ img.setAttribute('width', ''); | |
+ } else { | |
+ img.setAttribute('width', this.data.width); | |
+ } | |
+ | |
+ if (this.data.img_url === '') { | |
+ img.setAttribute('src', ''); | |
+ } else { | |
+ img.setAttribute('src', this.data.img_url); | |
+ img.setAttribute('data-cke-saved-src', this.data.img_url); | |
+ } | |
+ | |
+ if (this.data.img_link === '') { | |
+ link.setAttribute('href', ''); | |
+ } else { | |
+ link.setAttribute('href', this.data.img_link); | |
+ link.setAttribute('data-cke-saved-href', this.data.img_link) | |
+ } | |
+ | |
+ this.element.removeClass('inline'); | |
+ this.element.removeClass('align-left'); | |
+ this.element.removeClass('align-right'); | |
+ this.element.removeClass('align-center'); | |
+ | |
+ if (this.data.align) { | |
+ this.element.addClass('align-' + this.data.align); | |
+ } | |
+ if (this.data.align !== 'center') { | |
+ this.element.addClass('inline'); | |
+ } | |
+ }, | |
+ | |
+ template: | |
+ '<figure class="catalog-image caption">' + | |
+ '<a href="">' + | |
+ '<img src="" width="150px" alt=""/></a>' + | |
+ '<figcaption class="catalog-caption">Caption</figcaption>' + | |
+ '</figure>', | |
+ editables: { | |
+ caption: { | |
+ selector: '.catalog-caption', | |
+ allowedContent: 'strong em' | |
+ } | |
+ }, | |
+ allowedContent: | |
+ // 'div(!catalog-image,inline,align-left,align-right,align-center);' + | |
+ 'figure(!catalog-image, caption);a;img;figcaption(!catalog-caption);', | |
+ // requiredContent: 'div(catalog-image)', | |
+ upcast: function (element) { | |
+ return element.name === 'figure' && element.hasClass('catalog-image'); | |
+ } | |
+ }); | |
+ } | |
+}); | |
diff --git a/plugins/cataloglink/icons/cataloglink.png b/plugins/cataloglink/icons/cataloglink.png | |
new file mode 100644 | |
index 0000000000000000000000000000000000000000..156f779b3ba057b9f52f216f03a4693cc52a5d01 | |
GIT binary patch | |
literal 1150 | |
zcmZ`(TP&PG6rPQ~C=Fhk3JKw*Pb_sQX(Up&+D4-q%Y)n6T~u1@cfVw@%M!N-#oA~h | |
z;Xz8J)>}!~day#f>VZVI5q0Y(NL;$<YRK1_5lt_gKQsS7-<)&iob#Re2@%o9-JQ_c | |
zm*n3d<TfGXE*%u2$OTScT>JwFVdFZPpEskg&j78q5tWsd2no3dwYm<vre?6c>+Bfb | |
z-~SqIZEe`y-2s!VtPH5@)co7w_yMEQNPSja=|`i{a-1vEsiM3b;o+e;J3G6CV7Grq | |
zVqya1a>ZXhy1HIra%$?gUQ0_ef`i4_*|~^=ZESCEBQP)kt*xzGucD%o=fZOG@$rGp | |
z_Ko9uy&e)tA`T7?_?n$RI5-G@e?J;e7&Mv&tgo*_p-`Z^yBqE8od^pH#n01IEG#S_ | |
zIyxH1$H&~(Y@S0<P#`-8$;nSRc5-q8N#Y~ubWOCbYOpv`Q=ft1GMNk}(+t-uD=Wn< | |
zS63*NN;GP<h=>SBbF&UZLqjMoR&gDpaRMD3oyg6VVRG_46mmJopBEHBEEZ#WdYZ4< | |
zw6(Pb>lZ7=#@<4uD#G609<O0fPcJ4WjL6K)Kpo|3c6Jt$#}b^<eEyY<jju>clfui( | |
z6RWGMV75wSKKA$bP*_+9Z*MQu*4AKT<PA4HKR?IP(h@!{F7h?2PfE&D-cvT44ddhE | |
zv<^B%Mn+&@U;wePG4Swkr}#UrZ@1f#o}Px`;bF|p&GEQLM@MLVPxyXybv4f+J3E{6 | |
zl9ZGL7Z(>KB*by<kB*LDv3%lvER{-OwOY9yn=BR!^!h&D0|tWuGcz+-TU(>`9pw43 | |
zTm(UYr{^7R&tkb0#xLXl&$}Q9CGhj}<@M20zLu9iV`XK9@^&8%hvU+e_Td)tXw9y= | |
zOYGj&)YM>ea}ys-Cd9|b!c6mK!uZnbdnxzAmA03$Fuz@0-H3~eL(Ib%G&E>v9wn3) | |
zHO%J!@9&{osj%Uc7iAJTJJ*X8RfH71AVj4iB!G^WrGymZ5>iV47z&CDIrXBzLX#-! | |
N=7y8=gF`nV=NDO<ks1I1 | |
literal 0 | |
HcmV?d00001 | |
diff --git a/plugins/cataloglink/images/cataloglink.png b/plugins/cataloglink/images/cataloglink.png | |
new file mode 100644 | |
index 0000000000000000000000000000000000000000..5f28a5db15967fdc0189913644e637cf002043c5 | |
GIT binary patch | |
literal 394 | |
zcmV;50d@X~P)<h;3K|Lk000e1NJLTq000mG000mO1^@s7X!Otb0000PbVXQnQ*UN; | |
zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUzEJ;K`RCwBAWM${jXJBA3U}k1vSpj5x | |
z00<z4h{&k@3?KlMst4lt009JI?Eeo0AesRgfMkLAKR^J1^}zLkz<(%!@mbh7I17NZ | |
z094z4WHaW2Xn+8M+X4gVwlOgf0ze)9Am?Dg^T8g$qG3O>1V8{W>KPdB*V5F4D_F67 | |
znInphrsn4V6giTh0!E;b>w)wIBryjdegMP=fH;8>>S6&T1s{O80IDeg-HZL8I0oW) | |
zXk25sK>?HiK-T>J`Qsu;03g6Xy4It670uhA5RJ#@O928NRlsm7Ns&zeuz-jM4<9ld | |
zJamXC4WNL6x(F1^4X}7P01aLR9Qt5!695Z9Xt+!u#>V;3JoX<NJ^!K6HJ=#G?_n_j | |
ojo<e~X+$yrq-i}=V?Q=E0N84Z?&MNM)c^nh07*qoM6N<$g0)1MF#rGn | |
literal 0 | |
HcmV?d00001 | |
diff --git a/plugins/cataloglink/plugin.js b/plugins/cataloglink/plugin.js | |
new file mode 100644 | |
index 0000000000000000000000000000000000000000..e4546c35c390a262bbc5752dc00c87df0e2792a0 | |
--- /dev/null | |
+++ b/plugins/cataloglink/plugin.js | |
@@ -0,0 +1,159 @@ | |
+/*jslint indent: 2, maxlen: 80 */ | |
+/*globals CKEDITOR */ | |
+ | |
+CKEDITOR.plugins.add('cataloglink', { | |
+ init: function (editor) { | |
+ 'use strict'; | |
+ | |
+ editor.addCommand( | |
+ 'cataloglinkDialog', | |
+ new CKEDITOR.dialogCommand('cataloglinkDialog') | |
+ ); | |
+ | |
+ editor.ui.addButton('cataloglink', { | |
+ label: 'Insert Catalog Link', | |
+ command: 'cataloglinkDialog', | |
+ icon: this.path + 'images/cataloglink.png', | |
+ toolbar: 'nypl' | |
+ }); | |
+ | |
+ if (editor.contextMenu) { | |
+ editor.addMenuGroup('catalogLinkGroup'); | |
+ editor.addMenuItem('catalogLinkItem', { | |
+ label: 'Edit Catalog Link', | |
+ icon: this.path + 'images/cataloglink.png', | |
+ command: 'cataloglinkDialog', | |
+ group: 'catalogLinkGroup' | |
+ }); | |
+ editor.contextMenu.addListener(function (element) { | |
+ var catalogElement = element.getAscendant('a', true); | |
+ if (catalogElement && | |
+ catalogElement.getAttribute('class') === 'catalog-link') { | |
+ return { catalogLinkItem: CKEDITOR.TRISTATE_OFF }; | |
+ } | |
+ }) | |
+ } | |
+ | |
+ CKEDITOR.dialog.add('cataloglinkDialog', function (editor) { | |
+ return { | |
+ title: 'Catalog Link Properties', | |
+ minWidth: 400, | |
+ minHeight: 200, | |
+ contents: [ | |
+ { | |
+ id: 'tab1', | |
+ label: 'Add a Catalog link (Id or keywords)', | |
+ elements: [ | |
+ { | |
+ type: 'text', | |
+ id: 'text', | |
+ label: 'Text', | |
+ setup: function (element) { | |
+ this.setValue(element.getText()); | |
+ }, | |
+ commit: function (element) { | |
+ var text = this.getValue(); | |
+ if (text) { | |
+ element.setText(text); | |
+ } else if (!this.insertMode) { | |
+ element.removeText(text); | |
+ } | |
+ } | |
+ }, | |
+ { | |
+ type: 'text', | |
+ id: 'id', | |
+ label: 'Id', | |
+ setup: function (element) { | |
+ this.setValue(element.getAttribute('data-id')); | |
+ }, | |
+ commit: function (element) { | |
+ var id = this.getValue(); | |
+ if (id) { | |
+ element.setAttribute('data-id', id); | |
+ } else if (!this.insertMode) { | |
+ element.removeAttribute('data-id'); | |
+ } | |
+ } | |
+ }, | |
+ { | |
+ type: 'text', | |
+ id: 'keywords', | |
+ label: 'Keywords', | |
+ setup: function (element) { | |
+ this.setValue(element.getAttribute('data-keywords')); | |
+ }, | |
+ commit: function (element) { | |
+ var keywords = this.getValue(); | |
+ if (keywords) { | |
+ element.setAttribute('data-keywords', keywords); | |
+ } else if (!this.insertMode) { | |
+ element.removeAttribute('data-keywords'); | |
+ } | |
+ } | |
+ } | |
+ ] | |
+ } | |
+ ], | |
+ | |
+ onShow: function () { | |
+ var selection = editor.getSelection(), | |
+ element = selection.getStartElement(); | |
+ | |
+ if (element) { | |
+ element = element.getAscendant('a', true); | |
+ } | |
+ | |
+ if (!element || element.getName() !== 'a') { | |
+ element = editor.document.createElement('a'); | |
+ this.insertMode = true; | |
+ } else { | |
+ this.insertMode = false; | |
+ } | |
+ | |
+ this.element = element; | |
+ | |
+ if (!this.insertMode) { | |
+ this.setupContent(this.element); | |
+ } | |
+ }, | |
+ | |
+ onOk: function () { | |
+ var base = 'http://browse.nypl.org/iii/encore/search/', | |
+ dialog = this, | |
+ id = dialog.getValueOf('tab1', 'id'), | |
+ text = dialog.getValueOf('tab1', 'text'), | |
+ keywords = dialog.getValueOf('tab1', 'keywords'), | |
+ keywordsArr = keywords.split(' ').join('%20'), | |
+ cataloglink = dialog.element, | |
+ search = '', | |
+ link = ''; | |
+ | |
+ dialog.commitContent(cataloglink); | |
+ | |
+ if (dialog.insertMode) { | |
+ editor.insertElement(cataloglink); | |
+ } | |
+ | |
+ if (id) { | |
+ search += id; | |
+ } | |
+ if (keywords) { | |
+ search += '%20' + keywordsArr; | |
+ } | |
+ | |
+ link = base + 'C__S' + search + '__Orightresult__U?lang=eng&suite=def'; | |
+ | |
+ cataloglink.setAttribute('data-id', id); | |
+ cataloglink.setAttribute('data-keywords', keywords); | |
+ | |
+ cataloglink.setAttribute('class', 'catalog-link'); | |
+ cataloglink.setAttribute('title', text); | |
+ cataloglink.setText(text); | |
+ cataloglink.setAttribute('data-cke-saved-href', link); | |
+ cataloglink.setAttribute('href', link); | |
+ } | |
+ }; | |
+ }); | |
+ } | |
+}); | |
\ No newline at end of file | |
diff --git a/plugins/digitalcollection/dialogs/digitalcollection.js b/plugins/digitalcollection/dialogs/digitalcollection.js | |
new file mode 100644 | |
index 0000000000000000000000000000000000000000..6e2314e6091860e701fbda44b870862dfea593ea | |
--- /dev/null | |
+++ b/plugins/digitalcollection/dialogs/digitalcollection.js | |
@@ -0,0 +1,91 @@ | |
+/*jslint indent: 2, maxlen: 80 */ | |
+/*globals CKEDITOR */ | |
+ | |
+CKEDITOR.dialog.add('digitalcollectionDialog', function (editor) { | |
+ 'use strict'; | |
+ | |
+ return { | |
+ title: 'Digital Collection Image', | |
+ minWidth: 200, | |
+ minHeight: 100, | |
+ contents: [ | |
+ { | |
+ id: 'info', | |
+ elements: [ | |
+ { | |
+ id: 'align', | |
+ type: 'select', | |
+ label: 'Align', | |
+ items: [ | |
+ [ editor.lang.common.notSet, '' ], | |
+ [ editor.lang.common.alignLeft, 'left' ], | |
+ [ editor.lang.common.alignRight, 'right' ], | |
+ [ editor.lang.common.alignCenter, 'center' ] | |
+ ], | |
+ setup: function (widget) { | |
+ this.setValue(widget.data.align); | |
+ }, | |
+ commit: function (widget) { | |
+ widget.setData('align', this.getValue()); | |
+ } | |
+ }, | |
+ { | |
+ id: 'width', | |
+ type: 'text', | |
+ label: 'Width (px)', | |
+ setup: function (widget) { | |
+ this.setValue(widget.data.width); | |
+ }, | |
+ commit: function (widget) { | |
+ widget.setData('width', this.getValue()); | |
+ } | |
+ }, | |
+ { | |
+ id: 'alt', | |
+ type: 'text', | |
+ label: 'Alt Text', | |
+ required: true, | |
+ validate: CKEDITOR.dialog | |
+ .validate.notEmpty("Please fill out the Alternative Text field."), | |
+ setup: function (widget) { | |
+ this.setValue(widget.data.alt); | |
+ }, | |
+ commit: function (widget) { | |
+ widget.setData('alt', this.getValue()); | |
+ } | |
+ }, | |
+ { | |
+ id: 'img_id', | |
+ type: 'text', | |
+ label: 'Image ID', | |
+ required: true, | |
+ validate: CKEDITOR.dialog | |
+ .validate.notEmpty("The Image ID field cannot be empty. " + | |
+ "Please use the ID for the image from Digital Collections."), | |
+ setup: function (widget) { | |
+ this.setValue(widget.data.img_id); | |
+ }, | |
+ commit: function (widget) { | |
+ widget.setData('img_id', this.getValue()); | |
+ } | |
+ }, | |
+ { | |
+ id: 'img_url', | |
+ type: 'text', | |
+ label: 'Image URL', | |
+ required: true, | |
+ validate: CKEDITOR.dialog | |
+ .validate.notEmpty("The Image URL cannot be empty. Please use " + | |
+ "The URL for the image from Digital Collections."), | |
+ setup: function (widget) { | |
+ this.setValue(widget.data.img_url); | |
+ }, | |
+ commit: function (widget) { | |
+ widget.setData('img_url', this.getValue()); | |
+ } | |
+ } | |
+ ] | |
+ } | |
+ ] | |
+ }; | |
+}); | |
\ No newline at end of file | |
diff --git a/plugins/digitalcollection/icons/digitalcollection.png b/plugins/digitalcollection/icons/digitalcollection.png | |
new file mode 100644 | |
index 0000000000000000000000000000000000000000..156f779b3ba057b9f52f216f03a4693cc52a5d01 | |
GIT binary patch | |
literal 1150 | |
zcmZ`(TP&PG6rPQ~C=Fhk3JKw*Pb_sQX(Up&+D4-q%Y)n6T~u1@cfVw@%M!N-#oA~h | |
z;Xz8J)>}!~day#f>VZVI5q0Y(NL;$<YRK1_5lt_gKQsS7-<)&iob#Re2@%o9-JQ_c | |
zm*n3d<TfGXE*%u2$OTScT>JwFVdFZPpEskg&j78q5tWsd2no3dwYm<vre?6c>+Bfb | |
z-~SqIZEe`y-2s!VtPH5@)co7w_yMEQNPSja=|`i{a-1vEsiM3b;o+e;J3G6CV7Grq | |
zVqya1a>ZXhy1HIra%$?gUQ0_ef`i4_*|~^=ZESCEBQP)kt*xzGucD%o=fZOG@$rGp | |
z_Ko9uy&e)tA`T7?_?n$RI5-G@e?J;e7&Mv&tgo*_p-`Z^yBqE8od^pH#n01IEG#S_ | |
zIyxH1$H&~(Y@S0<P#`-8$;nSRc5-q8N#Y~ubWOCbYOpv`Q=ft1GMNk}(+t-uD=Wn< | |
zS63*NN;GP<h=>SBbF&UZLqjMoR&gDpaRMD3oyg6VVRG_46mmJopBEHBEEZ#WdYZ4< | |
zw6(Pb>lZ7=#@<4uD#G609<O0fPcJ4WjL6K)Kpo|3c6Jt$#}b^<eEyY<jju>clfui( | |
z6RWGMV75wSKKA$bP*_+9Z*MQu*4AKT<PA4HKR?IP(h@!{F7h?2PfE&D-cvT44ddhE | |
zv<^B%Mn+&@U;wePG4Swkr}#UrZ@1f#o}Px`;bF|p&GEQLM@MLVPxyXybv4f+J3E{6 | |
zl9ZGL7Z(>KB*by<kB*LDv3%lvER{-OwOY9yn=BR!^!h&D0|tWuGcz+-TU(>`9pw43 | |
zTm(UYr{^7R&tkb0#xLXl&$}Q9CGhj}<@M20zLu9iV`XK9@^&8%hvU+e_Td)tXw9y= | |
zOYGj&)YM>ea}ys-Cd9|b!c6mK!uZnbdnxzAmA03$Fuz@0-H3~eL(Ib%G&E>v9wn3) | |
zHO%J!@9&{osj%Uc7iAJTJJ*X8RfH71AVj4iB!G^WrGymZ5>iV47z&CDIrXBzLX#-! | |
N=7y8=gF`nV=NDO<ks1I1 | |
literal 0 | |
HcmV?d00001 | |
diff --git a/plugins/digitalcollection/icons/digitalcollectiontest.png b/plugins/digitalcollection/icons/digitalcollectiontest.png | |
new file mode 100755 | |
index 0000000000000000000000000000000000000000..7d863f949741ff83fd8373a77c0d95a3d95e441f | |
GIT binary patch | |
literal 622 | |
zcmV-!0+IcRP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00004XF*Lt006JZ | |
zHwB960000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!07*naR5;6} | |
zQ_pJ?Q4pS$w@qAVekfW^Q_+&87>YeaZ-G+53gSTz{SPWVdFiPaPX+$~@n)fi9>qgJ | |
zh4fN-QcEhq^wI<|vImjml9)pF*W2zl+qWbTPaSyKyqWKt`DS)j3xa?yVgf%ewhl|m | |
zA$_0x^Rx4E@d&=>uRoSN*Cm&aL#`7&zr0;L(pKMn1G#$ZszFkMC^?B8f`0w&-UD$u | |
zd-(?iK6#!;xZ`>J^A9DGiTfguewDOKwDEK<mL;X6%J<*Yu-X+69xa&k<iYHS^wR1Z | |
zn$Yzsw*a}YdcDs7QDJF*p6*-`Hzy}kG&7Z@TCK*he!oxUa+w^*4qKUsW&i@rG))Gf | |
zSIe@<YPG0XERt;-9D~2t>oL}`ZE_M}0=xvsgf$usmJeV$oo28d0#yu!pdgpag$giC | |
zhlKP!CMX3wsPMGgZ5n>Xg+hV--ENofAcH61#0B7Hvl-7Il}g2A6;lfG`FxbX8A>p$ | |
z0P;GW4il9Mr9jO9)xB^Rgy%*CSTdQ6D;kDDnM{U{5Q21FA4#ZM71$_Dba8z<-Y_Na | |
zS@|v#c0PZNDux9AoXD-ZoWP~q)7QrC`G<o;20dP08XMo;{X}9g7*MPCZ)C@nf*VuU | |
zxl(0sf2;zmy!OAZ(OlWwK0WO}#Ezsh*^}n`SIgsY+C@L-GloW+?l6nAU;qFB07*qo | |
IM6N<$f=tvEoB#j- | |
literal 0 | |
HcmV?d00001 | |
diff --git a/plugins/digitalcollection/images/digitalcollection.png b/plugins/digitalcollection/images/digitalcollection.png | |
new file mode 100644 | |
index 0000000000000000000000000000000000000000..513260c850639542b123402a12a44292c6f33d0a | |
GIT binary patch | |
literal 474 | |
zcmV<00VV#4P)<h;3K|Lk000e1NJLTq000mG000mO1^@s7X!Otb0000PbVXQnQ*UN; | |
zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUzd`Uz>RCwBAU}fj92jc%s3{U_NK#U+B | |
zhyfPK&B<W^2p|TKnuUuN{RaURHMRdBCHz211DGCw0D|j*1CUZ<Q?vi?-@pIg)Z7d) | |
z{?esO3}O<Ja4q)8IsgI)Y|DQ%aR0%B{~)vBMt}et2PYUWTD+JcBs7fS*N^WABX8Zj | |
zap2*@hYaZ8(4j*N1OY$*Vfq6VG%(fHRD<n%_2N0024Q}FeumYnRx-c?4Fq8R1Oa<H | |
zI|cy(0fd4FPzQp10b=Lo=71G}01Jq4b#sI3R#Vpi(=cy>70j7E8^d)MFJ8nEw5Z?# | |
z!EgWwFmPOe!kkn9(gW06&xCH^hYueZM8ze*G%`2{j22jYx*&NP!vGgIcZQE2KZ3(G | |
zIW-j}Y+(_xXV)(51{9Z+f)gJMEMB|>Y$M1;AX-&j9m8dC12%5j#4vfv6s+L{auEnT | |
zeE10LvV%ye3>*#e@^S~{<>eVj0ifgyG_ZjYEk^2z)W6{O&mRx51|q2d0ID0*UUxyz | |
Qg8%>k07*qoM6N<$f{KN>eE<Le | |
literal 0 | |
HcmV?d00001 | |
diff --git a/plugins/digitalcollection/plugin.js b/plugins/digitalcollection/plugin.js | |
new file mode 100644 | |
index 0000000000000000000000000000000000000000..ff54979ac3fa1d2d992272d18cdc44838354dcbc | |
--- /dev/null | |
+++ b/plugins/digitalcollection/plugin.js | |
@@ -0,0 +1,137 @@ | |
+/*jslint indent: 2, maxlen: 80 */ | |
+/*globals CKEDITOR */ | |
+ | |
+CKEDITOR.plugins.add('digitalcollection', { | |
+ requires: 'widget', | |
+ icons: 'digitalcollection', | |
+ init: function (editor) { | |
+ 'use strict'; | |
+ | |
+ CKEDITOR.dialog.add( | |
+ 'digitalcollectionDialog', | |
+ this.path + 'dialogs/digitalcollection.js' | |
+ ); | |
+ | |
+ editor.ui.addButton('digitalcollection', { | |
+ label: 'Add Digital Collections Image', | |
+ command: 'digitalcollection', | |
+ icon: this.path + 'images/digitalcollection.png', | |
+ toolbar: 'nypl' | |
+ }); | |
+ | |
+ editor.widgets.add('digitalcollection', { | |
+ dialog: 'digitalcollectionDialog', | |
+ init: function () { | |
+ var img = this.element.find('img').getItem(0), | |
+ link = this.element.find('a').getItem(0), | |
+ alt = img.getAttribute('alt'), | |
+ width = img.getAttribute('width'), | |
+ img_id = img.data('id'), | |
+ img_url = link.data('url'); | |
+ | |
+ if (alt && alt !== undefined) { | |
+ this.setData('alt', alt); | |
+ } | |
+ if (width) { | |
+ this.setData('width', width); | |
+ } | |
+ if (img_id) { | |
+ this.setData('img_id', img_id); | |
+ } | |
+ if (img_url) { | |
+ this.setData('img_url', img_url); | |
+ } | |
+ | |
+ if (this.element.hasClass('align-left')) { | |
+ this.setData('align', 'left'); | |
+ } | |
+ if (this.element.hasClass('align-right')) { | |
+ this.setData('align', 'right'); | |
+ } | |
+ if (this.element.hasClass('align-center')) { | |
+ this.setData('align', 'center'); | |
+ } | |
+ }, | |
+ data: function () { | |
+ var img = this.element.find('img').getItem(0), | |
+ link = this.element.find('a').getItem(0), | |
+ img_url; | |
+ | |
+ if (this.data.alt === '') { | |
+ img.setAttribute('alt', ''); | |
+ } else { | |
+ img.setAttribute('alt', this.data.alt); | |
+ } | |
+ | |
+ if (this.data.width === '') { | |
+ img.setAttribute('width', ''); | |
+ } else { | |
+ img.setAttribute('width', this.data.width); | |
+ } | |
+ | |
+ if (this.data.img_id === '') { | |
+ img.setAttribute('data-id', ''); | |
+ img.setAttribute('src', ''); | |
+ } else { | |
+ img.setAttribute('data-id', this.data.img_id); | |
+ img.setAttribute('data-cke-saved-src', | |
+ 'http://images.nypl.org/index.php?id=' + this.data.img_id + '&t=w'); | |
+ img.setAttribute('src', | |
+ 'http://images.nypl.org/index.php?id=' + this.data.img_id + '&t=w'); | |
+ } | |
+ | |
+ if (this.data.img_url === '') { | |
+ link.setAttribute('data-url', ''); | |
+ link.setAttribute('href', ''); | |
+ } else { | |
+ if (this.data.img_url) { | |
+ img_url = | |
+ this.data.img_url | |
+ .replace(/http:\/\/digitalcollections.nypl.org\/items\//, ''); | |
+ } | |
+ | |
+ link.setAttribute('data-url', img_url); | |
+ link.setAttribute('data-cke-saved-href', | |
+ 'http://digitalcollections.nypl.org/items/' + img_url); | |
+ link.setAttribute('href', | |
+ 'http://digitalcollections.nypl.org/items/' + img_url); | |
+ } | |
+ | |
+ this.element.removeClass('inline'); | |
+ this.element.removeClass('align-left'); | |
+ this.element.removeClass('align-right'); | |
+ this.element.removeClass('align-center'); | |
+ | |
+ if (this.data.align) { | |
+ this.element.addClass('align-' + this.data.align); | |
+ } | |
+ if (this.data.align !== 'center') { | |
+ this.element.addClass('inline'); | |
+ } | |
+ }, | |
+ | |
+ template: | |
+ '<div class="digcol-image">' + | |
+ '<figure class="caption digcol-image">' + | |
+ '<a href="">' + | |
+ '<img data-id src="" width="300px" alt=""/></a>' + | |
+ '<figcaption class="digcol-caption">Caption</figcaption>' + | |
+ '</figure>' + | |
+ '</div>', | |
+ editables: { | |
+ caption: { | |
+ selector: '.digcol-caption', | |
+ allowedContent: 'strong em' | |
+ } | |
+ }, | |
+ allowedContent: | |
+ 'div(!digcol-image,inline,align-left,align-right,align-center);' + | |
+ 'figure(!caption);a(!data-url);img(!data-id);' + | |
+ 'figcaption(!digcol-caption);', | |
+ requiredContent: 'div(digcol-image)', | |
+ upcast: function (element) { | |
+ return element.name === 'div' && element.hasClass('digcol-image'); | |
+ } | |
+ }); | |
+ } | |
+}); | |
-- | |
2.27.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment