diff --git a/h5p-accordion.js b/h5p-accordion.js index 41d53c3..5ddd6b4 100644 --- a/h5p-accordion.js +++ b/h5p-accordion.js @@ -32,10 +32,16 @@ H5P.Accordion = (function ($) { this.instances = []; for (var i = 0; i < this.params.panels.length; i++) { - this.instances[i] = H5P.newRunnable(this.params.panels[i].content, contentId); + this.instances[i] = H5P.newRunnable(this.params.panels[i], contentId); + + // Bubble resize events + this.bubbleUp(this.instances[i], 'resize', this); } this.idPrefix = (nextIdPrefix++) + '-'; + + // Resize children to fit inside parent + this.bubbleDown(this, 'resize', this.instances); } Accordion.prototype = Object.create(H5P.EventDispatcher.prototype); @@ -86,6 +92,12 @@ H5P.Accordion = (function ($) { self.animateResize(); }; + // Retrieve title from Column metadata + const title = ( + self.params.panels[id].metadata && + self.params.panels[id].metadata.title + ) ? self.params.panels[id].metadata.title : 'Unknown: Panel'; + // Create panel title var $title = $('<' + this.params.hTag + '/>', { 'id': titleId, @@ -98,7 +110,7 @@ H5P.Accordion = (function ($) { 'tabindex': '0', 'aria-expanded': 'false', 'aria-controls': contentId, - 'html': self.params.panels[id].title, + 'html': title, 'on': { 'click': toggleCollapse, 'keydown': function (event) { @@ -288,5 +300,46 @@ H5P.Accordion = (function ($) { return allowedLoopers.indexOf(myId) !== -1; }; + /** + * Bubble events from parent to children. + * + * @private + * @param {object} origin Origin of Event. + * @param {string} eventName Name of Event. + * @param {object[]} targets Targets to trigger event on. + */ + Accordion.prototype.bubbleDown = function (origin, eventName, targets) { + origin.on(eventName, function (event) { + if (origin.bubblingUpwards) { + return; // Prevent send event back down. + } + + for (var i = 0; i < targets.length; i++) { + targets[i].trigger(eventName, event); + } + }); + } + + /** + * Bubble events from child to parent. + * + * @private + * @param {object} origin Origin of Event. + * @param {string} eventName Name of Event. + * @param {object} target Target to trigger event on. + */ + Accordion.prototype.bubbleUp = function (origin, eventName, target) { + origin.on(eventName, function (event) { + // Prevent target from sending event back down + target.bubblingUpwards = true; + + // Trigger event + target.trigger(eventName, event); + + // Reset + target.bubblingUpwards = false; + }); + } + return Accordion; })(H5P.jQuery); diff --git a/language/.en.json b/language/.en.json index 7fc821d..75a4497 100644 --- a/language/.en.json +++ b/language/.en.json @@ -5,16 +5,7 @@ "entity": "panel", "field": { "label": "Content", - "entity": "content", - "fields": [ - { - "label": "Title" - }, - { - "label": "Content type", - "entity": "content" - } - ] + "entity": "content" } }, { @@ -33,4 +24,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/language/af.json b/language/af.json index 547b207..9b947b5 100644 --- a/language/af.json +++ b/language/af.json @@ -1,20 +1,11 @@ { "semantics": [ { - "label": "Panele", - "entity": "paneel", - "field": { - "label": "Inhoud", - "entity": "inhoud", - "fields": [ - { - "label": "Titel" - }, - { - "label": "Inhoud tipe", - "entity": "inhoud" - } - ] + "label":"Panele", + "entity":"paneel", + "field":{ + "label":"Inhoud", + "entity":"inhoud" } }, { diff --git a/language/ar.json b/language/ar.json index 85d2b39..be40ccf 100644 --- a/language/ar.json +++ b/language/ar.json @@ -5,16 +5,7 @@ "entity": "لوحه", "field": { "label": "المحتوي", - "entity": "المحتوي", - "fields": [ - { - "label": "عنوان فصل" - }, - { - "label": "نوع المحتوى", - "entity": "المحتوى" - } - ] + "entity": "المحتوي" } }, { diff --git a/language/bg.json b/language/bg.json index 1734fe5..937f8d8 100644 --- a/language/bg.json +++ b/language/bg.json @@ -5,16 +5,7 @@ "entity": "panel", "field": { "label": "Съдържание", - "entity": "content", - "fields": [ - { - "label": "Заглавие" - }, - { - "label": "Тип съдържание", - "entity": "content" - } - ] + "entity": "content" } }, { diff --git a/language/bs.json b/language/bs.json index bd74b0f..8026934 100644 --- a/language/bs.json +++ b/language/bs.json @@ -5,16 +5,7 @@ "entity":"panel", "field":{ "label":"Content", - "entity":"content", - "fields":[ - { - "label":"Title" - }, - { - "label":"Content type", - "entity":"content" - } - ] + "entity":"content" } }, { @@ -33,4 +24,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/language/ca.json b/language/ca.json index c5e682f..6239b41 100644 --- a/language/ca.json +++ b/language/ca.json @@ -3,18 +3,9 @@ { "label": "Taulers", "entity": "tauler", - "field": { - "label": "Contingut", - "entity": "contingut", - "fields": [ - { - "label": "Títol" - }, - { - "label": "Tipus de contingut", - "entity": "contingut" - } - ] + "field":{ + "label":"Contingut", + "entity":"contingut" } }, { diff --git a/language/cs.json b/language/cs.json index e37a91d..e47bed2 100644 --- a/language/cs.json +++ b/language/cs.json @@ -1,20 +1,11 @@ { "semantics": [ { - "label": "Panely", - "entity": "panel", - "field": { - "label": "Obsah", - "entity": "obsah", - "fields": [ - { - "label": "Nadpis" - }, - { - "label": "Typ obsahu", - "entity": "obsah" - } - ] + "label":"Panely", + "entity":"panel", + "field":{ + "label":"Obsah", + "entity":"obsah" } }, { diff --git a/language/da.json b/language/da.json index bd74b0f..8026934 100644 --- a/language/da.json +++ b/language/da.json @@ -5,16 +5,7 @@ "entity":"panel", "field":{ "label":"Content", - "entity":"content", - "fields":[ - { - "label":"Title" - }, - { - "label":"Content type", - "entity":"content" - } - ] + "entity":"content" } }, { @@ -33,4 +24,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/language/de.json b/language/de.json index edbe6e7..775addc 100644 --- a/language/de.json +++ b/language/de.json @@ -5,16 +5,7 @@ "entity": "Abschnitt", "field": { "label": "Inhalt", - "entity": "Inhalt", - "fields": [ - { - "label": "Titel" - }, - { - "label": "Inhaltstyp", - "entity": "Inhalt" - } - ] + "entity": "Inhalt" } }, { diff --git a/language/el.json b/language/el.json index 56b5f70..f0fc6a2 100644 --- a/language/el.json +++ b/language/el.json @@ -5,16 +5,7 @@ "entity":"πλαισιου", "field":{ "label":"Περιεχόμενο", - "entity":"περιεχομενου", - "fields":[ - { - "label":"Τίτλος" - }, - { - "label":"Τύπος περιεχομένου", - "entity":"περιεχομενου" - } - ] + "entity":"περιεχομενου" } }, { diff --git a/language/es-mx.json b/language/es-mx.json index 614b4ac..7829729 100644 --- a/language/es-mx.json +++ b/language/es-mx.json @@ -5,16 +5,7 @@ "entity": "panel", "field": { "label": "Contenido", - "entity": "contenido", - "fields": [ - { - "label": "Título" - }, - { - "label": "Tipo de contenido", - "entity": "contenido" - } - ] + "entity": "contenido" } }, { diff --git a/language/es.json b/language/es.json index 614b4ac..7829729 100644 --- a/language/es.json +++ b/language/es.json @@ -5,16 +5,7 @@ "entity": "panel", "field": { "label": "Contenido", - "entity": "contenido", - "fields": [ - { - "label": "Título" - }, - { - "label": "Tipo de contenido", - "entity": "contenido" - } - ] + "entity": "contenido" } }, { diff --git a/language/et.json b/language/et.json index 75f206a..fe3b70e 100644 --- a/language/et.json +++ b/language/et.json @@ -5,16 +5,7 @@ "entity":"paneel", "field":{ "label":"Sisu", - "entity":"sisu", - "fields":[ - { - "label":"Pealkiri" - }, - { - "label":"Sisu tüüp", - "entity":"sisu" - } - ] + "entity":"sisu" } }, { @@ -33,4 +24,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/language/eu.json b/language/eu.json index 95a7ab6..d16fede 100644 --- a/language/eu.json +++ b/language/eu.json @@ -5,16 +5,7 @@ "entity": "panela", "field": { "label": "Edukia", - "entity": "edukia", - "fields": [ - { - "label": "Izenburua" - }, - { - "label": "Eduki mota", - "entity": "edukia" - } - ] + "entity": "edukia" } }, { diff --git a/language/fa.json b/language/fa.json index 2c01a82..69a5e1b 100644 --- a/language/fa.json +++ b/language/fa.json @@ -5,16 +5,7 @@ "entity": "پنل", "field": { "label": "محتوا", - "entity": "محتوا", - "fields": [ - { - "label": "عنوان" - }, - { - "label": "نوع محتوا", - "entity": "محتوا" - } - ] + "entity": "محتوا" } }, { diff --git a/language/fi.json b/language/fi.json index fbe35b1..96d6e8b 100644 --- a/language/fi.json +++ b/language/fi.json @@ -5,16 +5,7 @@ "entity":"paneeli", "field":{ "label":"Sisältö", - "entity":"sisältö", - "fields":[ - { - "label":"Otsikko" - }, - { - "label":"Sisältötyyppi", - "entity":"sisältö" - } - ] + "entity":"sisältö" } }, { diff --git a/language/fr.json b/language/fr.json index 58eaf79..0ef1449 100644 --- a/language/fr.json +++ b/language/fr.json @@ -1,20 +1,11 @@ { "semantics": [ { - "label": "Panneaux", - "entity": "panneau", - "field": { - "label": "Contenu", - "entity": "contenu", - "fields": [ - { - "label": "Titre" - }, - { - "label": "Type de contenu", - "entity": "contenu" - } - ] + "label":"Titre de section", + "entity":"panneau", + "field":{ + "label":"Contenu", + "entity":"content" } }, { diff --git a/language/gl.json b/language/gl.json index bad0c29..68d8520 100644 --- a/language/gl.json +++ b/language/gl.json @@ -5,16 +5,7 @@ "entity": "panel", "field": { "label": "Contido", - "entity": "contido", - "fields": [ - { - "label": "Título" - }, - { - "label": "Tipo de contido", - "entity": "contido" - } - ] + "entity": "contido" } }, { diff --git a/language/he.json b/language/he.json index 38546fe..ee30884 100644 --- a/language/he.json +++ b/language/he.json @@ -5,16 +5,7 @@ "entity": "פאנל", "field": { "label": "תוכן", - "entity": "תוכן", - "fields": [ - { - "label": "כותרת" - }, - { - "label": "סוג תוכן", - "entity": "תוכן" - } - ] + "entity": "תוכן" } }, { diff --git a/language/hu.json b/language/hu.json index bd74b0f..8026934 100644 --- a/language/hu.json +++ b/language/hu.json @@ -5,16 +5,7 @@ "entity":"panel", "field":{ "label":"Content", - "entity":"content", - "fields":[ - { - "label":"Title" - }, - { - "label":"Content type", - "entity":"content" - } - ] + "entity":"content" } }, { @@ -33,4 +24,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/language/it.json b/language/it.json index f4f012c..c67c686 100644 --- a/language/it.json +++ b/language/it.json @@ -5,16 +5,7 @@ "entity": "pannello", "field": { "label": "Contenuto", - "entity": "contenuto", - "fields": [ - { - "label": "Titolo" - }, - { - "label": "Tipo di contenuto", - "entity": "contenuto" - } - ] + "entity": "contenuto" } }, { diff --git a/language/ja.json b/language/ja.json index 1f0b410..08e9532 100644 --- a/language/ja.json +++ b/language/ja.json @@ -1,20 +1,11 @@ { "semantics": [ { - "label": "パネル", - "entity": "パネル", - "field": { - "label": "コンテンツ", - "entity": "コンテンツ", - "fields": [ - { - "label": "タイトル" - }, - { - "label": "コンテンツタイプ", - "entity": "コンテンツ" - } - ] + "label":"パネル", + "entity":"パネル", + "field":{ + "label":"コンテンツ", + "entity":"コンテンツ" } }, { diff --git a/language/ka.json b/language/ka.json index 314be50..49ede46 100644 --- a/language/ka.json +++ b/language/ka.json @@ -4,17 +4,8 @@ "label": "პანელი", "entity": "პანელი", "field": { - "label": "შინაარსი", - "entity": "შინაარსი", - "fields": [ - { - "label": "სათაური" - }, - { - "label": "შინაარსის ტიპი", - "entity": "მასალის ნაირსახეობა" - } - ] + "label": "შიგთავსი", + "entity": "შიგთავსი" } }, { diff --git a/language/ko.json b/language/ko.json index 67c731c..fb0df13 100644 --- a/language/ko.json +++ b/language/ko.json @@ -5,16 +5,7 @@ "entity":"패널", "field":{ "label":"콘텐츠", - "entity":"콘텐츠", - "fields":[ - { - "label":"제목" - }, - { - "label":"콘텐츠 유형", - "entity":"콘텐츠" - } - ] + "entity":"콘텐츠" } }, { diff --git a/language/lt.json b/language/lt.json index 93eecd5..dfcffea 100644 --- a/language/lt.json +++ b/language/lt.json @@ -5,16 +5,7 @@ "entity": "skydelis", "field": { "label": "Turinys", - "entity": "turinys", - "fields": [ - { - "label": "Pavadinimas" - }, - { - "label": "Turinio tipas", - "entity": "turinys" - } - ] + "entity": "turinys" } }, { diff --git a/language/lv.json b/language/lv.json index 6f09f2b..8f4697b 100644 --- a/language/lv.json +++ b/language/lv.json @@ -5,16 +5,7 @@ "entity": "panelis", "field": { "label": "Saturs", - "entity": "saturs", - "fields": [ - { - "label": "Nosaukums" - }, - { - "label": "Satura veids", - "entity": "saturs" - } - ] + "entity": "saturs" } }, { diff --git a/language/mn.json b/language/mn.json index 525b1e2..6165faf 100644 --- a/language/mn.json +++ b/language/mn.json @@ -5,16 +5,7 @@ "entity": "самбар", "field": { "label": "Контент", - "entity": "контент", - "fields": [ - { - "label": "Гарчиг" - }, - { - "label": "Контентийн төрөл", - "entity": "контент" - } - ] + "entity": "контент" } }, { diff --git a/language/nb.json b/language/nb.json index f929576..6fb8977 100644 --- a/language/nb.json +++ b/language/nb.json @@ -5,16 +5,7 @@ "entity": "panel", "field": { "label": "Innhold", - "entity": "innhold", - "fields": [ - { - "label": "Tittel" - }, - { - "label": "Innholdstype", - "entity": "innhold" - } - ] + "entity": "innhold" } }, { diff --git a/language/nl.json b/language/nl.json index 98ae2f5..e784d65 100644 --- a/language/nl.json +++ b/language/nl.json @@ -1,20 +1,11 @@ { "semantics": [ { - "label": "Panelen", - "entity": "paneel", - "field": { - "label": "Inhoud", - "entity": "inhoud", - "fields": [ - { - "label": "Titel" - }, - { - "label": "Inhoudstype", - "entity": "inhoudstype" - } - ] + "label":"Panelen", + "entity":"paneel", + "field":{ + "label":"Inhoud", + "entity":"inhoud" } }, { diff --git a/language/nn.json b/language/nn.json index bd74b0f..8026934 100644 --- a/language/nn.json +++ b/language/nn.json @@ -5,16 +5,7 @@ "entity":"panel", "field":{ "label":"Content", - "entity":"content", - "fields":[ - { - "label":"Title" - }, - { - "label":"Content type", - "entity":"content" - } - ] + "entity":"content" } }, { @@ -33,4 +24,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/language/pl.json b/language/pl.json index 2340b36..63fa28d 100644 --- a/language/pl.json +++ b/language/pl.json @@ -1,20 +1,11 @@ { "semantics": [ { - "label": "Panele", - "entity": "panel", - "field": { - "label": "Zawartość", - "entity": "zawartość", - "fields": [ - { - "label": "Tytuł" - }, - { - "label": "Typ zawartości", - "entity": "zawartość" - } - ] + "label":"Panele", + "entity":"panel", + "field":{ + "label":"Zawartość", + "entity":"zawartość" } }, { diff --git a/language/pt-br.json b/language/pt-br.json index c4362e5..483e607 100644 --- a/language/pt-br.json +++ b/language/pt-br.json @@ -5,16 +5,7 @@ "entity": "Painel", "field": { "label": "Conteúdo", - "entity": "conteúdo", - "fields": [ - { - "label": "Título" - }, - { - "label": "Tipo de conteúdo", - "entity": "conteúdo" - } - ] + "entity": "conteúdo" } }, { diff --git a/language/pt.json b/language/pt.json index 063fdc7..1e9e83f 100644 --- a/language/pt.json +++ b/language/pt.json @@ -5,16 +5,7 @@ "entity": "painel", "field": { "label": "Conteúdo", - "entity": "conteúdo", - "fields": [ - { - "label": "Título" - }, - { - "label": "Tipo de conteúdo", - "entity": "conteúdo" - } - ] + "entity": "conteúdo" } }, { diff --git a/language/ro.json b/language/ro.json index bd74b0f..8026934 100644 --- a/language/ro.json +++ b/language/ro.json @@ -5,16 +5,7 @@ "entity":"panel", "field":{ "label":"Content", - "entity":"content", - "fields":[ - { - "label":"Title" - }, - { - "label":"Content type", - "entity":"content" - } - ] + "entity":"content" } }, { @@ -33,4 +24,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/language/ru.json b/language/ru.json index 5c668c3..b3812c3 100644 --- a/language/ru.json +++ b/language/ru.json @@ -5,16 +5,7 @@ "entity":"панель", "field":{ "label":"Содержимое", - "entity":"содержимое", - "fields":[ - { - "label":"Название" - }, - { - "label":"Тип материала", - "entity":"Тип материала" - } - ] + "entity":"содержимое" } }, { diff --git a/language/sl.json b/language/sl.json index 2fe363f..c1d7f14 100644 --- a/language/sl.json +++ b/language/sl.json @@ -5,16 +5,7 @@ "entity": "panel", "field": { "label": "Vsebina", - "entity": "content", - "fields": [ - { - "label": "Naslov" - }, - { - "label": "Tip vsebine", - "entity": "content" - } - ] + "entity": "content" } }, { diff --git a/language/sma.json b/language/sma.json index 7fc821d..75a4497 100644 --- a/language/sma.json +++ b/language/sma.json @@ -5,16 +5,7 @@ "entity": "panel", "field": { "label": "Content", - "entity": "content", - "fields": [ - { - "label": "Title" - }, - { - "label": "Content type", - "entity": "content" - } - ] + "entity": "content" } }, { @@ -33,4 +24,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/language/sme.json b/language/sme.json index 7fc821d..75a4497 100644 --- a/language/sme.json +++ b/language/sme.json @@ -5,16 +5,7 @@ "entity": "panel", "field": { "label": "Content", - "entity": "content", - "fields": [ - { - "label": "Title" - }, - { - "label": "Content type", - "entity": "content" - } - ] + "entity": "content" } }, { @@ -33,4 +24,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/language/smj.json b/language/smj.json index 7fc821d..75a4497 100644 --- a/language/smj.json +++ b/language/smj.json @@ -5,16 +5,7 @@ "entity": "panel", "field": { "label": "Content", - "entity": "content", - "fields": [ - { - "label": "Title" - }, - { - "label": "Content type", - "entity": "content" - } - ] + "entity": "content" } }, { @@ -33,4 +24,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/language/sr.json b/language/sr.json index ec6aab3..d4d2dcb 100644 --- a/language/sr.json +++ b/language/sr.json @@ -5,16 +5,7 @@ "entity":"panel", "field":{ "label":"Садржај", - "entity":"content", - "fields":[ - { - "label":"Наслов" - }, - { - "label":"Тип садржаја", - "entity":"content" - } - ] + "entity":"content" } }, { diff --git a/language/sv.json b/language/sv.json index efb402f..faa095d 100644 --- a/language/sv.json +++ b/language/sv.json @@ -1,20 +1,11 @@ { "semantics": [ { - "label": "Paneler", - "entity": "panel", - "field": { - "label": "Innehåll", - "entity": "innehåll", - "fields": [ - { - "label": "Titel" - }, - { - "label": "Innehållstyp", - "entity": "innehåll" - } - ] + "label":"Paneler", + "entity":"panel", + "field":{ + "label":"Innehåll", + "entity":"innehåll" } }, { diff --git a/language/te.json b/language/te.json index 1dd15e8..cf48ca3 100644 --- a/language/te.json +++ b/language/te.json @@ -3,16 +3,7 @@ { "entity": "ప్యానెల్", "field": { - "entity": "కంటెంట్", - "fields": [ - { - "label": "శీర్షిక" - }, - { - "label": "కంటెంట్ రకం", - "entity": "కంటెంట్" - } - ], + "entity": "కంటెంట్" "label": "కంటెంట్" }, "label": "ప్యానల్స్" diff --git a/language/th.json b/language/th.json index 5808ed8..a87425f 100644 --- a/language/th.json +++ b/language/th.json @@ -5,16 +5,7 @@ "entity": "แผงข้อมูล", "field": { "label": "เนื้อหา", - "entity": "เนื้อหา", - "fields": [ - { - "label": "ชื่อเรื่อง" - }, - { - "label": "ประเภทเนื้อหา", - "entity": "เนื้อหา" - } - ] + "entity": "เนื้อหา" } }, { diff --git a/language/tr.json b/language/tr.json index f9e5c5f..5fb4243 100644 --- a/language/tr.json +++ b/language/tr.json @@ -1,20 +1,11 @@ { "semantics": [ { - "label": "Paneller", - "entity": "panel", - "field": { - "label": "İçerik", - "entity": "içerik", - "fields": [ - { - "label": "Başlık" - }, - { - "label": "İçerik türü", - "entity": "içerik" - } - ] + "label":"Paneller", + "entity":"panel", + "field":{ + "label":"İçerik", + "entity":"içerik" } }, { diff --git a/language/uk.json b/language/uk.json index 6705aa0..a24059f 100644 --- a/language/uk.json +++ b/language/uk.json @@ -5,16 +5,7 @@ "entity":"панель", "field":{ "label":"Вміст", - "entity":"вміст", - "fields":[ - { - "label":"Назва" - }, - { - "label":"Тип матеріалу", - "entity":"Тип матеріалу" - } - ] + "entity":"вміст" } }, { diff --git a/language/vi.json b/language/vi.json index f5c2be2..b6b85f9 100644 --- a/language/vi.json +++ b/language/vi.json @@ -1,20 +1,11 @@ { "semantics": [ { - "label": "Bảng điều khiển", - "entity": "panel", - "field": { - "label": "Nội dung", - "entity": "nội dung", - "fields": [ - { - "label": "Tiêu đề" - }, - { - "label": "Dạng nội dung", - "entity": "nội dung" - } - ] + "label":"Bảng điều khiển", + "entity":"panel", + "field":{ + "label":"Dạng nội dung", + "entity":"nội dung" } }, { diff --git a/language/zh-cn.json b/language/zh-cn.json index 1a9c8e1..122170a 100644 --- a/language/zh-cn.json +++ b/language/zh-cn.json @@ -5,16 +5,7 @@ "entity": "面板", "field": { "label": "内容", - "entity": "内容", - "fields": [ - { - "label": "标题" - }, - { - "label": "内容类型", - "entity": "内容" - } - ] + "entity": "内容" } }, { diff --git a/language/zh-hans.json b/language/zh-hans.json index b0f8493..92c185e 100644 --- a/language/zh-hans.json +++ b/language/zh-hans.json @@ -5,16 +5,7 @@ "entity": "区块", "field": { "label": "区块", - "entity": "内容", - "fields": [ - { - "label": "标题" - }, - { - "label": "内容", - "entity": "内容" - } - ] + "entity": "内容" } }, { diff --git a/language/zh-hant.json b/language/zh-hant.json index 740779a..96a6b05 100644 --- a/language/zh-hant.json +++ b/language/zh-hant.json @@ -5,16 +5,7 @@ "entity": "panel", "field": { "label": "區塊", - "entity": "content", - "fields": [ - { - "label": "標題" - }, - { - "label": "內容", - "entity": "content" - } - ] + "entity": "content" } }, { diff --git a/library.json b/library.json index 5b333a0..32c4cae 100644 --- a/library.json +++ b/library.json @@ -1,8 +1,8 @@ { "title": "Accordion", "majorVersion": 1, - "minorVersion": 0, - "patchVersion": 34, + "minorVersion": 1, + "patchVersion": 0, "embedTypes": [ "iframe" ], @@ -27,6 +27,18 @@ "minorVersion": 5 } ], + "editorDependencies": [ + { + "machineName": "H5PEditor.Accordion", + "majorVersion": 1, + "minorVersion": 0 + }, + { + "machineName": "H5PEditor.VerticalTabs", + "majorVersion": 1, + "minorVersion": 3 + } + ], "preloadedCss": [ { "path": "h5p-accordion.css" diff --git a/semantics.json b/semantics.json index 9dbbc5f..0db39ac 100644 --- a/semantics.json +++ b/semantics.json @@ -6,30 +6,22 @@ "entity": "panel", "max": 100, "min": 1, + "widgets": [ + { + "name": "VerticalTabs", + "label": "Default" + } + ], "field": { "name": "content", - "type": "group", + "type": "library", "label": "Content", - "importance": "high", + "importance": "medium", "entity": "content", - "fields": [ - { - "name": "title", - "type": "text", - "label": "Title", - "importance": "high" - }, - { - "name": "content", - "type": "library", - "label": "Content type", - "importance": "medium", - "entity": "content", - "options": [ - "H5P.AdvancedText 1.1" - ] - } - ] + "options": [ + "H5P.Column 1.13" + ], + "widget": "editorAccordion" } }, { diff --git a/upgrades.js b/upgrades.js new file mode 100644 index 0000000..764ed2e --- /dev/null +++ b/upgrades.js @@ -0,0 +1,49 @@ +var H5PUpgrades = H5PUpgrades || {}; + +H5PUpgrades['H5P.Accordion'] = (function () { + return { + 1: { + /** + * Asynchronous content upgrade hook. + * + * Move previous single content to content group + * + * @param {object} parameters + * @param {function} finished + * @param {object} extras + */ + 1: function (parameters, finished, extras) { + // Move single content to Column + if (parameters.panels) { + for (i = 0; i < parameters.panels.length; i++) { + // Create Column parameters with previous text as sole content + parameters.panels[i] = { + library: "H5P.Column 1.13", + // We avoid using H5P.createUUID since this is an upgrade script and H5P function may change + subContentId: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (char) { + const random = Math.random() * 16 | 0, newChar = char === 'x' ? random : (random & 0x3 | 0x8); + return newChar.toString(16); + }), + metadata: { + contentType: "Column", + license: "U", + title: parameters.panels[i].title + }, + params: { + useSeparators: true, + content: [ + { + useSeparator: "auto", + content: parameters.panels[i].content + } + ] + } + } + } + } + + finished(null, parameters, extras); + } + } + }; +})();