Skip to content
Extraits de code Groupes Projets
Valider f5bf53a0 rédigé par Steffen van Bergerem's avatar Steffen van Bergerem
Parcourir les fichiers

Refactor vendor javascript

parent a0bcc8c3
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de avec 90 ajouts et 2177 suppressions
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
Diaspora.Alert = {
faceboxTemplate:
'<div id="diaspora_alert">' +
'<div class="span-12 last">' +
'<div id="facebox_header">' +
'<h4>' +
'<%= title %>' +
'</h4>' +
'</div>' +
'<%= content %>' +
'</div>' +
'</div>',
show: function(title, content) {
$(_.template(this.faceboxTemplate)({
title: title,
content: content
})).appendTo(document.body);
$.facebox({
div: "#diaspora_alert"
}, "diaspora_alert");
}
};
$(function() {
$(document).bind("close.facebox", function() {
$("#diaspora_alert").remove();
});
});
// @license-end
/* Copyright (c) 2010-2011, Diaspora Inc. This file is
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
//= require fileuploader-custom
......@@ -2,10 +2,10 @@
//= require handlebars.runtime
//= require templates
//= require main
//= require home
//= require fileuploader-custom
//= require inbox
//= require mobile/mobile
//= require profile
//= require jquery.autoSuggest.custom
//= require contact-list
//= require sinon
//= require jasmine-ajax
//= require mailchimp/jquery.form
//= require mailchimp/jquery.validate
//= require mailchimp/jquery126.min
\ No newline at end of file
/* Copyright (c) 2010-2011, Diaspora Inc. This file is
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
//= require jquery.autoSuggest.custom
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
/* Copyright (c) 2010-2011, Diaspora Inc. This file is
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
//= require mailchimp/jquery.form
var View = {
initialize: function() {
/* Buttons */
......@@ -26,25 +20,6 @@ var View = {
.on('click', this.dropdowns.selector, this.dropdowns.click)
.on('keypress', this.dropdowns.selector, this.dropdowns.click);
/* Clear forms after successful submit, this is some legacy dan hanson stuff, do we still want it? */
$.fn.clearForm = function() {
return this.each(function() {
if ($(this).is('form') && !$(this).hasClass('form_do_not_clear')) {
return $(':input', this).clearForm();
}
if ($(this).hasClass('clear_on_submit') || $(this).is(':text') || $(this).is(':password') || $(this).is('textarea')) {
$(this).val('');
} else if ($(this).is(':checkbox') || $(this).is(':radio')) {
$(this).attr('checked', false);
} else if ($(this).is('select')) {
this.selectedIndex = -1;
} else if ($(this).attr('name') === 'photos[]') {
$(this).val('');
}
$(this).blur();
});
};
$(document).on('ajax:success', 'form[data-remote]', function () {
$(this).clearForm();
$(this).focusout();
......
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
/* Clear form plugin - called using $("elem").clearForm(); */
$.fn.clearForm = function() {
return this.each(function() {
......@@ -16,4 +18,4 @@ $.fn.clearForm = function() {
$(this).blur();
});
};
// @license-end
describe("Diaspora.Alert", function() {
beforeEach(function() {
spec.loadFixture("aspects_index");
$(document).trigger("close.facebox");
});
afterEach(function() {
$("#facebox").remove();
});
describe("on widget ready", function() {
it("should remove #diaspora_alert on close.facebox", function() {
Diaspora.Alert.show("YEAH", "YEAHH");
expect($("#diaspora_alert").length).toEqual(1);
$(document).trigger("close.facebox");
expect($("#diaspora_alert").length).toEqual(0);
});
});
describe("alert", function() {
it("should render a mustache template and append it the body", function() {
Diaspora.Alert.show("YO", "YEAH");
expect($("#diaspora_alert").length).toEqual(1);
$(document).trigger("close.facebox");
});
});
});
Ce diff est replié.
Ce diff est replié.
Ce diff est replié.
function parse_url (str, component) {
// http://kevin.vanzonneveld.net
// + original by: Steven Levithan (http://blog.stevenlevithan.com)
// + reimplemented by: Brett Zamir (http://brett-zamir.me)
// + input by: Lorenzo Pisani
// + input by: Tony
// + improved by: Brett Zamir (http://brett-zamir.me)
// % note: Based on http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js
// % note: blog post at http://blog.stevenlevithan.com/archives/parseuri
// % note: demo at http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js
// % note: Does not replace invalid characters with '_' as in PHP, nor does it return false with
// % note: a seriously malformed URL.
// % note: Besides function name, is essentially the same as parseUri as well as our allowing
// % note: an extra slash after the scheme/protocol (to allow file:/// as in PHP)
// * example 1: parse_url('http://username:password@hostname/path?arg=value#anchor');
// * returns 1: {scheme: 'http', host: 'hostname', user: 'username', pass: 'password', path: '/path', query: 'arg=value', fragment: 'anchor'}
var key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port',
'relative', 'path', 'directory', 'file', 'query', 'fragment'],
ini = (this.php_js && this.php_js.ini) || {},
mode = (ini['phpjs.parse_url.mode'] &&
ini['phpjs.parse_url.mode'].local_value) || 'php',
parser = {
php: /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // Added one optional slash to post-scheme to catch file:/// (should restrict this)
};
var m = parser[mode].exec(str),
uri = {},
i = 14;
while (i--) {
if (m[i]) {
uri[key[i]] = m[i];
}
}
// source: https://github.com/kvz/phpjs/blob/master/functions/url/parse_url.js
// commit 4966dea
// 28 Dec 2014
if (component) {
return uri[component.replace('PHP_URL_', '').toLowerCase()];
}
if (mode !== 'php') {
var name = (ini['phpjs.parse_url.queryKey'] &&
ini['phpjs.parse_url.queryKey'].local_value) || 'queryKey';
parser = /(?:^|&)([^&=]*)=?([^&]*)/g;
uri[name] = {};
uri[key[12]].replace(parser, function ($0, $1, $2) {
if ($1) {uri[name][$1] = $2;}
});
function parse_url(str, component) {
// discuss at: http://phpjs.org/functions/parse_url/
// original by: Steven Levithan (http://blog.stevenlevithan.com)
// reimplemented by: Brett Zamir (http://brett-zamir.me)
// input by: Lorenzo Pisani
// input by: Tony
// improved by: Brett Zamir (http://brett-zamir.me)
// note: original by http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js
// note: blog post at http://blog.stevenlevithan.com/archives/parseuri
// note: demo at http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js
// note: Does not replace invalid characters with '_' as in PHP, nor does it return false with
// note: a seriously malformed URL.
// note: Besides function name, is essentially the same as parseUri as well as our allowing
// note: an extra slash after the scheme/protocol (to allow file:/// as in PHP)
// example 1: parse_url('http://username:password@hostname/path?arg=value#anchor');
// returns 1: {scheme: 'http', host: 'hostname', user: 'username', pass: 'password', path: '/path', query: 'arg=value', fragment: 'anchor'}
// example 2: parse_url('http://en.wikipedia.org/wiki/%22@%22_%28album%29');
// returns 2: {scheme: 'http', host: 'en.wikipedia.org', path: '/wiki/%22@%22_%28album%29'}
// example 3: parse_url('https://host.domain.tld/a@b.c/folder')
// returns 3: {scheme: 'https', host: 'host.domain.tld', path: '/a@b.c/folder'}
// example 4: parse_url('https://gooduser:secretpassword@www.example.com/a@b.c/folder?foo=bar');
// returns 4: { scheme: 'https', host: 'www.example.com', path: '/a@b.c/folder', query: 'foo=bar', user: 'gooduser', pass: 'secretpassword' }
try {
this.php_js = this.php_js || {};
} catch (e) {
this.php_js = {};
}
var query;
var ini = (this.php_js && this.php_js.ini) || {};
var mode = (ini['phpjs.parse_url.mode'] && ini['phpjs.parse_url.mode'].local_value) || 'php';
var key = [
'source',
'scheme',
'authority',
'userInfo',
'user',
'pass',
'host',
'port',
'relative',
'path',
'directory',
'file',
'query',
'fragment'
];
var parser = {
php : /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
loose : /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // Added one optional slash to post-scheme to catch file:/// (should restrict this)
};
var m = parser[mode].exec(str);
var uri = {};
var i = 14;
while (i--) {
if (m[i]) {
uri[key[i]] = m[i];
}
delete uri.source;
return uri;
}
if (component) {
return uri[component.replace('PHP_URL_', '').toLowerCase()];
}
if (mode !== 'php') {
var name = (ini['phpjs.parse_url.queryKey'] &&
ini['phpjs.parse_url.queryKey'].local_value) || 'queryKey';
parser = /(?:^|&)([^&=]*)=?([^&]*)/g;
uri[name] = {};
query = uri[key[12]] || '';
query.replace(parser, function ($0, $1, $2) {
if ($1) {
uri[name][$1] = $2;
}
});
}
delete uri.source;
return uri;
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter