mirror of
https://github.com/Mibew/mibew.git
synced 2025-04-21 22:27:23 +03:00
Compare commits
No commits in common. "master" and "v2.0-alpha2" have entirely different histories.
master
...
v2.0-alpha
24
.gitignore
vendored
24
.gitignore
vendored
@ -1,11 +1,6 @@
|
||||
# IDE folders
|
||||
.idea
|
||||
|
||||
src/mibew/install/package
|
||||
src/absent_*
|
||||
src/release*
|
||||
src/upload*
|
||||
src/*.po
|
||||
|
||||
# Do not index actual configuration files
|
||||
src/mibew/configs/config.yml
|
||||
@ -15,11 +10,6 @@ src/tests/server_side/mibew/libs/config.php
|
||||
src/mibew/files/avatar/*
|
||||
!src/mibew/files/avatar/.keep
|
||||
|
||||
# Do not index cache files
|
||||
src/mibew/cache/*
|
||||
!src/mibew/cache/.keep
|
||||
!src/mibew/cache/.htaccess
|
||||
|
||||
# Do not index plugins
|
||||
src/mibew/plugins/*
|
||||
!src/mibew/plugins/.keep
|
||||
@ -34,22 +24,20 @@ src/composer.lock
|
||||
|
||||
# Do not index third-party libraries
|
||||
src/mibew/vendor
|
||||
src/mibew/js/vendor
|
||||
|
||||
# Do not index node.js modules that are used for building
|
||||
src/node_modules
|
||||
src/package-lock.json
|
||||
|
||||
# Do not index compiled js files of the core
|
||||
src/mibew/js/compiled/*
|
||||
!src/mibew/js/compiled/.keep
|
||||
|
||||
# Do not index compiled files of chat styles
|
||||
src/mibew/styles/chats/*/templates_compiled/client_side/*
|
||||
!src/mibew/styles/chats/*/templates_compiled/client_side/.keep
|
||||
src/mibew/styles/chats/*/js/compiled/*
|
||||
!src/mibew/styles/chats/*/js/compiled/.keep
|
||||
src/mibew/styles/dialogs/default/templates_compiled/client_side/*
|
||||
!src/mibew/styles/dialogs/default/templates_compiled/client_side/.keep
|
||||
src/mibew/styles/dialogs/default/js/compiled/*
|
||||
!src/mibew/styles/dialogs/default/js/compiled/.keep
|
||||
|
||||
# Do not index compiled files of page styles
|
||||
src/mibew/styles/pages/*/templates_compiled/client_side/*
|
||||
!src/mibew/styles/pages/*/templates_compiled/client_side/.keep
|
||||
src/mibew/styles/pages/default/templates_compiled/client_side/*
|
||||
!src/mibew/styles/pages/default/templates_compiled/client_side/.keep
|
||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
||||
[submodule "src/i18n"]
|
||||
path = src/i18n
|
||||
url = git@github.com:Mibew/i18n.git
|
@ -1,12 +0,0 @@
|
||||
### Environment
|
||||
* Mibew Messenger version:
|
||||
* OS:
|
||||
* Web server:
|
||||
* PHP:
|
||||
* PHP extensions:
|
||||
* MySQL:
|
||||
### Expected behavior
|
||||
|
||||
### Actual behavior
|
||||
|
||||
### Steps to reproduce the behavior
|
@ -1,8 +0,0 @@
|
||||
Fixes # .
|
||||
|
||||
Changes proposed in this pull request:
|
||||
-
|
||||
-
|
||||
-
|
||||
|
||||
@Mibew/core-developers
|
38
README.md
38
README.md
@ -11,7 +11,7 @@ This repository contains the core of Mibew Messenger application.
|
||||
## Server requirements
|
||||
|
||||
1. A webserver or web hosting account running on any major Operating System
|
||||
2. PHP (7.2.5 and above) with PDO, pdo_mysql, cURL, mbstring and gd extensions
|
||||
2. PHP (5.3.3 and above) with MySQL support
|
||||
3. MySQL 5.0 and above
|
||||
|
||||
## Build from sources
|
||||
@ -33,39 +33,7 @@ Mibew Messenger is licensed under the terms of [Apache License, Version 2.0](htt
|
||||
|
||||
## Other repositories of the Mibew project
|
||||
|
||||
### Actual
|
||||
1. [Mibew Messenger i18n repository](https://github.com/Mibew/i18n)
|
||||
2. [Mibew Messenger design repository](https://github.com/Mibew/design)
|
||||
3. [Mibew documentation repository](https://github.com/Mibew/docs.mibew.org)
|
||||
|
||||
### Obsolete
|
||||
1. [Mibew Java applications repository](https://github.com/Mibew/java)
|
||||
2. [Mibew Tray repository](https://github.com/Mibew/tray)
|
||||
|
||||
### Plugins
|
||||
|
||||
1. [Mibew Boilerplate plugin](https://github.com/Mibew/boilerplate-plugin) - a template for a real plugin
|
||||
|
||||
#### Ready for production use
|
||||
|
||||
1. [Mibew Advanced Button plugin](https://github.com/Mibew/advanced-button-plugin)
|
||||
2. [Mibew Auto Invite plugin](https://github.com/Mibew/auto-invite-plugin)
|
||||
3. [Mibew Auto Reply plugin](https://github.com/Mibew/auto-reply-plugin)
|
||||
4. [Mibew Broadcast plugin](https://github.com/Mibew/broadcast-plugin)
|
||||
5. [Mibew Bulk Logs Operations plugin](https://github.com/Mibew/bulk-logs-operations-plugin)
|
||||
6. [Mibew Button Refresh plugin](https://github.com/Mibew/button-refresh-plugin)
|
||||
7. [Mibew Emoji plugin](https://github.com/Mibew/emoji-plugin)
|
||||
8. [Mibew Filter Visitors By Operator Code plugin](https://github.com/Mibew/filter-visitors-by-operator-code-plugin)
|
||||
9. [Mibew First Message plugin](https://github.com/Mibew/first-message-plugin)
|
||||
10. [Mibew Geo IP plugin](https://github.com/Mibew/geo-ip-plugin)
|
||||
11. [Mibew Google Maps plugin](https://github.com/Mibew/google-maps-plugin)
|
||||
12. [Mibew Open Street Map plugin](https://github.com/Mibew/open-street-map-plugin)
|
||||
13. [Mibew Operator Status plugin](https://github.com/Mibew/mibew-operator-status-plugin)
|
||||
14. [Mibew Purge History plugin](https://github.com/Mibew/purge-history-plugin)
|
||||
15. [Mibew Real Ban plugin](https://github.com/Mibew/real-ban-plugin)
|
||||
16. [Mibew Slack plugin](https://github.com/Mibew/mibew_slack)
|
||||
17. [Mibew Title Notification plugin](https://github.com/Mibew/title-notification-plugin)
|
||||
|
||||
#### Not ready for production use (not stable, broken, obsolete, etc.)
|
||||
|
||||
1. [Mibew External API plugin](https://github.com/Mibew/external-api-plugin)
|
||||
3. [Mibew Java applications repository](https://github.com/Mibew/java)
|
||||
4. [Mibew Tray repository](https://github.com/Mibew/tray)
|
||||
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"directory": "./mibew/js/vendor",
|
||||
"analytics": false
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
{
|
||||
"extends": "eslint:recommended",
|
||||
"rules": {
|
||||
"indent": ["error", 4, {"SwitchCase": 1}],
|
||||
"no-trailing-spaces": "error",
|
||||
"semi": ["error", "always"],
|
||||
"guard-for-in": "error",
|
||||
"no-unused-vars": ["error", {"caughtErrors": "none", "args": "none"}]
|
||||
},
|
||||
"globals": {
|
||||
"Mibew": true,
|
||||
"MibewAPI": true,
|
||||
"MibewAPIInteraction": true,
|
||||
"MibewAPIChatInteraction": true,
|
||||
"MibewAPIUsersInteraction": true,
|
||||
"MibewAPIExecutionContext": true,
|
||||
"Handlebars": true,
|
||||
"_": true,
|
||||
"Backbone": true,
|
||||
"jQuery": true,
|
||||
"vex": true,
|
||||
"validator": true
|
||||
},
|
||||
"env":{
|
||||
"browser": true
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
{
|
||||
"name": "mibew",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"underscore": "1.8.2",
|
||||
"json": "https://github.com/douglascrockford/JSON-js.git#c98948ae1944a28e2e8ebc3717894e580aeaaa05",
|
||||
"jquery": "1.11.3",
|
||||
"backbone": "1.1.2",
|
||||
"marionette": "2.4.1",
|
||||
"handlebars": "4.3.0",
|
||||
"vex": "2.3.2",
|
||||
"validator-js": "3.40.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"underscore": "1.8.2"
|
||||
}
|
||||
}
|
56
src/check_translation.pl
Executable file
56
src/check_translation.pl
Executable file
@ -0,0 +1,56 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
sub read_transl($) {
|
||||
my($from) = @_;
|
||||
my %translation = ();
|
||||
open(IN, "mibew/locales/$from/properties");
|
||||
while(<IN>) {
|
||||
chomp;
|
||||
if(/^([\w\.]+)=(.*)$/) {
|
||||
if($1 ne "encoding" && $1 ne "output_charset" && $1 ne "output_encoding") {
|
||||
$translation{$1} = $2;
|
||||
}
|
||||
} else {
|
||||
die "wrong line in $from: $_\n";
|
||||
}
|
||||
}
|
||||
close(IN);
|
||||
return %translation;
|
||||
}
|
||||
|
||||
%tr_en = read_transl("en");
|
||||
|
||||
@all_keys = keys %tr_en;
|
||||
|
||||
sub check_transl($%) {
|
||||
my($name,%tr) = @_;
|
||||
print "checking $name...\n";
|
||||
my @totransl = ();
|
||||
for $key (@all_keys) {
|
||||
unless(exists $tr{$key}) {
|
||||
push @totransl, "$key=".$tr_en{$key};
|
||||
}
|
||||
}
|
||||
for $key(keys %tr) {
|
||||
unless(exists $tr_en{$key}) {
|
||||
print "unknown key in $name: $key\n";
|
||||
}
|
||||
}
|
||||
if($#totransl >= 0) {
|
||||
print "@{[$#totransl+1]} lines absent in locales/$name/properties\n";
|
||||
open(OUT, "> absent_$name");
|
||||
for(sort @totransl) {
|
||||
print OUT "$_\n";
|
||||
}
|
||||
close(OUT);
|
||||
}
|
||||
}
|
||||
|
||||
check_transl("ru", read_transl("ru"));
|
||||
check_transl("fr", read_transl("fr"));
|
||||
check_transl("de", read_transl("de"));
|
||||
check_transl("sp", read_transl("sp"));
|
||||
check_transl("it", read_transl("it"));
|
||||
check_transl("pl", read_transl("pl"));
|
||||
check_transl("zh-tw", read_transl("zh-tw"));
|
||||
|
@ -1,49 +1,32 @@
|
||||
{
|
||||
"name": "mibew/mibew",
|
||||
"version": "3.6.0",
|
||||
"version": "2.0-dev",
|
||||
"description": "Mibew Messenger - open-source live support application",
|
||||
"type": "project",
|
||||
"homepage": "https://mibew.org",
|
||||
"homepage": "http://mibew.org",
|
||||
"license": "Apache-2.0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mibew Messenger Project",
|
||||
"homepage": "https://mibew.org/credits"
|
||||
"homepage": "http://mibew.org/credits"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"email": "support@mibew.org",
|
||||
"issues": "https://github.com/mibew/mibew/issues",
|
||||
"forum": "https://mibew.org/forums",
|
||||
"forum": "http://mibew.org/forums",
|
||||
"source": "https://github.com/mibew/mibew"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/mibew/handlebars.php"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/mibew/handlebars.php-helpers"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"mibew/handlebars.php": "~0.10.5",
|
||||
"mibew/handlebars.php-helpers": "1.*",
|
||||
"symfony/http-foundation": "4.4.*",
|
||||
"symfony/routing": "4.4.*",
|
||||
"symfony/config": "4.4.*",
|
||||
"symfony/yaml": "^5.2",
|
||||
"symfony/translation": "2.6.*",
|
||||
"tedivm/stash": "0.12.*",
|
||||
"mibew/html5": "1.1.*",
|
||||
"vierbergenlars/php-semver": "3.0.*",
|
||||
"swiftmailer/swiftmailer": "~5.4.0",
|
||||
"ua-parser/uap-php": "^3.9",
|
||||
"true/punycode": "~1.1"
|
||||
"xamin/handlebars.php": "dev-master#cd8cec42a048ba0d8c7dd0bfde39b973b6a14b3f",
|
||||
"symfony/http-foundation": "2.4.*",
|
||||
"symfony/routing": "2.4.*",
|
||||
"symfony/config": "2.4.*",
|
||||
"symfony/yaml": "2.4.*",
|
||||
"symfony/translation": "2.4.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "3.*"
|
||||
"squizlabs/php_codesniffer": "1.*"
|
||||
},
|
||||
"config": {
|
||||
"vendor-dir": "mibew/vendor"
|
||||
|
245
src/compute_resources.pl
Executable file
245
src/compute_resources.pl
Executable file
@ -0,0 +1,245 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use Digest::MD5 qw(md5 md5_hex md5_base64);
|
||||
|
||||
@rules = (
|
||||
["redirect(ed)?\\.tpl", 1],
|
||||
["\\.tpl", 0],
|
||||
|
||||
["view/license.php", 0],
|
||||
["view/themes.php", 2],
|
||||
["view/translate.php", 2],
|
||||
["view/translatelist.php", 2],
|
||||
["view/settings.php", 2],
|
||||
["view/updates.php", 2],
|
||||
["view/features.php", 2],
|
||||
["view/performance.php", 2],
|
||||
["view/avatar.php", 2],
|
||||
["view/permissions.php", 2],
|
||||
["view/agent.php", 2],
|
||||
["view/agents.php", 2],
|
||||
["view/group.php", 2],
|
||||
["view/groupmembers.php", 2],
|
||||
["view/groups.php", 2],
|
||||
["view/operator_groups.php", 2],
|
||||
["view/gen_button.php", 2],
|
||||
["view/install_err.php", 2],
|
||||
["view/install_index.php", 2],
|
||||
["view/.*\\.php", 1],
|
||||
|
||||
["install/.*\\.php", 2],
|
||||
|
||||
["operator/themes.php", 2],
|
||||
["operator/translate.php", 2],
|
||||
["operator/settings.php", 2],
|
||||
["operator/updates.php", 2],
|
||||
["operator/features.php", 2],
|
||||
["operator/performance.php", 2],
|
||||
["operator/avatar.php", 2],
|
||||
["operator/permissions.php", 2],
|
||||
["operator/operator.php", 2],
|
||||
["operator/operators.php", 2],
|
||||
["operator/group.php", 2],
|
||||
["operator/groupmembers.php", 2],
|
||||
["operator/groups.php", 2],
|
||||
["operator/opgroups.php", 2],
|
||||
["operator/getcode.php", 2],
|
||||
["operator/.*\\.php", 1],
|
||||
|
||||
["mibew/client.php", 0],
|
||||
["mibew/leavemessage.php", 0],
|
||||
["mibew/captcha.php", 0],
|
||||
["mibew/license.php", 0],
|
||||
["mibew/mail.php", 0],
|
||||
|
||||
["libs/operator_settings.php", 2],
|
||||
["mibew/libs/chat.php", 0],
|
||||
["libs/pagination.php", 1],
|
||||
["libs/settings.php", 2],
|
||||
["libs/groups.php", 2],
|
||||
["libs/demothread.php", 2],
|
||||
|
||||
["mibew/thread.php", 0],
|
||||
["mibew/b.php", 0],
|
||||
["mibew/button.php", 0],
|
||||
["mibew/index.php", 0],
|
||||
|
||||
["mibew/libs/.*\\.php", 1],
|
||||
);
|
||||
|
||||
%messagekeys = (
|
||||
"localeid" => 0,
|
||||
"output_charset" => 0,
|
||||
"output_encoding" => 0,
|
||||
"harderrors.header" => 0,
|
||||
|
||||
"errors.required" => 0,
|
||||
"errors.wrong_field" => 0,
|
||||
"errors.file.move.error" => 2,
|
||||
"errors.invalid.file.type" => 2,
|
||||
"errors.file.size.exceeded" => 2,
|
||||
|
||||
"permission.admin" => 1,
|
||||
"permission.takeover" => 1,
|
||||
"permission.viewthreads" => 1,
|
||||
|
||||
"chat.thread.state_chatting_with_agent" => 1,
|
||||
"chat.thread.state_closed" => 1,
|
||||
"chat.thread.state_loading" => 1,
|
||||
"chat.thread.state_wait" => 1,
|
||||
"chat.thread.state_wait_for_another_agent" => 1,
|
||||
|
||||
"clients.queue.chat" => 1,
|
||||
"clients.queue.prio" => 1,
|
||||
"clients.queue.wait" => 1,
|
||||
);
|
||||
|
||||
|
||||
$mibewPath = "mibew";
|
||||
|
||||
%urls = ();
|
||||
|
||||
%usermessages = ();
|
||||
%operatormessages = ();
|
||||
$current_level = 0;
|
||||
|
||||
sub usemsg($) {
|
||||
my ($m) = @_;
|
||||
$messagekeys{$m} = exists $messagekeys{$m} && $messagekeys{$m} < $current_level ? $messagekeys{$m} : $current_level;
|
||||
if($current_level == -1) {
|
||||
print " .. $m\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub file_content($) {
|
||||
my $input = $_[0];
|
||||
open( IN1, "< $input" ) or die "cannot find file $input";
|
||||
my $oldslash = $/;
|
||||
$/ = EOI;
|
||||
$content = <IN1>;
|
||||
close( IN1 );
|
||||
if($content =~ s/\r//g) {
|
||||
open( OUT1, "> $input") or die "cannot fix $input";
|
||||
print OUT1 $content;
|
||||
close(OUT1);
|
||||
}
|
||||
$/ = $oldslash;
|
||||
return $content;
|
||||
}
|
||||
|
||||
sub process_tpl($) {
|
||||
my ($filename) = @_;
|
||||
my $m = file_content($filename);
|
||||
while( $m =~ /\${msg:([\w\.]+)(,[\w\.]+)?}/g ) {
|
||||
usemsg($1);
|
||||
}
|
||||
while( $m =~ /\${url:([\w\.]+)(,[\w\.]+)?}/g ) {
|
||||
usemsg($1);
|
||||
$urls{"%$1"} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
sub process_php($) {
|
||||
my ($source) = @_;
|
||||
my $content = file_content($source);
|
||||
$content =~ s/<\?xml version=\\"1\.0\\" encoding=\\"UTF-8\\"\?>//;
|
||||
|
||||
while( $content =~ s/<\?(?!xml)(.*?)\?>//s ) {
|
||||
my $inner = $1;
|
||||
while($inner =~ s/(getlocal|no_field)2?_?\((.*?)[,\)]//s) {
|
||||
my $firstarg = $2;
|
||||
if( $firstarg =~ /^["']([\w\.]+)['"]$/) {
|
||||
usemsg($1);
|
||||
} elsif($firstarg =~ /^\$\w+$/ || $firstarg eq '"$var.header"' || $firstarg eq '"permission.$permid"' || $firstarg eq '$threadstate_key[$thread[\'istate\']]') {
|
||||
# skip
|
||||
} else {
|
||||
print "> unknown: $firstarg\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub file_checksum($) {
|
||||
my ($source) = @_;
|
||||
if($source =~ /\.(png|gif|jpg|ico|wav)$/ || $source =~ /config\.php$/) {
|
||||
return "-";
|
||||
}
|
||||
|
||||
my $content = file_content($source);
|
||||
return md5_hex($content);
|
||||
}
|
||||
|
||||
@allsources = ();
|
||||
|
||||
sub process_one($) {
|
||||
my($source) = @_;
|
||||
push @allsources, $source unless $source =~ /$mibewPath\/locales/ && $source !~ /$mibewPath\/locales\/(en|names)/ || $source =~ /\/package$/;
|
||||
|
||||
if($source !~ /\.(php|tpl)$/) {
|
||||
return;
|
||||
}
|
||||
|
||||
$current_level = -1;
|
||||
|
||||
A: foreach $rule (@rules) {
|
||||
my $key = $$rule[0];
|
||||
if($source =~ /$key/) {
|
||||
$current_level = $$rule[1];
|
||||
last A;
|
||||
}
|
||||
}
|
||||
if($current_level < 0 || $current_level > 2) {
|
||||
print "not detected for: $source\n";
|
||||
$current_level = 0;
|
||||
}
|
||||
|
||||
if($source =~ /\.php$/) {
|
||||
# print "$source ($current_level)\n";
|
||||
process_php($source);
|
||||
} elsif($source =~ /\.tpl$/) {
|
||||
process_tpl($source);
|
||||
} else {
|
||||
#print ". $source\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub process_files($) {
|
||||
my($from) = @_;
|
||||
opendir(DIR, $from) || die "can't opendir $from: $!";
|
||||
my @content = readdir(DIR);
|
||||
closedir DIR;
|
||||
|
||||
for(grep { -f "$from/$_" && ($_ !~ /^\./ || $_ eq ".htaccess") } @content) {
|
||||
process_one("$from/$_");
|
||||
}
|
||||
for(grep { -d "$from/$_" && $_ !~ /^\./ } @content) {
|
||||
process_files("$from/$_");
|
||||
}
|
||||
}
|
||||
|
||||
process_files($mibewPath);
|
||||
|
||||
# fix
|
||||
$messagekeys{'page.analysis.userhistory.title'} = 1;
|
||||
$messagekeys{'errors.failed.uploading.file'} = 2;
|
||||
|
||||
|
||||
open( OUT, "> $mibewPath/locales/names/level1") or die "cannot write file, $!";
|
||||
for $key(sort grep { $messagekeys{$_} == 0 } keys %messagekeys) {
|
||||
print OUT "$key\n";
|
||||
}
|
||||
close( OUT );
|
||||
|
||||
open( OUT, "> $mibewPath/locales/names/level2") or die "cannot write file, $!";
|
||||
for $key(sort grep { $messagekeys{$_} == 1 } keys %messagekeys) {
|
||||
print OUT "$key\n";
|
||||
}
|
||||
close( OUT );
|
||||
|
||||
open( OUT, "> $mibewPath/install/package") or die "cannot write file, $!";
|
||||
for $key(sort @allsources) {
|
||||
$digest = file_checksum($key);
|
||||
$key =~ s/$mibewPath\///;
|
||||
print OUT "$key $digest\n";
|
||||
}
|
||||
close( OUT );
|
690
src/gulpfile.js
690
src/gulpfile.js
@ -1,124 +1,60 @@
|
||||
// Initialize requirements
|
||||
var fs = require('fs'),
|
||||
https = require('https'),
|
||||
exec = require('child_process').exec,
|
||||
eventStream = require('event-stream'),
|
||||
runSequence = require('gulp4-run-sequence'),
|
||||
through = require('through2'),
|
||||
lodash = require('lodash'),
|
||||
PoFile = require('pofile'),
|
||||
strftime = require('strftime'),
|
||||
del = require('del'),
|
||||
bower = require('bower'),
|
||||
runSequence = require('run-sequence'),
|
||||
gulp = require('gulp'),
|
||||
uglify = require('gulp-uglify'),
|
||||
concat = require('gulp-concat'),
|
||||
phpcs = require('gulp-phpcs'),
|
||||
order = require('gulp-order'),
|
||||
handlebars = require('gulp-handlebars'),
|
||||
handlebarsEngine = require('handlebars'),
|
||||
defineModule = require('gulp-define-module'),
|
||||
header = require('gulp-header'),
|
||||
zip = require('gulp-zip'),
|
||||
tar = require('gulp-tar'),
|
||||
gzip = require('gulp-gzip'),
|
||||
chmod = require('gulp-chmod'),
|
||||
xgettext = require('gulp-xgettext'),
|
||||
concatPo = require('gulp-concat-po'),
|
||||
rename = require('gulp-rename'),
|
||||
eslint = require('gulp-eslint'),
|
||||
removeDuplicateHeaders = require('mibew-gulp-greh'),
|
||||
mkdirp = require('mkdirp');
|
||||
chmod = require('gulp-chmod');
|
||||
|
||||
// Set global configuration
|
||||
// Set global configs.
|
||||
var config = {
|
||||
mibewPath: 'mibew',
|
||||
configsPath: 'mibew/configs',
|
||||
phpVendorPath: 'mibew/vendor',
|
||||
jsVendorPath: 'mibew/js/vendor',
|
||||
pluginsPath: 'mibew/plugins',
|
||||
avatarsPath: 'mibew/files/avatar',
|
||||
cachePath: 'mibew/cache',
|
||||
jsPath: 'mibew/js',
|
||||
chatStylesPath: 'mibew/styles/chats',
|
||||
chatStylesPath: 'mibew/styles/dialogs',
|
||||
pageStylesPath: 'mibew/styles/pages',
|
||||
i18nPath: 'i18n',
|
||||
i18nPrefix: 'mibew-i18n-',
|
||||
releasePath: 'release',
|
||||
uploadPath: 'upload',
|
||||
compiledTemplatesHeader: fs.readFileSync('tools/compiled_templates_header.txt'),
|
||||
getComposerUrl: 'https://getcomposer.org/installer',
|
||||
phpBin: 'php -d "suhosin.executor.include.whitelist = phar" -d "memory_limit=512M"',
|
||||
package: require('./composer.json'),
|
||||
msginit: 'msginit',
|
||||
msgcat: 'msgcat'
|
||||
phpBin: 'php -d "suhosin.executor.include.whitelist = phar"',
|
||||
package: require('./package.json')
|
||||
}
|
||||
config.i18nSuffix = '-' + config.package.version + '-' + strftime('%Y%m%d');
|
||||
|
||||
// Tasks for cleaning //////////////////
|
||||
|
||||
// Cleans all built files
|
||||
gulp.task('clean', function(callback) {
|
||||
return del([
|
||||
config.releasePath,
|
||||
'composer.lock',
|
||||
config.phpVendorPath,
|
||||
config.jsVendorPath,
|
||||
config.jsPath + '/compiled/**/*',
|
||||
'!' + config.jsPath + '/compiled/.keep',
|
||||
config.chatStylesPath + '/*/templates_compiled/client_side/*.js',
|
||||
config.chatStylesPath + '/*/js/compiled/*.js',
|
||||
config.pageStylesPath + '/*/templates_compiled/client_side/*.js'
|
||||
], callback);
|
||||
// Checks all PHP files with PHP Code Sniffer.
|
||||
gulp.task('phpcs', ['composer-install-dev'], function() {
|
||||
return gulp.src([
|
||||
config.mibewPath + '/**/*.php',
|
||||
'!' + config.phpVendorPath + '/**/*.*',
|
||||
'!' + config.pluginsPath + '/**/*.*'
|
||||
])
|
||||
.pipe(phpcs({
|
||||
bin: config.phpVendorPath + '/bin/phpcs',
|
||||
standard: 'PSR2',
|
||||
warningSeverity: 0
|
||||
}));
|
||||
});
|
||||
|
||||
// Cleans temporary English translation in the release dir
|
||||
gulp.task('clean-tmp-po', function(callback) {
|
||||
return del([config.releasePath + '/translation.po'], callback);
|
||||
});
|
||||
|
||||
// Cleans temporary files of translations in the release dir
|
||||
gulp.task('clean-tmp-i18n-files', function(callback) {
|
||||
return del([
|
||||
config.releasePath + '/**/*',
|
||||
'!' + config.releasePath + '/*.zip',
|
||||
'!' + config.releasePath + '/*.tar.gz',
|
||||
'!' + config.releasePath + '/*.pot'
|
||||
], callback);
|
||||
});
|
||||
|
||||
// Cleans all files prepared for uploading to CDN
|
||||
gulp.task('clean-upload', function(callback) {
|
||||
return del([config.uploadPath], callback);
|
||||
});
|
||||
|
||||
// Cleans everything
|
||||
gulp.task('clean-all', function(callback) {
|
||||
runSequence( ['clean', 'clean-upload'],
|
||||
callback );
|
||||
});
|
||||
|
||||
|
||||
// Watcher tasks ///////////////////////
|
||||
|
||||
// Watch styles
|
||||
gulp.task('watch', function() {
|
||||
gulp.watch(config.pageStylesPath + '/**/*.handlebars', gulp.series('page-styles'));
|
||||
gulp.watch(config.chatStylesPath + '/**/js/source/**/*.js', gulp.series('chat-styles-js'));
|
||||
gulp.watch(config.chatStylesPath + '/**/*.handlebars', gulp.series('chat-styles-handlebars'));
|
||||
});
|
||||
|
||||
// Service tasks //////////////////
|
||||
|
||||
// Get and install PHP Composer
|
||||
gulp.task('get-composer', function(callback) {
|
||||
// Check whether Composer is already in place
|
||||
// Check if Composer already in place
|
||||
if (fs.existsSync('./composer.phar')) {
|
||||
callback(null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Get installer from the Internet
|
||||
// Get installer from the internet
|
||||
https.get(config.getComposerUrl, function(response) {
|
||||
// Run PHP to install Composer
|
||||
var php = exec(config.phpBin, function(error, stdout, stderr) {
|
||||
@ -130,107 +66,20 @@ gulp.task('get-composer', function(callback) {
|
||||
});
|
||||
|
||||
// Install Composer dependencies excluding development ones
|
||||
gulp.task('composer-install', gulp.series('get-composer', function(callback) {
|
||||
exec(config.phpBin + ' composer.phar install --no-dev',
|
||||
function(error, stdout, stderr) {
|
||||
callback(error ? stderr : null);
|
||||
});
|
||||
}));
|
||||
gulp.task('composer-install', ['get-composer'], function(callback) {
|
||||
exec(config.phpBin + ' composer.phar install --no-dev', function(error, stdout, stderr) {
|
||||
callback(error ? stderr : null);
|
||||
});
|
||||
});
|
||||
|
||||
// Install all Composer dependencies
|
||||
gulp.task('composer-install-dev', gulp.series('get-composer', function(callback) {
|
||||
exec(config.phpBin + ' composer.phar install',
|
||||
function(error, stdout, stderr) {
|
||||
callback(error ? stderr : null);
|
||||
});
|
||||
}));
|
||||
|
||||
// Installs bower dependencies
|
||||
gulp.task('bower-install', function(callback) {
|
||||
bower.commands.install([], {}, {})
|
||||
.on('error', function(error) {
|
||||
callback(error);
|
||||
})
|
||||
.on('end', function() {
|
||||
// We should manually minify JavaScript files that was not minified
|
||||
// by bower packages' authors
|
||||
// TODO: This is a temproary workaround and should be removed once
|
||||
// the packages will be fixed
|
||||
var stream = eventStream.merge(
|
||||
gulp.src(config.jsVendorPath + '/backbone/backbone.js',
|
||||
{base: config.jsVendorPath})
|
||||
.pipe(uglify({preserveComments: 'some'}))
|
||||
// There are neither "@license" tag nor "!preserve" in the
|
||||
// header. Add the header manually
|
||||
.pipe(header(
|
||||
"// Backbone.js 1.1.2\n"
|
||||
+ "// (c) 2010-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n"
|
||||
+ "// Backbone may be freely distributed under the MIT license.\n"
|
||||
+ "// For all details and documentation:\n"
|
||||
+ "// http://backbonejs.org\n"
|
||||
))
|
||||
.pipe(rename('backbone/backbone-min.js')),
|
||||
gulp.src(config.jsVendorPath + '/json/json2.js',
|
||||
{base: config.jsVendorPath})
|
||||
.pipe(uglify({preserveComments: 'some'}))
|
||||
// There are neither "@license" tag nor "!preserve" in the
|
||||
// header, add the header manually
|
||||
.pipe(header("// json2.js. Public Domain. See http://www.JSON.org/js.html\n"))
|
||||
.pipe(rename('json/json2.min.js'))
|
||||
)
|
||||
.pipe(gulp.dest(config.jsVendorPath));
|
||||
|
||||
stream
|
||||
.on('error', callback)
|
||||
.on('end', callback);
|
||||
});
|
||||
gulp.task('composer-install-dev', ['get-composer'], function(callback) {
|
||||
exec(config.phpBin + ' composer.phar install', function(error, stdout, stderr) {
|
||||
callback(error ? stderr : null);
|
||||
});
|
||||
});
|
||||
|
||||
// Tasks for checking //////////////////
|
||||
|
||||
// Checks all PHP files with PHP Code Sniffer
|
||||
gulp.task('phpcs', gulp.series('composer-install-dev', function() {
|
||||
return gulp.src([
|
||||
config.mibewPath + '/**/*.php',
|
||||
'!' + config.phpVendorPath + '/**/*.*',
|
||||
'!' + config.pluginsPath + '/**/*.*',
|
||||
'!' + config.cachePath + '/**/*.*'
|
||||
], {
|
||||
// Content of the cache directory is readable only for webserver.
|
||||
// Thus we must to set "strict" option to false to prevent "EACCES"
|
||||
// errors. At the same we need to see all errors that take place.
|
||||
strict: false,
|
||||
silent: false
|
||||
})
|
||||
.pipe(phpcs({
|
||||
bin: config.phpVendorPath + '/bin/phpcs',
|
||||
standard: 'PSR2',
|
||||
warningSeverity: 0
|
||||
}))
|
||||
.pipe(phpcs.reporter('log'))
|
||||
.pipe(phpcs.reporter('fail'));
|
||||
}));
|
||||
|
||||
// Checks all JavaScript Source files with ESLint
|
||||
gulp.task('eslint', function() {
|
||||
return gulp.src(config.jsPath + '/source/**/*.js')
|
||||
.pipe(eslint())
|
||||
.pipe(eslint.format())
|
||||
.pipe(eslint.failAfterError());
|
||||
});
|
||||
|
||||
|
||||
// Restore empty English translation in the source code
|
||||
gulp.task('post-pack-cleanup', function(callback) {
|
||||
gulp.src('translation.po')
|
||||
.pipe(gulp.dest(config.mibewPath + '/locales/en/'));
|
||||
|
||||
del(['translation.po', config.releasePath + '/translation.po'], callback);
|
||||
});
|
||||
|
||||
// Tasks of compiling //////////////////
|
||||
|
||||
// Compile all JavaScript files of the Mibew Messenger Core
|
||||
// Compile all JavaScript files of the Mibew Core
|
||||
gulp.task('js', function() {
|
||||
return eventStream.merge(
|
||||
getClientSideApp('default'),
|
||||
@ -240,376 +89,91 @@ gulp.task('js', function() {
|
||||
gulp.src(config.jsPath + '/source/**/*.js')
|
||||
)
|
||||
.pipe(uglify({preserveComments: 'some'}))
|
||||
.pipe(removeDuplicateHeaders())
|
||||
.pipe(gulp.dest(config.jsPath + '/compiled'));
|
||||
});
|
||||
|
||||
// Compile and concatenate Handlebars templates for all chat styles
|
||||
// Performs all job related with chat styles.
|
||||
gulp.task('chat-styles', ['chat-styles-handlebars', 'chat-styles-js'], function() {
|
||||
// This task is just a combination of other tasks. That is why there is no
|
||||
// real code.
|
||||
});
|
||||
|
||||
// Compile and concatenate handlebars files for all chat styles.
|
||||
gulp.task('chat-styles-handlebars', function() {
|
||||
return getChildDirs(config.chatStylesPath)
|
||||
.then(function (dirs) {
|
||||
return Promise.all(dirs.map(function (dir) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
gulp.src(config.chatStylesPath + '/' + dir
|
||||
+ '/templates_src/client_side/**/*.handlebars')
|
||||
.pipe(handlebars({
|
||||
// Use specific version of Handlebars.js
|
||||
handlebars: handlebarsEngine
|
||||
}))
|
||||
.pipe(wrapHandlebarsTemplate())
|
||||
.pipe(concat('templates.js'))
|
||||
.pipe(uglify({preserveComments: 'some'}))
|
||||
.pipe(header(config.compiledTemplatesHeader))
|
||||
.pipe(gulp.dest(config.chatStylesPath + '/' + dir
|
||||
+ '/templates_compiled/client_side'))
|
||||
.on('end', resolve)
|
||||
.on('error', reject);
|
||||
});
|
||||
}));
|
||||
});
|
||||
// TODO: Process all available styles, not only the default one.
|
||||
var stylePath = config.chatStylesPath + '/default';
|
||||
|
||||
return gulp.src(stylePath + '/templates_src/client_side/**/*.handlebars')
|
||||
.pipe(handlebars())
|
||||
.pipe(wrapHandlebarsTemplate())
|
||||
.pipe(concat('templates.js'))
|
||||
.pipe(uglify({preserveComments: 'some'}))
|
||||
.pipe(header(config.compiledTemplatesHeader))
|
||||
.pipe(gulp.dest(stylePath + '/templates_compiled/client_side'));
|
||||
});
|
||||
|
||||
// Compile and concatenate js files for all chat styles
|
||||
// Compile and concatenate js files for all chat styles.
|
||||
gulp.task('chat-styles-js', function() {
|
||||
return getChildDirs(config.chatStylesPath)
|
||||
.then(function (dirs) {
|
||||
return Promise.all(dirs.map(function (dir) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
gulp.src(config.chatStylesPath + '/' + dir
|
||||
+ '/js/source/**/*.js')
|
||||
.pipe(concat('scripts.js'))
|
||||
.pipe(uglify({preserveComments: 'some'}))
|
||||
.pipe(gulp.dest(config.chatStylesPath + '/' + dir
|
||||
+ '/js/compiled'))
|
||||
.on('end', resolve)
|
||||
.on('error', reject);
|
||||
});
|
||||
}));
|
||||
});
|
||||
// TODO: Process all available styles, not only the default one.
|
||||
var stylePath = config.chatStylesPath + '/default';
|
||||
|
||||
return gulp.src(stylePath + '/js/source/**/*.js')
|
||||
.pipe(concat('scripts.js'))
|
||||
.pipe(uglify({preserveComments: 'some'}))
|
||||
.pipe(gulp.dest(stylePath + '/js/compiled'));
|
||||
});
|
||||
|
||||
// Performs all job related to pages styles
|
||||
// Performs all job related with pages styles.
|
||||
gulp.task('page-styles', function() {
|
||||
return getChildDirs(config.pageStylesPath)
|
||||
.then(function (dirs) {
|
||||
return Promise.all(dirs.map(function (dir) {
|
||||
return new Promise(function(resolve, reject){
|
||||
gulp.src(config.pageStylesPath + '/' + dir
|
||||
+ '/templates_src/client_side/**/*.handlebars')
|
||||
.pipe(handlebars({
|
||||
// Use specific version of Handlebars.js
|
||||
handlebars: handlebarsEngine
|
||||
}))
|
||||
.pipe(wrapHandlebarsTemplate())
|
||||
.pipe(concat('templates.js'))
|
||||
.pipe(uglify({preserveComments: 'some'}))
|
||||
.pipe(header(config.compiledTemplatesHeader))
|
||||
.pipe(gulp.dest(config.pageStylesPath + '/' + dir
|
||||
+ '/templates_compiled/client_side'))
|
||||
.on('end', resolve)
|
||||
.on('error', reject);
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
// Performs all job related to chat styles
|
||||
gulp.task('chat-styles', gulp.series('chat-styles-handlebars', 'chat-styles-js'));
|
||||
|
||||
// Prepares ready to use development version of Mibew Messenger without
|
||||
// packing or validating it
|
||||
gulp.task('rebuild', function(callback) {
|
||||
runSequence(
|
||||
'clean',
|
||||
['js', 'chat-styles', 'page-styles', 'composer-install',
|
||||
'bower-install'],
|
||||
callback
|
||||
);
|
||||
});
|
||||
|
||||
// Tasks for localization issues ///////
|
||||
|
||||
// Generate POT-file based upon the source code
|
||||
gulp.task('generate-pot', function() {
|
||||
return eventStream.merge(
|
||||
gulp.src([
|
||||
config.mibewPath + '/**/*.php',
|
||||
'!' + config.phpVendorPath + '/**/*.*',
|
||||
'!' + config.pluginsPath + '/**/*.*',
|
||||
'!' + config.cachePath + '/**/*.*'
|
||||
], {
|
||||
// Content of the cache directory is readable only for
|
||||
// webserver. Thus we must to set "strict" option to false
|
||||
// to prevent "EACCES" errors. At the same we need to see all
|
||||
// errors that take place.
|
||||
strict: false,
|
||||
silent: false
|
||||
})
|
||||
.pipe(xgettext({
|
||||
language: 'PHP',
|
||||
keywords: [
|
||||
{name: 'getlocal'},
|
||||
{name: 'no_field'},
|
||||
{name: 'wrong_field'},
|
||||
{name: 'failed_uploading_file', singular: 2}
|
||||
]
|
||||
})),
|
||||
gulp.src(config.jsPath + '/source/**/*.js', {base: config.mibewPath})
|
||||
.pipe(xgettext({
|
||||
language: 'JavaScript',
|
||||
keywords: [
|
||||
{name: 'trans'}
|
||||
]
|
||||
})),
|
||||
gulp.src([
|
||||
config.chatStylesPath + '/default/templates_src/**/*.handlebars',
|
||||
config.pageStylesPath + '/default/templates_src/**/*.handlebars'
|
||||
], {base: config.mibewPath})
|
||||
.pipe(xgettextHandlebars())
|
||||
)
|
||||
.pipe(concatPo(config.i18nPrefix + 'translation'
|
||||
+ config.i18nSuffix + '.pot',
|
||||
{
|
||||
headers: {
|
||||
'Project-Id-Version': 'Mibew Messenger '
|
||||
+ config.package.version,
|
||||
'Report-Msgid-Bugs-To': config.package.support.email,
|
||||
'POT-Creation-Date': strftime('%Y-%m-%d %H:%M%z'),
|
||||
'PO-Revision-Date': '',
|
||||
'Last-Translator': '',
|
||||
'Language-Team': '',
|
||||
'Content-Type': 'text/plain; charset=UTF-8'
|
||||
}
|
||||
})
|
||||
)
|
||||
.pipe(gulp.dest(config.releasePath));
|
||||
});
|
||||
|
||||
// Generate temporary English translation to be used in the release
|
||||
gulp.task('generate-tmp-po', gulp.series('generate-pot', function(callback) {
|
||||
return exec(config.msginit + ' --no-translator --no-wrap -i '
|
||||
+ config.releasePath + '/' + config.i18nPrefix + 'translation'
|
||||
+ config.i18nSuffix + '.pot' + ' -l en -o '
|
||||
+ config.releasePath + '/translation.po',
|
||||
function(error, stdout, stderr) {
|
||||
callback(error ? stderr : null);
|
||||
});
|
||||
}));
|
||||
|
||||
// Generate complete translations (that includes missed strings) to be used
|
||||
// in the release
|
||||
gulp.task('generate-pos', gulp.series('generate-tmp-po', function(callback) {
|
||||
|
||||
return getChildDirs(config.i18nPath + '/translations')
|
||||
.then(function (dirs) {
|
||||
return Promise.all(dirs.map(function (dir) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
mkdirp(config.releasePath + '/' + dir, function (error) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
exec(config.msgcat + ' ' + config.i18nPath + '/translations/'
|
||||
+ dir + '/translation.po ' + config.releasePath
|
||||
+ '/translation.po --no-location --no-wrap --use-first'
|
||||
+ ' -o ' + config.releasePath + '/' + dir
|
||||
+ '/translation.po',
|
||||
function(error, stdout, stderr) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
|
||||
var sources = [
|
||||
config.i18nPath + '/translations/' + dir + '/**/*',
|
||||
'!' + config.i18nPath + '/translations/' + dir
|
||||
+ '/translation.po'
|
||||
];
|
||||
|
||||
gulp.src(sources)
|
||||
.pipe(gulp.dest(config.releasePath + '/' + dir))
|
||||
.on('error', reject)
|
||||
.on('end', resolve);
|
||||
});
|
||||
}));
|
||||
});
|
||||
}));
|
||||
|
||||
// Packaging tasks /////////////////////
|
||||
|
||||
// Pack sources for release as .zip and .tar.gz archives
|
||||
gulp.task('pack-sources', gulp.series('composer-install', 'bower-install', function() {
|
||||
gulp.src(config.mibewPath + '/locales/en/translation.po')
|
||||
.pipe(gulp.dest('.'));
|
||||
gulp.src(config.releasePath + '/translation.po')
|
||||
.pipe(gulp.dest(config.mibewPath + '/locales/en/'));
|
||||
|
||||
var sources = [
|
||||
config.mibewPath + '/**/*',
|
||||
// Exclude user's config
|
||||
'!' + config.configsPath + '/config.yml',
|
||||
// Exclude cache files but not the ".keep" file.
|
||||
'!' + config.cachePath + '/**/!(.keep)',
|
||||
// Exclude avatars but not the ".keep" file.
|
||||
'!' + config.avatarsPath + '/!(.keep)',
|
||||
// Exclude plugins but not the ".keep" file.
|
||||
'!' + config.pluginsPath + '/!(.keep)',
|
||||
'!' + config.pluginsPath + '/*/**/*',
|
||||
// Exclude Git repositories that can be shipped with third-party libs
|
||||
'!' + config.phpVendorPath + '/**/.git',
|
||||
'!' + config.phpVendorPath + '/**/.git/**/*',
|
||||
// Exclude vendors binaries
|
||||
'!' + config.phpVendorPath + '/bin/**/*',
|
||||
// Exclude JavaScript sources
|
||||
'!' + config.jsPath + '/source/**/*',
|
||||
// Actually we does not need backbone.babysitter and backbone.wreqr
|
||||
// dependencies because they embed into marionette.js. So we exclude
|
||||
// "backbone.babysitter" and "backbone.wreqr" directories and all their
|
||||
// contents.
|
||||
'!' + config.jsVendorPath + '/backbone.babysitter{,/**}',
|
||||
'!' + config.jsVendorPath + '/backbone.wreqr{,/**}',
|
||||
// Exclude dot files within third-party JS libraries.
|
||||
'!' + config.jsVendorPath + '/**/.*',
|
||||
// Exclude config files of various package systems
|
||||
'!' + config.jsVendorPath + '/**/{bower,component,package,composer}.json',
|
||||
// Exclude config files of various build systems
|
||||
'!' + config.jsVendorPath + '/**/Gruntfile.*',
|
||||
'!' + config.jsVendorPath + '/**/gulpfile.*',
|
||||
'!' + config.jsVendorPath + '/**/Makefile',
|
||||
// Exclude HTML files from third-party JS libraries. Such files can be
|
||||
// used for docs or for tests, we need none of them.
|
||||
'!' + config.jsVendorPath + '/**/*.html',
|
||||
// There are too many useless files in Vex.js library. Exclude them.
|
||||
'!' + config.jsVendorPath + '/vex/sass{,/**}',
|
||||
'!' + config.jsVendorPath + '/vex/docs{,/**}',
|
||||
'!' + config.jsVendorPath + '/vex/docs{,/**}',
|
||||
'!' + config.jsVendorPath + '/vex/coffee{,/**}'
|
||||
];
|
||||
var srcOptions = {
|
||||
// Dot files (.htaccess, .keep, etc.) must be included in the package
|
||||
dot: true,
|
||||
// Content of the cache directory is readable only for webserver. Thus
|
||||
// we must to set "strict" option to false to prevent "EACCES" errors.
|
||||
// At the same we need to see all errors that take place.
|
||||
strict: false,
|
||||
silent: false,
|
||||
// Preserve root directory name (i.e. 'mibew/')
|
||||
base: '.'
|
||||
}
|
||||
var version = config.package.version;
|
||||
// TODO: Process all available styles, not only the default one.
|
||||
var stylePath = config.pageStylesPath + '/default';
|
||||
|
||||
return eventStream.merge(
|
||||
gulp.src(sources, srcOptions)
|
||||
gulp.src(stylePath + '/templates_src/client_side/default/**/*.handlebars')
|
||||
.pipe(handlebars())
|
||||
.pipe(wrapHandlebarsTemplate())
|
||||
.pipe(concat('default_app.tpl.js')),
|
||||
gulp.src(stylePath + '/templates_src/client_side/users/**/*.handlebars')
|
||||
.pipe(handlebars())
|
||||
.pipe(wrapHandlebarsTemplate())
|
||||
.pipe(concat('users_app.tpl.js'))
|
||||
)
|
||||
.pipe(uglify({preserveComments: 'some'}))
|
||||
.pipe(header(config.compiledTemplatesHeader))
|
||||
.pipe(gulp.dest(stylePath + '/templates_compiled/client_side'));
|
||||
});
|
||||
|
||||
// Pack sources to .zip and .tar.gz archives.
|
||||
gulp.task('pack-sources', ['composer-install'], function() {
|
||||
var sources = config.mibewPath + '/**/*',
|
||||
version = config.package.version;
|
||||
|
||||
return eventStream.merge(
|
||||
gulp.src(sources, {dot: true})
|
||||
.pipe(zip('mibew-' + version + '.zip')),
|
||||
gulp.src(sources, srcOptions)
|
||||
gulp.src(sources, {dot: true})
|
||||
.pipe(tar('mibew-' + version + '.tar'))
|
||||
.pipe(gzip())
|
||||
)
|
||||
.pipe(chmod(644))
|
||||
.pipe(gulp.dest(config.releasePath));
|
||||
}));
|
||||
|
||||
// Pack translations for release as .zip and .tar.gz archives
|
||||
gulp.task('pack-i18n', function(callback) {
|
||||
return getChildDirs(config.i18nPath + '/translations')
|
||||
.then(function (dirs) {
|
||||
return Promise.all(dirs.map(function (dir) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
|
||||
var srcOptions = {
|
||||
base: config.releasePath
|
||||
};
|
||||
|
||||
eventStream.merge(
|
||||
gulp.src(config.releasePath + '/' + dir
|
||||
+ '/**/*', srcOptions)
|
||||
.pipe(zip(config.i18nPrefix + dir
|
||||
+ config.i18nSuffix + '.zip')),
|
||||
gulp.src(config.releasePath + '/' + dir
|
||||
+ '/**/*', srcOptions)
|
||||
.pipe(tar(config.i18nPrefix + dir
|
||||
+ config.i18nSuffix + '.tar'))
|
||||
.pipe(gzip())
|
||||
)
|
||||
.pipe(chmod(644))
|
||||
.pipe(gulp.dest(config.releasePath))
|
||||
.on('error', reject)
|
||||
.on('end', resolve);
|
||||
|
||||
});
|
||||
}));
|
||||
});
|
||||
.pipe(chmod(0644))
|
||||
.pipe(gulp.dest('release'));
|
||||
});
|
||||
|
||||
// Tasks of releasing //////////////////
|
||||
|
||||
// Prepare release of Mibew Messenger
|
||||
gulp.task('prepare-release', function(callback) {
|
||||
runSequence(
|
||||
'clean',
|
||||
['phpcs', 'js', 'chat-styles', 'page-styles', 'generate-pot',
|
||||
'generate-tmp-po'],
|
||||
'pack-sources',
|
||||
'post-pack-cleanup',
|
||||
callback
|
||||
);
|
||||
});
|
||||
|
||||
// Prepare releases of translations for Mibew Messenger
|
||||
gulp.task('prepare-i18n-release', function(callback) {
|
||||
runSequence( 'clean-tmp-po',
|
||||
'generate-pos',
|
||||
'pack-i18n',
|
||||
'clean-tmp-i18n-files',
|
||||
callback
|
||||
);
|
||||
});
|
||||
|
||||
// Mirror prepared releases of Mibew Messenger and its translations in a form
|
||||
// intended for uploading into the CDN
|
||||
gulp.task('prepare-for-upload', function(callback) {
|
||||
gulp.src(config.releasePath + '/mibew-' + config.package.version + '.*')
|
||||
.pipe(gulp.dest(config.uploadPath + '/core/' + config.package.version + '/'));
|
||||
|
||||
gulp.src(config.releasePath + '/mibew-i18n-translation-' + config.package.version + '-*.pot')
|
||||
.pipe(gulp.dest(config.uploadPath + '/i18n/_pot/' + config.package.version + '/'));
|
||||
|
||||
return getChildDirs(config.i18nPath + '/translations')
|
||||
.then(function (dirs) {
|
||||
return Promise.all(dirs.map(function (dir) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
gulp.src(config.releasePath + '/mibew-i18n-' + dir + '-' + config.package.version + '-*.*')
|
||||
.pipe(gulp.dest(config.uploadPath + '/i18n/' + dir + '/' + config.package.version + '/'))
|
||||
.on('error', reject)
|
||||
.on('end', resolve);
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
// Perform all preparations before uploading the release of Mibew Messenger and
|
||||
// its translations into the CDN
|
||||
gulp.task('prepare-all', function(callback) {
|
||||
runSequence('clean-all', 'prepare-release', 'prepare-i18n-release',
|
||||
'prepare-for-upload', callback);
|
||||
});
|
||||
|
||||
// Prepare release archives of the development version of Mibew Messenger
|
||||
// Builds all the sources
|
||||
gulp.task('default', function(callback) {
|
||||
runSequence(
|
||||
'clean',
|
||||
['js', 'chat-styles', 'page-styles', 'generate-tmp-po'],
|
||||
['phpcs', 'js', 'chat-styles', 'page-styles'],
|
||||
'pack-sources',
|
||||
['post-pack-cleanup', 'clean-tmp-po'],
|
||||
callback
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Loads and prepare js file for a client side application with the specified
|
||||
* name.
|
||||
*
|
||||
* @param {String} name Application name.
|
||||
* @param {String} name Application name
|
||||
* @returns A files stream that can be piped to any gulp plugin.
|
||||
*/
|
||||
var getClientSideApp = function(name) {
|
||||
@ -659,85 +223,7 @@ var wrapHandlebarsTemplate = function() {
|
||||
+ 'Handlebars.templates["<%= relative %>"] = <%= handlebars %>;\n'
|
||||
+ '})()',
|
||||
context: function(context) {
|
||||
return {relative: context.file.relative.replace(/\.js$/, '').replace(/\\/g, '/')};
|
||||
return {relative: context.file.relative.replace(/\.js$/, '')};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts gettext messages from handlebars templates.
|
||||
*
|
||||
* @returns {Function} A function that can be used in pipe() method of a file
|
||||
* stream.
|
||||
*/
|
||||
var xgettextHandlebars = function() {
|
||||
var helperRegExp = /\{{2}l10n\s*('|")(.*?[^\\])\1.*?\}{2}/g;
|
||||
|
||||
return through.obj(function (file, enc, callback) {
|
||||
var po = new PoFile();
|
||||
match = false,
|
||||
contents = file.contents.toString();
|
||||
|
||||
while (match = helperRegExp.exec(contents)) {
|
||||
// Try to find item in the .po file by its name
|
||||
var item = lodash.find(po.items, function(item) {
|
||||
return match[2] === item.msgid;
|
||||
});
|
||||
|
||||
var line = contents.substr(0, match.index).split(/\r?\n|\r/g).length;
|
||||
|
||||
if (!item) {
|
||||
// There is no such item, create new one
|
||||
item = new PoFile.Item();
|
||||
item.msgid = match[2].replace(/\\'/g, "'").replace(/\\"/g, '"');
|
||||
po.items.push(item);
|
||||
}
|
||||
|
||||
// Add new reference
|
||||
item.references.push(file.relative + ':' + line);
|
||||
}
|
||||
|
||||
// Update file contents
|
||||
file.contents = Buffer.from(po.toString());
|
||||
this.push(file);
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves list of all dirs which are placed in the specified one.
|
||||
*
|
||||
* @param {String} srcDir A dir to search.
|
||||
* @returns Promise A promise which will be resolved with list of child dirs or
|
||||
* rejected with the occured error.
|
||||
*/
|
||||
var getChildDirs = function(srcDir) {
|
||||
return (new Promise(function(resolve, reject) {
|
||||
fs.readdir(srcDir, function (err, files) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(files);
|
||||
}
|
||||
});
|
||||
})).then(function (files) {
|
||||
// Replace all files that are not a directory with nulls.
|
||||
return Promise.all(files.map(function (file) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
fs.lstat(srcDir + '/' + file, function (err, stat) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(stat.isDirectory() ? file : null);
|
||||
}
|
||||
});
|
||||
});
|
||||
}));
|
||||
}).then(function(dirs) {
|
||||
// Remove all nulls from the array.
|
||||
return dirs.filter(function (dir) {
|
||||
return null !== dir;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
1
src/i18n
1
src/i18n
@ -1 +0,0 @@
|
||||
Subproject commit 55868d9973f531c3550575481bde4233cc625b91
|
@ -1,14 +1,12 @@
|
||||
# Set default handler for incoming requests
|
||||
DirectoryIndex index.php
|
||||
|
||||
# Disable directory listing
|
||||
Options -Indexes
|
||||
|
||||
# Follow symbolic links in the directory
|
||||
Options +FollowSymLinks
|
||||
|
||||
<IfModule mod_negotiation.c>
|
||||
# Forbid apache to guess file extensions
|
||||
Options -MultiViews
|
||||
</IfModule>
|
||||
|
||||
# Disable mod_security for Apache 1.x
|
||||
<IfModule mod_security.c>
|
||||
SecFilterEngine Off
|
||||
@ -28,15 +26,12 @@ Options +FollowSymLinks
|
||||
|
||||
# Redirect requests to the front controller
|
||||
<IfModule mod_rewrite.c>
|
||||
# Use the front controller as a default handler
|
||||
DirectoryIndex index.php
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# Use separate front controller for the system installator
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^install(/(.*))?$ install.php [QSA,L]
|
||||
RewriteRule ^install(|/(.*))$ install.php [QSA,L]
|
||||
|
||||
# Rewrite all other requests for files and directories that do not exist to
|
||||
# the main front controller
|
||||
@ -45,20 +40,7 @@ Options +FollowSymLinks
|
||||
RewriteRule ^(.*)$ index.php [QSA,L]
|
||||
</IfModule>
|
||||
|
||||
<IfModule !mod_rewrite.c>
|
||||
# There is no mod_rewrite in the system. For the root Mibew Messenger
|
||||
# directory index_fallback.php should be loaded first to activate
|
||||
# old-fashioned URLs. For all other directories index.php is just a
|
||||
# directory index file.
|
||||
DirectoryIndex index_fallback.php index.php
|
||||
</IfModule>
|
||||
|
||||
# Deny access to internal system files
|
||||
<FilesMatch "\.(yml|po|ini|handlebars|keep)$">
|
||||
Deny from all
|
||||
</FilesMatch>
|
||||
|
||||
# Deny access to CLI cron worker from the outside
|
||||
<Files "cron.php">
|
||||
Deny from all
|
||||
</Files>
|
||||
|
@ -1,19 +1,17 @@
|
||||
Mibew Messenger
|
||||
Copyright 2005-2023 the original author or authors.
|
||||
Copyright 2005-2014 the original author or authors.
|
||||
|
||||
REQUIREMENTS
|
||||
|
||||
* Apache web server 1.3.34 or above with the ability to use local .htaccess
|
||||
files (mod_rewrite module is optional, but recommended)
|
||||
* Apache web server 1.3.34 or above
|
||||
* MySQL database 5.0 or above
|
||||
* PHP 7.2.5 or above with PDO, pdo_mysql, cURL, mbstring and gd extensions
|
||||
* PHP 5.3.3 or above with MySQL support
|
||||
|
||||
INSTALLATION
|
||||
|
||||
1. Create folder with name 'mibew' in the root of your website.
|
||||
2. Upload all the files contained in this archive (retaining the directory
|
||||
structure) into created folder.
|
||||
Be sure to chmod the mibew folder to 0755.
|
||||
2. Upload all the files contained in this archive (retaining the directory structure) into created folder.
|
||||
Be sure to chmod the mibew folder to 755.
|
||||
3. Add a MySQL database with the name 'mibew'
|
||||
4. Copy /mibew/configs/default_config.yml to /mibew/configs/config.yml
|
||||
5. Edit /mibew/configs/config.yml to the information needed to connect to the database
|
||||
@ -24,33 +22,10 @@ INSTALLATION
|
||||
user: admin
|
||||
password: <your password>
|
||||
9. Get button code and setup it on your site.
|
||||
10. Configure periodically running tasks by setting up an automated
|
||||
process to visit the page http://<yourdomain>/cron?cron_key=<key>
|
||||
|
||||
The full URL including the secret "cron key" used to protect against
|
||||
unauthorized access can be seen on the 'General' tab at the 'Settings' page.
|
||||
11. Change your name.
|
||||
12. Wait for your visitors on 'Pending users' page.
|
||||
|
||||
On unix/linux platforms change the owner of /mibew/files/avatar and
|
||||
/mibew/cache folders to the user, under which the web server is running
|
||||
(for instance, www). The owner should have all rights on the folders
|
||||
/mibew/files/avatar and /mibew/cache
|
||||
(chmod 0700 /mibew/files/avatar && chmod 0700 /mibew/cache).
|
||||
|
||||
UPDATE
|
||||
|
||||
1. Backup your actual installation (i.e. code and database).
|
||||
2. Disable all plugins.
|
||||
3. Delete all items in your Mibew Messenger directory on the server.
|
||||
4. Unpack the archive with the official distrubition in that directory.
|
||||
5. Remove install.php file.
|
||||
6. Restore configuration (configs/ directory), plugins (plugins/ directory),
|
||||
(maybe) custom styles (if you have any), (maybe) additional
|
||||
locales (if you use any), and avatars (files/avatar/ directory) from the
|
||||
backup you've made at the step 1.
|
||||
7. Visit http://<yourdomain>/<path to your Mibew Messenger>/update and follow
|
||||
the instructions to update the database tables (if needed).
|
||||
8. Enable disabled plugins.
|
||||
|
||||
10. Change your name.
|
||||
11. Wait for your visitors on 'Pending users' page.
|
||||
|
||||
On unix/linux platforms change the owner of /mibew/files/avatar folder
|
||||
to the user, under which the web server is running (for instance, www).
|
||||
The owner should have all rights on the folder /mibew/files/avatar
|
||||
(chmod 700 /mibew/files/avatar).
|
||||
|
@ -1 +1 @@
|
||||
Mibew/3.6.0
|
||||
Mibew/2.0
|
@ -72,7 +72,7 @@ thread:
|
||||
useragent: "varchar(255)"
|
||||
# Total count of user's messages related with the thread.
|
||||
messagecount: "varchar(16)"
|
||||
# ID of the group at Mibew Messenger side related with the thread.
|
||||
# ID of the group at Mibew side related with the thread.
|
||||
groupid: "int references {opgroup}(groupid)"
|
||||
|
||||
# Contains "by thread" statistics
|
||||
@ -104,7 +104,7 @@ requestcallback:
|
||||
fields:
|
||||
callbackid: "int NOT NULL auto_increment PRIMARY KEY"
|
||||
token: "varchar(64) NOT NULL DEFAULT ''"
|
||||
func: "varchar(64) NOT NULL"
|
||||
function: "varchar(64) NOT NULL"
|
||||
arguments: "varchar(1024)"
|
||||
indexes:
|
||||
token: [token]
|
||||
@ -129,23 +129,12 @@ translation:
|
||||
# Contains locales info
|
||||
locale:
|
||||
fields:
|
||||
# Artificial primary key.
|
||||
# Artificial primary key
|
||||
localeid: "int NOT NULL auto_increment PRIMARY KEY"
|
||||
# Locale code
|
||||
code: "varchar(5) NOT NULL"
|
||||
# Human readable name of the locale.
|
||||
name: "varchar(128) NOT NULL DEFAULT ''"
|
||||
# Indicates if the locale is enabled or not.
|
||||
# Indicates if a locale is enabled or not.
|
||||
enabled: "tinyint NOT NULL DEFAULT 0"
|
||||
# Indicates if the locale uses RTL writing.
|
||||
rtl: "tinyint NOT NULL DEFAULT 0"
|
||||
# Name of the locale which is used with PHP's setlocale to format dates.
|
||||
time_locale: "varchar(128) NOT NULL DEFAULT 'en_US'"
|
||||
# Serialized array of various date formats.
|
||||
date_format: "text"
|
||||
unique_keys:
|
||||
# Make sure locale code can be duplicated
|
||||
code: [code]
|
||||
|
||||
# Contains localized mail templates
|
||||
mailtemplate:
|
||||
@ -201,6 +190,7 @@ operator:
|
||||
istatus: "int DEFAULT 0"
|
||||
idisabled: "int DEFAULT 0"
|
||||
vcavatar: "varchar(255)"
|
||||
vcjabbername: "varchar(255)"
|
||||
# Operators privileges bitmask.
|
||||
iperm: "int DEFAULT 0"
|
||||
dtmrestore: "int NOT NULL DEFAULT 0"
|
||||
@ -226,7 +216,7 @@ operatorstatistics:
|
||||
|
||||
revision:
|
||||
fields:
|
||||
id: "INT NOT NULL PRIMARY KEY"
|
||||
id: "INT NOT NULL"
|
||||
|
||||
# Contains relations between operators and groups
|
||||
operatortoopgroup:
|
||||
@ -245,6 +235,7 @@ ban:
|
||||
dtmtill: "int NOT NULL DEFAULT 0"
|
||||
address: "varchar(255)"
|
||||
comment: "varchar(255)"
|
||||
blockedcount: "int DEFAULT 0"
|
||||
|
||||
# Contains dynamic configs
|
||||
config:
|
||||
@ -300,37 +291,3 @@ visitedpagestatistics:
|
||||
acceptedinvitations: "int NOT NULL DEFAULT 0"
|
||||
rejectedinvitations: "int NOT NULL DEFAULT 0"
|
||||
ignoredinvitations: "int NOT NULL DEFAULT 0"
|
||||
|
||||
# Contains info about installed plugins
|
||||
plugin:
|
||||
fields:
|
||||
# Artificial ID
|
||||
id: "INT NOT NULL auto_increment PRIMARY KEY"
|
||||
# Plugin name in "<Vendor>:<Name>" format.
|
||||
name: "varchar(255) NOT NULL"
|
||||
# Installed version of the plugin.
|
||||
version: "varchar(255) NOT NULL"
|
||||
# Indicates if the plugin is installed or not.
|
||||
installed: "tinyint NOT NULL DEFAULT 0"
|
||||
# Indicates if the plugin is enabled or not.
|
||||
enabled: "tinyint NOT NULL DEFAULT 0"
|
||||
# Indicates if the plugin is initialized or not.
|
||||
initialized: "tinyint NOT NULL DEFAULT 0"
|
||||
unique_keys:
|
||||
name: [name]
|
||||
|
||||
# Contains info about all available updates
|
||||
availableupdate:
|
||||
fields:
|
||||
# Artificial ID
|
||||
id: "INT NOT NULL auto_increment PRIMARY KEY"
|
||||
# Can be either "core" or fully qualified plugin's name
|
||||
target: "varchar(255) NOT NULL"
|
||||
# The latest available version of the plugin
|
||||
version: "varchar(255) NOT NULL"
|
||||
# A URL where the new version can be downloaded
|
||||
url: "text"
|
||||
# Description of the update
|
||||
description: "text"
|
||||
unique_keys:
|
||||
target: [target]
|
||||
|
@ -1,5 +1,5 @@
|
||||
# IMPORTANT: Before install Mibew Messenger copy this file to config.yml and
|
||||
# fill it with your own settings!
|
||||
# IMPORTANT: Before install mibew copy this file to config.yml and fill it with
|
||||
# your own settings!
|
||||
|
||||
|
||||
# MySQL Database parameters
|
||||
@ -12,60 +12,9 @@ database:
|
||||
tables_prefix: ""
|
||||
use_persistent_connection: false
|
||||
|
||||
# Mail
|
||||
## This value will be used as sender address in all e-mails Mibew Messenger send.
|
||||
# Mailbox
|
||||
mailbox: mibew@yourdomain.com
|
||||
|
||||
## Mailer parameters
|
||||
mailer:
|
||||
# This value determines what kind of mailer will be used. Possible values
|
||||
# are "mail" and "smtp".
|
||||
#
|
||||
# To use standard PHP mail function just set this option to "mail". No
|
||||
# additional configs are required in this case.
|
||||
#
|
||||
# To use SMTP-based solution set this option "smtp". This approach require
|
||||
# some extra configuration to be done (see below).
|
||||
transport: mail
|
||||
|
||||
# The lines below represents default SMTP mailer configurations. They will
|
||||
# be used only if the "transport" option is set to "smtp".
|
||||
host: localhost
|
||||
port: 25
|
||||
user: user
|
||||
pass: ""
|
||||
# The following option determines what kind of encryption should be used.
|
||||
# false means no encyption at all. Another values once can use are "ssl" and
|
||||
# "tls".
|
||||
encryption: false
|
||||
|
||||
# Cache subsystem
|
||||
cache:
|
||||
# This value determines where the cached data will be stored. Possible
|
||||
# values are "none", "file_system" and "memcached".
|
||||
#
|
||||
# If "none" is used the caching will be disabled. This option should be used
|
||||
# only if none of the other options works.
|
||||
#
|
||||
# If "file_system" is used the cached data will be stored in files within
|
||||
# the "cache/" directory. Notice, that the file system storage does not work
|
||||
# on NFS systems bucause exclusive file locks are not supported where.
|
||||
#
|
||||
# If "memcached" is used the cached data will be stored in Memcached
|
||||
# storage. Before using this kind of storage make sure PHP's memcached
|
||||
# extension is installed and enabled.
|
||||
storage: file_system
|
||||
|
||||
# The lines below represents default Memcached server configurations. They
|
||||
# will be used only if the "storage" option is set to "memcached".
|
||||
memcached_servers:
|
||||
- host: localhost
|
||||
port: 11211
|
||||
# The "weight" field is optional and can be omitted and it's only positive int number.
|
||||
weight: 1
|
||||
# Actually, one can use any number of memcached servers he wants. Just
|
||||
# add servers description like the one above.
|
||||
|
||||
# Locales
|
||||
## Native name will be used in this locale
|
||||
home_locale: en
|
||||
@ -77,22 +26,17 @@ default_locale: en
|
||||
# http://php.net/manual/en/timezones.php
|
||||
timezone: ""
|
||||
|
||||
# List of proxy's IP Mibew Messenger should trust. You should set this option
|
||||
# if you use Mibew Messenger with a load balancer or behind a proxy.
|
||||
trusted_proxies: []
|
||||
# Here is an example of what values this option can take:
|
||||
# trusted_proxies:
|
||||
# - 127.0.0.1
|
||||
# - ::1
|
||||
# - 10.0.0.0/8
|
||||
|
||||
# Plugins
|
||||
plugins: []
|
||||
|
||||
## Example of plugins configuration
|
||||
## Exapmle of plugins configuration
|
||||
# plugins:
|
||||
# "VendorName:PluginName":
|
||||
# weight: 100
|
||||
# some_configurable_value: value
|
||||
# "VendorName:AnotherPluginName":
|
||||
# very_important_value: "$3.50"
|
||||
# -
|
||||
# name: "VendorName:PluginName"
|
||||
# config:
|
||||
# weight: 100
|
||||
# some_configurable_value: value
|
||||
# -
|
||||
# name: "VendorName:AnotherPluginName"
|
||||
# config:
|
||||
# very_important_value: "$3.50"
|
||||
|
@ -49,14 +49,6 @@ chat_user:
|
||||
thread_id: \d{1,10}
|
||||
token: \d{1,10}
|
||||
|
||||
chat_user_check:
|
||||
path: /chat/{thread_id}/{token}/check
|
||||
defaults:
|
||||
_controller: Mibew\Controller\Chat\UserChatController::checkAction
|
||||
requirements:
|
||||
thread_id: \d{1,10}
|
||||
token: \d{1,10}
|
||||
|
||||
chat_user_invitation:
|
||||
path: /chat/invitation
|
||||
defaults:
|
||||
@ -80,33 +72,11 @@ chat_user_mail_send:
|
||||
token: \d{1,10}
|
||||
methods: [POST]
|
||||
|
||||
chat_user_popup_style:
|
||||
path: /chat/style/popup/{style}
|
||||
defaults:
|
||||
_controller: Mibew\Controller\Chat\StyleController::loadPopupStyleAction
|
||||
style: ""
|
||||
requirements:
|
||||
style: "[0-9A-Za-z_]*"
|
||||
|
||||
chat_user_popup_style_force_secure:
|
||||
path: /chat/style/popup/{style}/force_secure
|
||||
defaults:
|
||||
_controller: Mibew\Controller\Chat\StyleController::loadPopupStyleAction
|
||||
style: ""
|
||||
force_secure: on
|
||||
requirements:
|
||||
style: "[0-9A-Za-z_]*"
|
||||
|
||||
chat_user_start:
|
||||
path: /chat
|
||||
defaults:
|
||||
_controller: Mibew\Controller\Chat\UserChatController::startAction
|
||||
|
||||
chat_user_cookie_set_permission:
|
||||
path: /chat/cookies-set-permission
|
||||
defaults:
|
||||
_controller: Mibew\Controller\Chat\UserChatController::cookieSetPermissionAction
|
||||
|
||||
# Pages that are available for all users
|
||||
button:
|
||||
path: /b
|
||||
@ -120,12 +90,9 @@ cron:
|
||||
path: /cron
|
||||
defaults: { _controller: Mibew\Controller\CronController::runAction }
|
||||
|
||||
# A set of localization constants for the client side applications is generated
|
||||
# dynamically
|
||||
js_translation:
|
||||
path: /locales/{locale}/translation.js
|
||||
defaults:
|
||||
_controller: Mibew\Controller\Localization\JsTranslationController::indexAction
|
||||
license:
|
||||
path: /license
|
||||
defaults: { _controller: Mibew\Controller\LicenseController::indexAction }
|
||||
|
||||
widget_gateway:
|
||||
path: /widget
|
||||
@ -133,13 +100,6 @@ widget_gateway:
|
||||
|
||||
# Operators' pages
|
||||
|
||||
## About page
|
||||
about:
|
||||
path: /operator/about
|
||||
defaults:
|
||||
_controller: Mibew\Controller\AboutController::indexAction
|
||||
_access_check: Mibew\AccessControl\Check\LoggedInCheck
|
||||
|
||||
## Banned visitors
|
||||
ban_add:
|
||||
path: /operator/ban/add
|
||||
@ -200,24 +160,21 @@ canned_message_add:
|
||||
path: /operator/canned-message/add
|
||||
defaults:
|
||||
_controller: Mibew\Controller\CannedMessageController::showEditFormAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
_access_check: Mibew\AccessControl\Check\LoggedInCheck
|
||||
methods: [GET]
|
||||
|
||||
canned_message_add_save:
|
||||
path: /operator/canned-message/add
|
||||
defaults:
|
||||
_controller: Mibew\Controller\CannedMessageController::submitEditFormAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
_access_check: Mibew\AccessControl\Check\LoggedInCheck
|
||||
methods: [POST]
|
||||
|
||||
canned_message_delete:
|
||||
path: /operator/canned-message/{message_id}/delete
|
||||
defaults:
|
||||
_controller: Mibew\Controller\CannedMessageController::deleteAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
_access_check: Mibew\AccessControl\Check\LoggedInCheck
|
||||
requirements:
|
||||
message_id: \d{1,10}
|
||||
|
||||
@ -225,8 +182,7 @@ canned_message_edit:
|
||||
path: /operator/canned-message/{message_id}/edit
|
||||
defaults:
|
||||
_controller: Mibew\Controller\CannedMessageController::showEditFormAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
_access_check: Mibew\AccessControl\Check\LoggedInCheck
|
||||
requirements:
|
||||
message_id: \d{1,10}
|
||||
methods: [GET]
|
||||
@ -235,8 +191,7 @@ canned_message_edit_save:
|
||||
path: /operator/canned-message/{message_id}/edit
|
||||
defaults:
|
||||
_controller: Mibew\Controller\CannedMessageController::submitEditFormAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
_access_check: Mibew\AccessControl\Check\LoggedInCheck
|
||||
requirements:
|
||||
message_id: \d{1,10}
|
||||
methods: [POST]
|
||||
@ -245,8 +200,7 @@ canned_messages:
|
||||
path: /operator/canned-message
|
||||
defaults:
|
||||
_controller: Mibew\Controller\CannedMessageController::indexAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
_access_check: Mibew\AccessControl\Check\LoggedInCheck
|
||||
|
||||
## Groups
|
||||
group_add:
|
||||
@ -377,27 +331,7 @@ locale_disable:
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
requirements:
|
||||
locale: "[a-z\\-]{2,5}"
|
||||
|
||||
locale_edit:
|
||||
path: /operator/locale/{locale}/edit
|
||||
defaults:
|
||||
_controller: Mibew\Controller\Localization\LocaleController::showEditFormAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
requirements:
|
||||
locale: "[a-z\\-]{2,5}"
|
||||
methods: [GET]
|
||||
|
||||
locale_edit_save:
|
||||
path: /operator/locale/{locale}/edit
|
||||
defaults:
|
||||
_controller: Mibew\Controller\Localization\LocaleController::submitEditFormAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
requirements:
|
||||
locale: "[a-z\\-]{2,5}"
|
||||
methods: [POST]
|
||||
locale: "[a-z\-]{2,5}"
|
||||
|
||||
locale_enable:
|
||||
path: /operator/locale/{locale}/enable
|
||||
@ -406,7 +340,7 @@ locale_enable:
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
requirements:
|
||||
locale: "[a-z\\-]{2,5}"
|
||||
locale: "[a-z\-]{2,5}"
|
||||
|
||||
locales:
|
||||
path: /operator/locale
|
||||
@ -607,42 +541,6 @@ password_recovery_reset:
|
||||
defaults:
|
||||
_controller: Mibew\Controller\PasswordRecoveryController::resetAction
|
||||
|
||||
## Plugins
|
||||
plugin_enable:
|
||||
path: /operator/plugin/{plugin_name}/enable
|
||||
defaults:
|
||||
_controller: Mibew\Controller\PluginController::enableAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
|
||||
plugin_disable:
|
||||
path: /operator/plugin/{plugin_name}/disable
|
||||
defaults:
|
||||
_controller: Mibew\Controller\PluginController::disableAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
|
||||
plugin_uninstall:
|
||||
path: /operator/plugin/{plugin_name}/uninstall
|
||||
defaults:
|
||||
_controller: Mibew\Controller\PluginController::uninstallAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
|
||||
plugin_update:
|
||||
path: /operator/plugin/{plugin_name}/update
|
||||
defaults:
|
||||
_controller: Mibew\Controller\PluginController::updateAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
|
||||
plugins:
|
||||
path: /operator/plugin
|
||||
defaults:
|
||||
_controller: Mibew\Controller\PluginController::indexAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
|
||||
## Settings
|
||||
settings_common:
|
||||
path: /operator/settings
|
||||
@ -698,8 +596,7 @@ statistics:
|
||||
defaults:
|
||||
type: "by-date"
|
||||
_controller: Mibew\Controller\StatisticsController::indexAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_VIEWSTATISTICS]
|
||||
_access_check: Mibew\AccessControl\Check\LoggedInCheck
|
||||
requirements:
|
||||
type: by-date|by-operator|by-page
|
||||
|
||||
@ -721,7 +618,7 @@ translation_edit:
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
requirements:
|
||||
string_id: "\\d{1,10}"
|
||||
string_id: "\d{1,10}"
|
||||
methods: [GET]
|
||||
|
||||
translation_edit_save:
|
||||
@ -731,7 +628,7 @@ translation_edit_save:
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
requirements:
|
||||
string_id: "\\d{1,10}"
|
||||
string_id: "\d{1,10}"
|
||||
methods: [POST]
|
||||
|
||||
translation_export:
|
||||
@ -774,26 +671,11 @@ translations:
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
|
||||
## Updates
|
||||
update:
|
||||
path: /update
|
||||
updates:
|
||||
path: /operator/updates
|
||||
defaults:
|
||||
_controller: Mibew\Controller\UpdateController::indexAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
|
||||
update_run:
|
||||
path: /update/run
|
||||
defaults:
|
||||
_controller: Mibew\Controller\UpdateController::runUpdateAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
|
||||
update_check:
|
||||
path: /update/check
|
||||
defaults:
|
||||
_controller: Mibew\Controller\UpdateController::checkUpdatesAction
|
||||
_access_check: Mibew\AccessControl\Check\PermissionsCheck
|
||||
_access_permissions: [CAN_ADMINISTRATE]
|
||||
_controller: Mibew\Controller\UpdatesController::indexAction
|
||||
_access_check: Mibew\AccessControl\Check\LoggedInCheck
|
||||
|
||||
## Users (visitors avaiting page)
|
||||
users:
|
||||
@ -808,17 +690,7 @@ users_update:
|
||||
_controller: Mibew\Controller\UsersController::updateAction
|
||||
_access_check: Mibew\AccessControl\Check\LoggedInCheck
|
||||
|
||||
# System routes and includes
|
||||
|
||||
# The following route is a fake and is used only to load plugins routes. It can
|
||||
# have any unique name.
|
||||
_include_pluign_routes:
|
||||
# Resource name has no meaning and can be any value.
|
||||
resource: .
|
||||
# The type actually indicates that plugins routes should be included.
|
||||
type: plugin
|
||||
|
||||
# Remove trailing slashes. This route is the last one because previous rotes can
|
||||
# Remove trailing slashe. This route is the last one because previous rotes can
|
||||
# (but definitely should not) have trailing slashes.
|
||||
remove_trailing_slash:
|
||||
path: /{url}
|
||||
|
@ -1,9 +1,3 @@
|
||||
# The following route is a fake and is used only to load routes of the core. It
|
||||
# can have any unique name.
|
||||
_include_core_routes:
|
||||
resource: routing.yml
|
||||
type: yaml
|
||||
|
||||
# Override the home route to allow users use <mibew root>/install.php path to
|
||||
# the installer.
|
||||
home:
|
||||
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is a part of Mibew Messenger.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Initialize libraries
|
||||
require_once(dirname(__FILE__) . '/libs/init.php');
|
||||
|
||||
use Mibew\Cache\CacheFactory;
|
||||
use Mibew\Maintenance\CronWorker;
|
||||
use Mibew\Plugin\PluginManager;
|
||||
|
||||
$configs = load_system_configs();
|
||||
|
||||
// Prepare the cache. It is initialized in the same way as in index.php
|
||||
$cache_factory = new CacheFactory($configs['cache']);
|
||||
// For now directory for cache files cannot be changed via the configs file.
|
||||
$cache_factory->setOption('path', MIBEW_FS_ROOT . '/cache/stash');
|
||||
|
||||
// Run plugins
|
||||
if (get_maintenance_mode() === false) {
|
||||
$plugin_manager = PluginManager::getInstance();
|
||||
$plugin_manager->setCache($cache_factory->getCache());
|
||||
$plugin_manager->loadPlugins($configs['plugins']);
|
||||
}
|
||||
|
||||
// Do the job.
|
||||
$worker = new CronWorker($cache_factory->getCache());
|
||||
$success = $worker->run();
|
||||
|
||||
if ($success) {
|
||||
echo("All cron jobs done\n");
|
||||
} else {
|
||||
echo("Cron job failed. Here are the errors:\n");
|
||||
foreach ($worker->getErrors() as $error) {
|
||||
echo(' ' . $error . "\n");
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is a part of Mibew Messenger.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -22,53 +20,24 @@ require_once(dirname(__FILE__) . '/libs/init.php');
|
||||
|
||||
use Mibew\Application;
|
||||
use Mibew\Authentication\AuthenticationManager;
|
||||
use Mibew\Cache\CacheFactory;
|
||||
use Mibew\Mail\MailerFactory;
|
||||
use Mibew\Plugin\PluginManager;
|
||||
use Mibew\Routing\RouteCollectionLoader;
|
||||
use Mibew\Routing\Router;
|
||||
use Mibew\Routing\Loader\CacheLoader;
|
||||
use Mibew\Routing\Loader\PluginLoader;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Loader\YamlFileLoader;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
|
||||
$configs = load_system_configs();
|
||||
|
||||
// Prepare the cache
|
||||
$cache_factory = new CacheFactory($configs['cache']);
|
||||
// For now directory for cache files cannot be changed via the configs file.
|
||||
// TODO: Evaluate possibility of using custom cache directory.
|
||||
$cache_factory->setOption('path', MIBEW_FS_ROOT . '/cache/stash');
|
||||
|
||||
// Run plugins
|
||||
if (get_maintenance_mode() === false) {
|
||||
$plugin_manager = PluginManager::getInstance();
|
||||
$plugin_manager->setCache($cache_factory->getCache());
|
||||
$plugin_manager->loadPlugins($configs['plugins']);
|
||||
}
|
||||
|
||||
// The main route loader which loads nothig but works as a cache proxy for other
|
||||
// loaders.
|
||||
$route_loader = new CacheLoader($cache_factory->getCache());
|
||||
// Real loaders are attached via the resolver.
|
||||
$loader_resolver = new LoaderResolver(array(
|
||||
$route_loader,
|
||||
new YamlFileLoader(new FileLocator(array(MIBEW_FS_ROOT))),
|
||||
new PluginLoader(),
|
||||
));
|
||||
|
||||
$router = new Router($route_loader, 'configs/routing.yml');
|
||||
$file_locator = new FileLocator(array(MIBEW_FS_ROOT));
|
||||
$router = new Router(new RouteCollectionLoader($file_locator));
|
||||
$router->setOption(
|
||||
'route_collection',
|
||||
RouteCollectionLoader::ROUTES_CORE | RouteCollectionLoader::ROUTES_PLUGINS
|
||||
);
|
||||
|
||||
$application = new Application($router, new AuthenticationManager());
|
||||
$application->setCache($cache_factory->getCache());
|
||||
|
||||
// Use custom config-dependent mailer factory
|
||||
$application->setMailerFactory(new MailerFactory($configs['mailer']));
|
||||
|
||||
// Process request
|
||||
$request = Request::createFromGlobals();
|
||||
$response = $application->handleRequest($request);
|
||||
|
||||
// Send response to the user
|
||||
$response->prepare($request);
|
||||
$response->send();
|
||||
|
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is a part of Mibew Messenger.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Force the user to specify the entry point. This should be done only when
|
||||
// mod_rewrite is not used by apache.
|
||||
header('HTTP/1.0 301 Moved Permanently');
|
||||
header('Location: index.php');
|
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is a part of Mibew Messenger.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,28 +15,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
define('MAINTENANCE_MODE', 'install');
|
||||
define('INSTALLATION_IN_PROGRESS', true);
|
||||
|
||||
// Initialize libraries
|
||||
require_once(dirname(__FILE__) . '/libs/init.php');
|
||||
|
||||
use Mibew\Application;
|
||||
use Mibew\Authentication\DummyAuthenticationManager;
|
||||
use Mibew\Routing\Loader\DummyPluginLoader;
|
||||
use Mibew\Routing\RouteCollectionLoader;
|
||||
use Mibew\Routing\Router;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Loader\YamlFileLoader;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
|
||||
// Prepare router
|
||||
$file_locator = new FileLocator(array(MIBEW_FS_ROOT));
|
||||
$route_loader = new YamlFileLoader($file_locator);
|
||||
$loader_resolver = new LoaderResolver(array(
|
||||
$route_loader,
|
||||
new DummyPluginLoader(),
|
||||
));
|
||||
$router = new Router($route_loader, 'configs/routing_install.yml');
|
||||
$router = new Router(new RouteCollectionLoader($file_locator));
|
||||
$router->setOption(
|
||||
'route_collection',
|
||||
RouteCollectionLoader::ROUTES_CORE | RouteCollectionLoader::ROUTES_INSTALLATION
|
||||
);
|
||||
|
||||
$application = new Application($router, new DummyAuthenticationManager());
|
||||
|
||||
@ -47,4 +41,5 @@ $request = Request::createFromGlobals();
|
||||
$response = $application->handleRequest($request);
|
||||
|
||||
// Send response to the user
|
||||
$response->prepare($request);
|
||||
$response->send();
|
||||
|
2
src/mibew/js/libs/backbone-min.js
vendored
Normal file
2
src/mibew/js/libs/backbone-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
22
src/mibew/js/libs/backbone.marionette.min.js
vendored
Normal file
22
src/mibew/js/libs/backbone.marionette.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
106
src/mibew/js/libs/handlebars.js
Normal file
106
src/mibew/js/libs/handlebars.js
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
handlebars v1.3.0
|
||||
|
||||
Copyright (C) 2011 by Yehuda Katz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
var Handlebars=function(){var E=function(a){this.string=a};E.prototype.toString=function(){return""+this.string};var V=function(a){return U[a]||"&"},q={},U={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},W=/[&<>"'`]/g,X=/[&<>"'`]/;q.extend=function(a,b){for(var c in b)Object.prototype.hasOwnProperty.call(b,c)&&(a[c]=b[c])};var F=Object.prototype.toString;q.toString=F;var m=function(a){return"function"===typeof a};m(/x/)&&(m=function(a){return"function"===typeof a&&"[object Function]"===
|
||||
F.call(a)});q.isFunction=m;var M=Array.isArray||function(a){return a&&"object"===typeof a?"[object Array]"===F.call(a):!1};q.isArray=M;q.escapeExpression=function(a){if(a instanceof E)return a.toString();if(!a&&0!==a)return"";a=""+a;return!X.test(a)?a:a.replace(W,V)};q.isEmpty=function(a){return!a&&0!==a?!0:M(a)&&0===a.length?!0:!1};var j=function(a,b){var c;b&&b.firstLine&&(c=b.firstLine,a+=" - "+c+":"+b.firstColumn);for(var d=Error.prototype.constructor.call(this,a),f=0;f<G.length;f++)this[G[f]]=
|
||||
d[G[f]];c&&(this.lineNumber=c,this.column=b.firstColumn)},G="description fileName lineNumber message name number stack".split(" ");j.prototype=Error();var m=function(a,b){this.helpers=a||{};this.partials=b||{};var c=this;c.registerHelper("helperMissing",function(a){if(2!==arguments.length)throw new N("Missing helper: '"+a+"'");});c.registerHelper("blockHelperMissing",function(a,b){var e=b.inverse||function(){},h=b.fn;B(a)&&(a=a.call(this));return!0===a?h(this):!1===a||null==a?e(this):O(a)?0<a.length?
|
||||
c.helpers.each(a,b):e(this):h(a)});c.registerHelper("each",function(a,b){var c=b.fn,h=b.inverse,g=0,j="",r;B(a)&&(a=a.call(this));b.data&&(r=P(b.data));if(a&&"object"===typeof a)if(O(a))for(var k=a.length;g<k;g++)r&&(r.index=g,r.first=0===g,r.last=g===a.length-1),j+=c(a[g],{data:r});else for(k in a)a.hasOwnProperty(k)&&(r&&(r.key=k,r.index=g,r.first=0===g),j+=c(a[k],{data:r}),g++);0===g&&(j=h(this));return j});c.registerHelper("if",function(a,b){B(a)&&(a=a.call(this));return!b.hash.includeZero&&!a||
|
||||
u.isEmpty(a)?b.inverse(this):b.fn(this)});c.registerHelper("unless",function(a,b){return c.helpers["if"].call(this,a,{fn:b.inverse,inverse:b.fn,hash:b.hash})});c.registerHelper("with",function(a,b){B(a)&&(a=a.call(this));if(!u.isEmpty(a))return b.fn(a)});c.registerHelper("log",function(a,b){var e=b.data&&null!=b.data.level?parseInt(b.data.level,10):1;c.log(e,a)})},n=function(a,b){y.log(a,b)},p={},u=q,N=j;p.VERSION="1.3.0";p.COMPILER_REVISION=4;p.REVISION_CHANGES={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",
|
||||
3:"== 1.0.0-rc.4",4:">= 1.0.0"};var O=u.isArray,B=u.isFunction,Q=u.toString;p.HandlebarsEnvironment=m;m.prototype={constructor:m,logger:y,log:n,registerHelper:function(a,b,c){if("[object Object]"===Q.call(a)){if(c||b)throw new N("Arg not supported with multiple helpers");u.extend(this.helpers,a)}else c&&(b.not=c),this.helpers[a]=b},registerPartial:function(a,b){"[object Object]"===Q.call(a)?u.extend(this.partials,a):this.partials[a]=b}};var y={methodMap:{"0":"debug",1:"info",2:"warn",3:"error"},DEBUG:0,
|
||||
INFO:1,WARN:2,ERROR:3,level:3,log:function(a,b){if(y.level<=a){var c=y.methodMap[a];"undefined"!==typeof console&&console[c]&&console[c].call(console,b)}}};p.logger=y;p.log=n;var P=function(a){var b={};u.extend(b,a);return b};p.createFrame=P;var H=function(a,b,c){var d=function(a,d){d=d||{};return b(a,d.data||c)};d.program=a;d.depth=0;return d},v={},I=p.COMPILER_REVISION,R=p.REVISION_CHANGES;v.checkRevision=function(a){var b=a&&a[0]||1;if(b!==I){if(b<I)throw new j("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+
|
||||
R[I]+") or downgrade your runtime to an older version ("+R[b]+").");throw new j("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+a[1]+").");}};v.template=function(a,b){if(!b)throw new j("No environment passed to template");var c={escapeExpression:q.escapeExpression,invokePartial:function(a,c,e,h,g,n){var r=b.VM.invokePartial.apply(this,arguments);if(null!=r)return r;if(b.compile)return r={helpers:h,partials:g,data:n},
|
||||
g[c]=b.compile(a,{data:void 0!==n},b),g[c](e,r);throw new j("The partial "+c+" could not be compiled when running in runtime-only mode");},programs:[],program:function(a,b,c){var h=this.programs[a];c?h=H(a,b,c):h||(h=this.programs[a]=H(a,b));return h},merge:function(a,b){var c=a||b;a&&(b&&a!==b)&&(c={},q.extend(c,b),q.extend(c,a));return c},programWithDepth:b.VM.programWithDepth,noop:b.VM.noop,compilerInfo:null};return function(d,f){f=f||{};var e=f.partial?f:b,h,g;f.partial||(h=f.helpers,g=f.partials);
|
||||
e=a.call(c,e,d,h,g,f.data);f.partial||b.VM.checkRevision(c.compilerInfo);return e}};v.programWithDepth=function(a,b,c){var d=Array.prototype.slice.call(arguments,3),f=function(a,f){f=f||{};return b.apply(this,[a,f.data||c].concat(d))};f.program=a;f.depth=d.length;return f};v.program=H;v.invokePartial=function(a,b,c,d,f,e){d={partial:!0,helpers:d,partials:f,data:e};if(void 0===a)throw new j("The partial "+b+" could not be found");if(a instanceof Function)return a(c,d)};v.noop=function(){return""};
|
||||
n=function(){var a=new p.HandlebarsEnvironment;q.extend(a,p);a.SafeString=E;a.Exception=j;a.Utils=q;a.VM=v;a.template=function(b){return v.template(b,a)};return a};m=n();m.create=n;var C,l=function(a){a=a||{};this.firstLine=a.first_line;this.firstColumn=a.first_column;this.lastColumn=a.last_column;this.lastLine=a.last_line},z={ProgramNode:function(a,b,c,d){var f;3===arguments.length?(d=c,c=null):2===arguments.length&&(d=b,b=null);l.call(this,d);this.type="program";this.statements=a;this.strip={};
|
||||
c?((f=c[0])?(f={first_line:f.firstLine,last_line:f.lastLine,last_column:f.lastColumn,first_column:f.firstColumn},this.inverse=new z.ProgramNode(c,b,f)):this.inverse=new z.ProgramNode(c,b),this.strip.right=b.left):b&&(this.strip.left=b.right)},MustacheNode:function(a,b,c,d,f){l.call(this,f);this.type="mustache";this.strip=d;null!=c&&c.charAt?(c=c.charAt(3)||c.charAt(2),this.escaped="{"!==c&&"&"!==c):this.escaped=!!c;this.sexpr=a instanceof z.SexprNode?a:new z.SexprNode(a,b);this.sexpr.isRoot=!0;this.id=
|
||||
this.sexpr.id;this.params=this.sexpr.params;this.hash=this.sexpr.hash;this.eligibleHelper=this.sexpr.eligibleHelper;this.isHelper=this.sexpr.isHelper},SexprNode:function(a,b,c){l.call(this,c);this.type="sexpr";this.hash=b;c=this.id=a[0];a=this.params=a.slice(1);this.isHelper=(this.eligibleHelper=c.isSimple)&&(a.length||b)},PartialNode:function(a,b,c,d){l.call(this,d);this.type="partial";this.partialName=a;this.context=b;this.strip=c},BlockNode:function(a,b,c,d,f){l.call(this,f);if(a.sexpr.id.original!==
|
||||
d.path.original)throw new j(a.sexpr.id.original+" doesn't match "+d.path.original,this);this.type="block";this.mustache=a;this.program=b;this.inverse=c;this.strip={left:a.strip.left,right:d.strip.right};(b||c).strip.left=a.strip.right;(c||b).strip.right=d.strip.left;c&&!b&&(this.isInverse=!0)},ContentNode:function(a,b){l.call(this,b);this.type="content";this.string=a},HashNode:function(a,b){l.call(this,b);this.type="hash";this.pairs=a},IdNode:function(a,b){l.call(this,b);this.type="ID";for(var c=
|
||||
"",d=[],f=0,e=0,h=a.length;e<h;e++){var g=a[e].part,c=c+((a[e].separator||"")+g);if(".."===g||"."===g||"this"===g){if(0<d.length)throw new j("Invalid path: "+c,this);".."===g?f++:this.isScoped=!0}else d.push(g)}this.original=c;this.parts=d;this.string=d.join(".");this.depth=f;this.isSimple=1===a.length&&!this.isScoped&&0===f;this.stringModeValue=this.string},PartialNameNode:function(a,b){l.call(this,b);this.type="PARTIAL_NAME";this.name=a.original},DataNode:function(a,b){l.call(this,b);this.type=
|
||||
"DATA";this.id=a},StringNode:function(a,b){l.call(this,b);this.type="STRING";this.original=this.string=this.stringModeValue=a},IntegerNode:function(a,b){l.call(this,b);this.type="INTEGER";this.original=this.integer=a;this.stringModeValue=Number(a)},BooleanNode:function(a,b){l.call(this,b);this.type="BOOLEAN";this.bool=a;this.stringModeValue="true"===a},CommentNode:function(a,b){l.call(this,b);this.type="comment";this.comment=a}};C=z;var w=function(a,b){return{left:"~"===a.charAt(2),right:"~"===b.charAt(0)||
|
||||
"~"===b.charAt(1)}},n=function(){this.yy={}},D={trace:function(){},yy:{},symbols_:{error:2,root:3,statements:4,EOF:5,program:6,simpleInverse:7,statement:8,openInverse:9,closeBlock:10,openBlock:11,mustache:12,partial:13,CONTENT:14,COMMENT:15,OPEN_BLOCK:16,sexpr:17,CLOSE:18,OPEN_INVERSE:19,OPEN_ENDBLOCK:20,path:21,OPEN:22,OPEN_UNESCAPED:23,CLOSE_UNESCAPED:24,OPEN_PARTIAL:25,partialName:26,partial_option0:27,sexpr_repetition0:28,sexpr_option0:29,dataName:30,param:31,STRING:32,INTEGER:33,BOOLEAN:34,OPEN_SEXPR:35,
|
||||
CLOSE_SEXPR:36,hash:37,hash_repetition_plus0:38,hashSegment:39,ID:40,EQUALS:41,DATA:42,pathSegments:43,SEP:44,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"CLOSE_UNESCAPED",25:"OPEN_PARTIAL",32:"STRING",33:"INTEGER",34:"BOOLEAN",35:"OPEN_SEXPR",36:"CLOSE_SEXPR",40:"ID",41:"EQUALS",42:"DATA",44:"SEP"},productions_:[0,[3,2],[3,1],[6,2],[6,3],[6,2],[6,1],[6,1],[6,0],[4,1],[4,
|
||||
2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,4],[7,2],[17,3],[17,1],[31,1],[31,1],[31,1],[31,1],[31,1],[31,3],[37,1],[39,3],[26,1],[26,1],[26,1],[30,2],[21,1],[43,3],[43,1],[27,0],[27,1],[28,0],[28,2],[29,0],[29,1],[38,1],[38,2]],performAction:function(a,b,c,d,f,e){a=e.length-1;switch(f){case 1:return new d.ProgramNode(e[a-1],this._$);case 2:return new d.ProgramNode([],this._$);case 3:this.$=new d.ProgramNode([],e[a-1],e[a],this._$);break;case 4:this.$=new d.ProgramNode(e[a-
|
||||
2],e[a-1],e[a],this._$);break;case 5:this.$=new d.ProgramNode(e[a-1],e[a],[],this._$);break;case 6:this.$=new d.ProgramNode(e[a],this._$);break;case 7:this.$=new d.ProgramNode([],this._$);break;case 8:this.$=new d.ProgramNode([],this._$);break;case 9:this.$=[e[a]];break;case 10:e[a-1].push(e[a]);this.$=e[a-1];break;case 11:this.$=new d.BlockNode(e[a-2],e[a-1].inverse,e[a-1],e[a],this._$);break;case 12:this.$=new d.BlockNode(e[a-2],e[a-1],e[a-1].inverse,e[a],this._$);break;case 13:this.$=e[a];break;
|
||||
case 14:this.$=e[a];break;case 15:this.$=new d.ContentNode(e[a],this._$);break;case 16:this.$=new d.CommentNode(e[a],this._$);break;case 17:this.$=new d.MustacheNode(e[a-1],null,e[a-2],w(e[a-2],e[a]),this._$);break;case 18:this.$=new d.MustacheNode(e[a-1],null,e[a-2],w(e[a-2],e[a]),this._$);break;case 19:this.$={path:e[a-1],strip:w(e[a-2],e[a])};break;case 20:this.$=new d.MustacheNode(e[a-1],null,e[a-2],w(e[a-2],e[a]),this._$);break;case 21:this.$=new d.MustacheNode(e[a-1],null,e[a-2],w(e[a-2],e[a]),
|
||||
this._$);break;case 22:this.$=new d.PartialNode(e[a-2],e[a-1],w(e[a-3],e[a]),this._$);break;case 23:this.$=w(e[a-1],e[a]);break;case 24:this.$=new d.SexprNode([e[a-2]].concat(e[a-1]),e[a],this._$);break;case 25:this.$=new d.SexprNode([e[a]],null,this._$);break;case 26:this.$=e[a];break;case 27:this.$=new d.StringNode(e[a],this._$);break;case 28:this.$=new d.IntegerNode(e[a],this._$);break;case 29:this.$=new d.BooleanNode(e[a],this._$);break;case 30:this.$=e[a];break;case 31:e[a-1].isHelper=!0;this.$=
|
||||
e[a-1];break;case 32:this.$=new d.HashNode(e[a],this._$);break;case 33:this.$=[e[a-2],e[a]];break;case 34:this.$=new d.PartialNameNode(e[a],this._$);break;case 35:this.$=new d.PartialNameNode(new d.StringNode(e[a],this._$),this._$);break;case 36:this.$=new d.PartialNameNode(new d.IntegerNode(e[a],this._$));break;case 37:this.$=new d.DataNode(e[a],this._$);break;case 38:this.$=new d.IdNode(e[a],this._$);break;case 39:e[a-2].push({part:e[a],separator:e[a-1]});this.$=e[a-2];break;case 40:this.$=[{part:e[a]}];
|
||||
break;case 43:this.$=[];break;case 44:e[a-1].push(e[a]);break;case 47:this.$=[e[a]];break;case 48:e[a-1].push(e[a])}},table:[{3:1,4:2,5:[1,3],8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],25:[1,15]},{1:[3]},{5:[1,16],8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],25:[1,15]},{1:[2,2]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],25:[2,9]},{4:20,6:18,7:19,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,
|
||||
12],19:[1,21],20:[2,8],22:[1,13],23:[1,14],25:[1,15]},{4:20,6:22,7:19,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,21],20:[2,8],22:[1,13],23:[1,14],25:[1,15]},{5:[2,13],14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],25:[2,13]},{5:[2,14],14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],25:[2,14]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],25:[2,15]},{5:[2,16],14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,
|
||||
16],22:[2,16],23:[2,16],25:[2,16]},{17:23,21:24,30:25,40:[1,28],42:[1,27],43:26},{17:29,21:24,30:25,40:[1,28],42:[1,27],43:26},{17:30,21:24,30:25,40:[1,28],42:[1,27],43:26},{17:31,21:24,30:25,40:[1,28],42:[1,27],43:26},{21:33,26:32,32:[1,34],33:[1,35],40:[1,28],43:26},{1:[2,1]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],25:[2,10]},{10:36,20:[1,37]},{4:38,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,7],22:[1,13],23:[1,14],25:[1,15]},{7:39,
|
||||
8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,21],20:[2,6],22:[1,13],23:[1,14],25:[1,15]},{17:23,18:[1,40],21:24,30:25,40:[1,28],42:[1,27],43:26},{10:41,20:[1,37]},{18:[1,42]},{18:[2,43],24:[2,43],28:43,32:[2,43],33:[2,43],34:[2,43],35:[2,43],36:[2,43],40:[2,43],42:[2,43]},{18:[2,25],24:[2,25],36:[2,25]},{18:[2,38],24:[2,38],32:[2,38],33:[2,38],34:[2,38],35:[2,38],36:[2,38],40:[2,38],42:[2,38],44:[1,44]},{21:45,40:[1,28],43:26},{18:[2,40],24:[2,40],32:[2,40],33:[2,40],34:[2,40],35:[2,
|
||||
40],36:[2,40],40:[2,40],42:[2,40],44:[2,40]},{18:[1,46]},{18:[1,47]},{24:[1,48]},{18:[2,41],21:50,27:49,40:[1,28],43:26},{18:[2,34],40:[2,34]},{18:[2,35],40:[2,35]},{18:[2,36],40:[2,36]},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],25:[2,11]},{21:51,40:[1,28],43:26},{8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,3],22:[1,13],23:[1,14],25:[1,15]},{4:52,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,5],22:[1,13],23:[1,14],
|
||||
25:[1,15]},{14:[2,23],15:[2,23],16:[2,23],19:[2,23],20:[2,23],22:[2,23],23:[2,23],25:[2,23]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],25:[2,12]},{14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],25:[2,18]},{18:[2,45],21:56,24:[2,45],29:53,30:60,31:54,32:[1,57],33:[1,58],34:[1,59],35:[1,61],36:[2,45],37:55,38:62,39:63,40:[1,64],42:[1,27],43:26},{40:[1,65]},{18:[2,37],24:[2,37],32:[2,37],33:[2,37],34:[2,37],35:[2,37],36:[2,37],40:[2,37],42:[2,
|
||||
37]},{14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],25:[2,17]},{5:[2,20],14:[2,20],15:[2,20],16:[2,20],19:[2,20],20:[2,20],22:[2,20],23:[2,20],25:[2,20]},{5:[2,21],14:[2,21],15:[2,21],16:[2,21],19:[2,21],20:[2,21],22:[2,21],23:[2,21],25:[2,21]},{18:[1,66]},{18:[2,42]},{18:[1,67]},{8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],25:[1,15]},{18:[2,24],24:[2,24],36:[2,24]},{18:[2,44],24:[2,44],32:[2,44],33:[2,44],34:[2,44],35:[2,44],
|
||||
36:[2,44],40:[2,44],42:[2,44]},{18:[2,46],24:[2,46],36:[2,46]},{18:[2,26],24:[2,26],32:[2,26],33:[2,26],34:[2,26],35:[2,26],36:[2,26],40:[2,26],42:[2,26]},{18:[2,27],24:[2,27],32:[2,27],33:[2,27],34:[2,27],35:[2,27],36:[2,27],40:[2,27],42:[2,27]},{18:[2,28],24:[2,28],32:[2,28],33:[2,28],34:[2,28],35:[2,28],36:[2,28],40:[2,28],42:[2,28]},{18:[2,29],24:[2,29],32:[2,29],33:[2,29],34:[2,29],35:[2,29],36:[2,29],40:[2,29],42:[2,29]},{18:[2,30],24:[2,30],32:[2,30],33:[2,30],34:[2,30],35:[2,30],36:[2,30],
|
||||
40:[2,30],42:[2,30]},{17:68,21:24,30:25,40:[1,28],42:[1,27],43:26},{18:[2,32],24:[2,32],36:[2,32],39:69,40:[1,70]},{18:[2,47],24:[2,47],36:[2,47],40:[2,47]},{18:[2,40],24:[2,40],32:[2,40],33:[2,40],34:[2,40],35:[2,40],36:[2,40],40:[2,40],41:[1,71],42:[2,40],44:[2,40]},{18:[2,39],24:[2,39],32:[2,39],33:[2,39],34:[2,39],35:[2,39],36:[2,39],40:[2,39],42:[2,39],44:[2,39]},{5:[2,22],14:[2,22],15:[2,22],16:[2,22],19:[2,22],20:[2,22],22:[2,22],23:[2,22],25:[2,22]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],
|
||||
19:[2,19],20:[2,19],22:[2,19],23:[2,19],25:[2,19]},{36:[1,72]},{18:[2,48],24:[2,48],36:[2,48],40:[2,48]},{41:[1,71]},{21:56,30:60,31:73,32:[1,57],33:[1,58],34:[1,59],35:[1,61],40:[1,28],42:[1,27],43:26},{18:[2,31],24:[2,31],32:[2,31],33:[2,31],34:[2,31],35:[2,31],36:[2,31],40:[2,31],42:[2,31]},{18:[2,33],24:[2,33],36:[2,33],40:[2,33]}],defaultActions:{3:[2,2],16:[2,1],50:[2,42]},parseError:function(a){throw Error(a);},parse:function(a){var b=[0],c=[null],d=[],f=this.table,e="",h=0,g=0,j=0;this.lexer.setInput(a);
|
||||
this.lexer.yy=this.yy;this.yy.lexer=this.lexer;this.yy.parser=this;"undefined"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});a=this.lexer.yylloc;d.push(a);var n=this.lexer.options&&this.lexer.options.ranges;"function"===typeof this.yy.parseError&&(this.parseError=this.yy.parseError);for(var k,p,l,s,m={},q,t;;){l=b[b.length-1];if(this.defaultActions[l])s=this.defaultActions[l];else{if(null===k||"undefined"==typeof k)k=void 0,k=this.lexer.lex()||1,"number"!==typeof k&&(k=this.symbols_[k]||k);s=
|
||||
f[l]&&f[l][k]}if("undefined"===typeof s||!s.length||!s[0]){var u="";if(!j){t=[];for(q in f[l])this.terminals_[q]&&2<q&&t.push("'"+this.terminals_[q]+"'");u=this.lexer.showPosition?"Parse error on line "+(h+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+t.join(", ")+", got '"+(this.terminals_[k]||k)+"'":"Parse error on line "+(h+1)+": Unexpected "+(1==k?"end of input":"'"+(this.terminals_[k]||k)+"'");this.parseError(u,{text:this.lexer.match,token:this.terminals_[k]||k,line:this.lexer.yylineno,loc:a,
|
||||
expected:t})}}if(s[0]instanceof Array&&1<s.length)throw Error("Parse Error: multiple actions possible at state: "+l+", token: "+k);switch(s[0]){case 1:b.push(k);c.push(this.lexer.yytext);d.push(this.lexer.yylloc);b.push(s[1]);k=null;p?(k=p,p=null):(g=this.lexer.yyleng,e=this.lexer.yytext,h=this.lexer.yylineno,a=this.lexer.yylloc,0<j&&j--);break;case 2:t=this.productions_[s[1]][1];m.$=c[c.length-t];m._$={first_line:d[d.length-(t||1)].first_line,last_line:d[d.length-1].last_line,first_column:d[d.length-
|
||||
(t||1)].first_column,last_column:d[d.length-1].last_column};n&&(m._$.range=[d[d.length-(t||1)].range[0],d[d.length-1].range[1]]);l=this.performAction.call(m,e,g,h,this.yy,s[1],c,d);if("undefined"!==typeof l)return l;t&&(b=b.slice(0,-2*t),c=c.slice(0,-1*t),d=d.slice(0,-1*t));b.push(this.productions_[s[1]][0]);c.push(m.$);d.push(m._$);s=f[b[b.length-2]][b[b.length-1]];b.push(s);break;case 3:return!0}}return!0},lexer:{EOF:1,parseError:function(a,b){if(this.yy.parser)this.yy.parser.parseError(a,b);else throw Error(a);
|
||||
},setInput:function(a){this._input=a;this._more=this._less=this.done=!1;this.yylineno=this.yyleng=0;this.yytext=this.matched=this.match="";this.conditionStack=["INITIAL"];this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0};this.options.ranges&&(this.yylloc.range=[0,0]);this.offset=0;return this},input:function(){var a=this._input[0];this.yytext+=a;this.yyleng++;this.offset++;this.match+=a;this.matched+=a;a.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++;
|
||||
this.options.ranges&&this.yylloc.range[1]++;this._input=this._input.slice(1);return a},unput:function(a){var b=a.length,c=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-b-1);this.offset-=b;a=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1);this.matched=this.matched.substr(0,this.matched.length-1);c.length-1&&(this.yylineno-=c.length-1);var d=this.yylloc.range;this.yylloc={first_line:this.yylloc.first_line,
|
||||
last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:c?(c.length===a.length?this.yylloc.first_column:0)+a[a.length-c.length].length-c[0].length:this.yylloc.first_column-b};this.options.ranges&&(this.yylloc.range=[d[0],d[0]+this.yyleng-b]);return this},more:function(){this._more=!0;return this},less:function(a){this.unput(this.match.slice(a))},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(20<a.length?"...":"")+a.substr(-20).replace(/\n/g,
|
||||
"")},upcomingInput:function(){var a=this.match;20>a.length&&(a+=this._input.substr(0,20-a.length));return(a.substr(0,20)+(20<a.length?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=Array(a.length+1).join("-");return a+this.upcomingInput()+"\n"+b+"^"},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c;this._more||(this.match=this.yytext="");for(var d=this._currentRules(),f=0;f<d.length;f++)if((b=this._input.match(this.rules[d[f]]))&&(!a||
|
||||
b[0].length>a[0].length))if(a=b,c=f,!this.options.flex)break;if(a){if(b=a[0].match(/(?:\r\n?|\n).*/g))this.yylineno+=b.length;this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:b?b[b.length-1].length-b[b.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+a[0].length};this.yytext+=a[0];this.match+=a[0];this.matches=a;this.yyleng=this.yytext.length;this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]);
|
||||
this._more=!1;this._input=this._input.slice(a[0].length);this.matched+=a[0];a=this.performAction.call(this,this.yy,this,d[c],this.conditionStack[this.conditionStack.length-1]);this.done&&this._input&&(this.done=!1);if(a)return a}else return""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var a=this.next();return"undefined"!==typeof a?a:this.lex()},begin:function(a){this.conditionStack.push(a)},
|
||||
popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(a){this.begin(a)},options:{},performAction:function(a,b,c){function d(a,c){return b.yytext=b.yytext.substr(a,b.yyleng-c)}switch(c){case 0:"\\\\"===b.yytext.slice(-2)?(d(0,1),this.begin("mu")):"\\"===b.yytext.slice(-1)?(d(0,1),this.begin("emu")):
|
||||
this.begin("mu");if(b.yytext)return 14;break;case 1:return 14;case 2:return this.popState(),14;case 3:return d(0,4),this.popState(),15;case 4:return 35;case 5:return 36;case 6:return 25;case 7:return 16;case 8:return 20;case 9:return 19;case 10:return 19;case 11:return 23;case 12:return 22;case 13:this.popState();this.begin("com");break;case 14:return d(3,5),this.popState(),15;case 15:return 22;case 16:return 41;case 17:return 40;case 18:return 40;case 19:return 44;case 21:return this.popState(),
|
||||
24;case 22:return this.popState(),18;case 23:return b.yytext=d(1,2).replace(/\\"/g,'"'),32;case 24:return b.yytext=d(1,2).replace(/\\'/g,"'"),32;case 25:return 42;case 26:return 34;case 27:return 34;case 28:return 33;case 29:return 40;case 30:return b.yytext=d(1,2),40;case 31:return"INVALID";case 32:return 5}},rules:[/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#)/,/^(?:\{\{(~)?\/)/,
|
||||
/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{(~)?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:-?[0-9]+(?=([~}\s)])))/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)]))))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/],conditions:{mu:{rules:[4,5,6,7,8,
|
||||
9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32],inclusive:!1},emu:{rules:[2],inclusive:!1},com:{rules:[3],inclusive:!1},INITIAL:{rules:[0,1,32],inclusive:!0}}}};n.prototype=D;D.Parser=n;var J=new n,K=function(){};K.prototype={compiler:K,disassemble:function(){for(var a=this.opcodes,b,c=[],d,f,e=0,h=a.length;e<h;e++)if(b=a[e],"DECLARE"===b.opcode)c.push("DECLARE "+b.name+"="+b.value);else{d=[];for(var g=0;g<b.args.length;g++)f=b.args[g],"string"===typeof f&&(f='"'+f.replace("\n",
|
||||
"\\n")+'"'),d.push(f);c.push(b.opcode+" "+d.join(" "))}return c.join("\n")},equals:function(a){var b=this.opcodes.length;if(a.opcodes.length!==b)return!1;for(var c=0;c<b;c++){var d=this.opcodes[c],f=a.opcodes[c];if(d.opcode!==f.opcode||d.args.length!==f.args.length)return!1;for(var e=0;e<d.args.length;e++)if(d.args[e]!==f.args[e])return!1}b=this.children.length;if(a.children.length!==b)return!1;for(c=0;c<b;c++)if(!this.children[c].equals(a.children[c]))return!1;return!0},guid:0,compile:function(a,
|
||||
b){this.opcodes=[];this.children=[];this.depths={list:[]};this.options=b;var c=this.options.knownHelpers;this.options.knownHelpers={helperMissing:!0,blockHelperMissing:!0,each:!0,"if":!0,unless:!0,"with":!0,log:!0};if(c)for(var d in c)this.options.knownHelpers[d]=c[d];return this.accept(a)},accept:function(a){var b=a.strip||{};b.left&&this.opcode("strip");a=this[a.type](a);b.right&&this.opcode("strip");return a},program:function(a){a=a.statements;for(var b=0,c=a.length;b<c;b++)this.accept(a[b]);this.isSimple=
|
||||
1===c;this.depths.list=this.depths.list.sort(function(a,b){return a-b});return this},compileProgram:function(a){a=(new this.compiler).compile(a,this.options);var b=this.guid++,c;this.usePartial=this.usePartial||a.usePartial;this.children[b]=a;for(var d=0,f=a.depths.list.length;d<f;d++)c=a.depths.list[d],2>c||this.addDepth(c-1);return b},block:function(a){var b=a.mustache,c=a.program;a=a.inverse;c&&(c=this.compileProgram(c));a&&(a=this.compileProgram(a));var b=b.sexpr,d=this.classifySexpr(b);"helper"===
|
||||
d?this.helperSexpr(b,c,a):"simple"===d?(this.simpleSexpr(b),this.opcode("pushProgram",c),this.opcode("pushProgram",a),this.opcode("emptyHash"),this.opcode("blockValue")):(this.ambiguousSexpr(b,c,a),this.opcode("pushProgram",c),this.opcode("pushProgram",a),this.opcode("emptyHash"),this.opcode("ambiguousBlockValue"));this.opcode("append")},hash:function(a){a=a.pairs;var b,c;this.opcode("pushHash");for(var d=0,f=a.length;d<f;d++)b=a[d],c=b[1],this.options.stringParams?(c.depth&&this.addDepth(c.depth),
|
||||
this.opcode("getContext",c.depth||0),this.opcode("pushStringParam",c.stringModeValue,c.type),"sexpr"===c.type&&this.sexpr(c)):this.accept(c),this.opcode("assignToHash",b[0]);this.opcode("popHash")},partial:function(a){var b=a.partialName;this.usePartial=!0;a.context?this.ID(a.context):this.opcode("push","depth0");this.opcode("invokePartial",b.name);this.opcode("append")},content:function(a){this.opcode("appendContent",a.string)},mustache:function(a){this.sexpr(a.sexpr);a.escaped&&!this.options.noEscape?
|
||||
this.opcode("appendEscaped"):this.opcode("append")},ambiguousSexpr:function(a,b,c){a=a.id;var d=a.parts[0],f=null!=b||null!=c;this.opcode("getContext",a.depth);this.opcode("pushProgram",b);this.opcode("pushProgram",c);this.opcode("invokeAmbiguous",d,f)},simpleSexpr:function(a){a=a.id;"DATA"===a.type?this.DATA(a):a.parts.length?this.ID(a):(this.addDepth(a.depth),this.opcode("getContext",a.depth),this.opcode("pushContext"));this.opcode("resolvePossibleLambda")},helperSexpr:function(a,b,c){b=this.setupFullMustacheParams(a,
|
||||
b,c);c=a.id.parts[0];if(this.options.knownHelpers[c])this.opcode("invokeKnownHelper",b.length,c);else{if(this.options.knownHelpersOnly)throw new j("You specified knownHelpersOnly, but used the unknown helper "+c,a);this.opcode("invokeHelper",b.length,c,a.isRoot)}},sexpr:function(a){var b=this.classifySexpr(a);"simple"===b?this.simpleSexpr(a):"helper"===b?this.helperSexpr(a):this.ambiguousSexpr(a)},ID:function(a){this.addDepth(a.depth);this.opcode("getContext",a.depth);a.parts[0]?this.opcode("lookupOnContext",
|
||||
a.parts[0]):this.opcode("pushContext");for(var b=1,c=a.parts.length;b<c;b++)this.opcode("lookup",a.parts[b])},DATA:function(a){this.options.data=!0;if(a.id.isScoped||a.id.depth)throw new j("Scoped data references are not supported: "+a.original,a);this.opcode("lookupData");a=a.id.parts;for(var b=0,c=a.length;b<c;b++)this.opcode("lookup",a[b])},STRING:function(a){this.opcode("pushString",a.string)},INTEGER:function(a){this.opcode("pushLiteral",a.integer)},BOOLEAN:function(a){this.opcode("pushLiteral",
|
||||
a.bool)},comment:function(){},opcode:function(a){this.opcodes.push({opcode:a,args:[].slice.call(arguments,1)})},declare:function(a,b){this.opcodes.push({opcode:"DECLARE",name:a,value:b})},addDepth:function(a){0!==a&&!this.depths[a]&&(this.depths[a]=!0,this.depths.list.push(a))},classifySexpr:function(a){var b=a.isHelper,c=a.eligibleHelper,d=this.options;c&&!b&&(d.knownHelpers[a.id.parts[0]]?b=!0:d.knownHelpersOnly&&(c=!1));return b?"helper":c?"ambiguous":"simple"},pushParams:function(a){for(var b=
|
||||
a.length,c;b--;)if(c=a[b],this.options.stringParams)c.depth&&this.addDepth(c.depth),this.opcode("getContext",c.depth||0),this.opcode("pushStringParam",c.stringModeValue,c.type),"sexpr"===c.type&&this.sexpr(c);else this[c.type](c)},setupFullMustacheParams:function(a,b,c){var d=a.params;this.pushParams(d);this.opcode("pushProgram",b);this.opcode("pushProgram",c);a.hash?this.hash(a.hash):this.opcode("emptyHash");return d}};var A=function(a){this.value=a},x=function(){},S=p.COMPILER_REVISION,Y=p.REVISION_CHANGES,
|
||||
T=p.log;x.prototype={nameLookup:function(a,b){var c,d;0===a.indexOf("depth")&&(c=!0);d=/^[0-9]+$/.test(b)?a+"["+b+"]":x.isValidJavaScriptVariableName(b)?a+"."+b:a+"['"+b+"']";return c?"("+a+" && "+d+")":d},compilerInfo:function(){return"this.compilerInfo = ["+S+",'"+Y[S]+"'];\n"},appendToBuffer:function(a){return this.environment.isSimple?"return "+a+";":{appendToBuffer:!0,content:a,toString:function(){return"buffer += "+a+";"}}},initializeBuffer:function(){return this.quotedString("")},namespace:"Handlebars",
|
||||
compile:function(a,b,c,d){this.environment=a;this.options=b||{};T("debug",this.environment.disassemble()+"\n\n");this.name=this.environment.name;this.isChild=!!c;this.context=c||{programs:[],environments:[],aliases:{}};this.preamble();this.stackSlot=0;this.stackVars=[];this.registers={list:[]};this.hashes=[];this.compileStack=[];this.inlineStack=[];this.compileChildren(a,b);a=a.opcodes;this.i=0;for(c=a.length;this.i<c;this.i++)b=a[this.i],"DECLARE"===b.opcode?this[b.name]=b.value:this[b.opcode].apply(this,
|
||||
b.args),b.opcode!==this.stripNext&&(this.stripNext=!1);this.pushSource("");if(this.stackSlot||this.inlineStack.length||this.compileStack.length)throw new j("Compile completed with content left on stack");return this.createFunctionContext(d)},preamble:function(){var a=[];if(this.isChild)a.push("");else{var b=this.namespace,c="helpers = this.merge(helpers, "+b+".helpers);";this.environment.usePartial&&(c=c+" partials = this.merge(partials, "+b+".partials);");this.options.data&&(c+=" data = data || {};");
|
||||
a.push(c)}this.environment.isSimple?a.push(""):a.push(", buffer = "+this.initializeBuffer());this.lastContext=0;this.source=a},createFunctionContext:function(a){var b=this.stackVars.concat(this.registers.list);0<b.length&&(this.source[1]=this.source[1]+", "+b.join(", "));if(!this.isChild)for(var c in this.context.aliases)this.context.aliases.hasOwnProperty(c)&&(this.source[1]=this.source[1]+", "+c+"="+this.context.aliases[c]);this.source[1]&&(this.source[1]="var "+this.source[1].substring(2)+";");
|
||||
this.isChild||(this.source[1]+="\n"+this.context.programs.join("\n")+"\n");this.environment.isSimple||this.pushSource("return buffer;");b=this.isChild?["depth0","data"]:["Handlebars","depth0","helpers","partials","data"];c=0;for(var d=this.environment.depths.list.length;c<d;c++)b.push("depth"+this.environment.depths.list[c]);c=this.mergeSource();this.isChild||(c=this.compilerInfo()+c);if(a)return b.push(c),Function.apply(this,b);a="function "+(this.name||"")+"("+b.join(",")+") {\n "+c+"}";T("debug",
|
||||
a+"\n\n");return a},mergeSource:function(){for(var a="",b,c=0,d=this.source.length;c<d;c++){var f=this.source[c];f.appendToBuffer?b=b?b+"\n + "+f.content:f.content:(b&&(a+="buffer += "+b+";\n ",b=void 0),a+=f+"\n ")}return a},blockValue:function(){this.context.aliases.blockHelperMissing="helpers.blockHelperMissing";var a=["depth0"];this.setupParams(0,a);this.replaceStack(function(b){a.splice(1,0,b);return"blockHelperMissing.call("+a.join(", ")+")"})},ambiguousBlockValue:function(){this.context.aliases.blockHelperMissing=
|
||||
"helpers.blockHelperMissing";var a=["depth0"];this.setupParams(0,a);var b=this.topStack();a.splice(1,0,b);this.pushSource("if (!"+this.lastHelper+") { "+b+" = blockHelperMissing.call("+a.join(", ")+"); }")},appendContent:function(a){this.pendingContent&&(a=this.pendingContent+a);this.stripNext&&(a=a.replace(/^\s+/,""));this.pendingContent=a},strip:function(){this.pendingContent&&(this.pendingContent=this.pendingContent.replace(/\s+$/,""));this.stripNext="strip"},append:function(){this.flushInline();
|
||||
var a=this.popStack();this.pushSource("if("+a+" || "+a+" === 0) { "+this.appendToBuffer(a)+" }");this.environment.isSimple&&this.pushSource("else { "+this.appendToBuffer("''")+" }")},appendEscaped:function(){this.context.aliases.escapeExpression="this.escapeExpression";this.pushSource(this.appendToBuffer("escapeExpression("+this.popStack()+")"))},getContext:function(a){this.lastContext!==a&&(this.lastContext=a)},lookupOnContext:function(a){this.push(this.nameLookup("depth"+this.lastContext,a,"context"))},
|
||||
pushContext:function(){this.pushStackLiteral("depth"+this.lastContext)},resolvePossibleLambda:function(){this.context.aliases.functionType='"function"';this.replaceStack(function(a){return"typeof "+a+" === functionType ? "+a+".apply(depth0) : "+a})},lookup:function(a){this.replaceStack(function(b){return b+" == null || "+b+" === false ? "+b+" : "+this.nameLookup(b,a,"context")})},lookupData:function(){this.pushStackLiteral("data")},pushStringParam:function(a,b){this.pushStackLiteral("depth"+this.lastContext);
|
||||
this.pushString(b);"sexpr"!==b&&("string"===typeof a?this.pushString(a):this.pushStackLiteral(a))},emptyHash:function(){this.pushStackLiteral("{}");this.options.stringParams&&(this.push("{}"),this.push("{}"))},pushHash:function(){this.hash&&this.hashes.push(this.hash);this.hash={values:[],types:[],contexts:[]}},popHash:function(){var a=this.hash;this.hash=this.hashes.pop();this.options.stringParams&&(this.push("{"+a.contexts.join(",")+"}"),this.push("{"+a.types.join(",")+"}"));this.push("{\n "+
|
||||
a.values.join(",\n ")+"\n }")},pushString:function(a){this.pushStackLiteral(this.quotedString(a))},push:function(a){this.inlineStack.push(a);return a},pushLiteral:function(a){this.pushStackLiteral(a)},pushProgram:function(a){null!=a?this.pushStackLiteral(this.programExpression(a)):this.pushStackLiteral(null)},invokeHelper:function(a,b,c){this.context.aliases.helperMissing="helpers.helperMissing";this.useRegister("helper");a=this.lastHelper=this.setupHelper(a,b,!0);b=this.nameLookup("depth"+this.lastContext,
|
||||
b,"context");b="helper = "+a.name+" || "+b;a.paramsInit&&(b+=","+a.paramsInit);this.push("("+b+",helper ? helper.call("+a.callParams+") : helperMissing.call("+a.helperMissingParams+"))");c||this.flushInline()},invokeKnownHelper:function(a,b){var c=this.setupHelper(a,b);this.push(c.name+".call("+c.callParams+")")},invokeAmbiguous:function(a,b){this.context.aliases.functionType='"function"';this.useRegister("helper");this.emptyHash();var c=this.setupHelper(0,a,b),d=this.lastHelper=this.nameLookup("helpers",
|
||||
a,"helper"),f=this.nameLookup("depth"+this.lastContext,a,"context"),e=this.nextStack();c.paramsInit&&this.pushSource(c.paramsInit);this.pushSource("if (helper = "+d+") { "+e+" = helper.call("+c.callParams+"); }");this.pushSource("else { helper = "+f+"; "+e+" = typeof helper === functionType ? helper.call("+c.callParams+") : helper; }")},invokePartial:function(a){a=[this.nameLookup("partials",a,"partial"),"'"+a+"'",this.popStack(),"helpers","partials"];this.options.data&&a.push("data");this.context.aliases.self=
|
||||
"this";this.push("self.invokePartial("+a.join(", ")+")")},assignToHash:function(a){var b=this.popStack(),c,d;this.options.stringParams&&(d=this.popStack(),c=this.popStack());var f=this.hash;c&&f.contexts.push("'"+a+"': "+c);d&&f.types.push("'"+a+"': "+d);f.values.push("'"+a+"': ("+b+")")},compiler:x,compileChildren:function(a,b){for(var c=a.children,d,f,e=0,h=c.length;e<h;e++){d=c[e];f=new this.compiler;var g=this.matchExistingProgram(d);null==g?(this.context.programs.push(""),g=this.context.programs.length,
|
||||
d.index=g,d.name="program"+g,this.context.programs[g]=f.compile(d,b,this.context),this.context.environments[g]=d):(d.index=g,d.name="program"+g)}},matchExistingProgram:function(a){for(var b=0,c=this.context.environments.length;b<c;b++){var d=this.context.environments[b];if(d&&d.equals(a))return b}},programExpression:function(a){this.context.aliases.self="this";if(null==a)return"self.noop";var b=this.environment.children[a];a=b.depths.list;for(var c=[b.index,b.name,"data"],d=0,f=a.length;d<f;d++)b=
|
||||
a[d],1===b?c.push("depth0"):c.push("depth"+(b-1));return(0===a.length?"self.program(":"self.programWithDepth(")+c.join(", ")+")"},register:function(a,b){this.useRegister(a);this.pushSource(a+" = "+b+";")},useRegister:function(a){this.registers[a]||(this.registers[a]=!0,this.registers.list.push(a))},pushStackLiteral:function(a){return this.push(new A(a))},pushSource:function(a){this.pendingContent&&(this.source.push(this.appendToBuffer(this.quotedString(this.pendingContent))),this.pendingContent=void 0);
|
||||
a&&this.source.push(a)},pushStack:function(a){this.flushInline();var b=this.incrStack();a&&this.pushSource(b+" = "+a+";");this.compileStack.push(b);return b},replaceStack:function(a){var b="",c=this.isInline(),d,f,e;c?(d=this.popStack(!0),d instanceof A?(d=d.value,e=!0):(f=!this.stackSlot,b=!f?this.topStackName():this.incrStack(),b="("+this.push(b)+" = "+d+"),",d=this.topStack())):d=this.topStack();a=a.call(this,d);c?(e||this.popStack(),f&&this.stackSlot--,this.push("("+b+a+")")):(/^stack/.test(d)||
|
||||
(d=this.nextStack()),this.pushSource(d+" = ("+b+a+");"));return d},nextStack:function(){return this.pushStack()},incrStack:function(){this.stackSlot++;this.stackSlot>this.stackVars.length&&this.stackVars.push("stack"+this.stackSlot);return this.topStackName()},topStackName:function(){return"stack"+this.stackSlot},flushInline:function(){var a=this.inlineStack;if(a.length){this.inlineStack=[];for(var b=0,c=a.length;b<c;b++){var d=a[b];d instanceof A?this.compileStack.push(d):this.pushStack(d)}}},isInline:function(){return this.inlineStack.length},
|
||||
popStack:function(a){var b=this.isInline(),c=(b?this.inlineStack:this.compileStack).pop();if(!a&&c instanceof A)return c.value;if(!b){if(!this.stackSlot)throw new j("Invalid stack pop");this.stackSlot--}return c},topStack:function(a){var b=this.isInline()?this.inlineStack:this.compileStack,b=b[b.length-1];return!a&&b instanceof A?b.value:b},quotedString:function(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,
|
||||
"\\u2029")+'"'},setupHelper:function(a,b,c){var d=[];a=this.setupParams(a,d,c);var f=this.nameLookup("helpers",b,"helper");return{params:d,paramsInit:a,name:f,callParams:["depth0"].concat(d).join(", "),helperMissingParams:c&&["depth0",this.quotedString(b)].concat(d).join(", ")}},setupOptions:function(a,b){var c=[],d=[],f=[],e,h;c.push("hash:"+this.popStack());this.options.stringParams&&(c.push("hashTypes:"+this.popStack()),c.push("hashContexts:"+this.popStack()));e=this.popStack();if((h=this.popStack())||
|
||||
e)h||(this.context.aliases.self="this",h="self.noop"),e||(this.context.aliases.self="this",e="self.noop"),c.push("inverse:"+e),c.push("fn:"+h);for(h=0;h<a;h++)e=this.popStack(),b.push(e),this.options.stringParams&&(f.push(this.popStack()),d.push(this.popStack()));this.options.stringParams&&(c.push("contexts:["+d.join(",")+"]"),c.push("types:["+f.join(",")+"]"));this.options.data&&c.push("data:data");return c},setupParams:function(a,b,c){a="{"+this.setupOptions(a,b).join(",")+"}";if(c)return this.useRegister("options"),
|
||||
b.push("options"),"options="+a;b.push(a);return""}};for(var n="break else new var case finally return void catch for switch while continue function this with default if throw delete in try do instanceof typeof abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public let yield".split(" "),D=x.RESERVED_WORDS={},L=0,Z=n.length;L<Z;L++)D[n[L]]=
|
||||
!0;x.isValidJavaScriptVariableName=function(a){return!x.RESERVED_WORDS[a]&&/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(a)?!0:!1};var $=function(a){if(a.constructor===C.ProgramNode)return a;J.yy=C;return J.parse(a)},aa=m.create,n=function(){var a=aa();a.compile=function(b,c){var d=c;if(null==b||"string"!==typeof b&&b.constructor!==a.AST.ProgramNode)throw new j("You must pass a string or Handlebars AST to Handlebars.compile. You passed "+b);d=d||{};"data"in d||(d.data=!0);var f;return function(c,h){if(!f){var g=
|
||||
a.parse(b),g=(new a.Compiler).compile(g,d),g=(new a.JavaScriptCompiler).compile(g,d,void 0,!0);f=a.template(g)}return f.call(this,c,h)}};a.precompile=function(b,c){var d=c;if(null==b||"string"!==typeof b&&b.constructor!==a.AST.ProgramNode)throw new j("You must pass a string or Handlebars AST to Handlebars.precompile. You passed "+b);d=d||{};"data"in d||(d.data=!0);var f=a.parse(b),f=(new a.Compiler).compile(f,d);return(new a.JavaScriptCompiler).compile(f,d)};a.AST=C;a.Compiler=K;a.JavaScriptCompiler=
|
||||
x;a.Parser=J;a.parse=$;return a},m=n();m.create=n;return m}();
|
4
src/mibew/js/libs/jquery.min.js
vendored
Normal file
4
src/mibew/js/libs/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
13
src/mibew/js/libs/json2.js
Normal file
13
src/mibew/js/libs/json2.js
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
json2.js
|
||||
2011-10-19
|
||||
Public Domain.
|
||||
See http://www.JSON.org/js.html
|
||||
*/
|
||||
var JSON;JSON||(JSON={});
|
||||
(function(){function k(a){return 10>a?"0"+a:a}function o(a){p.lastIndex=0;return p.test(a)?'"'+a.replace(p,function(a){var c=r[a];return"string"===typeof c?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function m(a,j){var c,d,h,n,g=e,f,b=j[a];b&&("object"===typeof b&&"function"===typeof b.toJSON)&&(b=b.toJSON(a));"function"===typeof i&&(b=i.call(j,a,b));switch(typeof b){case "string":return o(b);case "number":return isFinite(b)?String(b):"null";case "boolean":case "null":return String(b);case "object":if(!b)return"null";
|
||||
e+=l;f=[];if("[object Array]"===Object.prototype.toString.apply(b)){n=b.length;for(c=0;c<n;c+=1)f[c]=m(c,b)||"null";h=0===f.length?"[]":e?"[\n"+e+f.join(",\n"+e)+"\n"+g+"]":"["+f.join(",")+"]";e=g;return h}if(i&&"object"===typeof i){n=i.length;for(c=0;c<n;c+=1)"string"===typeof i[c]&&(d=i[c],(h=m(d,b))&&f.push(o(d)+(e?": ":":")+h))}else for(d in b)Object.prototype.hasOwnProperty.call(b,d)&&(h=m(d,b))&&f.push(o(d)+(e?": ":":")+h);h=0===f.length?"{}":e?"{\n"+e+f.join(",\n"+e)+"\n"+g+"}":"{"+f.join(",")+
|
||||
"}";e=g;return h}}"function"!==typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+k(this.getUTCMonth()+1)+"-"+k(this.getUTCDate())+"T"+k(this.getUTCHours())+":"+k(this.getUTCMinutes())+":"+k(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var q=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
p=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,e,l,r={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},i;"function"!==typeof JSON.stringify&&(JSON.stringify=function(a,j,c){var d;l=e="";if(typeof c==="number")for(d=0;d<c;d=d+1)l=l+" ";else typeof c==="string"&&(l=c);if((i=j)&&typeof j!=="function"&&(typeof j!=="object"||typeof j.length!=="number"))throw Error("JSON.stringify");return m("",{"":a})});
|
||||
"function"!==typeof JSON.parse&&(JSON.parse=function(a,e){function c(a,d){var g,f,b=a[d];if(b&&typeof b==="object")for(g in b)if(Object.prototype.hasOwnProperty.call(b,g)){f=c(b,g);f!==void 0?b[g]=f:delete b[g]}return e.call(a,d,b)}var d,a=String(a);q.lastIndex=0;q.test(a)&&(a=a.replace(q,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
|
||||
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){d=eval("("+a+")");return typeof e==="function"?c({"":d},""):d}throw new SyntaxError("JSON.parse");})})();
|
6
src/mibew/js/libs/underscore-min.js
vendored
Normal file
6
src/mibew/js/libs/underscore-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,37 +0,0 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, $) {
|
||||
$(document).ready(function() {
|
||||
$('a.remove-link').click(function() {
|
||||
var url = $(this).attr('href'),
|
||||
message = Mibew.Localization.trans(
|
||||
'Are you sure that you want to delete address {0} from the blocked list?',
|
||||
$(this).data('ban-address')
|
||||
);
|
||||
|
||||
Mibew.Utils.confirm(message, function(value) {
|
||||
if (value) {
|
||||
window.location.href = url;
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
})(Mibew, jQuery);
|
38
src/mibew/js/source/brws.js
Normal file
38
src/mibew/js/source/brws.js
Normal file
@ -0,0 +1,38 @@
|
||||
/*!
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
var myAgent = "";
|
||||
var myVer = 0;
|
||||
var myRealAgent = "";
|
||||
|
||||
function detectAgent() {
|
||||
var AGENTS = ["opera","msie","safari","firefox","netscape","mozilla"];
|
||||
var agent = navigator.userAgent.toLowerCase();
|
||||
for (var i = 0; i < AGENTS.length; i++) {
|
||||
var agentStr = AGENTS[i];
|
||||
if (agent.indexOf(agentStr) != -1) {
|
||||
myAgent = agentStr;
|
||||
if (!window.RegExp)
|
||||
break;
|
||||
|
||||
var versionExpr = new RegExp(agentStr + "[ \/]?([0-9]+(\.[0-9]+)?)");
|
||||
if (versionExpr.exec(agent) != null) {
|
||||
myVer = parseFloat(RegExp.$1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
myRealAgent = myAgent;
|
||||
if( navigator.product == "Gecko")
|
||||
myAgent = "moz";
|
||||
}
|
||||
detectAgent();
|
||||
|
||||
function getEl(name) {
|
||||
return document.getElementById(name);
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, $) {
|
||||
$(document).ready(function(){
|
||||
$('#copy-button-code').click(function(e){
|
||||
$("#button-code").select();
|
||||
document.execCommand('copy');
|
||||
});
|
||||
});
|
||||
})(Mibew, jQuery);
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function (Mibew, _) {
|
||||
@ -28,6 +18,9 @@
|
||||
|
||||
// Initialize application
|
||||
app.addInitializer(function(options){
|
||||
// Store plugin options
|
||||
Mibew.PluginOptions = options.plugins || {};
|
||||
|
||||
// Initialize Server
|
||||
Mibew.Objects.server = new Mibew.Server(_.extend(
|
||||
{'interactionType': MibewAPIChatInteraction},
|
||||
@ -51,7 +44,8 @@
|
||||
app.Invitation.start(options.invitationOptions);
|
||||
break;
|
||||
default:
|
||||
throw new Error("Don't know how to start!");
|
||||
throw new Error('Dont know how to start!');
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew) {
|
||||
@ -24,25 +14,17 @@
|
||||
Mibew.Views.MessagesCollection = Mibew.Views.CollectionBase.extend(
|
||||
/** @lends Mibew.Views.MessagesCollection.prototype */
|
||||
{
|
||||
/**
|
||||
* Default item view constructor.
|
||||
* @type Function
|
||||
*/
|
||||
itemView: Mibew.Views.Message,
|
||||
|
||||
/**
|
||||
* Class name for view's DOM element
|
||||
* @type String
|
||||
*/
|
||||
className: 'messages-collection',
|
||||
|
||||
/**
|
||||
* Returns default child view constructor.
|
||||
*
|
||||
* The function is used instead of "childView" property to provide
|
||||
* an ability to override child view constructor without this class
|
||||
* overriding.
|
||||
*
|
||||
* @param {Backbone.Model} model The model the view created for.
|
||||
* @returns {Backbone.Marionette.ItemView}
|
||||
*/
|
||||
getChildView: function(model) {
|
||||
return Mibew.Views.Message;
|
||||
}
|
||||
className: 'messages-collection'
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew) {
|
||||
@ -24,25 +14,17 @@
|
||||
Mibew.Views.StatusCollection = Mibew.Views.CollectionBase.extend(
|
||||
/** @lends Mibew.Views.StatusCollection.prototype */
|
||||
{
|
||||
/**
|
||||
* Default item view constructor.
|
||||
* @type Function
|
||||
*/
|
||||
itemView: Mibew.Views.Status,
|
||||
|
||||
/**
|
||||
* Class name for view's DOM element
|
||||
* @type String
|
||||
*/
|
||||
className: 'status-collection',
|
||||
|
||||
/**
|
||||
* Returns default child view constructor.
|
||||
*
|
||||
* The function is used instead of "childView" property to provide
|
||||
* an ability to override child view constructor without this class
|
||||
* overriding.
|
||||
*
|
||||
* @param {Backbone.Model} model The model the view created for.
|
||||
* @returns {Backbone.Marionette.ItemView}
|
||||
*/
|
||||
getChildView: function(model) {
|
||||
return Mibew.Views.Status;
|
||||
}
|
||||
className: 'status-collection'
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone, _){
|
||||
@ -119,7 +109,7 @@
|
||||
eventArgs = {
|
||||
'messageData': messageData,
|
||||
'model': false
|
||||
};
|
||||
}
|
||||
|
||||
// Trigger event. See description of eventName and eventArgs
|
||||
// above.
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone){
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew){
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone){
|
||||
@ -21,7 +11,7 @@
|
||||
/**
|
||||
* Represents chat layout
|
||||
*/
|
||||
Mibew.Layouts.Chat = Backbone.Marionette.LayoutView.extend(
|
||||
Mibew.Layouts.Chat = Backbone.Marionette.Layout.extend(
|
||||
/** @lends Mibew.Layouts.Chat.prototype */
|
||||
{
|
||||
/**
|
||||
@ -39,7 +29,7 @@
|
||||
avatarRegion: '#avatar-region',
|
||||
messagesRegion: {
|
||||
selector: '#messages-region',
|
||||
regionClass: Mibew.Regions.Messages
|
||||
regionType: Mibew.Regions.Messages
|
||||
},
|
||||
statusRegion: '#status-region',
|
||||
messageFormRegion: '#message-form-region'
|
||||
@ -59,7 +49,7 @@
|
||||
return {
|
||||
page: models.page.toJSON(),
|
||||
user: models.user.toJSON()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone){
|
||||
@ -21,7 +11,7 @@
|
||||
/**
|
||||
* Represents invitation layout
|
||||
*/
|
||||
Mibew.Layouts.Invitation = Backbone.Marionette.LayoutView.extend(
|
||||
Mibew.Layouts.Invitation = Backbone.Marionette.Layout.extend(
|
||||
/** @lends Mibew.Layouts.Invitation.prototype */
|
||||
{
|
||||
/**
|
||||
@ -37,7 +27,7 @@
|
||||
regions: {
|
||||
messagesRegion: {
|
||||
selector: '#invitation-messages-region',
|
||||
regionClass: Mibew.Regions.Messages
|
||||
regionType: Mibew.Regions.Messages
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone){
|
||||
@ -21,7 +11,7 @@
|
||||
/**
|
||||
* Represents leave message page layout
|
||||
*/
|
||||
Mibew.Layouts.LeaveMessage = Backbone.Marionette.LayoutView.extend(
|
||||
Mibew.Layouts.LeaveMessage = Backbone.Marionette.Layout.extend(
|
||||
/** @lends Mibew.Layouts.LeaveMessage.prototype */
|
||||
{
|
||||
/**
|
||||
@ -51,7 +41,7 @@
|
||||
serializeData: function() {
|
||||
return {
|
||||
page: Mibew.Objects.Models.page.toJSON()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone){
|
||||
@ -21,7 +11,7 @@
|
||||
/**
|
||||
* Represents survey layout
|
||||
*/
|
||||
Mibew.Layouts.Survey = Backbone.Marionette.LayoutView.extend(
|
||||
Mibew.Layouts.Survey = Backbone.Marionette.Layout.extend(
|
||||
/** @lends Mibew.Layouts.Survey.prototype */
|
||||
{
|
||||
/**
|
||||
@ -50,7 +40,7 @@
|
||||
serializeData: function() {
|
||||
return {
|
||||
page: Mibew.Objects.Models.page.toJSON()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -40,6 +30,6 @@ MibewAPIChatInteraction = function() {
|
||||
return [
|
||||
'result'
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
MibewAPIChatInteraction.prototype = new MibewAPIInteraction();
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone, Handlebars) {
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars, _) {
|
||||
@ -49,15 +39,13 @@
|
||||
*/
|
||||
closeThread: function() {
|
||||
// Show confirmation message if can
|
||||
var confirmMessage = Mibew.Localization.trans('Are you sure that you want to leave the chat?'),
|
||||
context = this;
|
||||
var confirmMessage = Mibew.Localization.get('Are you sure want to leave chat?');
|
||||
if (confirmMessage !== false) {
|
||||
Mibew.Utils.confirm(confirmMessage, function(value) {
|
||||
if (value) {
|
||||
context.model.closeThread();
|
||||
}
|
||||
});
|
||||
if (! confirm(confirmMessage)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.model.closeThread();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars, _) {
|
||||
@ -45,13 +35,13 @@
|
||||
),
|
||||
|
||||
/**
|
||||
* Display history window
|
||||
* Dispalay history window
|
||||
*/
|
||||
showHistory: function() {
|
||||
var user = Mibew.Objects.Models.user;
|
||||
var link = this.model.get('link');
|
||||
if (user.get('isAgent') && link) {
|
||||
var winParams = Mibew.Utils.buildWindowParams(this.model.get('windowParams'));
|
||||
var winParams = this.model.get('windowParams');
|
||||
|
||||
// TODO: Kill & at the server side
|
||||
link = link.replace('&', '&', 'g');
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars, _) {
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars, _) {
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars, _) {
|
||||
@ -48,15 +38,11 @@
|
||||
* Move to secure chat
|
||||
*/
|
||||
secure: function() {
|
||||
if (window.location.protocol == 'https:') {
|
||||
return;
|
||||
}
|
||||
var link = this.model.get('link');
|
||||
var link = this.model.get('link')
|
||||
if (link) {
|
||||
var style = Mibew.Objects.Models.page.get('style');
|
||||
window.location.href = link.replace(/\&\;/g, '&')
|
||||
+ (style ? ((link.indexOf('?') > -1 ? '&' : '?')
|
||||
+ 'style=' + style) : '');
|
||||
+ (style ? ('&style=' + style) : '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars, _) {
|
||||
@ -44,17 +34,6 @@
|
||||
}
|
||||
),
|
||||
|
||||
/**
|
||||
* Override Backbone.Marionette.ItemView.serializeData to pass some
|
||||
* extra fields to template.
|
||||
* @returns {Object} Template data
|
||||
*/
|
||||
serializeData: function() {
|
||||
var data = this.model.toJSON();
|
||||
data.user = Mibew.Objects.Models.user.toJSON();
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Load and display send mail window
|
||||
*/
|
||||
@ -62,7 +41,7 @@
|
||||
var link = this.model.get('link');
|
||||
var page = Mibew.Objects.Models.page;
|
||||
if (link) {
|
||||
var winParams = Mibew.Utils.buildWindowParams(this.model.get('windowParams'));
|
||||
var winParams = this.model.get('windowParams');
|
||||
|
||||
var style = page.get('style');
|
||||
var styleArg = '';
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars, _) {
|
||||
|
@ -1,68 +0,0 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars, _) {
|
||||
/**
|
||||
* @class Represents Tracked path control view
|
||||
*/
|
||||
Mibew.Views.TrackedPathControl = Mibew.Views.Control.extend(
|
||||
/** @lends Mibew.Views.TrackedPathControl.prototype */
|
||||
{
|
||||
/**
|
||||
* Template function
|
||||
* @type Function
|
||||
*/
|
||||
template: Handlebars.templates['chat/controls/tracked_path'],
|
||||
|
||||
/**
|
||||
* Map ui events to view methods
|
||||
* The view inherits events from
|
||||
* {@link Mibew.Views.Control.prototype.events}.
|
||||
* @type Object
|
||||
*/
|
||||
events: _.extend(
|
||||
{},
|
||||
Mibew.Views.Control.prototype.events,
|
||||
{
|
||||
'click': 'showTrackedPath'
|
||||
}
|
||||
),
|
||||
|
||||
/**
|
||||
* Display tracked path window
|
||||
*/
|
||||
showTrackedPath: function() {
|
||||
var user = Mibew.Objects.Models.user;
|
||||
var link = this.model.get('link');
|
||||
if (user.get('isAgent') && link) {
|
||||
var winParams = Mibew.Utils.buildWindowParams(this.model.get('windowParams'));
|
||||
|
||||
// TODO: Kill & at the server side
|
||||
link = link.replace('&', '&', 'g');
|
||||
|
||||
var newWindow = window.open(link, 'UserTrackedPath', winParams);
|
||||
if (newWindow !== null) {
|
||||
newWindow.focus();
|
||||
newWindow.opener=window;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
})(Mibew, Handlebars, _);
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars, _) {
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone, Handlebars){
|
||||
@ -42,7 +32,7 @@
|
||||
serializeData: function() {
|
||||
return {
|
||||
page: Mibew.Objects.Models.page.toJSON()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars, _){
|
||||
@ -81,7 +71,7 @@
|
||||
|
||||
// Update group id
|
||||
if (this.model.get('groups')) {
|
||||
values.groupId = this.ui.groupSelect.val();
|
||||
values.groupId = this.ui.groupSelect.val()
|
||||
}
|
||||
|
||||
// Update name
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone, Handlebars){
|
||||
@ -42,7 +32,7 @@
|
||||
serializeData: function() {
|
||||
return {
|
||||
page: Mibew.Objects.Models.page.toJSON()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars) {
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone, Handlebars) {
|
||||
@ -40,7 +30,9 @@
|
||||
'keydown #message-input': 'messageKeyDown',
|
||||
'keyup #message-input': 'checkUserTyping',
|
||||
'change #message-input': 'checkUserTyping',
|
||||
'change #predefined': 'selectPredefinedAnswer'
|
||||
'change #predefined': 'selectPredefinedAnswer',
|
||||
'focus #message-input': 'setFocus',
|
||||
'blur #message-input': 'dropFocus'
|
||||
},
|
||||
|
||||
/**
|
||||
@ -76,7 +68,6 @@
|
||||
serializeData: function() {
|
||||
var data = this.model.toJSON();
|
||||
data.user = Mibew.Objects.Models.user.toJSON();
|
||||
data.sendShortcut = this.getSendShortcut();
|
||||
return data;
|
||||
},
|
||||
|
||||
@ -84,9 +75,6 @@
|
||||
* Get, check and post message
|
||||
*/
|
||||
postMessage: function() {
|
||||
if (this.isDisabledInput()){
|
||||
return;
|
||||
}
|
||||
var msg = this.ui.message.val();
|
||||
// TODO: Think about it
|
||||
// Cut multiple line breaks
|
||||
@ -94,12 +82,12 @@
|
||||
if (msg != '') {
|
||||
this.disableInput();
|
||||
this.model.postMessage(msg);
|
||||
Mibew.Objects.Collections.messages.once(
|
||||
'multiple:add',
|
||||
this.postMessageComplete,
|
||||
this
|
||||
);
|
||||
}
|
||||
Mibew.Objects.Collections.messages.on(
|
||||
'multiple:add',
|
||||
this.postMessageComplete,
|
||||
this
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -132,13 +120,6 @@
|
||||
},
|
||||
|
||||
/**
|
||||
* Check is disabled message input area
|
||||
*/
|
||||
isDisabledInput: function() {
|
||||
return this.ui.message.attr('disabled') == 'disabled';
|
||||
},
|
||||
|
||||
/**svn
|
||||
* Clear message input area
|
||||
*/
|
||||
clearInput: function() {
|
||||
@ -157,8 +138,14 @@
|
||||
postMessageComplete: function() {
|
||||
this.clearInput();
|
||||
this.enableInput();
|
||||
// Always set focus on message input after message sent
|
||||
this.ui.message.focus();
|
||||
if (this.focused) {
|
||||
this.ui.focus();
|
||||
}
|
||||
Mibew.Objects.Collections.messages.off(
|
||||
'multiple:add',
|
||||
this.postMessageComplete,
|
||||
this
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -196,20 +183,17 @@
|
||||
},
|
||||
|
||||
/**
|
||||
* Builds a string with send shortcut.
|
||||
*
|
||||
* @returns {String}
|
||||
* Set focus indicator
|
||||
*/
|
||||
getSendShortcut: function() {
|
||||
if (this.model.get('ignoreCtrl')) {
|
||||
return 'Enter';
|
||||
}
|
||||
setFocus: function() {
|
||||
this.focused = true
|
||||
},
|
||||
|
||||
// There is no Ctrl key on mac, thus we need to use a command
|
||||
// key instead.
|
||||
return (navigator.userAgent.indexOf('mac') !== -1)
|
||||
? '⌘-Enter'
|
||||
: 'Ctrl-Enter';
|
||||
/**
|
||||
* Unset focus indicator
|
||||
*/
|
||||
dropFocus: function() {
|
||||
this.focused = false;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone, Handlebars) {
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars) {
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars) {
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone){
|
||||
@ -39,7 +29,7 @@
|
||||
*/
|
||||
ui: {
|
||||
groupSelect: 'select[name="group"]',
|
||||
groupDescription: '#group-description',
|
||||
groupDescription: '#groupDescription',
|
||||
name: 'input[name="name"]',
|
||||
email: 'input[name="email"]',
|
||||
message: 'textarea[name="message"]',
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars, _){
|
||||
@ -58,7 +48,7 @@
|
||||
|
||||
// Update group id
|
||||
if (this.model.get('groups')) {
|
||||
values.groupId = this.ui.groupSelect.val();
|
||||
values.groupId = this.ui.groupSelect.val()
|
||||
}
|
||||
|
||||
// Update name
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _){
|
||||
@ -54,13 +44,6 @@
|
||||
_.bind(this.apiSetupAvatar, this)
|
||||
)
|
||||
);
|
||||
|
||||
// Update avatar if operator changed.
|
||||
Mibew.Objects.Models.thread.on(
|
||||
'change:agentId',
|
||||
this.setFromThread,
|
||||
this
|
||||
);
|
||||
},
|
||||
|
||||
// Model finalizer
|
||||
@ -79,37 +62,9 @@
|
||||
* @param args {Object} An object of passed arguments
|
||||
*/
|
||||
apiSetupAvatar: function(args) {
|
||||
this.set({imageLink: (args.imageLink || false)});
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets avatar based on data from the thread.
|
||||
* @param {Object} thread An instance of Mibew.Models.Thread
|
||||
*/
|
||||
setFromThread: function(thread) {
|
||||
if (!thread.get('agentId')) {
|
||||
// There is no operator. Hide the avatar.
|
||||
this.set({imageLink: false});
|
||||
|
||||
return;
|
||||
if (args.imageLink) {
|
||||
this.set({imageLink: args.imageLink});
|
||||
}
|
||||
|
||||
// Request operator's avatar at the server side
|
||||
Mibew.Objects.server.callFunctions(
|
||||
[{
|
||||
'function': 'getAvatar',
|
||||
'arguments': {
|
||||
'references': {},
|
||||
'return': {
|
||||
'imageLink': 'imageLink'
|
||||
},
|
||||
'threadId': thread.get('id'),
|
||||
'token': thread.get('token')
|
||||
}
|
||||
}],
|
||||
_.bind(this.apiSetupAvatar, this),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _) {
|
||||
@ -57,7 +47,7 @@
|
||||
* Not applicable for agents.
|
||||
* @type Boolean
|
||||
*/
|
||||
defaultName: true
|
||||
dafaultName: true
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew){
|
||||
@ -59,7 +49,7 @@
|
||||
}],
|
||||
function(args){
|
||||
if (args.closed) {
|
||||
Mibew.Utils.closeChatPopup();
|
||||
window.close();
|
||||
} else {
|
||||
// Something went wrong. Display error message
|
||||
Mibew.Objects.Models.Status.message.setMessage(
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _){
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _){
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew){
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _){
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _){
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _){
|
||||
@ -60,7 +50,7 @@
|
||||
* @returns {String} Model type
|
||||
*/
|
||||
getModelType: function() {
|
||||
return 'SoundControl';
|
||||
return 'SoundControl'
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -1,63 +0,0 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _){
|
||||
|
||||
/**
|
||||
* @class Tracked path control model
|
||||
*/
|
||||
Mibew.Models.TrackedPathControl = Mibew.Models.Control.extend(
|
||||
/** @lends Mibew.Models.TrackedPathControl.prototype */
|
||||
{
|
||||
/**
|
||||
* A list of default model values.
|
||||
*
|
||||
* The model inherits defaults from
|
||||
* {@link Mibew.Models.Control.prototype.defaults}.
|
||||
* @type Object
|
||||
*/
|
||||
defaults: _.extend(
|
||||
{},
|
||||
Mibew.Models.Control.prototype.defaults,
|
||||
{
|
||||
/**
|
||||
* An URL of the tracked path page or false by default.
|
||||
* @type String|Boolean
|
||||
*/
|
||||
link: false,
|
||||
|
||||
/**
|
||||
* Params string for tracked path popup window
|
||||
* @type String
|
||||
*/
|
||||
windowParams: ''
|
||||
}
|
||||
),
|
||||
|
||||
/**
|
||||
* Returns model type
|
||||
* @returns {String} Model type
|
||||
*/
|
||||
getModelType: function() {
|
||||
return 'TrackedPathControl';
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
})(Mibew, _);
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew){
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _){
|
||||
@ -63,24 +53,24 @@
|
||||
// Check email
|
||||
if (typeof attributes.email != 'undefined') {
|
||||
if (! attributes.email) {
|
||||
return l.trans('Please fill "{0}".', l.trans('Your email'));
|
||||
return l.get('leavemessage.error.email.required');
|
||||
}
|
||||
if(! Mibew.Utils.checkEmail(attributes.email)) {
|
||||
return l.trans('Please fill "{0}" correctly.', l.trans('Your email'));
|
||||
return l.get('leavemessage.error.wrong.email');
|
||||
}
|
||||
}
|
||||
|
||||
// Check name
|
||||
if (typeof attributes.name != 'undefined') {
|
||||
if (! attributes.name) {
|
||||
return l.trans('Please fill "{0}".', l.trans('Your name'));
|
||||
return l.get('leavemessage.error.name.required');
|
||||
}
|
||||
}
|
||||
|
||||
// Check message
|
||||
if (typeof attributes.message != 'undefined') {
|
||||
if (! attributes.message) {
|
||||
return l.trans('Please fill "{0}".', l.trans('Message'));
|
||||
return l.get('leavemessage.error.message.required');
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +78,7 @@
|
||||
if (this.get('showCaptcha')) {
|
||||
if (typeof attributes.captcha != 'undefined') {
|
||||
if (! attributes.captcha) {
|
||||
return l.trans('The letters you typed don\'t match the letters that were shown in the picture.');
|
||||
return l.get('The letters you typed don\'t match the letters that were shown in the picture.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew){
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone) {
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _) {
|
||||
@ -70,7 +60,7 @@
|
||||
playNewMessageSound: function() {
|
||||
if (! this.get('skipNextMessageSound')) {
|
||||
// Build sound path
|
||||
var path = Mibew.Objects.Models.page.get('mibewBasePath');
|
||||
var path = Mibew.Objects.Models.page.get('mibewRoot');
|
||||
if (typeof path !== 'undefined') {
|
||||
path += '/sounds/new_message';
|
||||
// Play sound
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _){
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _){
|
||||
@ -53,7 +43,7 @@
|
||||
* @returns {String} Model type
|
||||
*/
|
||||
getModelType: function() {
|
||||
return 'StatusMessage';
|
||||
return 'StatusMessage'
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _){
|
||||
@ -55,7 +45,7 @@
|
||||
* @returns {String} Model type
|
||||
*/
|
||||
getModelType: function() {
|
||||
return 'StatusTyping';
|
||||
return 'StatusTyping'
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew){
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _){
|
||||
@ -61,23 +51,11 @@
|
||||
* @param Object attributes Attributes hash for test
|
||||
*/
|
||||
validate: function(attributes) {
|
||||
// Check visitor's name
|
||||
if (this.get('canChangeName') && typeof attributes.name != 'undefined') {
|
||||
var trimmedName = attributes.name
|
||||
// Remove leading spaces from the name
|
||||
.replace(/^\s+/, '')
|
||||
// Remove trailing spaces from the name
|
||||
.replace(/\s+$/, '');
|
||||
if (trimmedName.length === 0) {
|
||||
return Mibew.Localization.trans('Name is required.');
|
||||
}
|
||||
}
|
||||
|
||||
// Check email
|
||||
if (this.get('showEmail')) {
|
||||
if (typeof attributes.email != 'undefined') {
|
||||
if(! Mibew.Utils.checkEmail(attributes.email)) {
|
||||
return Mibew.Localization.trans(
|
||||
return Mibew.Localization.get(
|
||||
'Wrong email address.'
|
||||
);
|
||||
}
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew){
|
||||
@ -101,15 +91,6 @@
|
||||
windowParams: options.windowsParams.history
|
||||
});
|
||||
ctrlsCollection.add(controls.history);
|
||||
|
||||
if (options.links.tracked) {
|
||||
controls.tracked_path = new Mibew.Models.TrackedPathControl({
|
||||
weight: 170,
|
||||
link: options.links.tracked,
|
||||
windowParams: options.windowsParams.trackedPath
|
||||
});
|
||||
ctrlsCollection.add(controls.tracked_path);
|
||||
}
|
||||
}
|
||||
|
||||
// Create toggle sound button
|
||||
@ -167,9 +148,7 @@
|
||||
|
||||
// Initialize avatar only for user
|
||||
if (! models.user.get('isAgent')) {
|
||||
models.avatar = new Mibew.Models.Avatar({
|
||||
imageLink: (options.avatar || false)
|
||||
});
|
||||
models.avatar = new Mibew.Models.Avatar();
|
||||
layout.avatarRegion.show(new Mibew.Views.Avatar({
|
||||
model: models.avatar
|
||||
}));
|
||||
@ -197,15 +176,6 @@
|
||||
|
||||
models.soundManager = new Mibew.Models.ChatSoundManager();
|
||||
|
||||
// If the chat is ran inside an iframe we need to tell the parent page
|
||||
// that the chat is started. This is needed to reopen chat when the user
|
||||
// navigates to another page.
|
||||
if (!models.user.get('isAgent') && options.links.chat) {
|
||||
if (window.parent && window.parent.postMessage && (window.parent !== window)) {
|
||||
window.parent.postMessage('mibew-chat-started:' + window.name + ':' + options.links.chat, '*');
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: May be move it somewhere else
|
||||
// Periodically call update function at the server side
|
||||
periodicallyCalled.push(
|
||||
@ -221,8 +191,6 @@
|
||||
"function": "update",
|
||||
"arguments": {
|
||||
"return": {
|
||||
'threadState': 'threadState',
|
||||
'threadAgentId': 'threadAgentId',
|
||||
'typing': 'typing',
|
||||
'canPost': 'canPost'
|
||||
},
|
||||
@ -234,7 +202,7 @@
|
||||
"user": (! user.get('isAgent'))
|
||||
}
|
||||
}
|
||||
];
|
||||
]
|
||||
},
|
||||
function(args) {
|
||||
// Check if there was an error
|
||||
@ -252,11 +220,6 @@
|
||||
Mibew.Objects.Models.user.set({
|
||||
canPost: args.canPost || false
|
||||
});
|
||||
// Update thread fields
|
||||
Mibew.Objects.Models.thread.set({
|
||||
'agentId': args.threadAgentId,
|
||||
'state': args.threadState
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
@ -267,12 +230,12 @@
|
||||
// Restart server updater because module just started and there are no
|
||||
// reasons to wait refresh time to get results of previous request
|
||||
Mibew.Objects.server.restartUpdater();
|
||||
});
|
||||
})
|
||||
|
||||
// Add module finalizer
|
||||
chat.addFinalizer(function() {
|
||||
// Close layout
|
||||
Mibew.Objects.chatLayout.destroy();
|
||||
Mibew.Objects.chatLayout.close();
|
||||
|
||||
|
||||
// Stop call functions periodically
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew){
|
||||
@ -78,7 +68,7 @@
|
||||
"user": true
|
||||
}
|
||||
}
|
||||
];
|
||||
]
|
||||
},
|
||||
function() {}
|
||||
)
|
||||
@ -90,12 +80,12 @@
|
||||
// Restart server updater because module just started and there are no
|
||||
// reasons to wait refresh time to get results of previous request
|
||||
Mibew.Objects.server.restartUpdater();
|
||||
});
|
||||
})
|
||||
|
||||
// Add module finalizer
|
||||
invitation.addFinalizer(function() {
|
||||
// Close layout
|
||||
Mibew.Objects.invitationLayout.destroy();
|
||||
Mibew.Objects.invitationLayout.close();
|
||||
|
||||
|
||||
// Stop call functions periodically
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew){
|
||||
@ -58,8 +48,8 @@
|
||||
// When message sent form should be hide and description should be
|
||||
// changed
|
||||
models.leaveMessageForm.on('submit:complete', function() {
|
||||
objs.leaveMessageLayout.leaveMessageFormRegion.empty();
|
||||
objs.leaveMessageLayout.descriptionRegion.empty();
|
||||
objs.leaveMessageLayout.leaveMessageFormRegion.close();
|
||||
objs.leaveMessageLayout.descriptionRegion.close();
|
||||
|
||||
objs.leaveMessageLayout.descriptionRegion.show(
|
||||
new Mibew.Views.LeaveMessageSentDescription()
|
||||
@ -71,7 +61,7 @@
|
||||
// Add module finalizer
|
||||
leaveMessage.addFinalizer(function() {
|
||||
// Close layout
|
||||
Mibew.Objects.leaveMessageLayout.destroy();
|
||||
Mibew.Objects.leaveMessageLayout.close();
|
||||
|
||||
// Remove instance of leaveMessage form model
|
||||
delete Mibew.Objects.Models.leaveMessageForm;
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew){
|
||||
@ -50,7 +40,7 @@
|
||||
// Add module finalizer
|
||||
survey.addFinalizer(function() {
|
||||
// Close layout
|
||||
Mibew.Objects.surveyLayout.destroy();
|
||||
Mibew.Objects.surveyLayout.close();
|
||||
|
||||
// Remove instance of survey form model
|
||||
delete Mibew.Objects.Models.surveyForm;
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone){
|
||||
@ -26,11 +16,11 @@
|
||||
{
|
||||
/**
|
||||
* Show view event handler. Register handler to view's
|
||||
* 'add:child' event.
|
||||
* 'after:item:added' event.
|
||||
* @param {Backbone.Marionette.ItemView} view View to show in region
|
||||
*/
|
||||
onShow: function(view) {
|
||||
view.on('add:child', this.scrollToBottom, this);
|
||||
view.on('after:item:added', this.scrollToBottom, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew){
|
||||
|
||||
/**
|
||||
* @namespace Holds utility functions
|
||||
*/
|
||||
Mibew.Utils = Mibew.Utils || {};
|
||||
|
||||
/**
|
||||
* Closes chat window.
|
||||
*
|
||||
* The method helps to close chat popup no mater how it's implemented
|
||||
* (iframe or window).
|
||||
*/
|
||||
Mibew.Utils.closeChatPopup = function() {
|
||||
if (window.parent && (window.parent !== window) && window.parent.postMessage) {
|
||||
// It seems that the chat is working in an iframe. Tell the parent
|
||||
// window that the chat is stoped so it could close the iframe.
|
||||
window.parent.postMessage('mibew-chat-closed:' + window.name, '*');
|
||||
} else {
|
||||
// Just close the window.
|
||||
window.close();
|
||||
}
|
||||
};
|
||||
|
||||
})(Mibew);
|
@ -1,629 +0,0 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @namespace Holds all Mibew Messenger functionality
|
||||
*/
|
||||
var Mibew = Mibew || {};
|
||||
|
||||
(function(Mibew) {
|
||||
if (Mibew.ChatPopup) {
|
||||
// It seems that this file was already loaded. We do not need to do the
|
||||
// job twice.
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @namespace Holds all functionality related with chat popups
|
||||
*/
|
||||
Mibew.ChatPopup = {};
|
||||
|
||||
/**
|
||||
* @namespace Holds objects instances
|
||||
*/
|
||||
Mibew.Objects = Mibew.Objects || {};
|
||||
|
||||
/**
|
||||
* @namespace Holds all popups instances.
|
||||
*/
|
||||
Mibew.Objects.ChatPopups = {};
|
||||
|
||||
/**
|
||||
* @namespace Holds utility functions
|
||||
*/
|
||||
Mibew.Utils = {};
|
||||
|
||||
/**
|
||||
* Create a cookie for the second level domain with path equals to '/'.
|
||||
*
|
||||
* @param {String} name Cookie name
|
||||
* @param {String} value Cookie value
|
||||
* @param {Date} expires Indicates when the cookie expires. If the value is
|
||||
* omitted a session cookie will be created.
|
||||
*/
|
||||
Mibew.Utils.createCookie = function(name, value, expires) {
|
||||
if (navigator.cookieEnabled) {
|
||||
var domain_parts = document.location.hostname.split('.').reverse();
|
||||
var domain = domain_parts[0];
|
||||
var position = 0;
|
||||
do {
|
||||
document.cookie = "" + name + "=" + value + "; "
|
||||
+ "path=/; "
|
||||
+ (document.location.protocol == 'https:' ? "SameSite=None; secure; " : '')
|
||||
+ "domain=" + (Mibew.Utils.cookiesDomain || domain) + "; "
|
||||
+ (expires ? ('expires=' + expires.toUTCString() + '; ') : '');
|
||||
if (Mibew.Utils.readCookie(name) == value) {
|
||||
if (!Mibew.Utils.cookiesDomain) {
|
||||
Mibew.Utils.cookiesDomain = domain;
|
||||
}
|
||||
}
|
||||
else {
|
||||
position++;
|
||||
domain = domain_parts[position] + '.' + domain;
|
||||
}
|
||||
} while((position < domain_parts.length) && !Mibew.Utils.cookiesDomain);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Try to read cookie.
|
||||
*
|
||||
* @param {String} name Cookie name
|
||||
* @returns {String|Boolean} Cookie value or boolean false if cookie with
|
||||
* specified name does not exist
|
||||
*/
|
||||
Mibew.Utils.readCookie = function(name) {
|
||||
var cookies = document.cookie.split('; ');
|
||||
var nameForSearch = name + '=';
|
||||
var value = false;
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
if (cookies[i].indexOf(nameForSearch) != -1) {
|
||||
value = cookies[i].substr(nameForSearch.length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Deletes cookie.
|
||||
*
|
||||
* @param {String} name Name of the cookie that should be deleted.
|
||||
*/
|
||||
Mibew.Utils.deleteCookie = function(name) {
|
||||
Mibew.Utils.createCookie(name, '', (new Date(0)));
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets correct prototypes chain.
|
||||
*
|
||||
* This function is based on the logic used in Object.create method.
|
||||
* Unfortunately not all target browsers support this function thus it
|
||||
* should be implemented here.
|
||||
*
|
||||
* Warning: this methods completely rewrites prototype of "ctor" argument.
|
||||
*
|
||||
* @type {Function}
|
||||
* @param {Function} ctor An object constructor which prototype should be
|
||||
* updated.
|
||||
* @param {Function} superCtor An object constructor which prototype should
|
||||
* be used.
|
||||
*/
|
||||
Mibew.Utils.inherits = (function() {
|
||||
// Tmp function is defined in closure because in such case only one
|
||||
// temporary function will be kept in memory regardless of inherits
|
||||
// function calls number.
|
||||
var Tmp = function() {};
|
||||
|
||||
return function(ctor, superCtor) {
|
||||
Tmp.prototype = superCtor.prototype;
|
||||
ctor.prototype = new Tmp();
|
||||
Tmp.prototype = null;
|
||||
ctor.prototype.constructor = ctor;
|
||||
};
|
||||
})();
|
||||
|
||||
/**
|
||||
* Attaches an event listener to the target object's event.
|
||||
*
|
||||
* This method uses native "addEventListener" in modern browsers and a
|
||||
* workaround for IE < 9.
|
||||
*
|
||||
* @param {Object} target The object which fires the event.
|
||||
* @param {String} eventName Name of the event.
|
||||
* @param {Function} listener The function that should be triggered.
|
||||
*/
|
||||
Mibew.Utils.addEventListener = function(target, eventName, listener) {
|
||||
if (target.addEventListener) {
|
||||
// A regular browser is used
|
||||
target.addEventListener(eventName, listener, false);
|
||||
} else {
|
||||
if (target.attachEvent) {
|
||||
// This is needed for IE < 9
|
||||
target.attachEvent(
|
||||
'on' + eventName,
|
||||
// The closure is used to use valid this reference in the
|
||||
// listener.
|
||||
function (event) {
|
||||
listener.call(target, event);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Loads CSS file and attach it to DOM.
|
||||
*
|
||||
* @param {String} url URL of the CSS that should be loaded.
|
||||
* @param {String} [id] ID of the DOM element that will be created. Can be
|
||||
* omitted.
|
||||
* @returns {Element} Appended DOM item.
|
||||
*/
|
||||
Mibew.Utils.loadStyleSheet = function(url, id) {
|
||||
var styleSheet = document.createElement('link');
|
||||
styleSheet.setAttribute('rel', 'stylesheet');
|
||||
styleSheet.setAttribute('type', 'text/css');
|
||||
styleSheet.setAttribute('href', url);
|
||||
if (id) {
|
||||
styleSheet.setAttribute('id', id);
|
||||
}
|
||||
document.getElementsByTagName('head')[0].appendChild(styleSheet);
|
||||
|
||||
return styleSheet;
|
||||
};
|
||||
|
||||
/**
|
||||
* Loads JavaScript file and attach it to DOM.
|
||||
*
|
||||
* @param {String} url URL of the JavaScript file that should be loaded.
|
||||
* @param {String} [id] ID of the DOM element that will be created. Can be
|
||||
* omitted.
|
||||
* @returns {Element} Appended DOM item.
|
||||
*/
|
||||
Mibew.Utils.loadScript = function(url, id) {
|
||||
var script = document.createElement('script');
|
||||
script.setAttribute('type', 'text/javascript');
|
||||
script.setAttribute('src', url);
|
||||
if (id) {
|
||||
script.setAttribute('id', id);
|
||||
}
|
||||
document.getElementsByTagName('head')[0].appendChild(script);
|
||||
|
||||
return script;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize a proper chat popup.
|
||||
*
|
||||
* This is a helper function which choose which popup (iframe or window)
|
||||
* should be created, create it and store into Mibew.Objects.ChatPopups
|
||||
* hash.
|
||||
*
|
||||
* @param {Object} options List of popup options.
|
||||
*/
|
||||
Mibew.ChatPopup.init = function(options) {
|
||||
var canUseIFrame = (window.postMessage && options.preferIFrame),
|
||||
Popup = canUseIFrame ? Mibew.ChatPopup.IFrame : Mibew.ChatPopup.Window;
|
||||
Mibew.Objects.ChatPopups[options.id] = new Popup(options);
|
||||
};
|
||||
|
||||
/**
|
||||
* A constructor for base (abstract) popup object.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} options A list of popup options.
|
||||
*/
|
||||
var BasePopup = function(options) {
|
||||
/**
|
||||
* Unique ID of the popup.
|
||||
* @type {String}
|
||||
*/
|
||||
this.id = options.id;
|
||||
|
||||
/**
|
||||
* Chat initialization URL.
|
||||
* @type {String}
|
||||
*/
|
||||
this.url = options.url;
|
||||
|
||||
/**
|
||||
* Width of the popup in pixels.
|
||||
* @type {Number}
|
||||
*/
|
||||
this.width = options.width;
|
||||
|
||||
/**
|
||||
* Height of the popup in pixels.
|
||||
* @type {Number}
|
||||
*/
|
||||
this.height = options.height;
|
||||
|
||||
/**
|
||||
* Indicats if the popup should be resizable.
|
||||
*
|
||||
* It can be appliedonly for window popup.
|
||||
*
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.resizable = options.resizable || false;
|
||||
|
||||
/**
|
||||
* Contains URL of JavaScript file that loads css file for IFrame popup.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
this.styleLoader = options.styleLoader;
|
||||
|
||||
/**
|
||||
* Indicates if special actions should be done to fix problems with
|
||||
* mod_security.
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.modSecurity = options.modSecurity || false;
|
||||
|
||||
/**
|
||||
* Chat style
|
||||
* @type {String}
|
||||
*/
|
||||
this.styleName = options.style;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Builds an URL that initializes a chat.
|
||||
*
|
||||
* @returns {String} Chat URL.
|
||||
*/
|
||||
BasePopup.prototype.buildChatUrl = function() {
|
||||
var href = document.location.href,
|
||||
referrer = document.referrer;
|
||||
|
||||
if (this.modSecurity) {
|
||||
href = href.replace('http://','').replace('https://','');
|
||||
referrer = referrer.replace('http://','').replace('https://','');
|
||||
}
|
||||
|
||||
return this.url
|
||||
+ ((this.url.indexOf('?') === -1) ? '?' : '&') + 'url=' + encodeURIComponent(href)
|
||||
+ '&referrer=' + encodeURIComponent(referrer);
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs IFrame popup.
|
||||
*
|
||||
* @constructor
|
||||
* @extends BasePopup
|
||||
* @param {Object} options List of popup options.
|
||||
*/
|
||||
Mibew.ChatPopup.IFrame = function(options) {
|
||||
// Call parent constructor.
|
||||
BasePopup.call(this, options);
|
||||
|
||||
/**
|
||||
* Store options in case we need some of them later.
|
||||
* @type {Object}
|
||||
*/
|
||||
this.options = options;
|
||||
|
||||
/**
|
||||
* Wrapper for popup iframe DOM Element.
|
||||
* @type {Node}
|
||||
*/
|
||||
this.wrapperDiv = null;
|
||||
|
||||
/**
|
||||
* Popup iframe DOM Element.
|
||||
* @type {Node}
|
||||
*/
|
||||
this.iframe = null;
|
||||
|
||||
/**
|
||||
* Toggle iframe DOM Element.
|
||||
* @type {Node}
|
||||
*/
|
||||
this.toggleDiv = null;
|
||||
|
||||
/**
|
||||
* Indicates if the popup is opened.
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.isOpened = false;
|
||||
|
||||
/**
|
||||
* Indicates if the popup is minified.
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.isMinified = false;
|
||||
|
||||
/**
|
||||
* Indicates if cookies are blocked.
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.cookiesBlocked = false;
|
||||
|
||||
// Load default styles. These styles hide the popup while real styles
|
||||
// are loading.
|
||||
this.attachDefaultStyles();
|
||||
// Load extra style sheets.
|
||||
Mibew.Utils.loadScript(this.styleLoader);
|
||||
|
||||
// Check if the popup should be reopened.
|
||||
var openedChatUrl = Mibew.Utils.readCookie('mibew-chat-frame-' + this.id);
|
||||
if (openedChatUrl) {
|
||||
// The chat was not closed so the popup should be reopened when a
|
||||
// new page is visited.
|
||||
this.safeOpen(openedChatUrl);
|
||||
}
|
||||
|
||||
// Check if it's possible to set cookies at all
|
||||
var rnd = Math.random();
|
||||
Mibew.Utils.createCookie('mibewCheckToken', rnd);
|
||||
var checkCookiesBlock = Mibew.Utils.loadScript(options.url.split('?')[0] + '/cookies-set-permission' + '?rnd=' + rnd);
|
||||
checkCookiesBlock.popup = this;
|
||||
checkCookiesBlock.onload = function() {
|
||||
this.popup.cookiesBlocked = false;
|
||||
};
|
||||
checkCookiesBlock.onerror = function() {
|
||||
this.popup.cookiesBlocked = true;
|
||||
};
|
||||
};
|
||||
|
||||
// Set correct prototype chain for IFrame popup.
|
||||
Mibew.Utils.inherits(Mibew.ChatPopup.IFrame, BasePopup);
|
||||
|
||||
/**
|
||||
* Attaches default styles to the DOM.
|
||||
*
|
||||
* This function do its job only once no matter how many times it is called.
|
||||
*
|
||||
* @type {Function}
|
||||
*/
|
||||
Mibew.ChatPopup.IFrame.prototype.attachDefaultStyles = (function() {
|
||||
var executed = false;
|
||||
|
||||
return function() {
|
||||
if (executed) {
|
||||
// The function was already called. Just do nothing.
|
||||
return;
|
||||
}
|
||||
|
||||
executed = true;
|
||||
|
||||
var style = document.createElement('style'),
|
||||
// These rules hides the popup while real styles are loading.
|
||||
css = '.mibew-chat-frame {height: 0px; width: 0px;}';
|
||||
|
||||
style.setAttribute('type', 'text/css');
|
||||
if (style.styleSheet){
|
||||
style.styleSheet.cssText = css;
|
||||
} else {
|
||||
style.appendChild(document.createTextNode(css));
|
||||
}
|
||||
|
||||
document.getElementsByTagName('head')[0].appendChild(style);
|
||||
};
|
||||
})();
|
||||
|
||||
/**
|
||||
* Opens the popup.
|
||||
*
|
||||
* @param {String} [url] The URL that should be opened in the popup. If the
|
||||
* value is omitted, the chat initialization URL will be loaded.
|
||||
*/
|
||||
Mibew.ChatPopup.IFrame.prototype.open = function(url) {
|
||||
if (this.isOpened) {
|
||||
// Do not open the popup twice.
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.cookiesBlocked) {
|
||||
// Last resort. Replace this iframe-based popup with window-based popup
|
||||
// and try to open a chat in a separate window.
|
||||
Mibew.Objects.ChatPopups[this.id] = new Mibew.ChatPopup.Window(this.options);
|
||||
Mibew.Objects.ChatPopups[this.id].open(url);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.wrapperDiv) {
|
||||
// Create new iframe and its wrapper.
|
||||
// There is a bug in IE <= 7 that make "name" attribute unchangeble
|
||||
// for elements that already exist. Thus a temporary div is used
|
||||
// here as a workaround.
|
||||
this.wrapperDiv = document.createElement('div');
|
||||
this.wrapperDiv.className = 'mibew-chat-wrapper';
|
||||
this.wrapperDiv.setAttribute('id', 'mibew-chat-wrapper-' + this.id);
|
||||
this.wrapperDiv.style.display = 'none';
|
||||
this.wrapperDiv.innerHTML = '<iframe name="mibewChat' + this.id + '"></iframe>';
|
||||
|
||||
this.iframe = this.wrapperDiv.getElementsByTagName('iframe')[0];
|
||||
this.iframe.setAttribute('id', 'mibew-chat-frame-' + this.id);
|
||||
this.iframe.className = 'mibew-chat-frame';
|
||||
this.iframe.setAttribute('frameBorder', 0);
|
||||
|
||||
document.getElementsByTagName('body')[0].appendChild(this.wrapperDiv);
|
||||
|
||||
// Setup toggle element. As it's not a part of the iframe, it should be
|
||||
// treated separately.
|
||||
this.toggleDiv = document.createElement('div');
|
||||
this.toggleDiv.setAttribute('id', 'mibew-chat-frame-toggle-' + this.id);
|
||||
this.toggleDiv.className = 'mibew-chat-frame-toggle mibew-chat-frame-toggle-on';
|
||||
Mibew.Utils.addEventListener(this.toggleDiv, 'click', function(event) {
|
||||
var popups = Mibew.Objects.ChatPopups,
|
||||
matches = /^mibew-chat-frame-toggle-([0-9A-Za-z]+)$/.exec(this.id);
|
||||
|
||||
if (matches && popups[matches[1]]) {
|
||||
popups[matches[1]].toggle();
|
||||
}
|
||||
});
|
||||
document.getElementsByTagName('body')[0].appendChild(this.toggleDiv);
|
||||
}
|
||||
|
||||
this.wrapperDiv.style.display = 'block';
|
||||
this.toggleDiv.style.display = 'block';
|
||||
this.iframe.src = url || this.buildChatUrl();
|
||||
this.isOpened = true;
|
||||
|
||||
// Store style name in case we need it during iframe reopening
|
||||
Mibew.Utils.createCookie('mibew-chat-frame-style-' + this.id, this.styleName);
|
||||
|
||||
// Check minification status of the popup and toggle it if needed.
|
||||
var minifiedPopup = Mibew.Utils.readCookie('mibew-chat-frame-minified-' + this.id);
|
||||
if (minifiedPopup === 'true') {
|
||||
this.toggle();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Check chat URL via special request, open the chat if check passes,
|
||||
* close the popup if the check fails.
|
||||
*
|
||||
* @param {String} [url] The URL to open in the popup
|
||||
*/
|
||||
Mibew.ChatPopup.IFrame.prototype.safeOpen = function(url) {
|
||||
var check = Mibew.Utils.loadScript(url + '/check', 'mibew-check-iframe-' + this.id);
|
||||
check.popup = this;
|
||||
check.url = url;
|
||||
var style = Mibew.Utils.readCookie('mibew-chat-frame-style-' + this.id);
|
||||
check.onload = function() {
|
||||
this.popup.open(this.url + (style ? '?style=' + style : ''));
|
||||
};
|
||||
check.onerror = function() {
|
||||
this.popup.close();
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the popup.
|
||||
*/
|
||||
Mibew.ChatPopup.IFrame.prototype.close = function() {
|
||||
if (!this.isOpened) {
|
||||
// A popup that was not opened thus it cannot be closed.
|
||||
return;
|
||||
}
|
||||
|
||||
this.wrapperDiv.style.display = 'none';
|
||||
this.iframe.src = '';
|
||||
this.isOpened = false;
|
||||
this.toggleDiv.style.display = 'none';
|
||||
Mibew.Utils.deleteCookie('mibew-chat-frame-' + this.id);
|
||||
Mibew.Utils.deleteCookie('mibew-chat-frame-minified-' + this.id);
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggles the popup.
|
||||
*/
|
||||
Mibew.ChatPopup.IFrame.prototype.toggle = function() {
|
||||
this.wrapperDiv.style.display = this.isMinified ? "block" : "none";
|
||||
this.isMinified = !this.isMinified;
|
||||
this.toggleDiv.className = 'mibew-chat-frame-toggle mibew-chat-frame-toggle-'
|
||||
+ (this.isMinified ? 'off' : 'on');
|
||||
Mibew.Utils.createCookie('mibew-chat-frame-minified-' + this.id, this.isMinified);
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs Window popup.
|
||||
*
|
||||
* @constructor
|
||||
* @extends BasePopup
|
||||
* @param {Object} options List of popup options.
|
||||
*/
|
||||
Mibew.ChatPopup.Window = function(options) {
|
||||
BasePopup.call(this, options);
|
||||
|
||||
this.window = null;
|
||||
};
|
||||
|
||||
// Set correct prototype chain for Window popup.
|
||||
Mibew.Utils.inherits(Mibew.ChatPopup.Window, BasePopup);
|
||||
|
||||
/**
|
||||
* Opens the popup.
|
||||
*
|
||||
* @param {String} [url] The URL that should be opened in the popup. If the
|
||||
* value is omitted, the chat initialization URL will be loaded.
|
||||
*/
|
||||
Mibew.ChatPopup.Window.prototype.open = function(url) {
|
||||
// Windows is already opened, nothing to do.
|
||||
if (this.window != null && !this.window.closed) {
|
||||
return;
|
||||
}
|
||||
this.window = window.open(
|
||||
url || this.buildChatUrl(),
|
||||
'mibewChat' + this.id,
|
||||
this.getWindowParams()
|
||||
);
|
||||
this.window.focus();
|
||||
this.window.opener = window;
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the popup.
|
||||
*/
|
||||
Mibew.ChatPopup.Window.prototype.close = function() {
|
||||
if (!this.window) {
|
||||
// There is nothing to close.
|
||||
return;
|
||||
}
|
||||
|
||||
this.window.close();
|
||||
this.window = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Builds window params string.
|
||||
*
|
||||
* Generated params string can be used in window.open method as the third
|
||||
* argument.
|
||||
*
|
||||
* @protected
|
||||
* @returns {String}
|
||||
*/
|
||||
Mibew.ChatPopup.Window.prototype.getWindowParams = function() {
|
||||
return [
|
||||
'toolbar=0',
|
||||
'scrollbars=0',
|
||||
'location=0',
|
||||
'status=1',
|
||||
'menubar=0',
|
||||
'width=' + this.width.toString(),
|
||||
'height=' + this.height.toString(),
|
||||
'resizable=' + (this.resizable ? '1' : '0')
|
||||
].join(',');
|
||||
};
|
||||
|
||||
// Attach a listener to window's "message" event to get the url of the chat
|
||||
// which is opened in iframe popup.
|
||||
Mibew.Utils.addEventListener(window, 'message', function(event) {
|
||||
var matches = /^mibew-chat-started\:mibewChat([0-9A-Za-z]+)\:(.*)$/.exec(event.data);
|
||||
if (matches) {
|
||||
Mibew.Utils.createCookie('mibew-chat-frame-' + matches[1], matches[2]);
|
||||
}
|
||||
});
|
||||
|
||||
// Attach a listener to window's "message" event to close the iframe when
|
||||
// the chat is closed.
|
||||
Mibew.Utils.addEventListener(window, 'message', function(event) {
|
||||
var popups = Mibew.Objects.ChatPopups,
|
||||
matches = /^mibew-chat-closed\:mibewChat([0-9A-Za-z]+)$/.exec(event.data);
|
||||
|
||||
if (matches && popups[matches[1]]) {
|
||||
popups[matches[1]].close();
|
||||
}
|
||||
});
|
||||
|
||||
})(Mibew);
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone, _){
|
||||
@ -24,24 +14,24 @@
|
||||
* Mibew.Views.CompositeBase
|
||||
* @private
|
||||
* @param {Backbone.Model} item Collection item
|
||||
* @param {Function} ChildViewType Default item view constructor
|
||||
* @param {Object} childViewOptions Additional item view options
|
||||
* @param {Function} ItemViewType Default item view constructor
|
||||
* @param {Object} itemViewOptions Additional item view options
|
||||
* @returns Item view instance
|
||||
*/
|
||||
var buildChildView = function(item, ChildViewType, childViewOptions) {
|
||||
var buildItemView = function(item, ItemViewType, itemViewOptions) {
|
||||
// Build options object
|
||||
var options = _.extend({model: item}, childViewOptions);
|
||||
var options = _.extend({model: item}, itemViewOptions);
|
||||
// Try to find special view for this model
|
||||
if (typeof item.getModelType != 'function') {
|
||||
return new ChildViewType(options);
|
||||
return new ItemViewType(options);
|
||||
}
|
||||
var modelType = item.getModelType();
|
||||
if (modelType && Mibew.Views[modelType]) {
|
||||
return new Mibew.Views[modelType](options);
|
||||
} else {
|
||||
return new ChildViewType(options);
|
||||
return new ItemViewType(options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @class Represents base collection view
|
||||
@ -53,13 +43,13 @@
|
||||
* Default item view constructor.
|
||||
* @type Function
|
||||
*/
|
||||
childView: Backbone.Marionette.ItemView,
|
||||
itemView: Backbone.Marionette.ItemView,
|
||||
|
||||
/**
|
||||
* Return special contructor for an item view if it exists or the
|
||||
* default constructor otherwise.
|
||||
*/
|
||||
buildChildView: buildChildView
|
||||
buildItemView: buildItemView
|
||||
}
|
||||
);
|
||||
|
||||
@ -70,7 +60,7 @@
|
||||
* Return special contructor for an item view if it exists or the
|
||||
* default constructor otherwise.
|
||||
*/
|
||||
buildChildView: buildChildView
|
||||
buildItemView: buildItemView
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew) {
|
||||
@ -24,25 +14,17 @@
|
||||
Mibew.Views.ControlsCollection = Mibew.Views.CollectionBase.extend(
|
||||
/** @lends Mibew.Views.ControlsCollection.prototype */
|
||||
{
|
||||
/**
|
||||
* Default item view constructor.
|
||||
* @type Function
|
||||
*/
|
||||
itemView: Mibew.Views.Control,
|
||||
|
||||
/**
|
||||
* Class name for view's DOM element
|
||||
* @type String
|
||||
*/
|
||||
className: 'controls-collection',
|
||||
|
||||
/**
|
||||
* Returns default child view constructor.
|
||||
*
|
||||
* The function is used instead of "childView" property to provide
|
||||
* an ability to override child view constructor without this class
|
||||
* overriding.
|
||||
*
|
||||
* @param {Backbone.Model} model The model the view created for.
|
||||
* @returns {Backbone.Marionette.ItemView}
|
||||
*/
|
||||
getChildView: function(model) {
|
||||
return Mibew.Views.Control;
|
||||
}
|
||||
className: 'controls-collection'
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone){
|
||||
|
@ -1,22 +1,63 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Handlebars){
|
||||
/**
|
||||
* Register 'apply' Handlebars helper.
|
||||
*
|
||||
* This helper provide an ability to apply several helpers to single
|
||||
* Handlebars expression
|
||||
*
|
||||
* Example of helper usage:
|
||||
* <code>
|
||||
* {{apply text "emHelper, strongHelper"}}
|
||||
* </code>
|
||||
* In the example above helpers will apply to text one after another: first
|
||||
* 'emHelper' and second 'strongHelper'.
|
||||
*/
|
||||
Handlebars.registerHelper('apply', function(text, helpers) {
|
||||
var result = text;
|
||||
var validHelperName = /^[0-9A-z_]+$/;
|
||||
helpers = helpers.split(/\s*,\s*/);
|
||||
// Apply helpers one after another
|
||||
for (var prop in helpers) {
|
||||
if (! helpers.hasOwnProperty(prop) ||
|
||||
! validHelperName.test(helpers[prop])) {
|
||||
continue;
|
||||
}
|
||||
if (typeof Handlebars.helpers[helpers[prop]] != 'function') {
|
||||
throw new Error(
|
||||
"Unregistered helper '" + helpers[prop] + "'!"
|
||||
);
|
||||
}
|
||||
result = Handlebars.helpers[helpers[prop]](result).toString();
|
||||
}
|
||||
return new Handlebars.SafeString(result);
|
||||
});
|
||||
|
||||
/**
|
||||
* Register 'allowTags' Handlebars helper.
|
||||
*
|
||||
* This helper unescape HTML entities for allowed (span and strong) tags.
|
||||
*/
|
||||
Handlebars.registerHelper('allowTags', function(text) {
|
||||
var result = text;
|
||||
result = result.replace(
|
||||
/<(span|strong)>(.*?)<\/\1>/g,
|
||||
'<$1>$2</$1>'
|
||||
);
|
||||
result = result.replace(
|
||||
/<span class="(.*?)">(.*?)<\/span>/g,
|
||||
'<span class="$1">$2</span>'
|
||||
);
|
||||
return new Handlebars.SafeString(result);
|
||||
});
|
||||
|
||||
/**
|
||||
* Register 'formatTime' Handlebars helper.
|
||||
*
|
||||
@ -41,33 +82,33 @@
|
||||
/**
|
||||
* Register 'urlReplace' Handlebars helper.
|
||||
*
|
||||
* This helper seeks URLs and replaces them by 'a' tag
|
||||
* This helper serch URLs and replace them by 'a' tag
|
||||
*/
|
||||
Handlebars.registerHelper('urlReplace', function(text) {
|
||||
return new Handlebars.SafeString(
|
||||
text.toString().replace(
|
||||
text.replace(
|
||||
/((?:https?|ftp):\/\/\S*)/g,
|
||||
'<a href="$1" target="_blank">$1</a>'
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Register 'nl2br' Handlebars helper.
|
||||
*
|
||||
* This helper replace all new line characters (\n) by 'br' tags
|
||||
*/
|
||||
Handlebars.registerHelper('nl2br', function(text) {
|
||||
return new Handlebars.SafeString(text.replace(/\n/g, "<br/>"));
|
||||
});
|
||||
|
||||
/**
|
||||
* Register 'l10n' Handlebars helper
|
||||
*
|
||||
* This helper returns translated string with specified key. Example of usage:
|
||||
* <code>
|
||||
* {{l10n "localization.string" arg1 arg2 arg3}}
|
||||
* </code>
|
||||
* where:
|
||||
* - "localization.string" is localization constant.
|
||||
* - arg* are arguments that will replace the placeholders.
|
||||
* This helper returns translated string with specified key
|
||||
*/
|
||||
Handlebars.registerHelper('l10n', function() {
|
||||
var l = Mibew.Localization,
|
||||
slice = Array.prototype.slice;
|
||||
|
||||
return l.trans.apply(l, slice.call(arguments));
|
||||
Handlebars.registerHelper('l10n', function(key) {
|
||||
return (Mibew.Localization.get(key) || '');
|
||||
});
|
||||
|
||||
/**
|
||||
@ -109,236 +150,4 @@
|
||||
return options.inverse(this);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Registers "ifAny" helper.
|
||||
*
|
||||
* This helper checks if at least one argumet can be treated as
|
||||
* "true" value. Example of usage:
|
||||
* <code>
|
||||
* {{#ifAny first second third}}
|
||||
* At least one of argument can be threated as "true".
|
||||
* {{else}}
|
||||
* All values are "falsy"
|
||||
* {{/ifAny}}
|
||||
* </code>
|
||||
*/
|
||||
Handlebars.registerHelper('ifAny', function() {
|
||||
var argsCount = arguments.length,
|
||||
// The last helper's argument is the options hash. We need it to
|
||||
// render the template.
|
||||
options = arguments[argsCount - 1],
|
||||
// All other helper's arguments are values that are used to evalute
|
||||
// condition. Exctract that values from arguments pseudo array.
|
||||
values = [].slice.call(arguments, 0, argsCount - 1);
|
||||
|
||||
for (var i = 0, l = values.length; i < l; i++) {
|
||||
if (values[i]) {
|
||||
// A true value is found. Render the positive block.
|
||||
return options.fn(this);
|
||||
}
|
||||
}
|
||||
|
||||
// All values are "falsy". Render the negative block.
|
||||
return options.inverse(this);
|
||||
});
|
||||
|
||||
/**
|
||||
* Registers "ifEqual" helper.
|
||||
*
|
||||
* This helper checks if two values are equal or not. Example of usage:
|
||||
* <code>
|
||||
* {{#ifEqual first second}}
|
||||
* The first argument is equal to the second one.
|
||||
* {{else}}
|
||||
* The arguments are not equal.
|
||||
* {{/ifEqual}}
|
||||
* </code>
|
||||
*/
|
||||
Handlebars.registerHelper('ifEqual', function(left, right, options) {
|
||||
// Not strict equality is used intentionally here.
|
||||
if (left == right) {
|
||||
return options.fn(this);
|
||||
} else {
|
||||
return options.inverse(this);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Registers "repeat" helper.
|
||||
*
|
||||
* This helper repeats a string specified number of times. Example of usage:
|
||||
* <code>
|
||||
* {{#repeat times}}content to repeat{{/repeat}}
|
||||
* </code>
|
||||
*/
|
||||
Handlebars.registerHelper('repeat', function(count, options) {
|
||||
var result = '',
|
||||
content = options.fn(this);
|
||||
|
||||
for (var i = 0; i < count; i++) {
|
||||
result += content;
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
/**
|
||||
* Registers "replace" helper.
|
||||
*
|
||||
* This helper replaces all found substrings with the specifed replacement.
|
||||
* Example of usage:
|
||||
* <code>
|
||||
* {{#replace search replacement}}target content{{/replace}}
|
||||
* </code>
|
||||
*/
|
||||
Handlebars.registerHelper('replace', function(search, replacement, options) {
|
||||
var unescapedSearch = search
|
||||
// Allow using new line character
|
||||
.replace(/\\n/g, '\n')
|
||||
// Allow using tab character
|
||||
.replace(/\\t/g, '\t')
|
||||
// Allow using all UTF characters in \uXXX format.
|
||||
.replace(/\\u([A-Za-z0-9])/g, function(match, code) {
|
||||
return String.fromCharCode(parseInt(code, 16));
|
||||
});
|
||||
|
||||
return options.fn(this).split(unescapedSearch).join(replacement);
|
||||
});
|
||||
|
||||
/**
|
||||
* Registers "cutString" helper.
|
||||
*
|
||||
* This helper cuts a string if it exceeds specified length. Example of
|
||||
* usage:
|
||||
* <code>
|
||||
* {{cutString string length}}
|
||||
* </code>
|
||||
*/
|
||||
Handlebars.registerHelper('cutString', function(length, options) {
|
||||
return options.fn(this).substr(0, length);
|
||||
});
|
||||
|
||||
/**
|
||||
* Registers "block" helper.
|
||||
*
|
||||
* This helper defines default content of a block. Example of usage:
|
||||
* <code>
|
||||
* {{#block "blockName"}}
|
||||
* Default content for the block
|
||||
* {{/block}}
|
||||
* </code>
|
||||
*/
|
||||
Handlebars.registerHelper('block', function(name, options) {
|
||||
if (this._blocksStorage && this._blocksStorage.hasOwnProperty(name)) {
|
||||
return this._blocksStorage[name];
|
||||
}
|
||||
|
||||
return options.fn(this);
|
||||
});
|
||||
|
||||
/**
|
||||
* Registers "extends" helper.
|
||||
*
|
||||
* This is used for templates inheritance. Example of usage:
|
||||
* <code>
|
||||
* {{#extends "parentTemplateName"}}
|
||||
* {{#override "blockName"}}
|
||||
* Overridden first block
|
||||
* {{/override}}
|
||||
*
|
||||
* {{#override "anotherBlockName"}}
|
||||
* Overridden second block
|
||||
* {{/override}}
|
||||
* {{/extends}}
|
||||
* </code>
|
||||
*/
|
||||
Handlebars.registerHelper('extends', function(parentTemplate, options) {
|
||||
// Create a blocks storage. If the current inheritance level is not the
|
||||
// deepest one, a storage already exists. In this case we do not need
|
||||
// to override it.
|
||||
this._blocksStorage = this._blocksStorage || {};
|
||||
|
||||
// Render content inside "extends" helper to override blocks
|
||||
options.fn(this);
|
||||
|
||||
// Check if the parent template exists
|
||||
if (!Handlebars.templates.hasOwnProperty(parentTemplate)) {
|
||||
throw Error('Parent template "' + parentTemplate + '" is not defined');
|
||||
}
|
||||
|
||||
// Render the parent template. We assume that templates are stored in
|
||||
// Handlebars.templates property. It is the most common case and take
|
||||
// place when templates were compiled with node.js Handlebars CLI tool.
|
||||
return Handlebars.templates[parentTemplate](this);
|
||||
});
|
||||
|
||||
/**
|
||||
* Registers "override" helper.
|
||||
*
|
||||
* This helper overrides content of a block. Example of usage:
|
||||
* <code>
|
||||
* {{#extends "parentTemplateName"}}
|
||||
* {{#override "blockName"}}
|
||||
* Overridden first block
|
||||
* {{/override}}
|
||||
*
|
||||
* {{#override "anotherBlockName"}}
|
||||
* Overridden second block
|
||||
* {{/override}}
|
||||
* {{/extends}}
|
||||
* </code>
|
||||
*/
|
||||
Handlebars.registerHelper('override', function(name, options) {
|
||||
// We need to provide unlimited inheritance level. Rendering is started
|
||||
// from the deepest level template. If the content is in the block
|
||||
// storage it is related with the deepest level template. Thus we do not
|
||||
// need to override it.
|
||||
if (!this._blocksStorage.hasOwnProperty(name)) {
|
||||
this._blocksStorage[name] = options.fn(this);
|
||||
}
|
||||
|
||||
// An empty string is returned for consistency.
|
||||
return '';
|
||||
});
|
||||
|
||||
/**
|
||||
* Registers "ifOverridden" helper.
|
||||
*
|
||||
* This helper checks if a block is overridden or not. Example of usage:
|
||||
* <code>
|
||||
* {{#ifOverridden "blockName"}}
|
||||
* The block was overridden
|
||||
* {{else}}
|
||||
* The block was not overridden
|
||||
* {{/ifOverridden}}
|
||||
* </code>
|
||||
*/
|
||||
Handlebars.registerHelper('ifOverridden', function(name, options) {
|
||||
if (this._blocksStorage && this._blocksStorage.hasOwnProperty(name)) {
|
||||
return options.fn(this);
|
||||
} else {
|
||||
return options.inverse(this);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Registers "unlessOverridden" helper.
|
||||
*
|
||||
* This helper checks if a block is overridden or not. Example of usage:
|
||||
* <code>
|
||||
* {{#unlessOverridden "blockName"}}
|
||||
* The block was not overridden
|
||||
* {{else}}
|
||||
* The block was overridden
|
||||
* {{/unlessOverridden}}
|
||||
* </code>
|
||||
*/
|
||||
Handlebars.registerHelper('unlessOverridden', function(name, options) {
|
||||
if (this._blocksStorage && this._blocksStorage.hasOwnProperty(name)) {
|
||||
return options.inverse(this);
|
||||
} else {
|
||||
return options.fn(this);
|
||||
}
|
||||
});
|
||||
})(Mibew, Handlebars);
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -26,7 +16,7 @@ var Mibew = {};
|
||||
// Use Backbone.Marionette with handlebars.js
|
||||
Backbone.Marionette.TemplateCache.prototype.compileTemplate = function(rawTemplate) {
|
||||
return Handlebars.compile(rawTemplate);
|
||||
};
|
||||
}
|
||||
|
||||
// Use all handlebars template as partials too
|
||||
// We does not use Handlebars.partials property because of it can be changed
|
||||
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, _){
|
||||
@ -30,24 +20,16 @@
|
||||
var localStrings = {};
|
||||
|
||||
/**
|
||||
* Localize string.
|
||||
*
|
||||
* @param {String} str String for localization.
|
||||
* @param {...String} placeholder A value that will replace a placeholder.
|
||||
* @returns {String} Localized string.
|
||||
* Localize string
|
||||
* @param {String} str String for localization
|
||||
* @returns {String} Localized string
|
||||
*/
|
||||
Mibew.Localization.trans = function(str) {
|
||||
// Replace "{n}" style placeholders with specified arguments. The first
|
||||
// argument is skipped because it is the localized string.
|
||||
var placeholders = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
// If there is no localized string use passed in one.
|
||||
var localized = localStrings.hasOwnProperty(str) ? localStrings[str] : str;
|
||||
|
||||
return localized.replace(/\{([0-9]+)\}/g, function(match, index) {
|
||||
return placeholders[parseInt(index)] || '';
|
||||
});
|
||||
};
|
||||
Mibew.Localization.get = function(str) {
|
||||
if (! localStrings.hasOwnProperty(str)) {
|
||||
return false;
|
||||
}
|
||||
return localStrings[str];
|
||||
}
|
||||
|
||||
/**
|
||||
* Store localization object. Can be call multiple times, localization
|
||||
@ -56,6 +38,6 @@
|
||||
*/
|
||||
Mibew.Localization.set = function(strs) {
|
||||
_.extend(localStrings, strs);
|
||||
};
|
||||
}
|
||||
|
||||
})(Mibew, _);
|
@ -1,19 +1,9 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone, Handlebars) {
|
||||
@ -74,7 +64,7 @@
|
||||
}
|
||||
return {
|
||||
'class': classes.join(' ')
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1,23 +1,34 @@
|
||||
/*!
|
||||
* This file is a part of Mibew Messenger.
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Copyright 2005-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function(Mibew, Backbone, Handlebars) {
|
||||
|
||||
/**
|
||||
* List of replacements pairs
|
||||
* @type Object
|
||||
* @private
|
||||
*/
|
||||
var badCharList = {
|
||||
"<": "<",
|
||||
">": ">",
|
||||
"&": "&",
|
||||
'"': """,
|
||||
"'": "'",
|
||||
"`": "`"
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular expression for characters that must be replaced by HTML entities
|
||||
* @type RegExp
|
||||
* @private
|
||||
*/
|
||||
var badCharRegEx = /[&<>'"`]/g;
|
||||
|
||||
/**
|
||||
* @class Represents default message view
|
||||
*/
|
||||
@ -54,7 +65,10 @@
|
||||
var messageKind = this.model.get('kind');
|
||||
|
||||
// Add message fields
|
||||
msg.allowFormatting = (messageKind != this.model.KIND_USER
|
||||
&& messageKind != this.model.KIND_AGENT);
|
||||
msg.kindName = this.kindToString(messageKind);
|
||||
msg.message = this.escapeString(msg.message);
|
||||
|
||||
return msg;
|
||||
},
|
||||
@ -75,10 +89,10 @@
|
||||
return "hidden";
|
||||
}
|
||||
if (kind == this.model.KIND_INFO) {
|
||||
return "info";
|
||||
return "inf";
|
||||
}
|
||||
if (kind == this.model.KIND_CONN) {
|
||||
return "connection";
|
||||
return "conn";
|
||||
}
|
||||
if (kind == this.model.KIND_EVENTS) {
|
||||
return "event";
|
||||
@ -87,6 +101,22 @@
|
||||
return "plugin";
|
||||
}
|
||||
return "";
|
||||
},
|
||||
|
||||
/**
|
||||
* Replace HTML special characters('<', '>', '&', "'", '"', '`') by
|
||||
* corresponding HTML entities.
|
||||
*
|
||||
* @param {String} str Unescaped string
|
||||
* @returns {String} Escaped string
|
||||
*/
|
||||
escapeString: function(str) {
|
||||
return str.replace(
|
||||
badCharRegEx,
|
||||
function(chr) {
|
||||
return badCharList[chr] || "&";
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user