mirror of
https://github.com/Mibew/mibew.git
synced 2024-11-15 16:44:11 +03:00
Move send shortcut string generation to the client side
This commit is contained in:
parent
6e6920851d
commit
c3956be558
@ -78,6 +78,7 @@
|
||||
serializeData: function() {
|
||||
var data = this.model.toJSON();
|
||||
data.user = Mibew.Objects.Models.user.toJSON();
|
||||
data.sendShortcut = this.getSendShortcut();
|
||||
return data;
|
||||
},
|
||||
|
||||
@ -204,6 +205,23 @@
|
||||
*/
|
||||
dropFocus: function() {
|
||||
this.focused = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Builds a string with send shortcut.
|
||||
*
|
||||
* @returns {String}
|
||||
*/
|
||||
getSendShortcut: function() {
|
||||
if (this.model.get('ignoreCtrl')) {
|
||||
return 'Enter';
|
||||
}
|
||||
|
||||
// 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';
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -193,18 +193,6 @@ function get_known_user_agents()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if browser is opera with mac os
|
||||
*
|
||||
* @return bool Result of comparison of visitor browser and Opera_on_mac
|
||||
*/
|
||||
function is_mac_opera()
|
||||
{
|
||||
$user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
|
||||
|
||||
return strstr($user_agent, "opera") && strstr($user_agent, "mac");
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare logo data
|
||||
*
|
||||
@ -245,13 +233,6 @@ function prepare_chat_app_data()
|
||||
{
|
||||
$data = array();
|
||||
|
||||
// Set enter key shortcut
|
||||
if (Settings::get('sendmessagekey') == 'enter') {
|
||||
$data['send_shortcut'] = "Enter";
|
||||
} else {
|
||||
$data['send_shortcut'] = is_mac_opera() ? "⌘-Enter" : "Ctrl-Enter";
|
||||
}
|
||||
|
||||
// Set refresh frequency
|
||||
$data['frequency'] = Settings::get('updatefrequency_chat');
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
</select>
|
||||
{{/if}}
|
||||
</div>
|
||||
<a href="javascript:void(0)" id="send-message" title="{{l10n "Send message"}}">{{l10n "chat.window.send_message_short_and_shortcut"}}</a>
|
||||
<a href="javascript:void(0)" id="send-message" title="{{l10n "Send message"}}">{{{l10n "Send ({0})" sendShortcut}}}</a>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
@ -31,10 +31,6 @@
|
||||
{{{additional_js}}}
|
||||
|
||||
<script type="text/javascript"><!--
|
||||
// Localized strings for the core
|
||||
Mibew.Localization.set({
|
||||
'chat.window.send_message_short_and_shortcut': '{{#jsString}}{{l10n "Send ({0})" send_shortcut}}{{/jsString}}'
|
||||
});
|
||||
// Plugins localization
|
||||
Mibew.Localization.set({{{additional_localized_strings}}});
|
||||
//--></script>
|
||||
|
Loading…
Reference in New Issue
Block a user