1/* 2 SiteComponents version: 3 7.1.3, tag SC_7_1_3, created Fri Jan 11 12:00:04 +0100 2013 4 5 Disclaimer 6 7 While we make every effort to ensure that this code is fit for its intended 8 purpose, we make no guarantees as to its functionality. CoreTrek AS will 9 accept no responsibility for the loss of data or any other damage or 10 financial loss caused by use of this code. 11 12 13 Copyright 14 15 This programming code is copyright of CoreTrek AS. Permission to run this 16 code is given to approved users of CoreTrek's publishing system CorePublish. 17 18 This source code may not be copied, modified or otherwise repurposed for use 19 by a third party without the written permission of CoreTrek AS. 20 21 Contact [email protected] for information. 22 23*/ 24 25/*jslint laxbreak: true, sub: true, white: false, browser: true, 26onevar: false, nomen: false, noindent: true, eqeqeq: false, plusplus: false, 27forin: true */ 28/*global siteComponentsConfig: false, getSiteComponentsConfig: false, 29Ajax: false, $$: false, $: false, Element: false, window: false, Class: false, 30Effect: false, lightbox: false, PeriodicalExecuter: false, Event: false, 31CtCookie: false, cpKeywords: false, CtTooltip: false, Prototype: false, 32cpWriteMediaObject: false */ 33 34/* 35 36 ============================================================================ 37 IMPORTANT! This javascript is dependent on Prototype. If Scriptaculous is 38 available the tooltip will use some nice effects. 39 ============================================================================ 40 41 JavaScript enhancements for offensive comment link 42 43*/ 44 45var OffensiveComment = Class.create({ 46 47 /** 48 * Constructor rewrites the HTML to Ajax style 49 */ 50 rewriteButtonToLink: function(element) { 51 this.element = element; 52 53 var form = element.down(); 54 55 this.ajaxifyForm(form); 56 57 var button = element.select("button").first(); 58 59 this.link = element.update('<a href="#offensive">' + button.firstChild.nodeValue + '</a>').down(); 60 this.link.observe('click', this.submitListener.bindAsEventListener(this)); 61 }, 62 63 ajaxifyForm: function(form) { 64 this.parameters = form.serialize(); 65 this.serviceUrl = form.readAttribute('action'); 66 67 this.tagOffensiveConfirmText = form.select("input[name=tag_offensive_confirm]")[0].value; 68 this.taggedOffensiveText = form.select("input[name=tagged_offensive]")[0].value; 69 70 this.button = form.select("button").first(); 71 72 this.button.observe('click', this.submitListener.bindAsEventListener(this)); 73 }, 74 75 // ======================================================================== 76 // Event listeners 77 78 submitListener: function(event) { 79 event.stop(); 80 81 if(confirm(this.tagOffensiveConfirmText)) { 82 new Ajax.Request(this.serviceUrl, { 83 parameters: this.parameters, 84 onSuccess: this.successListener.bindAsEventListener(this) 85 }); 86 } 87 }, 88 89 successListener: function(event) { 90 if(typeof this.link != 'undefined') { 91 var updatedElement = this.link.replace('<span>(' + this.taggedOffensiveText + ')</span>').down(); 92 93 try { 94 new Effect.Highlight(updatedElement); 95 } catch (err) { 96 // Scriptaculous is not available, just ignore.. 97 } 98 } else { 99 this.button.disabled = true; 100 this.button.addClassName('disabledbutton'); 101 } 102 } 103 104});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.