o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1388436950.167469:@value"ö{I"
class:EFI"BundledAsset; FI"logical_path; FI"!mercury/modals/insertlink.js; FI"
pathname; FI"›/Users/jrissler/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/mercury-6daffeeb487e/app/assets/javascripts/mercury/modals/insertlink.js.coffee; FI"content_type; FI"application/javascript; FI"
mtime; FI"2013-11-20T08:09:45-05:00; FI"length; FiÈI"digest; F"%93a20c4c6d79809db6526b8ce96f01dbI"source; FI"È(function() {
this.Mercury.modalHandlers.insertLink = {
initialize: function() {
var _this = this;
this.editing = false;
this.content = null;
this.element.find('.control-label input').on('click', this.onLabelChecked);
this.element.find('.controls .optional, .controls .required').on('focus', this.onInputFocused);
this.element.find('#link_target').on('change', function() {
return _this.onChangeTarget();
});
this.initializeForm();
return this.element.find('form').on('submit', function(event) {
event.preventDefault();
_this.validateForm();
if (!_this.valid) {
_this.resize();
return;
}
_this.submitForm();
return _this.hide();
});
},
initializeForm: function() {
var a, bookmarkSelect, href, img, newBookmarkInput, selection;
this.fillExistingBookmarks();
if (!(Mercury.region && Mercury.region.selection)) {
return;
}
selection = Mercury.region.selection();
if (selection.textContent) {
this.element.find('#link_text').val(selection.textContent());
}
if (selection && selection.commonAncestor) {
a = selection.commonAncestor(true).closest('a');
}
if (selection.htmlContent) {
img = /', {
value: jQuery(tag).attr('name')
}).text(jQuery(tag).text())));
}
return _results;
},
onLabelChecked: function() {
var forInput;
forInput = jQuery(this).closest('.control-label').attr('for');
return jQuery(this).closest('.control-group').find("#" + forInput).focus();
},
onInputFocused: function() {
return jQuery(this).closest('.control-group').find('input[type=radio]').prop('checked', true);
},
onChangeTarget: function() {
this.element.find(".link-target-options").hide();
this.element.find("#" + (this.element.find('#link_target').val()) + "_options").show();
return this.resize(true);
},
addInputError: function(input, message) {
input.after('' + Mercury.I18n(message) + '').closest('.control-group').addClass('error');
return this.valid = false;
},
clearInputErrors: function() {
this.element.find('.control-group.error').removeClass('error').find('.error-message').remove();
return this.valid = true;
},
validateForm: function() {
var el, type;
this.clearInputErrors();
type = this.element.find('input[name=link_type]:checked').val();
el = this.element.find("#link_" + type);
if (!el.val()) {
this.addInputError(el, "can't be blank");
}
if (!this.editing && !this.content) {
el = this.element.find('#link_text');
if (!el.val()) {
return this.addInputError(el, "can't be blank");
}
}
},
submitForm: function() {
var args, attrs, content, target, type, value;
content = this.element.find('#link_text').val();
target = this.element.find('#link_target').val();
type = this.element.find('input[name=link_type]:checked').val();
switch (type) {
case 'existing_bookmark':
attrs = {
href: "#" + (this.element.find('#link_existing_bookmark').val())
};
break;
case 'new_bookmark':
attrs = {
name: "" + (this.element.find('#link_new_bookmark').val())
};
break;
default:
attrs = {
href: this.element.find("#link_" + type).val()
};
}
switch (target) {
case 'popup':
args = {
width: parseInt(this.element.find('#link_popup_width').val()) || 500,
height: parseInt(this.element.find('#link_popup_height').val()) || 500,
menubar: 'no',
toolbar: 'no'
};
attrs['href'] = "javascript:void(window.open('" + attrs['href'] + "', 'popup_window', '" + (jQuery.param(args).replace(/&/g, ',')) + "'))";
break;
default:
if (target) {
attrs['target'] = target;
}
}
value = {
tagName: 'a',
attrs: attrs,
content: this.content || content
};
if (this.editing) {
return Mercury.trigger('action', {
action: 'replaceLink',
value: value,
node: this.editing.get(0)
});
} else {
return Mercury.trigger('action', {
action: 'insertLink',
value: value
});
}
}
};
}).call(this);
; FI"required_assets_digest; F"%b02ab4024823da5aace20d71c89d18b3I"
_version; F"%6776f581a4329e299531e1d52aa59832