mirror of https://github.com/zulip/zulip.git
Add hash_util.encodeHashComponent() shim.
This commit is contained in:
parent
d75efa19db
commit
27f37e6378
|
@ -48,6 +48,7 @@
|
||||||
"topic_list": false,
|
"topic_list": false,
|
||||||
"gear_menu": false,
|
"gear_menu": false,
|
||||||
"hashchange": false,
|
"hashchange": false,
|
||||||
|
"hash_util": false,
|
||||||
"message_list": false,
|
"message_list": false,
|
||||||
"Filter": false,
|
"Filter": false,
|
||||||
"pointer": false,
|
"pointer": false,
|
||||||
|
|
|
@ -28,6 +28,10 @@ set_global('resize', {
|
||||||
resize_page_components: function () {},
|
resize_page_components: function () {},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
set_global('hash_util', {
|
||||||
|
encodeHashComponent: global.hashchange.encodeHashComponent,
|
||||||
|
});
|
||||||
|
|
||||||
var me = {
|
var me = {
|
||||||
email: 'me@zulip.com',
|
email: 'me@zulip.com',
|
||||||
user_id: 999,
|
user_id: 999,
|
||||||
|
|
|
@ -54,6 +54,11 @@ set_global('$', function (obj) {
|
||||||
|
|
||||||
set_global('feature_flags', {local_echo: true});
|
set_global('feature_flags', {local_echo: true});
|
||||||
|
|
||||||
|
set_global('hash_util', {
|
||||||
|
encodeHashComponent: global.hashchange.encodeHashComponent,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
jsdom.changeURL(window, 'http://zulip.zulipdev.com');
|
jsdom.changeURL(window, 'http://zulip.zulipdev.com');
|
||||||
set_global('window', window);
|
set_global('window', window);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,11 @@ add_dependencies({
|
||||||
|
|
||||||
var hashchange = require('js/hashchange.js');
|
var hashchange = require('js/hashchange.js');
|
||||||
|
|
||||||
|
set_global('hash_util', {
|
||||||
|
encodeHashComponent: hashchange.encodeHashComponent,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
(function test_operators_round_trip() {
|
(function test_operators_round_trip() {
|
||||||
var operators;
|
var operators;
|
||||||
var hash;
|
var hash;
|
||||||
|
|
|
@ -12,6 +12,10 @@ var Filter = global.Filter;
|
||||||
var stream_data = global.stream_data;
|
var stream_data = global.stream_data;
|
||||||
var _ = global._;
|
var _ = global._;
|
||||||
|
|
||||||
|
set_global('hash_util', {
|
||||||
|
encodeHashComponent: global.hashchange.encodeHashComponent,
|
||||||
|
});
|
||||||
|
|
||||||
function set_filter(operators) {
|
function set_filter(operators) {
|
||||||
operators = _.map(operators, function (op) {
|
operators = _.map(operators, function (op) {
|
||||||
return {operator: op[0], operand: op[1]};
|
return {operator: op[0], operand: op[1]};
|
||||||
|
|
|
@ -14,6 +14,10 @@ set_global('message_store', {
|
||||||
|
|
||||||
set_global('unread', {});
|
set_global('unread', {});
|
||||||
|
|
||||||
|
set_global('hash_util', {
|
||||||
|
encodeHashComponent: global.hashchange.encodeHashComponent,
|
||||||
|
});
|
||||||
|
|
||||||
// TODO: move pm_list-related tests to their own module
|
// TODO: move pm_list-related tests to their own module
|
||||||
var pm_list = require('js/pm_list.js');
|
var pm_list = require('js/pm_list.js');
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,10 @@ add_dependencies({
|
||||||
|
|
||||||
set_global('blueslip', {});
|
set_global('blueslip', {});
|
||||||
|
|
||||||
|
set_global('hash_util', {
|
||||||
|
encodeHashComponent: global.hashchange.encodeHashComponent,
|
||||||
|
});
|
||||||
|
|
||||||
var stream_data = require('js/stream_data.js');
|
var stream_data = require('js/stream_data.js');
|
||||||
var people = global.people;
|
var people = global.people;
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,11 @@ add_dependencies({
|
||||||
|
|
||||||
var stream_list = require('js/stream_list.js');
|
var stream_list = require('js/stream_list.js');
|
||||||
|
|
||||||
|
set_global('hash_util', {
|
||||||
|
encodeHashComponent: global.hashchange.encodeHashComponent,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
var jsdom = require("jsdom");
|
var jsdom = require("jsdom");
|
||||||
var window = jsdom.jsdom().defaultView;
|
var window = jsdom.jsdom().defaultView;
|
||||||
global.$ = require('jquery')(window);
|
global.$ = require('jquery')(window);
|
||||||
|
|
|
@ -15,6 +15,10 @@ global.$ = require('jquery')(window);
|
||||||
|
|
||||||
var topic_list = require('js/topic_list.js');
|
var topic_list = require('js/topic_list.js');
|
||||||
|
|
||||||
|
set_global('hash_util', {
|
||||||
|
encodeHashComponent: global.hashchange.encodeHashComponent,
|
||||||
|
});
|
||||||
|
|
||||||
global.compile_template('topic_list_item');
|
global.compile_template('topic_list_item');
|
||||||
|
|
||||||
(function test_topic_list_build_widget() {
|
(function test_topic_list_build_widget() {
|
||||||
|
|
|
@ -92,7 +92,7 @@ $(function () {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var stream = stream_data.get_sub_by_id($(this).attr('data-stream-id'));
|
var stream = stream_data.get_sub_by_id($(this).attr('data-stream-id'));
|
||||||
if (stream) {
|
if (stream) {
|
||||||
window.location.href = '/#narrow/stream/' + hashchange.encodeHashComponent(stream.name);
|
window.location.href = '/#narrow/stream/' + hash_util.encodeHashComponent(stream.name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.location.href = $(this).attr('href');
|
window.location.href = $(this).attr('href');
|
||||||
|
|
|
@ -352,7 +352,7 @@ function handleStream(streamName) {
|
||||||
}
|
}
|
||||||
return '<a class="stream" data-stream-id="' + stream.stream_id + '" ' +
|
return '<a class="stream" data-stream-id="' + stream.stream_id + '" ' +
|
||||||
'href="' + window.location.origin + '/#narrow/stream/' +
|
'href="' + window.location.origin + '/#narrow/stream/' +
|
||||||
hashchange.encodeHashComponent(stream.name) + '"' +
|
hash_util.encodeHashComponent(stream.name) + '"' +
|
||||||
'>' + '#' + stream.name + '</a>';
|
'>' + '#' + stream.name + '</a>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ exports.operators_to_hash = function (operators) {
|
||||||
var operand = elem.operand;
|
var operand = elem.operand;
|
||||||
|
|
||||||
var sign = elem.negated ? '-' : '';
|
var sign = elem.negated ? '-' : '';
|
||||||
hash += '/' + sign + hashchange.encodeHashComponent(operator)
|
hash += '/' + sign + hash_util.encodeHashComponent(operator)
|
||||||
+ '/' + hashchange.encode_operand(operator, operand);
|
+ '/' + hashchange.encode_operand(operator, operand);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -614,30 +614,30 @@ exports.by_sender_uri = function (reply_to) {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.by_stream_uri = function (stream) {
|
exports.by_stream_uri = function (stream) {
|
||||||
return "#narrow/stream/" + hashchange.encodeHashComponent(stream);
|
return "#narrow/stream/" + hash_util.encodeHashComponent(stream);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.by_stream_subject_uri = function (stream, subject) {
|
exports.by_stream_subject_uri = function (stream, subject) {
|
||||||
return "#narrow/stream/" + hashchange.encodeHashComponent(stream) +
|
return "#narrow/stream/" + hash_util.encodeHashComponent(stream) +
|
||||||
"/subject/" + hashchange.encodeHashComponent(subject);
|
"/subject/" + hash_util.encodeHashComponent(subject);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.by_message_uri = function (message_id) {
|
exports.by_message_uri = function (message_id) {
|
||||||
return "#narrow/id/" + hashchange.encodeHashComponent(message_id);
|
return "#narrow/id/" + hash_util.encodeHashComponent(message_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.by_near_uri = function (message_id) {
|
exports.by_near_uri = function (message_id) {
|
||||||
return "#narrow/near/" + hashchange.encodeHashComponent(message_id);
|
return "#narrow/near/" + hash_util.encodeHashComponent(message_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.by_conversation_and_time_uri = function (message) {
|
exports.by_conversation_and_time_uri = function (message) {
|
||||||
if (message.type === "stream") {
|
if (message.type === "stream") {
|
||||||
return "#narrow/stream/" + hashchange.encodeHashComponent(message.stream) +
|
return "#narrow/stream/" + hash_util.encodeHashComponent(message.stream) +
|
||||||
"/subject/" + hashchange.encodeHashComponent(message.subject) +
|
"/subject/" + hash_util.encodeHashComponent(message.subject) +
|
||||||
"/near/" + hashchange.encodeHashComponent(message.id);
|
"/near/" + hash_util.encodeHashComponent(message.id);
|
||||||
}
|
}
|
||||||
return "#narrow/pm-with/" + hashchange.encodeHashComponent(message.reply_to) +
|
return "#narrow/pm-with/" + hash_util.encodeHashComponent(message.reply_to) +
|
||||||
"/near/" + hashchange.encodeHashComponent(message.id);
|
"/near/" + hash_util.encodeHashComponent(message.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Are we narrowed to PMs: all PMs or PMs with particular people.
|
// Are we narrowed to PMs: all PMs or PMs with particular people.
|
||||||
|
|
|
@ -13,5 +13,8 @@ var compose_actions = {};
|
||||||
compose_actions.start = compose.start;
|
compose_actions.start = compose.start;
|
||||||
compose_actions.cancel = compose.cancel;
|
compose_actions.cancel = compose.cancel;
|
||||||
|
|
||||||
|
var hash_util = {};
|
||||||
|
hash_util.encodeHashComponent = hashchange.encodeHashComponent;
|
||||||
|
|
||||||
var compose_state = {};
|
var compose_state = {};
|
||||||
compose_state.has_message_content = compose.has_message_content;
|
compose_state.has_message_content = compose.has_message_content;
|
||||||
|
|
|
@ -1423,7 +1423,7 @@ $(function () {
|
||||||
|
|
||||||
window.location.hash = "#streams" + "/" +
|
window.location.hash = "#streams" + "/" +
|
||||||
stream_id + "/" +
|
stream_id + "/" +
|
||||||
hashchange.encodeHashComponent(sub.name);
|
hash_util.encodeHashComponent(sub.name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue