{I" class:ETI"ProcessedAsset; FI"logical_path; TI"$alchemy/alchemy.link_overlay.js; FI" pathname; TI"h/Users/tvd/code/ruby/gems/alchemy_cms/app/assets/javascripts/alchemy/alchemy.link_overlay.js.coffee; FI"content_type; TI"application/javascript; TI" mtime; Tl+–®RI"length; Ti&$I"digest; TI"%e3b0dbbf0d1fd98171674253e131fe99; FI"source; TI"&$(function() { Alchemy.LinkOverlay = { open: function(linked_element) { var $dialog, _this = this; $dialog = $('
'); $dialog.html(Alchemy.getOverlaySpinner({ width: 600, height: 450 })); this.current = $dialog.dialog({ modal: true, minWidth: 600, minHeight: 450, title: 'Link setzen', show: "fade", hide: "fade", resizable: false, open: function(event, ui) { return $.ajax({ url: Alchemy.routes.link_admin_pages_path, success: function(data, status, xhr) { $dialog.html(data); Alchemy.SelectBox('#alchemyLinkOverlay'); $dialog.css({ overflow: 'visible' }); $dialog.dialog('widget').css({ overflow: 'visible' }); _this.attachEvents(); return $('#overlay_tabs').tabs(); }, error: function(xhr, status, errorThrown) { return Alchemy.AjaxErrorHandler($dialog, xhr.status, status, errorThrown); } }); }, close: function() { return $dialog.remove(); } }); return this.current.linked_element = linked_element; }, attachEvents: function() { var _this = this; $('a.sitemap_pagename_link, a.show_elements_to_link', '#alchemyLinkOverlay').click(function(e) { var $this, page_id, url; e.preventDefault(); $this = $(e.target); page_id = $this.data('page-id'); url = $this.data('url'); _this.selectPage(page_id, url); if ($this.is('.show_elements_to_link')) { Alchemy.Spinner.small().spin($this.next()[0]); } if ($this.hasClass('show_elements_to_link')) { return _this.showElementsSelect(page_id); } }); return $('.create-link.button', '#alchemyLinkOverlay').click(function(e) { var link_type, url; e.preventDefault(); link_type = $(e.target).data('link-type'); if (link_type === 'internal') { url = $('#internal_urlname').val() + $('#page_anchor').val(); } else if (link_type === 'external') { url = $('#external_url').val(); } else if (link_type === 'file') { url = $('#public_filename').val(); } else { url = $("#" + link_type + "_urlname").val(); } return _this.createLink(link_type, { url: url, title: $("#" + link_type + "_link_title").val(), target: $("#" + link_type + "_link_target").val() }); }); }, close: function() { this.current.dialog('close'); return true; }, selectPage: function(selected_element, urlname) { $('#page_anchor').removeAttr('value'); $('.elements_for_page').hide().html(''); $('#internal_urlname').val('/' + urlname); $('#alchemyLinkOverlay #sitemap .selected_page').removeClass('selected_page'); return $('#sitemap_sitename_' + selected_element).addClass('selected_page').attr('name', urlname); }, createLink: function(link_type, options) { if (link_type === 'external') { if (this.validateURLFormat(options.url)) { this.setLink(options.url, link_type, options.title, options.target); } else { return this.showValidationError(); } } else { this.setLink(options.url, link_type, options.title, options.target); } return this.close(); }, setLink: function(url, link_type, title, target) { var element; element = this.current.linked_element; Alchemy.setElementDirty($(element).parents('.element_editor')); if (element.editor) { return this.executeTinyMCEcommand(url, title, link_type, target); } else { return this.linkEssence(url, title, link_type, target); } }, selectTab: function() { var link, linked_element, title; linked_element = this.current.linked_element; if (linked_element.nodeType) { link = this.createTempLink(linked_element); } else { if (linked_element.node.nodeName === 'A') { link = linked_element.node; linked_element.selection.moveToBookmark(linked_element.bookmark); } else { return false; } } $('#alchemyLinkOverlay .link_title').val(link.title); $('#alchemyLinkOverlay .link_target').val($(link).attr('data-link-target')); if ($(link).is("a")) { title = link.title === null ? "" : link.title; if ((link.className === '') || link.className === 'internal') { this.selectInternalLinkTab(link); } if (link.className === 'external') { $('#overlay_tabs').tabs().tabs("select", '#overlay_tab_external_link'); $('#external_url').val(link.href); } if (link.className === 'file') { $('#overlay_tabs').tabs().tabs("select", '#overlay_tab_file_link'); return $('#public_filename').val(link.pathname + link.search); } } }, selectInternalLinkTab: function(link) { var $select_container, $sitemap_line, internal_anchor, internal_urlname; internal_anchor = link.hash.split('#')[1]; internal_urlname = link.pathname; $('#overlay_tabs').tabs().tabs("select", '#overlay_tab_internal_link'); $('#internal_urlname').val(internal_urlname); $sitemap_line = $('.sitemap_sitename').closest('[name="' + internal_urlname + '"]'); if ($sitemap_line.length > 0) { $sitemap_line.addClass("selected_page"); $('#page_selector_container').scrollTo($sitemap_line.parents('li'), { duration: 400, offset: -10 }); if (internal_anchor) { $select_container = $sitemap_line.parent().find('.elements_for_page'); $select_container.show(); return $.get(Alchemy.routes.list_admin_elements_path, { page_urlname: $(internal_urlname.split('/')).last()[0], internal_anchor: internal_anchor }); } } }, showElementsSelect: function(id) { $('#elements_for_page_' + id).show(); return $('#page_selector_container').scrollTo('#sitemap_sitename_' + id, { duration: 400, offset: -10 }); }, hideElementsSelect: function(id) { $('#elements_for_page_' + id).hide(); $('#page_anchor').removeAttr('value'); return $('#page_selector_container').scrollTo('#sitemap_sitename_' + id, { duration: 400, offset: -10 }); }, createTempLink: function(linked_element) { var $tmp_link, content_id; $tmp_link = $(""); content_id = $(linked_element).data('content-id'); $tmp_link.attr('href', $("#contents_" + content_id + "_link").val()); $tmp_link.attr('title', $("#contents_" + content_id + "_link_title").val()); $tmp_link.attr('data-link-target', $("#contents_" + content_id + "_link_target").val()); $tmp_link.attr('target', $("#contents_" + content_id + "_link_target").val() === 'blank' ? '_blank' : null); $tmp_link.addClass($("#contents_" + content_id + "_link_class_name").val()); return $tmp_link[0]; }, removeLink: function(link, content_id) { Alchemy.setElementDirty($(link).parents('.element_editor')); $("#contents_" + content_id + "_link").val('').change(); $("#contents_" + content_id + "_link_title").val(''); $("#contents_" + content_id + "_link_class_name").val(''); $("#contents_" + content_id + "_link_target").val(''); $(link).removeClass('linked').addClass('disabled'); return $('#edit_link_' + content_id).removeClass('linked'); }, executeTinyMCEcommand: function(url, title, link_type, target) { var editor, element; element = this.current.linked_element; editor = element.editor; editor.execCommand('mceInsertLink', false, { href: url, 'class': link_type, title: title, 'data-link-target': target, target: target === 'blank' ? '_blank' : null }); return editor.selection.collapse(); }, linkEssence: function(url, title, link_type, target) { var content_id, element; element = this.current.linked_element; content_id = $(element).data('content-id'); $("#contents_" + content_id + "_link").val(url).change(); $("#contents_" + content_id + "_link_title").val(title); $("#contents_" + content_id + "_link_class_name").val(link_type); $("#contents_" + content_id + "_link_target").val(target); $(element).addClass('linked'); return $(element).next().addClass('linked').removeClass('disabled'); }, validateURLFormat: function(url) { if (url.match(/^(mailto:|\/|[a-z]+:\/\/)/)) { return true; } else { return false; } }, showValidationError: function() { $('#errors ul').html("