Changeset 6568
- Timestamp:
- 02/28/10 09:11:35 (2 years ago)
- Location:
- trunk/TagMePlugin
- Files:
-
- 4 deleted
- 8 edited
-
data/System/TagMeAjaxHelper.txt (modified) (4 diffs)
-
data/System/TagMePlugin.txt (modified) (5 diffs)
-
lib/Foswiki/Plugins/TagMePlugin.pm (modified) (2 diffs)
-
lib/Foswiki/Plugins/TagMePlugin/DEPENDENCIES (modified) (1 diff)
-
lib/Foswiki/Plugins/TagMePlugin/MANIFEST (modified) (2 diffs)
-
pub/System/TagMeAjaxHelper/jquery.tagmeui.css (deleted)
-
pub/System/TagMeAjaxHelper/jquery.tagmeui.css.gz (deleted)
-
pub/System/TagMeAjaxHelper/jquery.tagmeui.js (deleted)
-
pub/System/TagMeAjaxHelper/jquery.tagmeui.js.gz (deleted)
-
pub/System/TagMeAjaxHelper/jquery.tagmeui.uncompressed.css (modified) (2 diffs)
-
pub/System/TagMeAjaxHelper/jquery.tagmeui.uncompressed.js (modified) (2 diffs)
-
pub/System/TagMePlugin/jquery.tagmeui.png (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
trunk/TagMePlugin/data/System/TagMeAjaxHelper.txt
r6270 r6568 8 8 }% 9 9 %ENDSECTION{"tagquery"}% 10 %STARTSECTION{"jqui"}%%JQREQUIRE{"textboxlist"}%%JQREQUIRE{"autocomplete"}%%JQREQUIRE{"simplemodal"}%%JQREQUIRE{"hoverintent"}%%JQREQUIRE{"queryobject"}%%ADDTOHEAD{ 11 "TAGMEPLUGIN::JQUI" 12 text="<meta name='foswiki.TagMePlugin.jquitags' 13 content='%TAGME{tpaction="%URLPARAM{"tpaction" default="showalltags"}%" 14 tag="%URLPARAM{"tptag"}%" web="%BASEWEB%" topic="%BASETOPIC%" separator=","}%' 15 /><script type='text/javascript' src='%PUBURLPATH%/%SYSTEMWEB%/%TOPIC%/jquery.tagmeui.js'></script> 16 <link rel='stylesheet' href='%PUBURLPATH%/%SYSTEMWEB%/TagMeAjaxHelper/jquery.tagmeui.css' 17 type='text/css' media='all'/>" 18 requires="JQUERYPLUGIN::TEXTBOXLIST, JQUERYPLUGIN::AUTOCOMPLETE, JQUERYPLUGIN::SIMPLEMODAL, JQUERYPLUGIN::HOVERINTENT, JQUERYPLUGIN::QUERYOBJECT" 19 }%<div id='tagmejqcontainer'><span id="tagmejqtagstatus"> </span> 10 %STARTSECTION{"jqui"}%%JQREQUIRE{"textboxlist"}%%JQREQUIRE{"autocomplete"}%%JQREQUIRE{"simplemodal"}%%JQREQUIRE{"hoverintent"}%%JQREQUIRE{"queryobject"}%%ADDTOZONE{"head" 11 tag="TAGMEPLUGIN::JQUI:CSS" 12 text="<meta name='foswiki.TagMePlugin.jquitags' content='%TAGME{tpaction="%URLPARAM{"tpaction" default="showalltags"}%" tag="%URLPARAM{"tptag"}%" web="%BASEWEB%" topic="%BASETOPIC%" separator=","}%' /> 13 <meta name='foswiki.TagMePlugin.remove' content='%IF{"($TAGMEPLUGIN_JQUIREMOVEALL='everybody') OR ($TAGMEPLUGIN_JQUIREMOVEALL='topicchange' AND '%BASEWEB%.%BASETOPIC%' allows 'CHANGE') OR ('%USERNAME%' ingroup 'AdminGroup')" then="all"}%' /> 14 <link rel='stylesheet' href='%PUBURLPATH%/%SYSTEMWEB%/TagMeAjaxHelper/jquery.tagmeui.css' type='text/css' media='all'/>" 15 requires="JQUERYPLUGIN::TEXTBOXLIST, JQUERYPLUGIN::AUTOCOMPLETE, JQUERYPLUGIN::SIMPLEMODAL, JQUERYPLUGIN::HOVERINTENT, JQUERYPLUGIN::QUERYOBJECT, JQUERYPLUGIN" 16 }%%ADDTOZONE{"body" 17 tag="TAGMEPLUGIN::JQUI::JS" 18 text="<script type='text/javascript' src='%PUBURLPATH%/%SYSTEMWEB%/%TOPIC%/jquery.tagmeui.js'></script>" 19 requires="JQUERYPLUGIN::TEXTBOXLIST, JQUERYPLUGIN::AUTOCOMPLETE, JQUERYPLUGIN::SIMPLEMODAL, JQUERYPLUGIN::HOVERINTENT, JQUERYPLUGIN::QUERYOBJECT, JQUERYPLUGIN" 20 }%<div id='tagmejqcontainer'> 20 21 <div id="tagmejqcloud" style="display:none"></div> 21 <span id="tagmejqtag" title="%MAKETEXT{"Click for tag cloud pop-up"}%"> 22 <form id="tagmejqtaglistform" name="tagmeshow" method="post" action="%SCRIPTURLPATH{"viewauth"}%/%WEB%/%TOPIC%"> 23 <span id="tagmejqtagstatus"> </span> 24 <span id="tagmejqtagbutton" title="%MAKETEXT{"Click for tag cloud pop-up"}%"> 22 25 %MAKETEXT{"Tags"}% </span> 23 <form name="tagmeshow" method="post" action="%SCRIPTURLPATH{"viewauth"}%/%WEB%/%TOPIC%">24 26 <input type="text" name="add" id="tagmejqinputfield" title="%MAKETEXT{"Enter a tag name to apply to this topic"}%" size="15" value="%TAGME{ tpaction="showalltags" web="%BASEWEB%" topic="%BASETOPIC%"}%"/> 25 27 </form></div>%ENDSECTION{"jqui"}% … … 30 32 else="%MAKETEXT{"[[[_1].WebHome][[_1]]] web" args="%URLPARAM{"tpweb"}%"}%" 31 33 }% 32 <form id="tagmeWebSelect" method="post" action="%SCRIPTURLPATH{"view"}%/%WEB%/%TOPIC%"> 33 <input type="checkbox" id="tagmeCheckboxJustThisWeb" name="tpweb"\ 34 <br/> 35 <form id="tagmejqWebSelect" method="post" action="%SCRIPTURLPATH{"view"}%/%WEB%/%TOPIC%"> 36 <input type="checkbox" id="tagmejqCheckboxJustThisWeb" name="tpweb"\ 34 37 value="%URLPARAM{"tpweb"}%" %IF{"'%URLPARAM{"tpweb"}%'=''" then="checked='checked'"}%\ 35 38 title="%MAKETEXT{"Show tags from all webs"}%"\ 36 39 /> 37 40 <label for="tpweb">%MAKETEXT{"all webs"}%</label> | 38 <input type="checkbox" id="tagme CheckboxJustMe" name="tpuser" value="me" \41 <input type="checkbox" id="tagmejqCheckboxJustMe" name="tpuser" value="me" \ 39 42 %IF{"'%URLPARAM{"tpuser"}%'='me'" then="checked='checked'"}%\ 40 43 title="%MAKETEXT{"Show tags used by me"}%"\ … … 46 49 title="%MAKETEXT{"Delete tags"}%">%MAKETEXT{"delete..."}%</a> 47 50 </form> 48 <div id="tagme TagCloud" style="line-height:2em;">51 <div id="tagmejqTagCloud" style="line-height:2em;"> 49 52 %TAGME{tpaction="showalltags" 50 53 web="%URLPARAM{"tpweb"}%" … … 60 63 * Set NOWYSIWYG = 1 61 64 --> 62 -
trunk/TagMePlugin/data/System/TagMePlugin.txt
r6270 r6568 65 65 All features work without having to re-load the topic: 66 66 * Auto-complete tag names. Saves newly selected tags immediately 67 * If auto-complete fails to match the entered tag and the user submits68 it, the tag is immediately created and applied67 * The entered tag is created and added even if the tag did not 68 previously exist. 69 69 * Access tag cloud in a modal dialogue at the click of a button. Check-box 70 70 toggles are applied immediately (show cloud for just this web/all webs, … … 74 74 from the originating web (avoids reliance on browser back button 75 75 when exploring a web via tag cloud) 76 * Removing a tag may optionally clear the tag from the current topic 77 regardless of vote count (default for members of Main.AdminGroup). 78 * =Set TAGMEPLUGIN_JQUIREMOVEALL = everybody= <br/> 79 will allow any logged-in user to remove a tag, or 80 * =Set TAGMEPLUGIN_JQUIREMOVEALL = topicchange= <br/>to only give this 81 ability to those users who have CHANGE permission on the current 82 topic (everbody else will still be able to vote down tags as 83 usual)<br/> 84 * %ICON{"warning"}% 85 jqui uses an undocumented feature of TagMePlugin to access the 86 removeall feature, which does not appear to follow any access 87 controls internally. 76 88 77 89 Include it into your WebTopBar (See WebTopBarExample) or any part of your skin that has horizontal space to spare, as follows: 78 90 <verbatim class="tml">%INCLUDE{"%SYSTEMWEB%.TagMeAjaxHelper" section="jqui"}%</verbatim> 79 91 80 <div class="foswikiImage"><img src="%ATTACHURLPATH%/jquery.tagmeui.png" alt="Screenshot of experimental jQuery UI" width=" 522" height="156" /></div>92 <div class="foswikiImage"><img src="%ATTACHURLPATH%/jquery.tagmeui.png" alt="Screenshot of experimental jQuery UI" width="493" height="205" /></div> 81 93 82 94 Dependencies: … … 199 211 | =nostatus="on"= | Turn off status text shown when a tag is added or voted on | (show status text) | 200 212 201 * =%<nop>TAGME{ tpaction="newtag andadd" ... }%= - create new tag and add tag to topic213 * =%<nop>TAGME{ tpaction="newtagsandadd" ... }%= - create new tag and add tag to topic 202 214 | *Parameter* | *Comment* | *Default* | 203 215 | =tag="..."= | Name of tag. Accepts alphanumeric and underscore characters only (unless =NORMALIZE_TAG_INPUT= is set to 0 to allow any user input) | (required) | … … 374 386 | Release: | %$RELEASE% | 375 387 | Change History: | <!-- versions below in reverse order --> | 376 | 31 Jan 2010: | Foswiki:Main.PaulHarvey: Added an interactive user interface implemented with JQuery |388 | 31 Jan 2010: | Foswiki:Main.PaulHarvey: Added an interactive user interface implemented with JQuery; ship missing blog style tmpl files; fix docs/implementation of newtagsandadd | 377 389 | 11 Jun 2009: | Foswiki port, and moved settings out of this topic | 378 390 | 30 Aug 2008: | Foswiki:Main.ColasNahaboo: enhancements to the "blog" style: Bundles, count of known tags, option to delete tags | … … 414 426 __Related Topics:__ %SYSTEMWEB%.TagMeViewAllTags, %SYSTEMWEB%.TagMeViewMyTags, %SYSTEMWEB%.TagMeSearch, %SYSTEMWEB%.TagMeDebugViewTags, %SYSTEMWEB%.TagMeDebugSearch, %SYSTEMWEB%.TagMeAjaxHelper, [[%SYSTEMWEB%.Plugins][Plugins]], %SYSTEMWEB%.DeveloperDocumentationCategory, %SYSTEMWEB%.AdminDocumentationCategory, %SYSTEMWEB%.DefaultPreferences, %USERSWEB%.SitePreferences 415 427 416 %META:FILEATTACHMENT{name="jquery.tagmeui.png" attr="h" comment="Screenshot of experimental jQuery UI" date="1264982400" path="jquery.tagmeui.png" size=" 16289" user="ProjectContributor" version="1.1"}%428 %META:FILEATTACHMENT{name="jquery.tagmeui.png" attr="h" comment="Screenshot of experimental jQuery UI" date="1264982400" path="jquery.tagmeui.png" size="27644" user="ProjectContributor" version="1.1"}% 417 429 %META:FILEATTACHMENT{name="tag_add.gif" attr="h" comment="Button: add tag" date="1141691885" path="tag_add.gif" size="857" user="ProjectContributor" version="1.1"}% 418 430 %META:FILEATTACHMENT{name="tag_remove.gif" attr="h" comment="Button: remove tag" date="1141697484" path="tag_remove.gif" size="862" user="ProjectContributor" version="1.1"}% -
trunk/TagMePlugin/lib/Foswiki/Plugins/TagMePlugin.pm
r6196 r6568 36 36 37 37 our $VERSION = '$Rev$'; 38 our $RELEASE = ' 01Feb 2010';38 our $RELEASE = '28 Feb 2010'; 39 39 our $NO_PREFS_IN_TOPIC = 1; 40 40 our $SHORTDESCRIPTION = … … 1184 1184 $tag = _makeSafeTag($tag); 1185 1185 if ($tag) { 1186 $args = 'tag="' . $tag . '"';1186 $args = {tag => $tag}; 1187 1187 $text = _newTag($args); 1188 1188 $text = _addTag($args) unless $text =~ /foswikiAlert/; -
trunk/TagMePlugin/lib/Foswiki/Plugins/TagMePlugin/DEPENDENCIES
r342 r6568 1 Foswiki::Plugins::JQueryPlugin,>=6308,perl,optional 2 Foswiki::Plugins::FilterPlugin,>=3491,perl,optional -
trunk/TagMePlugin/lib/Foswiki/Plugins/TagMePlugin/MANIFEST
r6196 r6568 1 data/System/TagMeAjaxHelper.txt 0644 2 data/System/TagMeChangeRequests.txt 0644 3 data/System/TagMeCreateNewTag.txt 0644 1 4 data/System/TagMeDebugSearch.txt 0644 2 5 data/System/TagMeDebugViewTags.txt 0644 3 data/System/TagMePlugin.txt 0644 6 data/System/TagMeDeleteTag.txt 0644 7 data/System/TagMeRenameTag.txt 0644 4 8 data/System/TagMeSearch.txt 0644 5 9 data/System/TagMeViewAllTags.txt 0644 6 10 data/System/TagMeViewMyTags.txt 0644 7 data/System/TagMeCreateNewTag.txt 0644 8 data/System/TagMeRenameTag.txt 0644 9 data/System/TagMeDeleteTag.txt 0644 10 data/System/TagMeChangeRequests.txt 0644 11 lib/Foswiki/Plugins/TagMePlugin.pm 0444 11 lib/Foswiki/Plugins/TagMePlugin.pm 0644 12 pub/System/TagMeAjaxHelper/Makefile 0644 13 pub/System/TagMeAjaxHelper/cloudspinner.gif 0644 From http://www.ajaxload.info 14 pub/System/TagMeAjaxHelper/jquery.tagmeui.uncompressed.css 0644 15 pub/System/TagMeAjaxHelper/jquery.tagmeui.css 0644 16 pub/System/TagMeAjaxHelper/jquery.tagmeui.css.gz 0644 17 pub/System/TagMeAjaxHelper/jquery.tagmeui.uncompressed.js 0644 18 pub/System/TagMeAjaxHelper/jquery.tagmeui.js 0644 19 pub/System/TagMeAjaxHelper/jquery.tagmeui.js.gz 0644 20 pub/System/TagMeAjaxHelper/spinner.gif 0644 From http://www.ajaxload.info 21 pub/System/TagMeAjaxHelper/tag.png 0644 From FamFamFamSilkIcons 12 22 pub/System/TagMePlugin/alltagcloud.gif 0644 23 #pub/System/TagMePlugin/buttons_gradient.psd 0644 24 pub/System/TagMePlugin/jquery.tagmeui.png 0644 13 25 pub/System/TagMePlugin/tag_add.gif 0644 14 26 pub/System/TagMePlugin/tag_addnew.gif 0644 … … 16 28 pub/System/TagMePlugin/tagme.css 0644 17 29 pub/System/TagMePlugin/topictags.gif 0644 18 pub/System/TagMePlugin/jqui.png 0644 30 pub/System/TagMePlugin/topictags_styleblog.gif 0644 31 pub/System/TagMePlugin/topictags_styleblog_open.gif 0644 19 32 templates/view.tagme.tmpl 0644 33 templates/view.tagme_styleblog.tmpl 0644 20 34 templates/view.tagme_styleblogbutton.tmpl 0644 21 templates/view.tagme_styleblog.tmpl 064422 35 templates/view.tagmejquiajax.tmpl 0644 23 pub/System/TagMeAjaxHelper/jqui.js 064424 pub/System/TagMeAjaxHelper/jqui.css 064425 pub/System/TagMeAjaxHelper/tag.png 0644 From FamFamFamSilkIcons26 pub/System/TagMeAjaxHelper/spinner.gif 0644 From http://www.ajaxload.info27 pub/System/TagMeAjaxHelper/cloudspinner.gif 0644 From http://www.ajaxload.info28 data/System/TagMeAjaxHelper.txt 0644 -
trunk/TagMePlugin/pub/System/TagMeAjaxHelper/jquery.tagmeui.uncompressed.css
r6270 r6568 1 #tagme TagCloud {1 #tagmejqTagCloud { 2 2 padding-top: 1em; 3 3 } 4 #tagmejqtagstatus, #tagmejqtag{5 float: left;4 .jqTextboxListContainer { 5 display: inline; 6 6 } 7 #tagmejqtag {7 #tagmejqtagbutton { 8 8 text-decoration: underline; 9 9 } 10 #tagmejqtag :hover {10 #tagmejqtagbutton:hover { 11 11 color: #C0FFC0; 12 12 background-color: #778899; … … 23 23 background-image: url('cloudspinner.gif'); 24 24 } 25 #tagmejqtag {25 #tagmejqtagbutton { 26 26 background-image: url('tag.png'); 27 27 background-position: right; -
trunk/TagMePlugin/pub/System/TagMeAjaxHelper/jquery.tagmeui.uncompressed.js
r6270 r6568 23 23 'use strict'; 24 24 jQuery(document).ready(function () { 25 (function ($) {26 $.fn.tagmeui = function (options) {25 (function ($) { 26 $.fn.tagmeui = function (options) { 27 27 /* TODO: 28 28 * - Prevent multiple instantiations on DOM elements. … … 30 30 * jquery metadata plugin, and so opts can be extracted from DOM 31 31 * element. Eg: $('#myTagMeDivWithMetaData').tagmeui({extra: 'opts'}); 32 * - Modify TagMePlugin itself to support hard removal of tags,33 * instead of the bogus vote count subtraction currently34 32 * - There is no meaningful feedback to user if ajax calls fail 35 33 * (auth/permissions, etc) */ 36 $(this).each(function () {37 var tagmeui = new TagMeUI($(this), options);38 39 tagmeui.initTagField();40 });41 42 return this;43 };44 45 function TagMeUI(caller, options) {46 var that = this;47 48 this.caller = caller;49 this.urlQuery = $.query;50 this.cloudQuery = this.urlQuery.copy();51 this.cloudQuery.SET('skin', 'text');52 this.cloudQuery.SET('contenttype', 'text/plain');53 this.cloudQuery.SET('section', 'cloud');54 /* Convert comma separated list of tags (from html meta) to array */55 this.tags = foswiki.TagMePlugin.jquitags.split(',');56 if (!this.cloudQuery.get('qcallingweb')) {57 this.cloudQuery.SET('qcallingweb', foswiki.web);58 }59 this.settings = {60 cloudSpinner: '#tagmejqtag',61 cloudContainer: '#tagmejqcloud',62 cloudWeb: (function () {63 var web = that.cloudQuery.get('qcallingweb');64 65 if (!web) {66 web = foswiki.web;67 }68 69 if (!that.cloudQuery.get('tpweb')) {70 that.cloudQuery.SET('tpweb', web);71 }72 73 return web;74 }()),75 cloudGetUrl: foswiki.scriptUrlPath + '/view/' +76 foswiki.systemWebName + '/TagMeAjaxHelper',77 cloudUiJustThisWeb: '#tagmeCheckboxJustThisWeb',78 cloudUiJustMe: '#tagmeCheckboxJustMe',79 cloudModalOpts: {80 opacity: 7,81 position: ['50px', null],82 maxWidth: (document.width - 50),83 persist: true,84 onShow: function () {85 $('#simplemodal-overlay').click(86 87 function () {88 $.modal.close();89 });90 }91 },92 taglistSpinner: '#tagmejqtagstatus',93 taglistContainer: '#tagmejqcontainer',94 taglistInputField: '#tagmejqinputfield',95 tagLinkUrl: foswiki.scriptUrlPath + '/view/' +96 foswiki.systemWebName + '/TagMeSearch',34 $(this).each(function () { 35 var tagmeui = new TagMeUI($(this), options); 36 37 tagmeui.initTagField(); 38 }); 39 40 return this; 41 }; 42 43 function TagMeUI(caller, options) { 44 var that = this; 45 46 this.caller = caller; 47 this.urlQuery = $.query; 48 this.cloudQuery = this.urlQuery.copy(); 49 this.cloudQuery.SET('skin', 'text'); 50 this.cloudQuery.SET('contenttype', 'text/plain'); 51 this.cloudQuery.SET('section', 'cloud'); 52 /* Convert comma separated list of tags (from html meta) to array */ 53 this.tags = foswiki.TagMePlugin.jquitags.split(','); 54 if (!this.cloudQuery.get('qcallingweb')) { 55 this.cloudQuery.SET('qcallingweb', foswiki.web); 56 } 57 this.settings = { 58 cloudSpinner: '#tagmejqtagbutton', 59 cloudContainer: '#tagmejqcloud', 60 cloudWeb: (function () { 61 var web = that.cloudQuery.get('qcallingweb'); 62 63 if (!web) { 64 web = foswiki.web; 65 } 66 67 if (!that.cloudQuery.get('tpweb')) { 68 that.cloudQuery.SET('tpweb', web); 69 } 70 71 return web; 72 }()), 73 cloudGetUrl: foswiki.scriptUrlPath + '/view/' + 74 foswiki.systemWebName + '/TagMeAjaxHelper', 75 cloudUiJustThisWeb: '#tagmejqCheckboxJustThisWeb', 76 cloudUiJustMe: '#tagmejqCheckboxJustMe', 77 cloudModalOpts: { 78 opacity: 7, 79 position: ['70px', null], 80 maxWidth: (document.width - 50), 81 persist: true, 82 onShow: function () { 83 $('#simplemodal-overlay').click( 84 85 function () { 86 $.modal.close(); 87 }); 88 } 89 }, 90 taglistSpinner: '#tagmejqtagstatus', 91 taglistContainer: '#tagmejqcontainer', 92 taglistInputField: '#tagmejqinputfield', 93 tagLinkUrl: foswiki.scriptUrlPath + '/view/' + 94 foswiki.systemWebName + '/TagMeSearch', 97 95 tagLinkTitle: 'Other topics with this tag', 98 tagPostUrl: foswiki.scriptUrlPath + '/viewauth/' + foswiki.web +99 '/' + foswiki.topic,100 autocompleteUrl: foswiki.scriptUrlPath + '/view/' +101 foswiki.systemWebName + '/TagMeAjaxHelper',102 autocompleteOpts: {103 extraParams: {104 section: 'tagquery',105 contenttype: 'text/plain',106 skin: 'text'107 },108 autoFill: true,109 matchCase: false,110 multiple: false,111 max: 0,112 mustMatch: false113 }114 };115 $.extend(this.settings, options);116 }117 118 /* Check that tagName exists inList, and if not, POST the action and execute119 ** the finishHandler(tagName) */120 TagMeUI.prototype.actOnMissingTag = function (tagName, inList, action, finishHandler) {121 var didModify = false,122 that = this;123 124 if ($.inArray(tagName, inList) === -1) {125 $(this.settings.taglistSpinner).addClass('spinning');126 $.post(this.settings.postUrl, {127 tpaction: action,128 tptag: tagName,129 contenttype: 'text/plain',130 skin: 'tagmejquiajax'131 },132 133 function (data) {134 that.linkifyTagText(that.settings.taglistContainer);135 $(that.settings.taglistSpinner).removeClass('spinning');136 finishHandler(tagName);137 });138 didModify = true;139 }140 141 return didModify;142 };143 144 /* By default, textboxlist doesn't handle hyperlinks in the list items.145 ** This would be much better implemented using some sort of callback, but146 ** textboxlist didn't seem to implement a suitable hook. */147 TagMeUI.prototype.linkifyTagText = function (selector) {148 var that = this;149 $(selector + ' > form > div.jqTextboxListContainer > span:not(.linkified)').each(150 function (index, tagSpan) {151 var tagQuery = $.query.copy(),96 tagPostUrl: foswiki.scriptUrlPath + '/viewauth/' + foswiki.web + 97 '/' + foswiki.topic, 98 autocompleteUrl: foswiki.scriptUrlPath + '/view/' + 99 foswiki.systemWebName + '/TagMeAjaxHelper', 100 autocompleteOpts: { 101 extraParams: { 102 section: 'tagquery', 103 contenttype: 'text/plain', 104 skin: 'text' 105 }, 106 autoFill: true, 107 matchCase: false, 108 multiple: false, 109 max: 0, 110 mustMatch: false 111 } 112 }; 113 $.extend(this.settings, options); 114 } 115 116 /* Check that tagName exists inList, and if not, POST the action and execute 117 ** the finishHandler(tagName) */ 118 TagMeUI.prototype.actOnMissingTag = function (tagName, inList, action, finishHandler) { 119 var didModify = false, 120 that = this; 121 122 if ($.inArray(tagName, inList) === -1) { 123 $(this.settings.taglistSpinner).addClass('spinning'); 124 $.post(this.settings.postUrl, { 125 tpaction: action, 126 tptag: tagName, 127 contenttype: 'text/plain', 128 skin: 'tagmejquiajax' 129 }, 130 131 function (data) { 132 that.linkifyTagText(that.settings.taglistContainer); 133 $(that.settings.taglistSpinner).removeClass('spinning'); 134 finishHandler(tagName); 135 }); 136 didModify = true; 137 } 138 139 return didModify; 140 }; 141 142 /* By default, textboxlist doesn't handle hyperlinks in the list items. 143 ** This would be much better implemented using some sort of callback, but 144 ** textboxlist didn't seem to implement a suitable hook. */ 145 TagMeUI.prototype.linkifyTagText = function (selector) { 146 var that = this; 147 $(selector + ' > form > div.jqTextboxListContainer > span:not(.linkified)').each( 148 function (index, tagSpan) { 149 var tagQuery = $.query.copy(), 152 150 theTag = $(tagSpan).text(); 153 154 /* There must be an easier way to remove the textNode from a span; but155 ** I don't know it... yet. .text('') destroys child elements we want to156 ** keep. */157 function removeTextNodes(element) {158 $(element).contents().filter(159 function () {160 if (this.nodeType === Node.TEXT_NODE) {161 this.textContent = '';162 }163 }164 );165 166 return;167 }168 169 tagQuery.SET('tag', theTag);170 tagQuery.SET('qcallingweb', foswiki.web);171 removeTextNodes(tagSpan);172 $(tagSpan).append('<a href="' + that.settings.tagLinkUrl +173 tagQuery.toString() + '" title="' +151 152 /* There must be an easier way to remove the textNode from a span; but 153 ** I don't know it... yet. .text('') destroys child elements we want to 154 ** keep. */ 155 function removeTextNodes(element) { 156 $(element).contents().filter( 157 function () { 158 if (this.nodeType === Node.TEXT_NODE) { 159 this.textContent = ''; 160 } 161 } 162 ); 163 164 return; 165 } 166 167 tagQuery.SET('tag', theTag); 168 tagQuery.SET('qcallingweb', foswiki.web); 169 removeTextNodes(tagSpan); 170 $(tagSpan).append('<a href="' + that.settings.tagLinkUrl + 171 tagQuery.toString() + '" title="' + 174 172 that.settings.tagLinkTitle + '">' + theTag + '</a>'); 175 $(tagSpan).addClass('linkified');176 }177 );178 179 return;180 };173 $(tagSpan).addClass('linkified'); 174 } 175 ); 176 177 return; 178 }; 181 179 182 180 /* Populates a hidden div with the tag cloud and then displays it 183 181 * with simplemodal. Some messiness to bind events on the cloud modal */ 184 TagMeUI.prototype.loadCloud = function () {185 var that = this;186 187 function initDialogue() {188 function setQueryWithCheckbox(qkey, qvalue, checkbox, sense) {189 if ($(checkbox).is(':checked') === sense) {190 that.cloudQuery.SET(qkey, qvalue);191 } else {192 that.cloudQuery = that.cloudQuery.remove(qkey);193 }194 }195 182 TagMeUI.prototype.loadCloud = function () { 183 var that = this; 184 185 function initDialogue() { 186 function setQueryWithCheckbox(qkey, qvalue, checkbox, sense) { 187 if ($(checkbox).is(':checked') === sense) { 188 that.cloudQuery.SET(qkey, qvalue); 189 } else { 190 that.cloudQuery = that.cloudQuery.remove(qkey); 191 } 192 } 193 196 194 /* Would be nice if simplemodal had more sensible autosizing 197 195 * with content. */ 198 if ($('#simplemodal-container').width() > $(document).width() - 50) { 199 $('#simplemodal-container').width($(document).width() - 50); 200 } 201 $(that.settings.cloudUiJustThisWeb).click(function () { 202 setQueryWithCheckbox('tpweb', that.settings.cloudWeb, 203 that.settings.cloudUiJustThisWeb, false); 204 that.loadCloud(); 205 }); 206 $(that.settings.cloudUiJustMe).click(function () { 207 setQueryWithCheckbox('tpuser', 'me', 208 that.settings.cloudUiJustMe, true); 209 that.loadCloud(); 210 }); 211 } 212 213 $(this.settings.cloudSpinner).addClass('spinning'); 214 $(this.settings.cloudContainer).load(this.settings.cloudGetUrl + 215 this.cloudQuery.toString(), function () { 216 $(that.settings.cloudSpinner).removeClass('spinning'); 217 $(that.settings.cloudContainer).modal(that.settings.cloudModalOpts); 218 initDialogue(); 219 }); 220 }; 221 222 TagMeUI.prototype.initTagField = function () { 223 /* MD's textboxlist jq plugin allows the user to easily work on tags */ 224 var that = this; 225 226 $(this.settings.taglistInputField).textboxlist({ 227 onSelect: function (input) { 228 /* The logic here is a bit odd, started out anticipating a batch rather than 229 ** one-by-one POST to updated a modified selection of tags... */ 230 var selectedTags = input.currentValues, 231 didAdd = false; 232 233 /* If there's a selected tag that isn't in the list of stored tags, 234 ** it needs to be added. */ 235 $.each(selectedTags, function (index, tagName) { 236 if (that.actOnMissingTag(tagName, that.tags, 'add', 237 function (tagName) { 238 that.tags.push(tagName); 239 }) 240 ) { 241 didAdd = true; 242 } 243 }); 244 245 if (!didAdd) { 246 /* If there's a stored tag that isn't in the list of selected tags, 247 ** it needs to be removed. */ 248 $.each(that.tags, function (index, tagName) { 249 if (!that.actOnMissingTag(tagName, selectedTags, 'remove', 250 function (tagName) { 251 that.tags.pop(tagName); 252 }) 253 ) { 254 that.linkifyTagText(that.settings.taglistContainer); 255 } 256 }); 257 } 258 }, 259 260 autocomplete: this.settings.autocompleteUrl, 261 autocompleteOpts: this.settings.autocompleteOpts 262 }); 263 264 this.linkifyTagText(this.settings.taglistContainer); 265 266 $(this.settings.cloudSpinner).click(function () { 267 that.loadCloud(); 268 }); 269 }; 270 271 }(jQuery)); 196 if ($('#simplemodal-container').width() > $(document).width() - 50) { 197 $('#simplemodal-container').width($(document).width() - 50); 198 } 199 $(that.settings.cloudUiJustThisWeb).click(function () { 200 setQueryWithCheckbox('tpweb', that.settings.cloudWeb, 201 that.settings.cloudUiJustThisWeb, false); 202 that.loadCloud(); 203 }); 204 $(that.settings.cloudUiJustMe).click(function () { 205 setQueryWithCheckbox('tpuser', 'me', 206 that.settings.cloudUiJustMe, true); 207 that.loadCloud(); 208 }); 209 } 210 211 $(this.settings.cloudSpinner).addClass('spinning'); 212 $(this.settings.cloudContainer).load(this.settings.cloudGetUrl + 213 this.cloudQuery.toString(), function () { 214 $(that.settings.cloudSpinner).removeClass('spinning'); 215 $(that.settings.cloudContainer).modal(that.settings.cloudModalOpts); 216 initDialogue(); 217 }); 218 }; 219 220 TagMeUI.prototype.initTagField = function () { 221 /* MD's textboxlist jq plugin allows the user to easily work on tags */ 222 var that = this; 223 224 $(this.settings.taglistInputField).textboxlist({ 225 onSelect: function (input) { 226 /* The logic here is a bit odd, started out anticipating a batch rather than 227 ** one-by-one POST to updated a modified selection of tags... */ 228 var selectedTags = input.currentValues, 229 didAdd = false; 230 231 /* If there's a selected tag that isn't in the list of stored tags, 232 ** it needs to be added. */ 233 $.each(selectedTags, function (index, tagName) { 234 if (that.actOnMissingTag(tagName, that.tags, 'newtagsandadd', 235 function (tagName) { 236 that.tags.push(tagName); 237 }) 238 ) { 239 didAdd = true; 240 } 241 }); 242 243 if (!didAdd) { 244 /* If there's a stored tag that isn't in the list of selected tags, 245 ** it needs to be removed. */ 246 $.each(that.tags, function (index, tagName) { 247 var removeAction = 'remove'; 248 if ( (typeof(foswiki.TagMePlugin) !== 'undefined') && (foswiki.TagMePlugin.remove === 'all') ) { 249 removeAction = 'removeall'; 250 } 251 if (!that.actOnMissingTag(tagName, selectedTags, removeAction, 252 function (tagName) { 253 that.tags.pop(tagName); 254 }) 255 ) { 256 that.linkifyTagText(that.settings.taglistContainer); 257 } 258 }); 259 } 260 261 }, 262 263 autocomplete: this.settings.autocompleteUrl, 264 autocompleteOpts: this.settings.autocompleteOpts 265 }); 266 this.linkifyTagText(this.settings.taglistContainer); 267 268 $(this.settings.cloudSpinner).click(function () { 269 that.loadCloud(); 270 }); 271 }; 272 273 }(jQuery)); 272 274 273 275 /* Install tagmeui using default options */
Note: See TracChangeset
for help on using the changeset viewer.
