{I"
class:ETI"ProcessedAsset; FI"logical_path; TI"!mercury/modals/insertlink.js; FI"
pathname; TI"‘/home/edik/.rvm/gems/ruby-2.0.0-p247@very_simple_cms/bundler/gems/mercury-3e0245e33195/app/assets/javascripts/mercury/modals/insertlink.js.coffee; FI"content_type; TI"application/javascript; TI"
mtime; Tl+½¡9RI"length; TiÇI"digest; TI"%aef82a415433c79bee0c72df7d8777dc; FI"source; TI"Ç(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);
; TI"dependency_digest; TI"%3a562e8eceae7983597ad8c62bc8da68; FI"required_paths; T[I"‘/home/edik/.rvm/gems/ruby-2.0.0-p247@very_simple_cms/bundler/gems/mercury-3e0245e33195/app/assets/javascripts/mercury/modals/insertlink.js.coffee; FI"dependency_paths; T[{I" path; TI"‘/home/edik/.rvm/gems/ruby-2.0.0-p247@very_simple_cms/bundler/gems/mercury-3e0245e33195/app/assets/javascripts/mercury/modals/insertlink.js.coffee; FI"
mtime; TI"2013-09-18T16:51:09+04:00; TI"digest; TI"%c5b4289be62f79e816c0c3945be8cf6b; FI"
_version; TI"%2cf3622cbba861b85d33ffabfa420c13; F