// Generate possible selectors for the given element function createPathFinder( elem ) { var path = $('<ol/>'), step, tag, pos; function addClassOption(i, name) { if ( name.length && !/^SELECTACULAR/.test(name) ) { createSelectorOption('.' + name, 'class').appendTo(step); } } while ( elem ) { step = $('<li class="selector"/>').data("node", elem); tag = elem.nodeName.toLowerCase(); if ( elem.id ) { createSelectorOption('#' + elem.id, 'id').appendTo(step); } $.each($.trim(elem.className).split(/\s+/), addClassOption); createSelectorOption(tag, 'tag').appendTo(step); path.prepend(step); if ( tag === 'body' ) { elem = null; } else { path.prepend('<li class="combinator">></li>'); elem = elem.parentNode; } } return path; }
$(document).ready(function() { var request; function submitForm() { var form = $('#jqlform'); $('.results > div').fadeTo('fast', 0.4); if (request) { request.abort(); } request = $.ajax({url: form.attr('action'), type: 'POST', data: form.serialize(), success: function(data) { var results = $('.results > div', data) $('.results > div').remove(); $('.results').append(results); $('.results > #jqlerror').remove(); // push this to the end of the event queue setTimeout(function() { $('#primary').remove(); $('#primary', data).prependTo('#main-content'); }, 0); } }); } $('#jqltext').bind('keyup', $.defer(10, function(event) { if ($('.jqlgood').length) { submitForm(); } })); });
return function() { // Save the vars for the real callback var that = this, args = arguments; // Reset the delay clearTimeout(timerDataName ? $.data(this, timerDataName) : timer); // Delay the real callback timer = setTimeout(function() { callback.apply(that, args); }, delay); if ( timerDataName ) { $.data(this, timerDataName, timer); } };
function sendCreateData(params, callback) { var createButton = $('#extension-wizard-create'); $('#extension-wizard-create').attr('disabled', 'true'); createButton.parent().append('<img class="waiting" alt="waiting" src="' + staticResourcesPrefix + '/com.atlassian.labs.speakeasy-plugin:shared/images/wait.gif">'); $.ajax({ url: contextPath + "/rest/speakeasy/1/plugins/create/" + params.key, type: 'POST', beforeSend: function(jqXHR, settings) { jqXHR.setRequestHeader("X-Atlassian-Token", "nocheck"); }, data: params, success: function(data) { $('#plugins-table').trigger('pluginsUpdated', data); addMessage('success', {body: "<b>" + params.name + "</b> was created successfully", shadowed: false}); $('.waiting', createButton).remove(); $('#extension-wizard-create').removeAttr('disabled'); callback(); }, error: function(data) { var err = JSON.parse(data.responseText).error; AJS.messages.error('#wizard-errors', {body:err}); $('.waiting', createButton.parent()).remove(); $('#extension-wizard-create').removeAttr('disabled'); } }); }
page.find('th').each(function(index) { var key = $(this).text().trim(); if ($.inArray(key, keys) > -1) { props[key] = $(this).next().text().trim(); } });
function callFn(type, id) { if ($.isFunction(id)) { id = id(); } if (type && id) { fn(type, id); return id; } }
var blogs = $.map(data, function(blog) { var isCommonModule = false; $.each(blog.labels, function(index, label) { if (label.name == "commonmodule") { isCommonModule = true } }); return isCommonModule ? blog : null; });
conf.getBlogsInPeriod('DEV', start, end, function(data) { var blogs = $.map(data, function(blog) { var isCommonModule = false; $.each(blog.labels, function(index, label) { if (label.name == "commonmodule") { isCommonModule = true } }); return isCommonModule ? blog : null; }); var modules = $.map(blogs, function(val) { var props = extractProperties(["Project", "Version", "Difficulty", "Required", "Summary"], val.content); props.id = val.id; props.title = val.title; props.url = val.url; return props.Project ? props : null; }); var form = $("<form/>").attr({ 'method' : "POST", id : 'cmup', 'action' : contextPath + "/pages/createpage.action?spaceKey=DEV&fromPageId=1700136498" }); form.append($('<input/>').attr({ type : 'hidden', name : "title", value : 'Common Module Upgrade Pack - ' + start.getFullYear() + "-" + pad(start.getMonth() + 1, 2) })); var template = require('./report').render({ "Required" : $.map(modules, function(module) { return module.Required == "Yes" ? module : null;}), "Optional" : $.map(modules, function(module) { return module.Required == "No" ? module : null;}) }); form.append($('<input/>').attr({ type : 'hidden', name : "wysiwygContent", value : template })); $('body').append(form); $('#cmup').submit(); });
exports.openDialog = function(pluginKey, link, attachedRow) { var desc = $.trim($('.plugin-description', attachedRow).text()); var dialog = new AJS.Dialog({width:500, height:450, id:'fork-dialog'}); var pluginName = $('td[headers=plugin-name] .plugin-name', attachedRow).text(); dialog.addHeader("Fork '" + pluginName + "'"); var forkDialogContents = require('./dialog').render({ pluginKey : pluginKey, description : desc }); dialog.addPanel("Fork", forkDialogContents, "panel-body"); dialog.addButton("Fork", function (dialog) { var description = $('#fork-description').val(); forkPlugin(link, attachedRow, description); dialog.remove(); }, "fork-submit"); dialog.addButton("Cancel", function (dialog) { dialog.remove(); }, "fork-cancel"); dialog.show(); };
function forkPlugin(link, attachedRow, description, callbacks) { var pluginName = $('.plugin-name', attachedRow).text(); $.ajax({ url: contextPath + link.attr('href'), type: 'POST', beforeSend: function(jqXHR, settings) { jqXHR.setRequestHeader("X-Atlassian-Token", "nocheck"); }, data: {description:description}, success: function(data) { $('#plugins-table').trigger('pluginsUpdated', data); addMessage('success', {body: "<b>" + pluginName + "</b> was forked successfully", shadowed: false}); callbacks.success(); }, error: function(data) { addMessage('error', {title: "Error forking extension", body: data.responseText, shadowed: false}); callbacks.success(); } }); }
function validate(data) { $("#wizard-errors").children().remove(); var errors = []; if (!data.key || !data.key.match(/[a-zA-Z-_]+/) || data.key.length > 20) { errors.push("Invalid key, must be less than 20 characters and only include letters, dashes, and underscores"); } else if (!data.name || data.name.length > 30) { errors.push("Invalid name, must be less than 30 characters"); } else if (!data.description || data.description.length > 120) { errors.push("Invalid description, must be less than 200 characters"); } if (errors.length > 0) { $.each(errors, function(id, val) { AJS.messages.error('#wizard-errors', {body:val}); }); return false; } else { return true; } }
exports.openDialog = function(pluginKey, link, attachedRow) { var desc = $.trim($('.plugin-description', attachedRow).text()); var pluginName = $('td[headers="plugin-info"] .plugin-name', attachedRow).text(); dialog.openOnePanelDialog({ id : 'fork-dialog', width : 500, height : 450, header : "Fork '" + pluginName + "'", content : require('./dialog').render({ pluginKey : pluginKey, description : desc }), submit : function(dialog, callbacks) { var description = $('#fork-description').val(); forkPlugin(link, attachedRow, description, callbacks); }, submitClass : 'fork-submit', cancelClass : 'fork-cancel' }); return dialog; };
function forkPlugin(link, attachedRow, description) { //var enabled = ("Disable" == link.text()); link.append('<img class="waiting" alt="waiting" src="' + staticResourcesPrefix + '/download/resources/com.atlassian.labs.speakeasy-plugin:shared/images/wait.gif" />'); var pluginName = $('td[headers=plugin-name] .plugin-name', attachedRow).text(); $.ajax({ url: contextPath + link.attr('href'), type: 'POST', beforeSend: function(jqXHR, settings) { jqXHR.setRequestHeader("X-Atlassian-Token", "nocheck"); }, data: {description:description}, success: function(data) { $('#plugins-table').trigger('pluginsUpdated', data); addMessage('success', {body: "<b>" + pluginName + "</b> was forked successfully", shadowed: false}); $('.waiting', link).remove(); }, error: function(data) { addMessage('error', {title: "Error forking extension", body: data.responseText, shadowed: false}); $('.waiting', link).remove(); } }); }
function submitForm() { var form = $('#jqlform'); $('.results > div').fadeTo('fast', 0.4); if (request) { request.abort(); } request = $.ajax({url: form.attr('action'), type: 'POST', data: form.serialize(), success: function(data) { var results = $('.results > div', data) $('.results > div').remove(); $('.results').append(results); $('.results > #jqlerror').remove(); // push this to the end of the event queue setTimeout(function() { $('#primary').remove(); $('#primary', data).prependTo('#main-content'); }, 0); } }); }
window.clearTimeout(selectTimeout); window.setTimeout(function() { freeze(event.target); }, 0); return false; }) .bind("mouseup.selectacular click.selectacular", function() { return false; }); return exports; } tools.addTool("close-selectacular", { label: "x", desc: "Close Selectacular", close: true }); $.extend(exports, tools); exports.start = start; exports.stop = stop; exports.open = open; exports.close = close; exports.select = select; exports.selector = selector; exports.selected = function() { return selected; };