javascript - I need to inject a Tealium code in below attached comment.js file -


following code needs inserted in comment.js file

(function(a,b,c,d){         a='//tags.tiqcdn.com/utag/sapient/main/qa/utag.js';         b=document;c='script';d=b.createelement(c);d.src=a;d.type='text/java'+c;d.async=true;         a=b.getelementsbytagname(c)[0];a.parentnode.insertbefore(d,a);     })(); 

following below comment.js file code

(function() {  /**  * "slides" comment form in , out of view  *   * @method togglecommentform  * @param {event} e event object  */ function togglecommentform(e) {     var activityitem = ajs.$(e.target).closest('div.activity-item'),         form = activityitem.find('form.activity-item-comment-form');      e.preventdefault();      if (!form.length) {         form = buildcommentform(e, activityitem);         form.appendto(activityitem);     }     if (form.is(':visible')) {         form.slideup(function() {             form.trigger('contentresize.streams').removeclass('ready');         });     } else {         form.slidedown(function() {             form.find('textarea').focus();             // remove 'display: block' set slidedown fn can hide form css             form.css({display: ''});             form.trigger('contentresize.streams').addclass('ready');         });     } }  /**  * returns html inline add comment form  *   * @method buildcommentform  * @param {event} e event object  * @param {object} activityitem .activity-item div  * @return {htmlelement}  */ function buildcommentform(e, activityitem) {     var form,         fieldset,         submit,         feeditem;      if (!e.data || !e.data.feeditem) {         activitystreams.inlineactions.statusmessage(activityitem, ajs.i18n.gettext('streams.comment.action.error.invalid.comment'), 'error');         return null;     }      feeditem = e.data.feeditem;     form = ajs.$('<form class="activity-item-comment-form" method="post" action=""></form>').css({display: 'none'});      fieldset = ajs.$('<fieldset></fieldset>')         .appendto(form);     ajs.$('<input type="hidden" name="replyto">')         .val(feeditem.links['http://streams.atlassian.com/syndication/reply-to'])         .appendto(fieldset);      // name of hidden xsrf token field must correspond value of cross_product_token_param     // in com.atlassian.streams.internal.servlet.xsrfawarerequest class (in streams aggregator plugin)     ajs.$('<input type="hidden" name="xsrftoken">')             .val(window.top.ajs.$("#atlassian-token").attr("content"))             .appendto(fieldset);      ajs.$('<textarea cols="40" rows="6" name="comment"></textarea>')         .appendto(fieldset);      submit = ajs.$('<div class="submit"></div>')         .appendto(form);     ajs.$('<button name="submit" type="submit"></button>')         .text(ajs.i18n.gettext('streams.comment.action.add'))         .appendto(submit);     ajs.$('<a href="#" class="streams-cancel"></a>')         .text(ajs.i18n.gettext('streams.comment.action.cancel'))         .click(togglecommentform)         .appendto(submit);      form.submit(function(e) {         e.preventdefault();         var form = ajs.$(e.target),             commentbody = ajs.$.trim(form.find("textarea").val());         if (commentbody.length === 0) {             activitystreams.inlineactions.statusmessage(activityitem, ajs.i18n.gettext('streams.comment.action.error.add.comment'), 'error');             return;         }         form.find("button").attr("disabled", "true");          ajs.$.ajax({             type : 'post',             url : activitystreams.getbaseurl() + '/plugins/servlet/streamscomments',             data : form.serialize(),             datatype : 'json',             global: false,             beforesend: function() {                 form.trigger('begininlineaction');             },             complete: function() {                 form.trigger('completeinlineaction');             },             success : function(data, textstatus, xhr) {                 togglecommentform(e);                 form.find("button").removeattr("disabled");                 form.find("textarea").val("");                  //302 not considered error, jira using return blocked url errors https://sdog.jira.com/browse/jstdev-670 , https://studio.atlassian.com/browse/strm-1982                 if(xhr.status == 302) {                     activitystreams.inlineactions.statusmessage(activityitem, ajs.i18n.gettext('streams.comment.action.error.invalid.comment'), 'error');                 }                 else {                     activitystreams.inlineactions.statusmessage(activityitem, ajs.i18n.gettext('streams.comment.action.success.add.comment'), 'info');                     form.trigger('issuecommented', feeditem);                 }             },             error : function(response) {                 var data = (response && response.data) || response,                     subcode = (data && data.responsetext && ajs.json.parse(data.responsetext).subcode) || 'streams.comment.action.error.invalid.comment';                 togglecommentform(e);                 form.find('button').removeattr('disabled');                 activitystreams.inlineactions.statusmessage(activityitem, ajs.i18n.gettext(subcode), 'error');             }         });     });      return form; }  /**  * builds anchor element toggles comment form if feeditem has replyto link  *   * @method buildtrigger  * @param {string} label display text link  * @param {object} feeditem object representing activity item  * @return {htmlelement}  */ function buildtrigger(label, feeditem) {     //if no reply link exists in feed item, not bind entry comment handler     if (!feeditem.links['http://streams.atlassian.com/syndication/reply-to']) {         return null;     }       return ajs.$('<a href="#" class="activity-item-comment-link"></a>')         .text(label)         .bind('click', {feeditem: feeditem}, togglecommentform); }  /**  * builds "comment" link toggles comment form  *  * @method buildcommentlink  * @param {object} feeditem object representing activity item  * @return {htmlelement}  */ function buildcommentlink(feeditem) {     var label = ajs.i18n.gettext('streams.comment.action.comment');     if (feeditem.application !== 'com.atlassian.jira' && feeditem.type === 'comment') {         label = ajs.i18n.gettext('streams.comment.action.reply');     }     return buildtrigger(label, feeditem); }  // registers comment action various types in feed activitystreams.registeraction('article comment page issue file job', buildcommentlink, 1); 

})();


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -