2013-05-25 16:26:22 +00:00
|
|
|
/*\
|
2013-12-28 23:19:51 +00:00
|
|
|
title: $:/core/modules/filters/sort.js
|
2013-05-25 16:26:22 +00:00
|
|
|
type: application/javascript
|
|
|
|
module-type: filteroperator
|
|
|
|
|
|
|
|
Filter operator for sorting
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/*
|
|
|
|
Export our filter function
|
|
|
|
*/
|
|
|
|
exports.sort = function(source,operator,options) {
|
2013-12-28 23:15:11 +00:00
|
|
|
var results = prepare_results(source);
|
2014-04-10 18:56:21 +00:00
|
|
|
options.wiki.sortTiddlers(results,operator.operand || "title",operator.prefix === "!",false,false);
|
2013-12-28 23:15:11 +00:00
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.nsort = function(source,operator,options) {
|
|
|
|
var results = prepare_results(source);
|
2014-04-10 18:56:21 +00:00
|
|
|
options.wiki.sortTiddlers(results,operator.operand || "title",operator.prefix === "!",false,true);
|
2013-12-28 23:15:11 +00:00
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
2018-03-05 11:09:25 +00:00
|
|
|
exports.sortan = function(source, operator, options) {
|
|
|
|
var results = prepare_results(source);
|
|
|
|
options.wiki.sortTiddlers(results, operator.operand || "title", operator.prefix === "!",false,false,true);
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
2013-12-28 23:15:11 +00:00
|
|
|
exports.sortcs = function(source,operator,options) {
|
|
|
|
var results = prepare_results(source);
|
2014-04-10 18:56:21 +00:00
|
|
|
options.wiki.sortTiddlers(results,operator.operand || "title",operator.prefix === "!",true,false);
|
2013-12-28 23:15:11 +00:00
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.nsortcs = function(source,operator,options) {
|
|
|
|
var results = prepare_results(source);
|
2014-04-10 18:56:21 +00:00
|
|
|
options.wiki.sortTiddlers(results,operator.operand || "title",operator.prefix === "!",true,true);
|
2013-12-28 23:15:11 +00:00
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
|
|
|
var prepare_results = function (source) {
|
2014-04-03 19:49:16 +00:00
|
|
|
var results = [];
|
|
|
|
source(function(tiddler,title) {
|
|
|
|
results.push(title);
|
|
|
|
});
|
2013-05-25 16:26:22 +00:00
|
|
|
return results;
|
2014-08-30 19:44:26 +00:00
|
|
|
};
|
2013-05-25 16:26:22 +00:00
|
|
|
|
|
|
|
})();
|