Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove mbp helper and refactor mobile publisher js #6261

Merged
merged 2 commits into from Jul 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 3 additions & 39 deletions app/assets/javascripts/mobile/mobile.js
Expand Up @@ -6,7 +6,7 @@
*/
//= require jquery.charcount
//= require js-routes
//= require mbp-helper
//= require autosize
//= require jquery.autoSuggest.custom
//= require fileuploader-custom
//= require rails-timeago
Expand All @@ -18,7 +18,8 @@
//= require mobile/mobile_file_uploader
//= require mobile/profile_aspects
//= require mobile/tag_following
//= require mobile/mobile_comments.js
//= require mobile/publisher
//= require mobile/mobile_comments

$(document).ready(function(){

Expand Down Expand Up @@ -125,42 +126,5 @@ $(document).ready(function(){
}
}
});

$(".service_icon").bind("tap click", function() {
var service = $(this).toggleClass("dim"),
selectedServices = $("#new_status_message .service_icon:not(.dim)"),
provider = service.attr("id"),
hiddenField = $("#new_status_message input[name='services[]'][value='" + provider + "']"),
publisherMaxChars = 40000,
serviceMaxChars;


$("#new_status_message .counter").remove();

$.each(selectedServices, function() {
serviceMaxChars = parseInt($(this).attr("maxchar"));
if(publisherMaxChars > serviceMaxChars) {
publisherMaxChars = serviceMaxChars;
}
});

$('#status_message_text').charCount({allowed: publisherMaxChars, warning: publisherMaxChars/10 });

if(hiddenField.length > 0) { hiddenField.remove(); }
else {
$("#new_status_message").append(
$("<input/>", {
name: "services[]",
type: "hidden",
value: provider
})
);
}
});

$("#submit_new_message").bind("tap click", function(evt){
evt.preventDefault();
$("#new_status_message").submit();
});
});
// @license-end
2 changes: 1 addition & 1 deletion app/assets/javascripts/mobile/mobile_comments.js
Expand Up @@ -112,7 +112,7 @@ $(document).ready(function() {
var bottomBar = link.closest(".bottom_bar").first();
bottomBar.append(data);
var textArea = bottomBar.find("textarea.comment_box").first()[0];
MBP.autogrow(textArea);
autosize(textArea);
}

$(".stream").on("submit", ".new_comment", function(evt) {
Expand Down
43 changes: 43 additions & 0 deletions app/assets/javascripts/mobile/publisher.js
@@ -0,0 +1,43 @@
$(document).ready(function(){
// no publisher available
if($("#new_status_message").length === 0) { return; }

$(".service_icon").bind("tap click", function() {
var service = $(this).toggleClass("dim"),
selectedServices = $("#new_status_message .service_icon:not(.dim)"),
provider = service.attr("id"),
hiddenField = $("#new_status_message input[name='services[]'][value='" + provider + "']"),
publisherMaxChars = 40000,
serviceMaxChars;


$("#new_status_message .counter").remove();

$.each(selectedServices, function() {
serviceMaxChars = parseInt($(this).attr("maxchar"));
if(publisherMaxChars > serviceMaxChars) {
publisherMaxChars = serviceMaxChars;
}
});

$("#status_message_text").charCount({allowed: publisherMaxChars, warning: publisherMaxChars/10 });

if(hiddenField.length > 0) { hiddenField.remove(); }
else {
$("#new_status_message").append(
$("<input/>", {
name: "services[]",
type: "hidden",
value: provider
})
);
}
});

$("#submit_new_message").bind("tap click", function(evt){
evt.preventDefault();
$("#new_status_message").submit();
});

autosize($("#status_message_text"));
});
171 changes: 0 additions & 171 deletions vendor/assets/javascripts/mbp-helper.js

This file was deleted.