From bf4be5df28dca2e9a143b4c091f705144733d7d5 Mon Sep 17 00:00:00 2001 From: James Montalvo Date: Thu, 11 Dec 2014 08:33:07 -0600 Subject: [PATCH] Add collapsible; bump to v0.3.0 --- ImportFiles/README.md | 1 + ImportFiles/import.xml | 180 +++++++++++++++--- SemanticMeetingMinutes.php | 2 +- modules/form/SF_MultipleInstanceRefire.js | 6 +- modules/form/meeting-minutes.js | 219 +++++++--------------- 5 files changed, 226 insertions(+), 182 deletions(-) diff --git a/ImportFiles/README.md b/ImportFiles/README.md index 9de92ec..c2d3024 100644 --- a/ImportFiles/README.md +++ b/ImportFiles/README.md @@ -15,6 +15,7 @@ Template:Meeting Minutes Block info for table row highlighted Template:Meeting references row Template:File link Template:Meeting Minutes/Files +Template:Collapsible Form:Meeting Form:Meeting Minutes Category:Meeting diff --git a/ImportFiles/import.xml b/ImportFiles/import.xml index 2c8674c..648c14b 100644 --- a/ImportFiles/import.xml +++ b/ImportFiles/import.xml @@ -38,14 +38,14 @@ 10 5 - 36 - 5 - 2014-12-09T16:20:03Z + 65 + 36 + 2014-12-11T14:20:49Z Ejmontal 1 - <includeonly><!-- + <includeonly><!-- # Template:Meeting # (1) Setup JS/CSS and category # (2) Add category @@ -110,7 +110,7 @@ | {{#arraymap:{{{Managed by cadre(s)|}}}|,|x|[[Managed by cadre::x]]}} |- ! Notable attendee(s) -| {{#arraymap:{{{Notable attendee(s)|}}}|,|x|[[Notable attendee::x]]}} +| {{#arraymap:{{{Notable attendee(s)|}}}|,|x|[[Notable attendee::User:x]]}} |} <!-- @@ -176,7 +176,7 @@ It should be called in the following format: </pre> Edit the page to see the template text. </noinclude> - 2c63o4icboba8ty4neccsvmxw99pj10 + ibaq9o2w9shbp9lvmiauh3el8mxozgg wikitext text/x-wiki @@ -186,13 +186,14 @@ Edit the page to see the template text. 10 6 - 6 - 2014-11-26T16:29:13Z + 64 + 6 + 2014-12-11T14:18:27Z Ejmontal 1 - <includeonly><!-- + <includeonly><!-- # # Template:Meeting minutes # (1) Setup JS/CSS and category @@ -245,7 +246,7 @@ Edit the page to see the template text. | [[Start time::{{{Start time hour|}}}:{{{Start time minute|}}}]] |- ! Notes taken by -| {{#arraymap:{{{Notes taken by|}}}|,|x|[[Notes taken by::x]]}} +| {{#arraymap:{{{Notes taken by|}}}|,|x|[[Notes taken by::User:x]]}} |- ! style="text-align: center; background-color:#ccccff;" colspan="2" |<big>Meeting Documents</big> |- @@ -297,7 +298,7 @@ If edited manually, it should be called in the following format: Edit the page to see the template text. </noinclude> - chx9ygq46mflpuby9es2w6fxcybfo5a + rgum81qvygmcw23g012km1umuwj4ljx wikitext text/x-wiki @@ -619,6 +620,131 @@ The above wikitext displays as {{File link | file=http://example.com/somefile.pd text/x-wiki + + Template:Collapsible + 10 + 42 + + 63 + 59 + 2014-12-11T14:16:21Z + + Ejmontal + 1 + + <noinclude>This template creates a content field which can be shown/hidden by the click of a button. + +== Use the following form == +<pre> +{{Collapsible + | Content = + | Collapse text = (default = Collapse) + | Expand text = (default = Expand) + | Start hidden = (true or false, default = false) + | Class = (class applied to the outermost <div>) + | Before trigger = (text, html, wiki syntax to go before trigger; default = blank) + | After trigger = (text, html, wiki syntax to go after trigger but before content; default = blank) +}} +</pre> + + +== Example 1 == +=== Code === +<pre> +{{Collapsible + | Content = +* Line one +* Line 2 +* Line C +* Line IV + | Collapse text = Collapse This + | Expand text = + | Start hidden = true + | Class = + | Before trigger = Click here to:&amp;nbsp; + | After trigger = ! +}} +</pre> +=== Result === +{{Collapsible + | Content = +* Line one +* Line 2 +* Line C +* Line IV + | Collapse text = Collapse This + | Expand text = + | Start hidden = true + | Class = + | Before trigger = Click here to:&nbsp; + | After trigger = ! +}} + +Note: If you want a space between the colon in "Click here to:" and the expand/collapse button, you need to add a special character. Just typing a regular space (hitting the space bar) will not work, as MediaWiki will ignore this white space. Instead you need to add a [http://en.wikipedia.org/wiki/Non-breaking_space Non-breaking space], by typing <code>&amp;nbsp;</code> after the colon. + +== Example 2 == +=== Code === +<pre> +{{Collapsible + | Content = +* Line one +* Line 2 +* Line C +* Line IV + | Collapse text = Hide + | Expand text = Show + | Start hidden = + | Class = + | Before trigger = + | After trigger = +}} +</pre> +=== Result === +{{Collapsible + | Content = +* Line one +* Line 2 +* Line C +* Line IV + | Collapse text = Hide + | Expand text = Show + | Start hidden = + | Class = + | Before trigger = + | After trigger = +}} +</noinclude><includeonly><!-- + + + Create the initial "wrapper" <div> + * Add optional Class + * If content should initially be hidden add the smm-collapsed class + * Add the text that should be used for the expand and collapse triggers + +--><div class="smm-collapsible {{{Class|}}} {{#ifeq: {{{Start hidden}}} | true | smm-collapsed | }}" data-collapsetext="{{#if: {{{Collapse text|}}} | {{{Collapse text|}}} | Collapse}}" data-expandtext="{{#if: {{{Expand text|}}} | {{{Expand text|}}} | Expand}}"><!-- + + + Optionally create elements that will go before and after the trigger + * Trigger = the "link" which will expand/collapse the content + * The trigger will be added via javascript in common.js + * Wrap Before trigger and After trigger in <span> tags for common.js and common.css to access them + +-->{{#if: {{{Before trigger|}}} | <span class="pre-trigger">{{{Before trigger|}}}</span> | }}{{#if: {{{After trigger|}}} | <span class="post-trigger">{{{After trigger|}}}</span> | }}<!-- + + + Create content element and close out "wrapper" <div> + * If no "Content" parameter, use first parameter + +--><div class="smm-collapsible-content">{{#if: {{{Content|}}} |&nbsp; +{{{Content|}}} |&nbsp; +{{{1}}} }}</div></div><!-- + +--></includeonly> + a6p19wczl21ntjcovx6xw6ao8qu92xe + wikitext + text/x-wiki + + Form:Meeting 106 @@ -694,14 +820,14 @@ if a page with that name already exists, you will be sent to a form to edit that 106 9 - 50 - 49 - 2014-12-09T17:01:50Z + 62 + 61 + 2014-12-11T14:14:37Z Ejmontal 1 - <includeonly>{{#meetingminutesform:}}__NOTOC__{{{info|page name=<Meeting minutes[Meeting type]> - <Meeting minutes[Meeting date]>}}} + <includeonly>{{#meetingminutesform:}}__NOTOC__{{{info|page name=<Meeting minutes[Meeting type]> - <Meeting minutes[Meeting date]>}}} <div id="wikiPreview" style="display: none; padding-bottom: 25px; margin-bottom: 25px; border-bottom: 1px solid #AAAAAA;"></div> {{{for template|Meeting minutes}}}<!-- @@ -786,20 +912,20 @@ Local files must be uploaded first. See [[Help:Meeting Minutes|the help page]] f --> == Free text == - -<div class="montalvo-collapsible mw-collapsed" data-collapsetext="Hide Free Text" data-expandtext="Show Free Text Entry"> -  <div class="mw-collapsible-content"> +{{Collapsible + | Content = * '''Use this field ''very'' sparingly''' * Nothing in this field will be distributed to related pages * Info in this field will be added to the end of the meeting minutes page {{{standard input|free text|rows=10}}} -  </div> -</div> - + | Collapse text = Hide Free Text + | Expand text = Show Free Text Entry + | Start hidden = true +}} == Save Page == -<div class="montalvo-collapsible mw-collapsed" data-collapsetext="Hide Help" data-expandtext="Show Help"> -  <div class="mw-collapsible-content"> +{{Collapsible + | Content = * '''Summary:''' Not required, but recommended if making a revision to a page. The summary will be included emails sent to people watching this page. * '''Minor edit checkbox:''' Not required * '''Watch this page checkbox:''' Check this box. If you are editing this page, in all likelihood you care about the content. Watch the page to have greater visibility into future changes. You can make it so the box is automatically checked by editing your preferences (top right of the screen). For more info see [[Help:Watching Pages]]. @@ -807,8 +933,10 @@ Local files must be uploaded first. See [[Help:Meeting Minutes|the help page]] f * '''Show preview:''' Click this to see what your wiki-markup will look like when formatted. Very handy for learning how to use the wiki. * '''Show changes:''' Shows all changes you've made, compared to the previous revision (doesn't do much when creating a brand new page). * '''Cancel:''' Don't click this unless you want to lose what you've been working on. -  </div> -</div> + | Collapse text = Hide Help + | Expand text = Show Help + | Start hidden = true +}} {{{standard input|summary}}} @@ -823,7 +951,7 @@ Local files must be uploaded first. See [[Help:Meeting Minutes|the help page]] f --><noinclude> This is the "Meeting Minutes" form. Click edit to make changes to the structure of the form itself. Or [[Special:FormEdit/Meeting_Minutes|create new meeting minutes]].<!--{{#forminput:form=Meeting Minutes}}--></noinclude> - snbov127hl8l71qquy8vqm42ca2tnut + rp260gs4l9czatk03dkenbtkbx5uet3 wikitext text/x-wiki diff --git a/SemanticMeetingMinutes.php b/SemanticMeetingMinutes.php index fa9d4c0..7fbb61f 100644 --- a/SemanticMeetingMinutes.php +++ b/SemanticMeetingMinutes.php @@ -25,7 +25,7 @@ 'url' => 'http://github.com/enterprisemediawiki/SemanticMeetingMinutes', 'author' => 'James Montalvo', 'descriptionmsg' => 'meetingminutes-desc', - 'version' => '0.2.1' + 'version' => '0.3.0' ); $GLOBALS['wgMessagesDirs']['MeetingMinutes'] = __DIR__ . '/i18n'; diff --git a/modules/form/SF_MultipleInstanceRefire.js b/modules/form/SF_MultipleInstanceRefire.js index 04c169b..c6fb485 100644 --- a/modules/form/SF_MultipleInstanceRefire.js +++ b/modules/form/SF_MultipleInstanceRefire.js @@ -20,7 +20,11 @@ window.addMultipleInstanceRefire = function(options, refireFn) { if (reorder) console.log("not yet supported"); //window.SF_MultipleInstanceRefire_reorder.push(refireFn); - setTimeout(refireFn, 2000); // without delay some things aren't fully setup yet, even after DOM load + // Semantic Forms passes an options.pageload = true param. Should that + // determine if this is fired? + // FIXME: without delay some things aren't fully setup yet, even after DOM + // load. This sucks. + setTimeout(refireFn, 2000); }; diff --git a/modules/form/meeting-minutes.js b/modules/form/meeting-minutes.js index 882f942..ea77197 100644 --- a/modules/form/meeting-minutes.js +++ b/modules/form/meeting-minutes.js @@ -178,160 +178,71 @@ $(function(){ } }; -}); - - - - - -/* - -window.noLinkInSemanticFormsMessages = [ - "You may not use links in this field. Please remove all square braces.", - "No, seriously. You can't use links here.", - "Really? You're going to keep trying to put square braces in this box?", - "This isn't going to work.", - "Please stop.", - "I said please.", - "Okay, one more time: you cannot use square brackets...so no [ or ]", - "I'm not talking to you anymore", - "[no response]", - "Ha ha look: I can use square brackets", - "[no response]" -]; - -// this will add wikilink warnings to all input elements without them -addMultipleInstanceRefire(function () { - - // find all elements that need checking, and remove those that already - // have it...then added it to them - $(".no-links-allowed").unbind("blur").blur(function(ev){ - // if the field has a [ or a ] - if($(ev.target).val().search(/\[/) != -1 || $(ev.target).val().search(/]/) != -1) { - - var messages = window.noLinkInSemanticFormsMessages; - - // inform user that the cannot use links in the field - // alert("You may not use links in this field. Please remove all square braces."); - var count = $(".validation-error-message").size(); - if( ! messages[count]) - count = messages.length - 1; - - $(ev.target).after("
" + messages[count] + "
"); - - // send focus back to the field so they can edit the contents - $(ev.target).focus(); - - $(ev.target).addClass("validation-error"); - } - else { - $(ev.target).removeClass("validation-error"); - $(".validation-error-message").remove(); - } - }); -}); - - -// this adds collapsible content to properly marked templates. Use Template:Collapsible -addMultipleInstanceRefire(function(){ - - $(".montalvo-collapsible").each(function(index,element){ - - var collapseText = $(element).attr("data-collapsetext") || "Collapse"; - var expandText = $(element).attr("data-expandtext") || "Expand"; - var buttonText; - - // if no tags within collapsible, then it hasn't been setup yet - // this only performed the first time on each collapsible - if ( ! $(element).find(".collapsible-trigger").size() ) { - - if ($(element).hasClass("mw-collapsed")) { - $(element).children(".mw-collapsible-content").first().hide(); - buttonText = expandText; - } - else { - $(element).children(".mw-collapsible-content").first().show(); - buttonText = collapseText; - } - - // if there is a pre-trigger element, insert the trigger after it - // otherwise, insert the trigger as the first element (prepend) - if( $(element).find(".pre-trigger").size() ) - $(element).find(".pre-trigger").after("" + buttonText + ""); - else - $(element).prepend("" + buttonText + ""); - + addMultipleInstanceRefire( + { + pageload: true, + addBefore:true, + addEnd: true, + reorder: false, + remove: false + }, + // perform this function at events defined above + // this adds collapsible content to properly marked templates. Use Template:Collapsible + function () { + + $(".smm-collapsible").each(function(index,element){ + + var collapseText = $(element).attr("data-collapsetext") || "Collapse"; + var expandText = $(element).attr("data-expandtext") || "Expand"; + var buttonText; + + // if no tags within collapsible, then it hasn't been setup yet + // this only performed the first time on each collapsible + if ( ! $(element).find(".collapsible-trigger").size() ) { + + if ($(element).hasClass("smm-collapsed")) { + $(element).children(".smm-collapsible-content").first().hide(); + buttonText = expandText; + } + else { + $(element).children(".smm-collapsible-content").first().show(); + buttonText = collapseText; + } + + // if there is a pre-trigger element, insert the trigger after it + // otherwise, insert the trigger as the first element (prepend) + if( $(element).find(".pre-trigger").size() ) + $(element).find(".pre-trigger").after("" + buttonText + ""); + else + $(element).prepend("" + buttonText + ""); + + } + + $(element).find("a.collapsible-trigger").unbind("click").click(function(ev){ + + if( $(ev.target).parent().hasClass("smm-collapsed") ) { + $(ev.target).parent().find(".smm-collapsible-content").first().slideDown("slow"); + + // change button to collapse + $(ev.target).text(collapseText); + } + else { + $(ev.target).parent().find(".smm-collapsible-content").first().slideUp("slow"); + + // change button to expand + $(ev.target).text(expandText); + } + + $(ev.target).parent().toggleClass("smm-collapsed"); + + return false; + + }); + + }); + } - - $(element).find("a.collapsible-trigger").unbind("click").click(function(ev){ - - if( $(ev.target).parent().hasClass("mw-collapsed") ) { - $(ev.target).parent().find(".mw-collapsible-content").first().slideDown("slow"); - - // change button to collapse - $(ev.target).text(collapseText); - } - else { - $(ev.target).parent().find(".mw-collapsible-content").first().slideUp("slow"); - - // change button to expand - $(ev.target).text(expandText); - } - - $(ev.target).parent().toggleClass("mw-collapsed"); - - return false; - - }); - - }); + ); -}); - -// adds a counter to text fields limited to 255 characters -addMultipleInstanceRefire(function(){ - - $(".character-limit-255").each(function(index,element){ - - $(element).removeClass(".character-limit-255").addClass(".character-limit-255-added"); - - var counter = $("").css({ - "text-align" : "right" - }); - - $(element).keyup(function(ev){ - - var chars = $(this).val().length; - - counter.html(chars + " of 255 characters"); - - var css; - if (chars < 200) { - css = { - color : "black", - "font-weight" : "normal" - } - } - else { - css = { - color : "red", - "font-weight" : "bold" - } - } - - counter.css(css); - - }).blur(function(){ - if( $(this).val().length < 255 ) { - counter.hide(); - } - }).focus(function(){ - counter.show(); - }).after(counter); - - }); - -}); - -*/ \ No newline at end of file +}); \ No newline at end of file