Bug #10010
Choice in use of libraries mootools or jquery in the archive/category widgets
| Status: | Closed | Start date: | 2010-09-30 | |
|---|---|---|---|---|
| Priority: | Won't have this time | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | Feature | |||
| Target version: | - | |||
| Votes: | 0 |
Description
Besides, it is good to give a choice of use of libraries mootools or jquery. Though always probably to use jQuery.noConflict (), it creates difficulties. For archive widget there is a decision in expansion t3blogjquery, but it would be desirable to have a choice and adjustment in one place...
Аnd use parametre jQuery.noConflict() on/off.
Related issues
| related to T3BLOG - Bug #10009: Incorrect work [+] / [-] toggle in the archive/category w... | Needs Feedback | 2010-09-30 |
History
Updated by Dmitry Dulepov over 2 years ago
- Category set to Feature
- Status changed from New to On Hold
- Priority changed from Should have to Won't have this time
Not planned any soon because needs a lot of time investment for development and testing.
Updated by Felix Nagel over 2 years ago
I use T3Blog with jQuery just by changing TypoScript and some lines of custom JS code. If there is any need for my changes, just comment this issue!
Updated by Andrey Aksenov over 2 years ago
It would be good to look at changing TypoScript and some lines of custom JS code.
There is an extension for the use of jQuery in the list of Archives (t3blogjquery) successfully used this JS code.
But in general I would like to have the choice of scheme used, for example, in the constants when setting up extensions.
Updated by Felix Nagel over 2 years ago
No prob, use following TS code:
plugin.tx_t3blog_pi1 {
categories {
list {
20 >
}
}
}
and this jQuery JS code:
// category toggle
var uls = $(".tx-t3blog-pi2 ul#togglecat0 li ul");
uls.each(function(index){
var ul = $(this);
ul.attr("aria-hidden", true).attr("aria-expanded", false).hide();
var link = ul.prevAll("a.iconbeforetext");
toggleLink(ul, link);
});
// helper function to toggle archive and categrory link
function toggleLink(ul, link) {
link.text("[+]").toggle(function() {
link.text("[-]")
ul.attr("aria-hidden", false).attr("aria-expanded", true).slideDown();
return false;
}, function() {
link.text("[+]")
ul.attr("aria-hidden", true).attr("aria-expanded", false).slideUp();
return false;
});
}
Updated by Andrey Aksenov over 2 years ago
Thanks, will check in soon ...
Updated by Andrey Aksenov over 2 years ago
Once all did not work, had to rework...
TS Setup for t3blog:
page {
includeJS {
jquerycookie = fileadmin/config/plugins/t3blog/js/jquery.cookie.js
t3blogarchiv = fileadmin/config/plugins/t3blog/js/t3blog_archive.js
t3blogcategories = fileadmin/config/plugins/t3blog/js/t3blog_cat.js
}
}
plugin.tx_t3blog_pi1 {
categories {
listItem.dataWrap = <li>{field:catname} <span class="postnum">({field:postnum})</span>{field:subcategories}</li>
catLink.cropHTML = 12|...
list {
20 >
}
}
archive {
listWrap.30 >
}
}
Here we include in page header three js file, I have all of them are in the folder "fileadmin/config/plugins/t3blog/js /". JQuery library itself is connected with the extension t3jQuery, and is set to "jQuery.noConflict ();".
File jquery.cookie.js from extension t3blogjquery:
/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
// CAUTION: Needed to parenthesize options.path and options.domain
// in the following expressions, otherwise they evaluate to undefined
// in the packed version for some reason...
var path = options.path ? '; path=' + (options.path) : '';
var domain = options.domain ? '; domain=' + (options.domain) : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
};
File t3blog_archive.js from extension t3blogjquery:
jQuery(document).ready(function() {
jQuery("a[id^='toggle']").each(function () {
var year = this.id.substr(6);
if(jQuery.cookie('archive_'+year)=='1') {
jQuery('#archive_'+year).slideUp('fast');
jQuery('#'+this.id).text('[+]');
} else {
jQuery('#'+this.id).text('[-]');
}
jQuery('#'+this.id).click(function() {
if(jQuery('#'+this.id).text()=='[-]') {
jQuery('#archive_'+year).slideUp('fast');
jQuery.cookie('archive_'+year,'1',{ path:'/'});
jQuery('#'+this.id).text('[+]');
} else {
jQuery('#archive_'+year).slideDown('fast');
jQuery.cookie('archive_'+year,'0',{ path:'/'});
jQuery('#'+this.id).text('[-]');
}
return false;
});
});
});
File t3blog_cat.js:
jQuery(document).ready(function() {
// helper function to toggle archive and categrory link
function toggleLink(ul, link) {
link.text("[+]").toggle(function() {
link.text("[-]")
ul.attr("aria-hidden", false).attr("aria-expanded", true).slideDown();
return false;
}, function() {
link.text("[+]")
ul.attr("aria-hidden", true).attr("aria-expanded", false).slideUp();
return false;
});
}
// category toggle
var uls = jQuery(".tx-t3blog-pi2 ul#togglecat0 li ul");
uls.each(function(index){
var ul = jQuery(this);
ul.attr("aria-hidden", true).attr("aria-expanded", false).hide();
var link = ul.prevAll("a.iconbeforetext");
toggleLink(ul, link);
});
});
Everything works ...
Updated by Hauke Hain over 2 years ago
I use t3blogjquery:
http://typo3.org/extensions/repository/view/t3blogjquery/current/
Archive widget uses jQuery instead of Mootools.
The extension behaves exactly like the Mootools version. Only TypoScript gets included and via TypoScript the needed JavaScript files. It you need noConflict mode, you can insert this script via TypoScript in a higher level before the included JavaScript gets used.
As you can see in Andrey example, it is easy to adjust.
Updated by Andrey Aksenov over 2 years ago
This bug can be closed, because it is completely solved extension t3blogjquery.
Updated by Felix Nagel about 1 year ago
- Status changed from On Hold to Closed