mirror of
https://github.com/Mibew/mibew.git
synced 2025-04-12 02:30:10 +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() {
|
serializeData: function() {
|
||||||
var data = this.model.toJSON();
|
var data = this.model.toJSON();
|
||||||
data.user = Mibew.Objects.Models.user.toJSON();
|
data.user = Mibew.Objects.Models.user.toJSON();
|
||||||
|
data.sendShortcut = this.getSendShortcut();
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -204,6 +205,23 @@
|
|||||||
*/
|
*/
|
||||||
dropFocus: function() {
|
dropFocus: function() {
|
||||||
this.focused = false;
|
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
|
* Prepare logo data
|
||||||
*
|
*
|
||||||
@ -245,13 +233,6 @@ function prepare_chat_app_data()
|
|||||||
{
|
{
|
||||||
$data = array();
|
$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
|
// Set refresh frequency
|
||||||
$data['frequency'] = Settings::get('updatefrequency_chat');
|
$data['frequency'] = Settings::get('updatefrequency_chat');
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
</select>
|
</select>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</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>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
@ -31,10 +31,6 @@
|
|||||||
{{{additional_js}}}
|
{{{additional_js}}}
|
||||||
|
|
||||||
<script type="text/javascript"><!--
|
<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
|
// Plugins localization
|
||||||
Mibew.Localization.set({{{additional_localized_strings}}});
|
Mibew.Localization.set({{{additional_localized_strings}}});
|
||||||
//--></script>
|
//--></script>
|
||||||
|
Loading…
Reference in New Issue
Block a user