Create config files for dialogs and core styles

This commit is contained in:
Dmitriy Simushev 2013-01-24 12:36:36 +00:00
parent abac28fa46
commit ad4f4e8d8e
15 changed files with 133 additions and 26 deletions

View File

@ -5,4 +5,4 @@
Copyright (c) 2005-2011 Mibew Messenger Community
License: http://mibew.org/license.php
*/
(function(b,d,e){b.Views.HistoryControl=b.Views.Control.extend({template:d.templates.history_control,events:e.extend({},b.Views.Control.prototype.events,{click:"showHistory"}),showHistory:function(){var c=b.Objects.Models.user,a=this.model.get("link");c.get("isAgent")&&a&&(c=this.$el.find(".control-config").eq(0).data("win-params"),a=a.replace("&","&","g"),a=window.open(a,"UserHistory",c),null!==a&&(a.focus(),a.opener=window))}})})(Mibew,Handlebars,_);
(function(b,c,e){b.Views.HistoryControl=b.Views.Control.extend({template:c.templates.history_control,events:e.extend({},b.Views.Control.prototype.events,{click:"showHistory"}),showHistory:function(){var d=b.Objects.Models.user,c=b.Objects.Models.page,a=this.model.get("link");d.get("isAgent")&&a&&(d=c.get("historyWindowParams"),a=a.replace("&","&","g"),a=window.open(a,"UserHistory",d),null!==a&&(a.focus(),a.opener=window))}})})(Mibew,Handlebars,_);

View File

@ -5,4 +5,4 @@
Copyright (c) 2005-2011 Mibew Messenger Community
License: http://mibew.org/license.php
*/
(function(b,c,e){b.Views.SendMailControl=b.Views.Control.extend({template:c.templates.send_mail_control,events:e.extend({},b.Views.Control.prototype.events,{click:"sendMail"}),sendMail:function(){var a=this.model.get("link");if(a){var c=this.$el.find(".control-config").eq(0).data("win-params"),d=b.Objects.Models.page.get("style"),a=a.replace(/\&amp\;/g,"&")+(d?"&style="+d:""),a=window.open(a,"ForwardMail",c);null!==a&&(a.focus(),a.opener=window)}}})})(Mibew,Handlebars,_);
(function(b,e,f){b.Views.SendMailControl=b.Views.Control.extend({template:e.templates.send_mail_control,events:f.extend({},b.Views.Control.prototype.events,{click:"sendMail"}),sendMail:function(){var a=this.model.get("link"),c=b.Objects.Models.page;if(a){var c=c.get("mailWindowParams"),d=b.Objects.Models.page.get("style"),a=a.replace(/\&amp\;/g,"&")+(d?"&style="+d:""),a=window.open(a,"ForwardMail",c);null!==a&&(a.focus(),a.opener=window)}}})})(Mibew,Handlebars,_);

View File

@ -29,12 +29,12 @@ this.add(e)},updateFunctionBuilder:function(){var a=b.Objects.Models.thread,c=b.
(function(a,b,c){a.Views.Status=b.Marionette.ItemView.extend({template:c.templates.status,className:"status",modelEvents:{change:"render"},onBeforeRender:function(){this.model.get("visible")?this.$el.show():this.$el.hide()}})})(Mibew,Backbone,Handlebars);
(function(a,b,c){a.Views.Avatar=b.Marionette.ItemView.extend({template:c.templates.avatar,className:"avatar",modelEvents:{change:"render"}})})(Mibew,Backbone,Handlebars);
(function(a,c,d){a.Views.CloseControl=a.Views.Control.extend({template:c.templates.close_control,events:d.extend({},a.Views.Control.prototype.events,{click:"close"}),close:function(){var b=a.Localization.get("chat.close.confirmation");(!1===b||confirm(b))&&this.model.closeThread()}})})(Mibew,Handlebars,_);
(function(b,d,e){b.Views.HistoryControl=b.Views.Control.extend({template:d.templates.history_control,events:e.extend({},b.Views.Control.prototype.events,{click:"showHistory"}),showHistory:function(){var c=b.Objects.Models.user,a=this.model.get("link");c.get("isAgent")&&a&&(c=this.$el.find(".control-config").eq(0).data("win-params"),a=a.replace("&","&","g"),a=window.open(a,"UserHistory",c),null!==a&&(a.focus(),a.opener=window))}})})(Mibew,Handlebars,_);
(function(b,c,e){b.Views.HistoryControl=b.Views.Control.extend({template:c.templates.history_control,events:e.extend({},b.Views.Control.prototype.events,{click:"showHistory"}),showHistory:function(){var d=b.Objects.Models.user,c=b.Objects.Models.page,a=this.model.get("link");d.get("isAgent")&&a&&(d=c.get("historyWindowParams"),a=a.replace("&","&","g"),a=window.open(a,"UserHistory",d),null!==a&&(a.focus(),a.opener=window))}})})(Mibew,Handlebars,_);
(function(a,d,e){a.Views.RedirectControl=a.Views.Control.extend({template:d.templates.redirect_control,events:e.extend({},a.Views.Control.prototype.events,{click:"redirect"}),initialize:function(){a.Objects.Models.user.on("change",this.render,this)},serializeData:function(){var b=this.model.toJSON();b.user=a.Objects.Models.user.toJSON();return b},redirect:function(){var b=a.Objects.Models.user;if(b.get("isAgent")&&b.get("canPost")&&(b=this.model.get("link"))){var c=a.Objects.Models.page.get("style");
window.location.href=b.replace(/\&amp\;/g,"&")+(c?"&style="+c:"")}}})})(Mibew,Handlebars,_);
(function(a,b,c){a.Views.RefreshControl=a.Views.Control.extend({template:b.templates.refresh_control,events:c.extend({},a.Views.Control.prototype.events,{click:"refresh"}),refresh:function(){this.model.refresh()}})})(Mibew,Handlebars,_);
(function(a,d,e){a.Views.SecureModeControl=a.Views.Control.extend({template:d.templates.secure_mode_control,events:e.extend({},a.Views.Control.prototype.events,{click:"secure"}),secure:function(){var b=this.model.get("link");if(b){var c=a.Objects.Models.page.get("style");window.location.href=b.replace(/\&amp\;/g,"&")+(c?"&style="+c:"")}}})})(Mibew,Handlebars,_);
(function(b,c,e){b.Views.SendMailControl=b.Views.Control.extend({template:c.templates.send_mail_control,events:e.extend({},b.Views.Control.prototype.events,{click:"sendMail"}),sendMail:function(){var a=this.model.get("link");if(a){var c=this.$el.find(".control-config").eq(0).data("win-params"),d=b.Objects.Models.page.get("style"),a=a.replace(/\&amp\;/g,"&")+(d?"&style="+d:""),a=window.open(a,"ForwardMail",c);null!==a&&(a.focus(),a.opener=window)}}})})(Mibew,Handlebars,_);
(function(b,e,f){b.Views.SendMailControl=b.Views.Control.extend({template:e.templates.send_mail_control,events:f.extend({},b.Views.Control.prototype.events,{click:"sendMail"}),sendMail:function(){var a=this.model.get("link"),c=b.Objects.Models.page;if(a){var c=c.get("mailWindowParams"),d=b.Objects.Models.page.get("style"),a=a.replace(/\&amp\;/g,"&")+(d?"&style="+d:""),a=window.open(a,"ForwardMail",c);null!==a&&(a.focus(),a.opener=window)}}})})(Mibew,Handlebars,_);
(function(a,b,c){a.Views.SoundControl=a.Views.Control.extend({template:b.templates.sound_control,events:c.extend({},a.Views.Control.prototype.events,{click:"toggle"}),toggle:function(){this.model.set({enabled:!this.model.get("enabled")})}})})(Mibew,Handlebars,_);
(function(b,c,d){b.Views.UserNameControl=b.Views.Control.extend({template:c.templates.user_name_control,events:d.extend({},b.Views.Control.prototype.events,{"click .user-name-control-set":"changeName","click .user-name-control-change":"showNameInput","keydown #user-name-control-input":"inputKeyDown"}),ui:{nameInput:"#user-name-control-input"},initialize:function(){b.Objects.Models.user.on("change:name",this.hideNameInput,this);this.nameInput=b.Objects.Models.user.get("defaultName")},serializeData:function(){var a=
this.model.toJSON();a.user=b.Objects.Models.user.toJSON();a.nameInput=this.nameInput;return a},inputKeyDown:function(a){a=a.which;(13==a||10==a)&&this.changeName()},hideNameInput:function(){this.nameInput=!1;this.render()},showNameInput:function(){this.nameInput=!0;this.render()},changeName:function(){var a=this.ui.nameInput.val();this.model.changeName(a)}})})(Mibew,Handlebars,_);

View File

@ -39,13 +39,10 @@
*/
showHistory: function() {
var user = Mibew.Objects.Models.user;
var page = Mibew.Objects.Models.page;
var link = this.model.get('link');
if (user.get('isAgent') && link) {
// TODO: Create wiki docs for it
var winParams = this.$el
.find('.control-config')
.eq(0)
.data('win-params');
var winParams = page.get('historyWindowParams');
// TODO: Kill & at the server side
link = link.replace('&', '&', 'g');

View File

@ -38,13 +38,10 @@
* Load and display send mail window
*/
sendMail: function() {
var link = this.model.get('link')
var link = this.model.get('link');
var page = Mibew.Objects.Models.page;
if (link) {
// TODO: Create wiki docs for it
var winParams = this.$el
.find('.control-config')
.eq(0)
.data('win-params');
var winParams = page.get('mailWindowParams');
var style = Mibew.Objects.Models.page.get('style');

View File

@ -267,6 +267,15 @@ function setup_chatview_for_user($thread, $level)
$page['neediframesrc'] = needsFramesrc();
$page['frequency'] = Settings::get('updatefrequency_chat');
// Load dialogs style options
$style_config = get_dialogs_style_config(getchatstyle());
$page['chatStyles.chatWindowParams'] = $style_config['chat']['window_params'];
$page['chatStyles.mailWindowParams'] = $style_config['mail']['window_params'];
// Load core style options
$style_config = get_core_style_config();
$page['coreStyles.historyWindowParams'] = $style_config['history']['window_params'];
}
function setup_chatview_for_operator($thread, $operator)
@ -334,6 +343,15 @@ function setup_chatview_for_operator($thread, $operator)
$page['namePostfix'] = "";
$page['frequency'] = Settings::get('updatefrequency_chat');
// Load dialogs style options
$style_config = get_dialogs_style_config(getchatstyle());
$page['chatStyles.chatWindowParams'] = $style_config['chat']['window_params'];
$page['chatStyles.mailWindowParams'] = $style_config['mail']['window_params'];
// Load core style options
$style_config = get_core_style_config();
$page['coreStyles.historyWindowParams'] = $style_config['history']['window_params'];
}
function ban_for_addr($addr)

View File

@ -0,0 +1,82 @@
<?php
/*
* Copyright 2005-2013 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.
*/
/**
* Read and parse configuration ini file
*
* @param string $file Path to Configuration file
* @return boolean|array Array of configurations or boolean false if file can
* not be read.
*/
function read_config_file($file) {
if (! is_readable($file)) {
return false;
}
return parse_ini_file($file, true);
}
/**
* Load configuration array for core style
*
* @return array Configuration array
*/
function get_core_style_config() {
// Get root dir of mibew messanger
$base_path = realpath(dirname(__FILE__) . '/../../');
// Load config
$config = read_config_file($base_path.'/view/config.ini');
// Set default values
$config = ($config === false) ? array() : $config;
$config += array(
'history' => array(
'window_params' => ''
)
);
return $config;
}
/**
* Load configuration array for dialogs style
*
* @param string $style Style name
* @return array Configuration array
*/
function get_dialogs_style_config($style) {
// Get root dir of mibew messanger
$base_path = realpath(dirname(__FILE__) . '/../../');
// Load config
$config = read_config_file($base_path.'/styles/dialogs/'.$style.'/config.ini');
// Set default values
$config = ($config === false) ? array() : $config;
$config += array(
'chat' => array(
'window_params' => ''
),
'mail' => array(
'window_params' => ''
)
);
return $config;
}
?>

View File

@ -29,6 +29,7 @@ require_once(dirname(__FILE__) . '/classes/plugin_manager.php');
require_once(dirname(__FILE__) . '/classes/plugin.php');
// Include common libs
require_once(dirname(__FILE__) . '/common/configurations.php');
require_once(dirname(__FILE__) . '/common/constants.php');
require_once(dirname(__FILE__) . '/common/csrf.php');
require_once(dirname(__FILE__) . '/common/datetime.php');

View File

@ -105,9 +105,6 @@ img {
cursor: pointer;
float: right;
}
.control-config {
display: none;
}
.tpl-image {
width: 16px;
height: 16px;

View File

@ -0,0 +1,10 @@
; This file determines some dialog styles options
; Comments starts with ';'
[chat]
; window_param use as param string in JavaScript window.open method
window_params = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1"
[mail]
; window_param use as param string in JavaScript window.open method
window_params = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=603,height=254,resizable=0"

View File

@ -1,3 +1 @@
<div class="tpl-image" title="{{L10n "page.analysis.userhistory.title"}}"></div>
{{! Use div with ".control-config" class and its data-* attributes to pass data to the JavaScript app}}
<div class="control-config" data-win-params="toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,width=720,height=560,resizable=1"></div>
<div class="tpl-image" title="{{L10n "page.analysis.userhistory.title"}}"></div>

View File

@ -1,3 +1 @@
<div class="tpl-image" title="{{L10n "chat.window.toolbar.mail_history"}}"></div>
{{! Use div with ".control-config" class and its data-* attributes to pass data to the JavaScript app}}
<div class="control-config" data-win-params="toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,width=603,height=254,resizable=0"></div>
<div class="tpl-image" title="{{L10n "chat.window.toolbar.mail_history"}}"></div>

File diff suppressed because one or more lines are too long

View File

@ -85,7 +85,10 @@
page: {
style: '${styleid}',
webimRoot: '${webimroot}',
tplRoot: '${tplroot}'
tplRoot: '${tplroot}',
chatWindowParams: "${page:chatStyles.chatWindowParams}",
mailWindowParams: "${page:chatStyles.mailWindowParams}",
historyWindowParams: "${page:coreStyles.historyWindowParams}"
},
plugins: ${page:js_plugin_options}
});

View File

@ -0,0 +1,6 @@
; This file determines some core styles options
; Comments starts with ';'
[history]
; window_param use as param string in JavaScript window.open method
window_params = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=720,height=560,resizable=1"