Commit d3cc385e authored by Mukul's avatar Mukul

[erp5_officejs][erp5_web_renderjs_ui] Adds random play feature in officejs media player.

parent 94df7891
......@@ -72,7 +72,10 @@
}
jio_options = {
type: 'dateupdater',
sub_storage: jio_options,
sub_storage: {
type: 'random',
sub_storage: jio_options
},
property_list: ['modification_date']
};
try {
......
......@@ -222,7 +222,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>vincent</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.36985.29761.10359</string> </value>
<value> <string>966.54536.8656.36676</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1507216488.77</float>
<float>1524152028.08</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -12,6 +12,7 @@
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod('redirect', 'redirect')
/////////////////////////////////////////////////////////////////
// declared methods
......@@ -83,6 +84,15 @@
['description', 'Description'],
['version', 'Version'],
['modification_date', 'Modification Date']
],
sort_list = [
['title', 'Title'],
['reference', 'Reference'],
['language', 'Language'],
['description', 'Description'],
['version', 'Version'],
['modification_date', 'Modification Date'],
['random', 'Random']
];
return result[0].render({
erp5_document: {
......@@ -100,7 +110,7 @@
result[1] + "%22",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort_column_list": sort_list,
"sort": [['modification_date', 'descending']],
"title": "Documents",
"type": "ListBox"
......
......@@ -273,7 +273,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.44404.50238.55500</string> </value>
<value> <string>967.4474.3819.63505</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -291,7 +291,7 @@
</tuple>
<state>
<tuple>
<float>1523022279.07</float>
<float>1524558413.59</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10056,6 +10056,78 @@ return new Parser;
jIO.addStorage('uuid', UUIDStorage);
}(jIO));
;/*jslint nomen: true*/
(function (jIO) {
"use strict";
/**
* The jIO RandomStorage extension
*
* @class RandomStorage
* @constructor
*/
function RandomStorage(spec) {
this._sub_storage = jIO.createJIO(spec.sub_storage);
}
RandomStorage.prototype.get = function () {
return this._sub_storage.get.apply(this._sub_storage, arguments);
};
RandomStorage.prototype.allAttachments = function () {
return this._sub_storage.allAttachments.apply(this._sub_storage, arguments);
};
RandomStorage.prototype.post = function () {
return this._sub_storage.post.apply(this._sub_storage, arguments);
};
RandomStorage.prototype.put = function () {
return this._sub_storage.put.apply(this._sub_storage, arguments);
};
RandomStorage.prototype.remove = function () {
return this._sub_storage.remove.apply(this._sub_storage, arguments);
};
RandomStorage.prototype.getAttachment = function () {
return this._sub_storage.getAttachment.apply(this._sub_storage, arguments);
};
RandomStorage.prototype.putAttachment = function () {
return this._sub_storage.putAttachment.apply(this._sub_storage, arguments);
};
RandomStorage.prototype.removeAttachment = function () {
return this._sub_storage.removeAttachment.apply(this._sub_storage,
arguments);
};
RandomStorage.prototype.hasCapacity = function (name) {
return this._sub_storage.hasCapacity(name);
};
RandomStorage.prototype.buildQuery = function (options) {
if (options.sort_on[0][0] === 'random') {
var limit = options.limit;
delete options.limit;
}
return this._sub_storage.buildQuery.apply(this._sub_storage,
arguments)
.push(function (result) {
// Random shuffle the result when random is present in the options.
if (options.sort_on[0][0] === 'random') {
var final_result = [],
random_number;
while (limit[1] && result.length - limit[0]) {
random_number = Math.floor(Math.random() * result.length);
random_number = random_number === result.length ? result.length - 1 : random_number;
final_result.push(result.splice(random_number, 1)[0]);
limit[1] -= 1;
}
return final_result;
}
return result;
});
};
jIO.addStorage('random', RandomStorage);
}(jIO));
;/*
* Copyright 2013, Nexedi SA
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.12481.11377.36966</string> </value>
<value> <string>967.4461.64143.42632</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1522845747.33</float>
<float>1524557708.76</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment