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

Converted the coffeescript to javascript ahead of time #159

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.7
3.1.2
17 changes: 17 additions & 0 deletions app/assets/javascripts/jquery-mobile-rs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(function() {
$(function() {
$(document).on("recurring_select:cancel recurring_select:save", ".recurring_select", function() {
return $(this).selectmenu('refresh');
});
return $(document).on("recurring_select:dialog_opened", ".rs_dialog_holder", function() {
$(this).find("select").attr("data-theme", $('.recurring_select').data("theme")).attr("data-mini", true).selectmenu();
$(this).find("input[type=text]").textinput();
return $(this).on("recurring_select:dialog_positioned", ".rs_dialog", function() {
return $(this).css({
"top": $(window).scrollTop() + "px"
});
});
});
});

}).call(this);
15 changes: 0 additions & 15 deletions app/assets/javascripts/jquery-mobile-rs.js.coffee

This file was deleted.

116 changes: 116 additions & 0 deletions app/assets/javascripts/recurring_select.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
(function() {
var $, methods;

$ = jQuery;

$(function() {
$(document).on("focus", ".recurring_select", function() {
return $(this).recurring_select('set_initial_values');
});
return $(document).on("change", ".recurring_select", function() {
return $(this).recurring_select('changed');
});
});

methods = {
set_initial_values: function() {
this.data('initial-value-hash', this.val());
return this.data('initial-value-str', $(this.find("option").get()[this.prop("selectedIndex")]).text());
},
changed: function() {
if (this.val() === "custom") {
return methods.open_custom.apply(this);
} else {
return methods.set_initial_values.apply(this);
}
},
open_custom: function() {
this.data("recurring-select-active", true);
new RecurringSelectDialog(this);
return this.blur();
},
save: function(new_rule) {
var new_json_val;
this.find("option[data-custom]").remove();
new_json_val = JSON.stringify(new_rule.hash);
if ($.inArray(new_json_val, this.find("option").map(function() {
return $(this).val();
})) === -1) {
methods.insert_option.apply(this, [new_rule.str, new_json_val]);
}
this.val(new_json_val);
methods.set_initial_values.apply(this);
return this.trigger("recurring_select:save");
},
current_rule: function() {
return {
str: this.data("initial-value-str"),
hash: $.parseJSON(this.data("initial-value-hash"))
};
},
cancel: function() {
this.val(this.data("initial-value-hash"));
this.data("recurring-select-active", false);
return this.trigger("recurring_select:cancel");
},
insert_option: function(new_rule_str, new_rule_json) {
var new_option, separator;
separator = this.find("option:disabled");
if (separator.length === 0) {
separator = this.find("option");
}
separator = separator.last();
new_option = $(document.createElement("option"));
new_option.attr("data-custom", true);
if (new_rule_str.substr(new_rule_str.length - 1) !== "*") {
new_rule_str += "*";
}
new_option.text(new_rule_str);
new_option.val(new_rule_json);
return new_option.insertBefore(separator);
},
methods: function() {
return methods;
}
};

$.fn.recurring_select = function(method) {
if (method in methods) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else {
return $.error("Method " + method + " does not exist on jQuery.recurring_select");
}
};

$.fn.recurring_select.options = {
monthly: {
show_week: [true, true, true, true, false, false]
}
};

$.fn.recurring_select.texts = {
locale_iso_code: "en",
repeat: "Repeat",
last_day: "Last Day",
frequency: "Frequency",
daily: "Daily",
weekly: "Weekly",
monthly: "Monthly",
yearly: "Yearly",
every: "Every",
days: "day(s)",
weeks_on: "week(s) on",
months: "month(s)",
years: "year(s)",
day_of_month: "Day of month",
day_of_week: "Day of week",
cancel: "Cancel",
ok: "OK",
summary: "Summary",
first_day_of_week: 0,
days_first_letter: ["S", "M", "T", "W", "T", "F", "S"],
order: ["1st", "2nd", "3rd", "4th", "5th", "Last"],
show_week: [true, true, true, true, false, false]
};

}).call(this);
105 changes: 0 additions & 105 deletions app/assets/javascripts/recurring_select.js.coffee

This file was deleted.

27 changes: 27 additions & 0 deletions app/assets/javascripts/recurring_select/fr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(function() {
$.fn.recurring_select.texts = {
locale_iso_code: "fr",
repeat: "Récurrence",
last_day: "Dernier jour",
frequency: "Fréquence",
daily: "Tous les jours",
weekly: "Toutes les semaines",
monthly: "Tous les mois",
yearly: "Tous les ans",
every: "Tous les",
days: "jour(s)",
weeks_on: "semaine(s) le",
months: "mois",
years: "année(s)",
cancel: "Annuler",
day_of_month: "Jour du mois",
day_of_week: "Jour de la semaine",
ok: "OK",
summary: "Résumé",
first_day_of_week: 1,
days_first_letter: ["D", "L", "M", "M", "J", "V", "S"],
order: ["1er", "2ème", "3ème", "4ème", "5ème", "Dernier"],
show_week: [true, true, true, true, false, false]
};

}).call(this);
24 changes: 0 additions & 24 deletions app/assets/javascripts/recurring_select/fr.js.coffee

This file was deleted.

Loading