From 23a138326b870205c92038ec8efdbf157d3f8977 Mon Sep 17 00:00:00 2001 From: Mikael Date: Thu, 11 Jul 2019 09:55:32 +0200 Subject: [PATCH 1/4] Add PMG to upload file --- libs/PageForms.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/PageForms.js b/libs/PageForms.js index aaf3ee2f..e7042cda 100644 --- a/libs/PageForms.js +++ b/libs/PageForms.js @@ -1666,6 +1666,10 @@ $(document).ready( function() { $('.multipleTemplateInstance').initializeJSElements(true); $('.multipleTemplateAdder').click( function() { $(this).addInstance( false ); + $('.addFileAttachment').on('click', function () { + var container = $(this).prev('.inputSpan').get(0); + mw.hook('pf.addSimpleTemplateInstance').fire(container); + }); }); $('.multipleTemplateList').sortable({ axis: 'y', From f579da855515b6c5c9e3cec42e20ad348af12c60 Mon Sep 17 00:00:00 2001 From: Mikael Date: Mon, 15 Jul 2019 10:42:41 +0200 Subject: [PATCH 2/4] Correction --- libs/PageForms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/PageForms.js b/libs/PageForms.js index e7042cda..3b595975 100644 --- a/libs/PageForms.js +++ b/libs/PageForms.js @@ -1667,7 +1667,7 @@ $(document).ready( function() { $('.multipleTemplateAdder').click( function() { $(this).addInstance( false ); $('.addFileAttachment').on('click', function () { - var container = $(this).prev('.inputSpan').get(0); + var container = $(this).prev().get(0); mw.hook('pf.addSimpleTemplateInstance').fire(container); }); }); From ef63a0341dcb3a8cde5104cfb3ed733c419d6821 Mon Sep 17 00:00:00 2001 From: Mikael Date: Mon, 15 Jul 2019 12:23:30 +0200 Subject: [PATCH 3/4] Correction --- libs/PageForms.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/PageForms.js b/libs/PageForms.js index 3b595975..e613f9c0 100644 --- a/libs/PageForms.js +++ b/libs/PageForms.js @@ -1326,7 +1326,11 @@ $.fn.addInstance = function( addAboveCurInstance ) { // Hook that fires each time a new template instance is added. // The first parameter is a jQuery selection of the newly created instance div. - mw.hook('pf.addTemplateInstance').fire(new_div); + if($(new_div).find('.msuploadContainer').length > 0){ + mw.hook('pf.addTemplateInstance').fire(new_div); + } else if ($(new_div).parents('.simplePMG').length > 0){ + mw.hook('pf.addSimpleTemplateInstance').fire($(new_div).find('.inputSpan').get(0)); + } }; // The first argument is needed, even though it's an attribute of the element @@ -1666,10 +1670,6 @@ $(document).ready( function() { $('.multipleTemplateInstance').initializeJSElements(true); $('.multipleTemplateAdder').click( function() { $(this).addInstance( false ); - $('.addFileAttachment').on('click', function () { - var container = $(this).prev().get(0); - mw.hook('pf.addSimpleTemplateInstance').fire(container); - }); }); $('.multipleTemplateList').sortable({ axis: 'y', From 9cf0ee1edf988bc3fc58d3709319053b8851654c Mon Sep 17 00:00:00 2001 From: Mikael Date: Mon, 15 Jul 2019 12:37:37 +0200 Subject: [PATCH 4/4] Correction --- libs/PageForms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/PageForms.js b/libs/PageForms.js index e613f9c0..73a7f1e2 100644 --- a/libs/PageForms.js +++ b/libs/PageForms.js @@ -1329,7 +1329,7 @@ $.fn.addInstance = function( addAboveCurInstance ) { if($(new_div).find('.msuploadContainer').length > 0){ mw.hook('pf.addTemplateInstance').fire(new_div); } else if ($(new_div).parents('.simplePMG').length > 0){ - mw.hook('pf.addSimpleTemplateInstance').fire($(new_div).find('.inputSpan').get(0)); + mw.hook('pf.addSimplePMG').fire($(new_div).find('.inputSpan').get(0)); } };