Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/rdutra/Chatforce
Browse files Browse the repository at this point in the history
  • Loading branch information
meyer429 committed Feb 24, 2012
2 parents 4f0d644 + d393270 commit 26fd554
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 45 deletions.
8 changes: 5 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ def save_setting
options = {
:history => ahistory,
:skin => params["select_skin"],
:buddy_id => @session["buddy_id"]
:buddy_id => @session["buddy_id"],
:show_offline => params["show_offline"],
:idle_time => params["idle_time"]
}
Setting.save_settings(options)
#redirect_to :controller => 'buddies', :action => 'index'
Setting.save_settings(options, params["status"])
redirect_to "buddies/list"
end

private
Expand Down
66 changes: 33 additions & 33 deletions app/views/settings/_settings.haml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
=form_tag('/save_settings', :id => 'Settings_form') do
.settingsContainer.acordeon
.settingsListHeader.acordeonHeader
Settings
.AcordeonListHeaderBtn{:onclick => "toggleAcordeon(this);"}
.acordeonList
.settings.acordeonListItem
.settingsLeft
Set your status mesage
.settingsRight
%input.settings{:type => 'text', :style => "width: 100%;text-align: left;", "data-role" => "none", :name => "status", :value => @buddy["nickname"]}
.settings.acordeonListItem
.settingsLeft
Lets others know im idle after
.settingsRight
%input.settings{:type => 'text', :style => "width: 34px;", "data-role" => "none", :name => "idle_time", :value => @settings["idle_time"]}
mins of inactivity
.settings.acordeonListItem
.settingsLeft
Show Offline contacts :
.settingsRight
.CheckboxSwitch.green{:onclick => "toggleSwitch(this);"}
%input.CheckboxSwitch{:type => "checkbox", "data-role" => "none", :name => "show_offline", ((!@settings["show_offline"].nil? &&@settings["show_offline"])? 'checked': 'unchecked' ) => "" }
.checkboxSwitchContainer
.switchOn ON
.switch
.switchOff OFF
%div{:style => "padding: 12px 42px;background: #e1ecee;"}
%button{:class => "settingsSubmitBtn green", "data-role" => "none", :style => "margin-bottom: 20px"}
Use default
= submit_tag 'Done', {:class => "submitBtn settingsSubmitBtn green", "data-role" => "none" }
.settingsContainer.acordeon
.settingsListHeader.acordeonHeader
Settings
.AcordeonListHeaderBtn{:onclick => "toggleAcordeon(this);"}
.acordeonList
.settings.acordeonListItem
.settingsLeft
Set your status mesage
.settingsRight
%input.settings{:type => 'text', :style => "width: 100%;text-align: left;", "data-role" => "none", :name => "status", :id => "status", :value => @buddy["nickname"]}

.settings.acordeonListItem
.settingsLeft
Lets others know im idle after
.settingsRight
%input.settings{:type => 'text', :style => "width: 34px;", "data-role" => "none", :name => "idle_time", :id => "idle_time",:value => @settings["idle_time"]}
mins of inactivity

.settings.acordeonListItem
.settingsLeft
Show Offline contacts :
.settingsRight
.CheckboxSwitch.green{:onclick => "toggleSwitch(this);"}
%input.CheckboxSwitch{:type => "checkbox", "data-role" => "none", :name => "show_offline", ((!@settings["show_offline"].nil? &&@settings["show_offline"])? 'checked': 'unchecked' ) => "" }
.checkboxSwitchContainer
.switchOn ON
.switch
.switchOff OFF
%div{:style => "padding: 12px 42px;background: #e1ecee;"}
%button{:id => "default_setting_ajax", :class => "settingsSubmitBtn green", "data-role" => "none", :style => "margin-bottom: 20px"}
Use default
%button{:id => "submit_setting_ajax",:class => "submitBtn settingsSubmitBtn green", "data-role" => "none" }
Done
50 changes: 41 additions & 9 deletions public/javascripts/comm.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,36 @@ $(".buddyLink").live('click', function(){
$("#mesg").html("");
});

$("#submit_setting_ajax").live('click', function(){
var new_status = $("#status").val();
var new_idle = $("#idle_time").val();
var new_show_offline = $(".CheckboxSwitch").find('input')[0].checked;

$.ajax({
url: '/settings/save_setting',
type: 'POST',
data: "show_offline=" + new_show_offline + "&idle_time=" + new_idle + "&status=" + new_status,
success: function(data){
if(data.signed == "false") window.location.replace("/index.html");
window.location.replace("buddies");
}
});

});

$("#default_setting_ajax").live('click', function(){

$.ajax({
url: '/settings/save_setting',
type: 'POST',
data: "show_offline=false&idle_time=10&status=",
success: function(data){
if(data.signed == "false") window.location.replace("/index.html");
window.location.replace("buddies");
}
});

});


function init()
Expand Down Expand Up @@ -62,7 +92,7 @@ function init()

function channel_subscribe(channel)
{

console.info("Channel de channel suscribe: " + channel)
if (!(typeof jugger_comm !== undefined && jugger_comm))
{
jugger_comm = new Juggernaut(data_session);
Expand Down Expand Up @@ -197,7 +227,7 @@ function enableChat(data, buffer)
console.info("enableChat", data)
if(data.channel == channel_selected)
{
if(data.sender != data_session.buddy_id && $('.ui-page-active').attr('id') == "buddies" && data.sender != undefined) runEffect(data.message['sender']);
if(data.sender != data_session.buddy_id && ( $('.ui-page-active').attr('id') == "buddies" || $('.ui-page-active').attr('id') == "settings" ) && data.sender != undefined) runEffect(data.message['sender']);

var who = (data.message['sender'] == data_session.buddy_id)? 'left': 'right';
var ul = '<div class="conversationContainer">';
Expand Down Expand Up @@ -237,9 +267,6 @@ function enableChat(data, buffer)

}




setTimeout(function(){window.scroll(0,$(document).height()+200)},300);
}

Expand Down Expand Up @@ -305,9 +332,12 @@ function runEffect(buddy_id) {

function init_chat(channel, buffer, id_sender)
{

$("#chat_window").unbind("submit");
$("#chat_window").submit(function(event) {
console.info("aca2");
console.info(buffer);
console.info(id_sender);
event.preventDefault();
$("#header-main").css("top", "0px")
var message = $.trim(this.msg_body.value)
Expand All @@ -322,6 +352,7 @@ function init_chat(channel, buffer, id_sender)
type: 'POST',
data: "channel="+channel_selected+"&message="+message+"&sender="+real_sender,
success: function(data_buffer){
console.info('ffff')
if(data_buffer.signed == "false") window.location.replace("/index.html");
jQuery('#msg_body').keyup();
}
Expand Down Expand Up @@ -368,9 +399,8 @@ function init_chat(channel, buffer, id_sender)
}
});

if(buffer && id_sender == undefined)
if(buffer && id_sender == undefined )
{

$.ajax({
url: "/chat/get_buffer",
type: 'POST',
Expand All @@ -379,6 +409,7 @@ function init_chat(channel, buffer, id_sender)
if(data.signed == "false") window.location.replace("/index.html");
for (i=data.length-1;i>=0;i--)
{
console.info(i)
enableChat(data[i], true)
}
}
Expand All @@ -388,9 +419,10 @@ function init_chat(channel, buffer, id_sender)

function init_buffer(channel, receiver)
{

$("#chat_window").unbind("submit");
$("#chat_window").submit(function(event) {
console.info("aca1");
event.preventDefault();
$("#header-main").css("top", "0px")
var message = $.trim(this.msg_body.value)
Expand Down

0 comments on commit 26fd554

Please sign in to comment.