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

CoffeeScript 1.6.x to make use of prettyErrorMessage #1125

Merged
merged 1 commit into from
Apr 7, 2013
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,8 @@ push_repo = (args=[], cb, cb_err) ->
run 'git', ['push'].concat(args), cb, cb_err

print_error = (error, file_name, file_contents) ->
line = error.message.match /line ([0-9]+):/
if line && line[1] && line = parseInt(line[1])
contents_lines = file_contents.split "\n"
first = if line-4 < 0 then 0 else line-4
last = if line+3 > contents_lines.size then contents_lines.size else line+3
console.log "Error compiling #{file_name}. \"#{error.message}\"\n"
index = 0
for line in contents_lines[first...last]
index++
line_number = first + 1 + index
console.log "#{(' ' for [0..(3-(line_number.toString().length))]).join('')} #{line}"
if error.location
console.log CoffeeScript.helpers.prettyErrorMessage(error, file_name, file_contents, true)
else
console.log """
Error compiling #{file_name}:
Expand All @@ -171,8 +162,6 @@ Error compiling #{file_name}:

"""



task 'release', 'build, tag the current release, and push', ->
console.log "Trying to tag #{version_tag()}..."
with_clean_repo ->
Expand Down
64 changes: 47 additions & 17 deletions chosen/chosen.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
var SelectParser;

SelectParser = (function() {

function SelectParser() {
this.options_index = 0;
this.parsed = [];
Expand All @@ -27,6 +26,7 @@

SelectParser.prototype.add_group = function(group) {
var group_position, option, _i, _len, _ref, _results;

group_position = this.parsed.length;
this.parsed.push({
array_index: group_position,
Expand Down Expand Up @@ -79,6 +79,7 @@

SelectParser.select_to_array = function(select) {
var child, parser, _i, _len, _ref;

parser = new SelectParser();
_ref = select.childNodes;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
Expand All @@ -91,7 +92,6 @@
this.SelectParser = SelectParser;

}).call(this);

/*
Chosen source: generate output using 'cake build'
Copyright (c) 2011 by Harvest
Expand All @@ -104,7 +104,6 @@ Copyright (c) 2011 by Harvest
root = this;

AbstractChosen = (function() {

function AbstractChosen(form_field, options) {
this.form_field = form_field;
this.options = options != null ? options : {};
Expand All @@ -119,6 +118,7 @@ Copyright (c) 2011 by Harvest

AbstractChosen.prototype.set_default_values = function() {
var _this = this;

this.click_test_action = function(evt) {
return _this.test_active_click(evt);
};
Expand Down Expand Up @@ -162,6 +162,7 @@ Copyright (c) 2011 by Harvest

AbstractChosen.prototype.input_focus = function(evt) {
var _this = this;

if (this.is_multiple) {
if (!this.active_field) {
return setTimeout((function() {
Expand All @@ -177,6 +178,7 @@ Copyright (c) 2011 by Harvest

AbstractChosen.prototype.input_blur = function(evt) {
var _this = this;

if (!this.mouse_on_container) {
this.active_field = false;
return setTimeout((function() {
Expand All @@ -187,6 +189,7 @@ Copyright (c) 2011 by Harvest

AbstractChosen.prototype.result_add_option = function(option) {
var classes, style;

if (!option.disabled) {
option.dom_id = this.container_id + "_o_" + option.array_index;
classes = option.selected && this.is_multiple ? [] : ["active-result"];
Expand Down Expand Up @@ -234,6 +237,7 @@ Copyright (c) 2011 by Harvest

AbstractChosen.prototype.keyup_checker = function(evt) {
var stroke, _ref;

stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
this.search_field_scale();
switch (stroke) {
Expand Down Expand Up @@ -270,13 +274,15 @@ Copyright (c) 2011 by Harvest

AbstractChosen.prototype.generate_field_id = function() {
var new_id;

new_id = this.generate_random_id();
this.form_field.id = new_id;
return new_id;
};

AbstractChosen.prototype.generate_random_char = function() {
var chars, newchar, rand;

chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
rand = Math.floor(Math.random() * chars.length);
return newchar = chars.substring(rand, rand + 1);
Expand All @@ -289,15 +295,14 @@ Copyright (c) 2011 by Harvest
root.AbstractChosen = AbstractChosen;

}).call(this);

/*
Chosen source: generate output using 'cake build'
Copyright (c) 2011 by Harvest
*/


(function() {
var $, Chosen, get_side_border_padding, root,
var $, Chosen, get_side_border_padding, root, _ref,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

Expand All @@ -308,6 +313,7 @@ Copyright (c) 2011 by Harvest
$.fn.extend({
chosen: function(options) {
var browser, match, ua;

ua = navigator.userAgent.toLowerCase();
match = /(msie) ([\w.]+)/.exec(ua) || [];
browser = {
Expand All @@ -319,6 +325,7 @@ Copyright (c) 2011 by Harvest
}
return this.each(function(input_field) {
var $this;

$this = $(this);
if (!$this.hasClass("chzn-done")) {
return $this.data('chosen', new Chosen(this, options));
Expand All @@ -328,11 +335,11 @@ Copyright (c) 2011 by Harvest
});

Chosen = (function(_super) {

__extends(Chosen, _super);

function Chosen() {
return Chosen.__super__.constructor.apply(this, arguments);
_ref = Chosen.__super__.constructor.apply(this, arguments);
return _ref;
}

Chosen.prototype.setup = function() {
Expand All @@ -347,6 +354,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.set_up_html = function() {
var container_classes, container_div, container_props, dd_top, dd_width, sf_width;

this.container_id = this.form_field.id.length ? this.form_field.id.replace(/[^\w]/g, '_') : this.generate_field_id();
this.container_id += "_chzn";
container_classes = ["chzn-container"];
Expand Down Expand Up @@ -403,6 +411,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.register_observers = function() {
var _this = this;

this.container.mousedown(function(evt) {
_this.container_mousedown(evt);
});
Expand Down Expand Up @@ -476,6 +485,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.container_mousedown = function(evt) {
var target_closelink;

if (!this.is_disabled) {
target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
if (evt && evt.type === "mousedown" && !this.results_showing) {
Expand Down Expand Up @@ -538,7 +548,8 @@ Copyright (c) 2011 by Harvest
};

Chosen.prototype.results_build = function() {
var content, data, _i, _len, _ref;
var content, data, _i, _len, _ref1;

this.parsing = true;
this.results_data = root.SelectParser.select_to_array(this.form_field);
if (this.is_multiple && this.choices > 0) {
Expand All @@ -553,9 +564,9 @@ Copyright (c) 2011 by Harvest
}
}
content = '';
_ref = this.results_data;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
data = _ref[_i];
_ref1 = this.results_data;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
data = _ref1[_i];
if (data.group) {
content += this.result_add_group(data);
} else if (!data.empty) {
Expand Down Expand Up @@ -588,6 +599,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.result_do_highlight = function(el) {
var high_bottom, high_top, maxHeight, visible_bottom, visible_top;

if (el.length) {
this.result_clear_highlight();
this.result_highlight = el;
Expand All @@ -614,6 +626,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.results_show = function() {
var dd_top;

if (!this.is_multiple) {
this.selected_item.addClass("chzn-single-with-drop");
if (this.result_single_selected) {
Expand Down Expand Up @@ -655,6 +668,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.set_tab_index = function(el) {
var ti;

if (this.form_field_jq.attr("tabindex")) {
ti = this.form_field_jq.attr("tabindex");
this.form_field_jq.attr("tabindex", -1);
Expand All @@ -674,6 +688,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.search_results_mouseup = function(evt) {
var target;

target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
if (target.length) {
this.result_highlight = target;
Expand All @@ -684,6 +699,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.search_results_mouseover = function(evt) {
var target;

target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
if (target) {
return this.result_do_highlight(target);
Expand All @@ -706,6 +722,7 @@ Copyright (c) 2011 by Harvest
Chosen.prototype.choice_build = function(item) {
var choice_id, html, link,
_this = this;

if (this.is_multiple && this.max_selected_options <= this.choices) {
this.form_field_jq.trigger("liszt:maxselected", {
chosen: this
Expand Down Expand Up @@ -769,6 +786,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.result_select = function(evt) {
var high, high_id, item, position;

if (this.result_highlight) {
high = this.result_highlight;
high_id = high.attr("id");
Expand Down Expand Up @@ -817,6 +835,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.result_deselect = function(pos) {
var result, result_data;

result_data = this.results_data[pos];
if (!this.form_field.options[result_data.options_index].disabled) {
result_data.selected = false;
Expand All @@ -842,16 +861,17 @@ Copyright (c) 2011 by Harvest
};

Chosen.prototype.winnow_results = function() {
var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len1, _ref;
var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len1, _ref1;

this.no_results_clear();
results = 0;
searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
regexAnchor = this.search_contains ? "" : "^";
regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
_ref = this.results_data;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i];
_ref1 = this.results_data;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
option = _ref1[_i];
if (!option.disabled && !option.empty) {
if (option.group) {
$('#' + option.dom_id).css('display', 'none');
Expand Down Expand Up @@ -905,6 +925,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.winnow_results_clear = function() {
var li, lis, _i, _len, _results;

this.search_field.val("");
lis = this.search_results.find("li");
_results = [];
Expand All @@ -924,6 +945,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.winnow_results_set_highlight = function() {
var do_high, selected_results;

if (!this.result_highlight) {
selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
Expand All @@ -935,6 +957,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.no_results = function(terms) {
var no_results_html;

no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
no_results_html.find("span").first().html(terms);
return this.search_results.append(no_results_html);
Expand All @@ -946,6 +969,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.keydown_arrow = function() {
var first_active, next_sib;

if (!this.result_highlight) {
first_active = this.search_results.find("li.active-result").first();
if (first_active) {
Expand All @@ -964,6 +988,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.keyup_arrow = function() {
var prev_sibs;

if (!this.results_showing && !this.is_multiple) {
return this.results_show();
} else if (this.result_highlight) {
Expand All @@ -981,6 +1006,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.keydown_backstroke = function() {
var next_available_destroy;

if (this.pending_backstroke) {
this.choice_destroy(this.pending_backstroke.find("a").first());
return this.clear_backstroke();
Expand All @@ -1005,8 +1031,9 @@ Copyright (c) 2011 by Harvest
};

Chosen.prototype.keydown_checker = function(evt) {
var stroke, _ref;
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
var stroke, _ref1;

stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
this.search_field_scale();
if (stroke !== 8 && this.pending_backstroke) {
this.clear_backstroke();
Expand Down Expand Up @@ -1036,6 +1063,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.search_field_scale = function() {
var dd_top, div, h, style, style_block, styles, w, _i, _len;

if (this.is_multiple) {
h = 0;
w = 0;
Expand Down Expand Up @@ -1067,6 +1095,7 @@ Copyright (c) 2011 by Harvest

Chosen.prototype.generate_random_id = function() {
var string;

string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
while ($("#" + string).length > 0) {
string += this.generate_random_char();
Expand All @@ -1082,6 +1111,7 @@ Copyright (c) 2011 by Harvest

get_side_border_padding = function(elmt) {
var side_border_padding;

return side_border_padding = elmt.outerWidth() - elmt.width();
};

Expand Down
2 changes: 1 addition & 1 deletion chosen/chosen.jquery.min.js

Large diffs are not rendered by default.

Loading