catching leftover mootoolsisms

This commit is contained in:
Sean McArthur 2011-12-29 12:54:04 -08:00
Родитель eecf269e83
Коммит 991a6af4ad
8 изменённых файлов: 124 добавлений и 117 удалений

Просмотреть файл

@ -20,8 +20,11 @@ var Class = require('shipyard/class/Class'),
Validator = require('../views/Validator'), Validator = require('../views/Validator'),
//TODO: this is bad practice //TODO: this is bad practice
settings = dom.window.get('settings'), settings = dom.window.get('settings');
fd = dom.window.get('fd');
function fd() {
return dom.window.get('fd');
}
var LOADING_CLASS = 'loading'; var LOADING_CLASS = 'loading';
@ -152,7 +155,7 @@ module.exports = new Class({
}); });
} }
fd.addEvent('xpi_downloaded', function() { fd().addEvent('xpi_downloaded', function() {
controller.generateHashtag(); controller.generateHashtag();
}); });
@ -194,9 +197,9 @@ module.exports = new Class({
this.console_el = dom.$(this.options.console_el); this.console_el = dom.$(this.options.console_el);
this.console_el.addEvent('click', function(e) { this.console_el.addEvent('click', function(e) {
e.preventDefault(); e.preventDefault();
var FD = dom.window.get('mozFlightDeck'); var abh = dom.window.get('mozFlightDeck');
if (FD) { if (abh) {
FD.send({ abh.send({
cmd: 'toggleConsole', cmd: 'toggleConsole',
contents: 'open' contents: 'open'
}); });
@ -242,7 +245,7 @@ module.exports = new Class({
onSuccess: function(text) { onSuccess: function(text) {
var response = JSON.parse(text); var response = JSON.parse(text);
// set the redirect data to view_url of the new revision // set the redirect data to view_url of the new revision
fd.setURIRedirect(response.view_url); //fd().setURIRedirect(response.view_url);
// set data changed by save // set data changed by save
controller.registerRevision(response); controller.registerRevision(response);
// change url to the SDK lib code // change url to the SDK lib code
@ -251,7 +254,7 @@ module.exports = new Class({
// change name of the SDK lib // change name of the SDK lib
dom.$('core_library_lib').getElement('span').set( dom.$('core_library_lib').getElement('span').set(
'text', response.lib_name); 'text', response.lib_name);
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
}, },
onComplete: function() { onComplete: function() {
loader.removeClass(LOADING_CLASS); loader.removeClass(LOADING_CLASS);
@ -367,7 +370,7 @@ module.exports = new Class({
method: 'get', method: 'get',
url: string.subsitute(this.options.revisions_list_html_url, this.options), url: string.subsitute(this.options.revisions_list_html_url, this.options),
onSuccess: function(html) { onSuccess: function(html) {
var modal = fd.displayModal(html), var modal = fd().displayModal(html),
modalEl = dom.$(modal).getElement('.UI_Modal'), modalEl = dom.$(modal).getElement('.UI_Modal'),
showVersionsEl = modalEl.getElement('#versions_only'); showVersionsEl = modalEl.getElement('#versions_only');
//setup handler for "Show versions only" checkbox //setup handler for "Show versions only" checkbox
@ -427,7 +430,7 @@ module.exports = new Class({
}, },
askForReload: function() { askForReload: function() {
fd.warning.alert( fd().warning.alert(
'New revision detected', 'New revision detected',
'There is a newer revision available. <a href="'+ 'There is a newer revision available. <a href="'+
this.options.latest_url +'">Click this link to go to it now.</a>' this.options.latest_url +'">Click this link to go to it now.</a>'
@ -445,12 +448,12 @@ module.exports = new Class({
this._is_copying = true; this._is_copying = true;
if (!settings.user) { if (!settings.user) {
fd.alertNotAuthenticated(); fd().alertNotAuthenticated();
return; return;
} }
if (this.edited) { if (this.edited) {
fd.error.alert("There are unsaved changes", fd().error.alert("There are unsaved changes",
"To make a copy, please save your changes."); "To make a copy, please save your changes.");
return; return;
} }
@ -479,7 +482,7 @@ module.exports = new Class({
} }
el.addClass('clicked'); el.addClass('clicked');
fd.tests[this.options.hashtag] = { fd().tests[this.options.hashtag] = {
spinner: el.addClass('loading').addClass('small') spinner: el.addClass('loading').addClass('small')
}; };
var data = { var data = {
@ -494,7 +497,7 @@ module.exports = new Class({
el.removeClass('clicked'); el.removeClass('clicked');
}, },
onSuccess: function() { onSuccess: function() {
fd.downloadXPI(data); fd().downloadXPI(data);
} }
}).send(); }).send();
}, },
@ -505,15 +508,15 @@ module.exports = new Class({
this.data.live_data_testing = true; this.data.live_data_testing = true;
} }
var el = this.test_el; var el = this.test_el;
if (fd.alertIfNoAddOn()) { if (fd().alertIfNoAddOn()) {
if (el.hasClass('pressed')) { if (el.hasClass('pressed')) {
fd.uninstallXPI(el.get('data-jetpackid')); fd().uninstallXPI(el.get('data-jetpackid'));
} else { } else {
this.installAddon(); this.installAddon();
} }
} else { } else {
fd.whenAddonInstalled(function() { fd().whenAddonInstalled(function() {
fd.message.alert( fd().message.alert(
'Add-on Builder Helper', 'Add-on Builder Helper',
'Now that you have installed the Add-on Builder Helper, loading the add-on into your browser for testing...' 'Now that you have installed the Add-on Builder Helper, loading the add-on into your browser for testing...'
); );
@ -529,7 +532,7 @@ module.exports = new Class({
} }
var loader = this.test_el.getElement('a'); var loader = this.test_el.getElement('a');
fd.tests[this.options.hashtag] = { fd().tests[this.options.hashtag] = {
spinner: loader.addClass(LOADING_CLASS).addClass('small') spinner: loader.addClass(LOADING_CLASS).addClass('small')
}; };
var data = this.data || {}; var data = this.data || {};
@ -538,7 +541,7 @@ module.exports = new Class({
url: this.options.test_url, url: this.options.test_url,
data: data, data: data,
onSuccess: function() { onSuccess: function() {
fd.testXPI(data); fd().testXPI(data);
}, },
onComplete: function() { onComplete: function() {
loader.removeClass(LOADING_CLASS); loader.removeClass(LOADING_CLASS);
@ -550,12 +553,12 @@ module.exports = new Class({
if (this.getOption('readonly')) { if (this.getOption('readonly')) {
return; return;
} }
this.options.hashtag = fd.generateHashtag(this.package_.get('id_number')); this.options.hashtag = fd().generateHashtag(this.package_.get('id_number'));
}, },
//Package.View //Package.View
showInfo: function() { showInfo: function() {
fd.displayModal(this.options.package_info); fd().displayModal(this.options.package_info);
}, },
//Package.Edit //Package.Edit
@ -605,7 +608,7 @@ module.exports = new Class({
} }
// else if uneditable Attachment // else if uneditable Attachment
else if (file instanceof Attachment) { else if (file instanceof Attachment) {
// then show in fd.modal // then show in fd().modal
this.showAttachmentModal(file); this.showAttachmentModal(file);
} }
// else if Library // else if Library
@ -637,7 +640,7 @@ module.exports = new Class({
file.get('shortName')+ file.get('shortName')+
'</a>'; '</a>';
var spinner, img; var spinner, img;
var modal = fd.displayModal(template_start+template_middle+template_end); var modal = fd().displayModal(template_start+template_middle+template_end);
var target = dom.$(modal).getElement('.UI_Modal_Section p'); var target = dom.$(modal).getElement('.UI_Modal_Section p');
if (file.isImage()) { if (file.isImage()) {
template_middle += '<p></p>'; template_middle += '<p></p>';
@ -682,7 +685,7 @@ module.exports = new Class({
var that = this; var that = this;
if (this.edited) { if (this.edited) {
// display message // display message
fd.showQuestion({ fd().showQuestion({
title: 'You\'ve got unsaved changes.', title: 'You\'ve got unsaved changes.',
message: 'Choose from the following options', message: 'Choose from the following options',
buttons: [{ buttons: [{
@ -703,7 +706,7 @@ module.exports = new Class({
'class': 'submit', 'class': 'submit',
type: 'button', type: 'button',
callback: function(){ callback: function(){
fd.addVolatileEvent('save', this.boundDownloadAddon); fd().once('save', this.boundDownloadAddon);
this.save(); this.save();
}.bind(this), }.bind(this),
'default': true 'default': true
@ -744,7 +747,7 @@ module.exports = new Class({
return; return;
} }
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
var attachment = controller.newAttachment({ var attachment = controller.newAttachment({
filename: response.filename, filename: response.filename,
ext: response.ext, ext: response.ext,
@ -760,7 +763,7 @@ module.exports = new Class({
} }
}, },
onFailure: function(text) { onFailure: function(text) {
fd.error.alert( fd().error.alert(
string.substitute('Error {status}', this.xhr), string.substitute('Error {status}', this.xhr),
string.substitute('{statusText}<br/>{responseText}', this.xhr) string.substitute('{statusText}<br/>{responseText}', this.xhr)
); );
@ -796,9 +799,9 @@ module.exports = new Class({
method: 'post', method: 'post',
onSuccess: function(text) { onSuccess: function(text) {
var response = JSON.parse(text); var response = JSON.parse(text);
fd.setURIRedirect(response.view_url); //fd().setURIRedirect(response.view_url);
controller.registerRevision(response); controller.registerRevision(response);
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
var att = controller.newAttachment({ var att = controller.newAttachment({
filename: response.filename, filename: response.filename,
ext: response.ext, ext: response.ext,
@ -842,14 +845,14 @@ module.exports = new Class({
}, },
onSuccess: function(text) { onSuccess: function(text) {
var response = JSON.parse(text); var response = JSON.parse(text);
fd.setURIRedirect(response.view_url); //fd().setURIRedirect(response.view_url);
that.registerRevision(response); that.registerRevision(response);
if (!quiet) { if (!quiet) {
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
} }
if (!att) { if (!att) {
log.warn("Attachment (" + uid + ") couldn't be found in fd.item"); log.warn("Attachment (" + uid + ") couldn't be found in fd().item");
return; return;
} }
att.set({ att.set({
@ -880,9 +883,9 @@ module.exports = new Class({
data: {uid: attachment.get('uid')}, data: {uid: attachment.get('uid')},
onSuccess: function(text) { onSuccess: function(text) {
var response = JSON.parse(text); var response = JSON.parse(text);
fd.setURIRedirect(response.view_url); //fd().setURIRedirect(response.view_url);
controller.registerRevision(response); controller.registerRevision(response);
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
attachment.destroy(); attachment.destroy();
} }
}).send(); }).send();
@ -898,10 +901,10 @@ module.exports = new Class({
onSuccess: function addModule_onSuccess(text) { onSuccess: function addModule_onSuccess(text) {
var response = JSON.parse(text); var response = JSON.parse(text);
// set the redirect data to view_url of the new revision // set the redirect data to view_url of the new revision
fd.setURIRedirect(response.view_url); //fd().setURIRedirect(response.view_url);
// set data changed by save // set data changed by save
controller.registerRevision(response); controller.registerRevision(response);
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
// initiate new Module // initiate new Module
var mod = controller.newModule({ var mod = controller.newModule({
active: true, active: true,
@ -932,9 +935,9 @@ module.exports = new Class({
}, },
onSuccess: function(text) { onSuccess: function(text) {
var response = JSON.parse(text); var response = JSON.parse(text);
fd.setURIRedirect(response.view_url); //fd().setURIRedirect(response.view_url);
controller.registerRevision(response); controller.registerRevision(response);
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
var mod = controller.modules[oldName]; var mod = controller.modules[oldName];
var modId = mod.get('uid'); var modId = mod.get('uid');
@ -964,9 +967,9 @@ module.exports = new Class({
data: module.toJSON(), data: module.toJSON(),
onSuccess: function(text) { onSuccess: function(text) {
var response = JSON.parse(text); var response = JSON.parse(text);
fd.setURIRedirect(response.view_url); //fd().setURIRedirect(response.view_url);
controller.registerRevision(response); controller.registerRevision(response);
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
module.destroy(); module.destroy();
}, },
onComplete: function() { onComplete: function() {
@ -987,9 +990,9 @@ module.exports = new Class({
}, },
onSuccess: function(text) { onSuccess: function(text) {
var response = JSON.parse(text); var response = JSON.parse(text);
fd.setURIRedirect(response.view_url); //fd().setURIRedirect(response.view_url);
controller.registerRevision(response); controller.registerRevision(response);
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
response.removed_attachments.forEach(function(uid) { response.removed_attachments.forEach(function(uid) {
controller.attachments[uid].destroy(); controller.attachments[uid].destroy();
}); });
@ -1013,9 +1016,9 @@ module.exports = new Class({
data: {filename: path+'/'}, data: {filename: path+'/'},
onSuccess: function(text) { onSuccess: function(text) {
var response = JSON.parse(text); var response = JSON.parse(text);
fd.setURIRedirect(response.view_url); //fd().setURIRedirect(response.view_url);
controller.registerRevision(response); controller.registerRevision(response);
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
response.removed_modules.forEach(function(filename) { response.removed_modules.forEach(function(filename) {
controller.modules[filename].destroy(); controller.modules[filename].destroy();
}); });
@ -1043,9 +1046,9 @@ module.exports = new Class({
}, },
onSuccess: function(text) { onSuccess: function(text) {
var response = JSON.parse(text); var response = JSON.parse(text);
fd.setURIRedirect(response.view_url); //fd().setURIRedirect(response.view_url);
controller.registerRevision(response); controller.registerRevision(response);
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
controller.newFolder({ controller.newFolder({
name: response.name, name: response.name,
root_dir: root_dir root_dir: root_dir
@ -1066,9 +1069,9 @@ module.exports = new Class({
data: folder.toJSON(), data: folder.toJSON(),
onSuccess: function(text) { onSuccess: function(text) {
var response = JSON.parse(text); var response = JSON.parse(text);
fd.setURIRedirect(response.view_url); //fd().setURIRedirect(response.view_url);
controller.registerRevision(response); controller.registerRevision(response);
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
folder.destroy(); folder.destroy();
}, },
onComplete: function() { onComplete: function() {
@ -1080,7 +1083,7 @@ module.exports = new Class({
assignLibrary: function(library_id) { assignLibrary: function(library_id) {
if (library_id) { if (library_id) {
var controller = this, var controller = this,
el = dom.$('plugins'); el = dom.$('libraries');
el.addClass(LOADING_CLASS).addClass('small'); el.addClass(LOADING_CLASS).addClass('small');
return new Request({ return new Request({
url: this.options.assign_library_url, url: this.options.assign_library_url,
@ -1088,10 +1091,10 @@ module.exports = new Class({
onSuccess: function(text) { onSuccess: function(text) {
var response = JSON.parse(text); var response = JSON.parse(text);
// set the redirect data to view_url of the new revision // set the redirect data to view_url of the new revision
fd.setURIRedirect(response.view_url); //fd().setURIRedirect(response.view_url);
// set data changed by save // set data changed by save
controller.registerRevision(response); controller.registerRevision(response);
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
controller.newDependency({ controller.newDependency({
full_name: response.library_full_name, full_name: response.library_full_name,
id_number: response.library_id_number, id_number: response.library_id_number,
@ -1105,7 +1108,7 @@ module.exports = new Class({
} }
}).send(); }).send();
} else { } else {
fd.error.alert('No such Library', 'Please choose a library from the list'); fd().error.alert('No such Library', 'Please choose a library from the list');
} }
}, },
@ -1121,9 +1124,9 @@ module.exports = new Class({
}, },
onSuccess: function(text) { onSuccess: function(text) {
var response = JSON.parse(text); var response = JSON.parse(text);
fd.setURIRedirect(response.view_url); //fd().setURIRedirect(response.view_url);
controller.registerRevision(response); controller.registerRevision(response);
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
lib.set({ lib.set({
view_url: response.library_url view_url: response.library_url
}); });
@ -1186,9 +1189,9 @@ module.exports = new Class({
data: {'id_number': lib.get('id_number')}, data: {'id_number': lib.get('id_number')},
onSuccess: function(text) { onSuccess: function(text) {
var response = JSON.parse(text); var response = JSON.parse(text);
fd.setURIRedirect(response.view_url); //fd().setURIRedirect(response.view_url);
controller.registerRevision(response); controller.registerRevision(response);
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
lib.destroy(); lib.destroy();
}, },
onComplete: function() { onComplete: function() {
@ -1232,8 +1235,8 @@ module.exports = new Class({
url: activateButton.getElement('a').get('href'), url: activateButton.getElement('a').get('href'),
onSuccess: function(text) { onSuccess: function(text) {
var response = JSON.parse(text); var response = JSON.parse(text);
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
fd.fireEvent('activate_' + response.package_type); fd().fireEvent('activate_' + response.package_type);
activateButton.addClass('pressed').getElement('a').addClass('inactive'); activateButton.addClass('pressed').getElement('a').addClass('inactive');
dom.$('UI_DisableLink').removeClass('pressed').getElement('a').removeClass('inactive'); dom.$('UI_DisableLink').removeClass('pressed').getElement('a').removeClass('inactive');
}, },
@ -1259,8 +1262,8 @@ module.exports = new Class({
return new Request({ return new Request({
url: deactivateButton.getElement('a').get('href'), url: deactivateButton.getElement('a').get('href'),
onSuccess: function(response) { onSuccess: function(response) {
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
fd.fireEvent('disable_' + response.package_type); fd().fireEvent('disable_' + response.package_type);
dom.$('activate').addEvent('click', controller.makePublic.bind(controller)); dom.$('activate').addEvent('click', controller.makePublic.bind(controller));
deactivateButton.addClass('pressed').getElement('a').addClass('inactive'); deactivateButton.addClass('pressed').getElement('a').addClass('inactive');
dom.$('UI_ActivateLink').removeClass('pressed').getElement('a').removeClass('inactive'); dom.$('UI_ActivateLink').removeClass('pressed').getElement('a').removeClass('inactive');
@ -1278,14 +1281,14 @@ module.exports = new Class({
editInfo: function() { editInfo: function() {
var controller = this; var controller = this;
this.savenow = false; this.savenow = false;
fd.editPackageInfoModal = fd.displayModal( fd().editPackageInfoModal = fd().displayModal(
string.substitute(settings.edit_package_info_template, string.substitute(settings.edit_package_info_template,
object.merge({}, this.data, this.options))); object.merge({}, this.data, this.options)));
dom.$('full_name').addEvent('change', function() { dom.$('full_name').addEvent('change', function() {
fd.fireEvent('change'); fd().fireEvent('change');
}); });
dom.$('package_description').addEvent('change', function() { dom.$('package_description').addEvent('change', function() {
fd.fireEvent('change'); fd().fireEvent('change');
}); });
var savenow = dom.$('savenow'); var savenow = dom.$('savenow');
if (savenow) { if (savenow) {
@ -1337,7 +1340,7 @@ module.exports = new Class({
if (this.savenow) { if (this.savenow) {
return this.save(); return this.save();
} }
fd.editPackageInfoModal.destroy(); fd().editPackageInfoModal.destroy();
}, },
collectData: function() { collectData: function() {
@ -1405,10 +1408,10 @@ module.exports = new Class({
}, this }, this
); );
} }
fd.setURIRedirect(response.view_url); //fd().setURIRedirect(response.view_url);
// set data changed by save // set data changed by save
this.registerRevision(response); this.registerRevision(response);
fd.message.alert(response.message_title, response.message); fd().message.alert(response.message_title, response.message);
// clean data leaving package_info data // clean data leaving package_info data
this.data = {}; this.data = {};
this.options.package_info_form_elements.forEach(function(key) { this.options.package_info_form_elements.forEach(function(key) {
@ -1416,8 +1419,8 @@ module.exports = new Class({
this.data[key] = response[key]; this.data[key] = response[key];
} }
}, this); }, this);
if (fd.editPackageInfoModal) { if (fd().editPackageInfoModal) {
fd.editPackageInfoModal.destroy(); fd().editPackageInfoModal.destroy();
} }
if (this.test_el && this.test_el.hasClass('pressed')) { if (this.test_el && this.test_el.hasClass('pressed')) {
// only one add-on of the same id should be allowed on the Helper side // only one add-on of the same id should be allowed on the Helper side
@ -1544,7 +1547,7 @@ module.exports = new Class({
shortcuts.push('<strong>Tree</strong>'); shortcuts.push('<strong>Tree</strong>');
this.sidebar.keyboard.getShortcuts().forEach(buildLines); this.sidebar.keyboard.getShortcuts().forEach(buildLines);
this._shortcutsModal = fd.displayModal('<h3>Keyboard Shortcuts</h3>'+ this._shortcutsModal = fd().displayModal('<h3>Keyboard Shortcuts</h3>'+
'<div class="UI_Modal_Section"><p>'+ '<div class="UI_Modal_Section"><p>'+
shortcuts.join('</p><p>')+ shortcuts.join('</p><p>')+
'</p></div>' '</p></div>'
@ -1573,7 +1576,7 @@ module.exports = new Class({
}, },
alertUnsavedData: function(e) { alertUnsavedData: function(e) {
if (this.edited && !fd.saving) { if (this.edited && !fd().saving) {
e.preventDefault(); e.preventDefault();
} }
} }

Просмотреть файл

@ -27,7 +27,7 @@ var stripDeltas = function(stack) {
// [[DeltaObject1], [DeltaObject2], ... ] // [[DeltaObject1], [DeltaObject2], ... ]
// these objects have to be copied - not referenced // these objects have to be copied - not referenced
var deltas = []; var deltas = [];
stack.each(function(single){ stack.forEach(function(single){
deltas.push(object.merge({}, single[0])); deltas.push(object.merge({}, single[0]));
}); });
return deltas; return deltas;
@ -36,7 +36,7 @@ var stripDeltas = function(stack) {
var buildStack = function(deltas) { var buildStack = function(deltas) {
// Extract stored deltas into the stack // Extract stored deltas into the stack
var stack = []; var stack = [];
deltas.each(function(delta){ deltas.forEach(function(delta){
stack.push([object.merge({}, delta)]); stack.push([object.merge({}, delta)]);
}); });
return stack; return stack;
@ -69,7 +69,7 @@ module.exports = new Class({
var that = this; var that = this;
['blur', 'focus'].each(function(ev) { ['blur', 'focus'].forEach(function(ev) {
that.editor.on(ev, function(){ that.editor.on(ev, function(){
that.emit(ev); that.emit(ev);
}); });

Просмотреть файл

@ -2,6 +2,7 @@ var Class = require('shipyard/class/Class'),
Tree = require('./tree/Tree'), Tree = require('./tree/Tree'),
LocalStorageCollapse = require('./tree/LocalStorageCollapse'), LocalStorageCollapse = require('./tree/LocalStorageCollapse'),
object = require('shipyard/utils/object'), object = require('shipyard/utils/object'),
string = require('shipyard/utils/string'),
dom = require('shipyard/dom'), dom = require('shipyard/dom'),
File = require('../models/File'), File = require('../models/File'),
@ -130,11 +131,11 @@ var FileTree = module.exports = new Class({
delete options.remove; delete options.remove;
} }
attr.html = ('<a class="expand" href="#"></a>' + attr.html = string.substitute('<a class="expand" href="#"></a>' +
'<div class="holder">' + '<div class="holder">' +
'<span id="{id}" class="label" title="{title}">{title}</span><span class="icon"></span>' + '<span id="{id}" class="label" title="{title}">{title}</span><span class="icon"></span>' +
'<div class="actions">{add}{edit}{remove}</div>' + '<div class="actions">{add}{edit}{remove}</div>' +
'</div>{dir}').substitute({ '</div>{dir}', {
title: attr.title, title: attr.title,
id: attr.name ? attr.name + '_switch' : attr.title + '_folder', id: attr.name ? attr.name + '_switch' : attr.title + '_folder',
dir: attr.rel === 'directory' ? '<ul' + (options.collapsed ? ' style="display:none;"' : '') + '></ul>' : '', dir: attr.rel === 'directory' ? '<ul' + (options.collapsed ? ' style="display:none;"' : '') + '></ul>' : '',
@ -158,7 +159,7 @@ var FileTree = module.exports = new Class({
}); });
li.inject(target, where); li.inject(target, where);
this.fireEvent('addBranch', [li].combine(arguments)); this.emit('addBranch', li, attr, target, options);
return li; return li;
}, },
@ -167,7 +168,7 @@ var FileTree = module.exports = new Class({
label = li.getElement('.label'), label = li.getElement('.label'),
text = label.get('text').trim(); text = label.get('text').trim();
this.fireEvent('renameStart', [li, label]); this.fireEvent('renameStart', li, label);
label.set('tabIndex', 0).set('contenteditable', true).focus(); label.set('tabIndex', 0).set('contenteditable', true).focus();
@ -265,7 +266,7 @@ var FileTree = module.exports = new Class({
options = options || {}; options = options || {};
var suffix = options.suffix || '', var suffix = options.suffix || '',
splitted = obj.get('fullName').split('/'), splitted = obj.get('fullName').split('/'),
elements = Array.clone(splitted), elements = object.clone(splitted),
end = splitted.length - 1, end = splitted.length - 1,
selector = '', selector = '',
tree = this, tree = this,
@ -282,7 +283,7 @@ var FileTree = module.exports = new Class({
} }
//TODO: my eyes! //TODO: my eyes!
elements.each(function(name, i){ elements.forEach(function(name, i){
var path = splitted.slice(0, i + 1).join('/'); var path = splitted.slice(0, i + 1).join('/');
if (i === end){ if (i === end){
var previous = elements[i - 1] ? elements[i - 1].getElement('ul') : (options.target.getElement('ul') || options.target); var previous = elements[i - 1] ? elements[i - 1].getElement('ul') : (options.target.getElement('ul') || options.target);
@ -364,7 +365,7 @@ FileTree.Collapse = new Class({
updatePath: function(element){ updatePath: function(element){
var parent = element.getParent('li'), var parent = element.getParent('li'),
path = parent ? parent.get('path') : false; path = parent ? parent.get('path') : false;
element.set('path', (path ? path + '/' : '') + (element.get('path') || '').split('/').getLast()); element.set('path', (path ? path + '/' : '') + (element.get('path') || '').split('/').pop());
} }
}); });

Просмотреть файл

@ -17,8 +17,11 @@ var Class = require('shipyard/class/Class'),
URI = require('../utils/URI'); URI = require('../utils/URI');
//TODO: Bad practice. //TODO: Bad practice.
var fd = dom.window.get('fd'), var settings = dom.window.get('settings');
settings = dom.window.get('settings');
function fd() {
return dom.window.get('fd');
}
//globals: FlightDeck.Autocomplete //globals: FlightDeck.Autocomplete
@ -97,7 +100,7 @@ var Sidebar = module.exports = new Class({
}; };
if(dom.$('LibTree') && !trees.lib) { if(dom.$('LibTree') && !trees.lib) {
trees.lib = new FileTree('LibTree', Object.merge({ trees.lib = new FileTree('LibTree', object.merge({
id_prefix: 'l' id_prefix: 'l'
}, treeOptions)); }, treeOptions));
trees.lib.collapse = new FileTree.Collapse('LibTree', collapseOptions); trees.lib.collapse = new FileTree.Collapse('LibTree', collapseOptions);
@ -111,7 +114,7 @@ var Sidebar = module.exports = new Class({
} }
if(dom.$('DataTree') && !trees.data) { if(dom.$('DataTree') && !trees.data) {
trees.data = new FileTree('DataTree', Object.merge({ trees.data = new FileTree('DataTree', object.merge({
id_prefix: 'd' id_prefix: 'd'
},treeOptions)); },treeOptions));
trees.data.collapse = new FileTree.Collapse('DataTree', collapseOptions); trees.data.collapse = new FileTree.Collapse('DataTree', collapseOptions);
@ -125,7 +128,7 @@ var Sidebar = module.exports = new Class({
} }
if(dom.$('PluginsTree') && !trees.plugins) { if(dom.$('PluginsTree') && !trees.plugins) {
trees.plugins = new FileTree('PluginsTree', Object.merge({}, treeOptions, { actions: { trees.plugins = new FileTree('PluginsTree', object.merge({}, treeOptions, { actions: {
add: false, add: false,
edit: false, edit: false,
remove: true remove: true
@ -216,7 +219,7 @@ var Sidebar = module.exports = new Class({
}, },
renameFile: function(file, fullpath) { renameFile: function(file, fullpath) {
var pack = fd.item; var pack = fd().item;
if (file instanceof Module) { if (file instanceof Module) {
pack.renameModule(file.get('uid'), fullpath); pack.renameModule(file.get('uid'), fullpath);
} else if (file instanceof Attachment) { } else if (file instanceof Attachment) {
@ -302,7 +305,7 @@ var Sidebar = module.exports = new Class({
if(isFile && (file.active || file.get('main')) && file.isEditable()) { if(isFile && (file.active || file.get('main')) && file.isEditable()) {
this.setSelectedFile(element); this.setSelectedFile(element);
} }
}.protect(), },
addLib: function(lib) { addLib: function(lib) {
this.addFileToTree('lib', lib); this.addFileToTree('lib', lib);
@ -417,7 +420,7 @@ var Sidebar = module.exports = new Class({
titleOpts.name = titleOpts.name.split('/').getLast(); titleOpts.name = titleOpts.name.split('/').getLast();
fd.showQuestion({ fd().showQuestion({
title: title.substitute(titleOpts), title: title.substitute(titleOpts),
message: file instanceof Module ? 'You may always copy it from this revision' : '', message: file instanceof Module ? 'You may always copy it from this revision' : '',
buttons: [ buttons: [
@ -434,17 +437,17 @@ var Sidebar = module.exports = new Class({
'irreversible': true, 'irreversible': true,
'callback': function() { 'callback': function() {
if (file instanceof Module) { if (file instanceof Module) {
fd.item.removeModule(file); fd().item.removeModule(file);
} else if (file instanceof Attachment) { } else if (file instanceof Attachment) {
fd.item.removeAttachment(file); fd().item.removeAttachment(file);
} else if (file instanceof Package) { } else if (file instanceof Package) {
fd.item.removeLibrary(file); fd().item.removeLibrary(file);
} else if (file instanceof Folder) { } else if (file instanceof Folder) {
fd.item.removeFolder(file); fd().item.removeFolder(file);
} else if (fileType === Module) { } else if (fileType === Module) {
fd.item.removeModules(file); fd().item.removeModules(file);
} else if (fileType === Attachment) { } else if (fileType === Attachment) {
fd.item.removeAttachments(file); fd().item.removeAttachments(file);
} }
} }
@ -460,7 +463,7 @@ var Sidebar = module.exports = new Class({
path += '/'; path += '/';
} }
fd.showQuestion({ fd().showQuestion({
title: 'Create a new file or folder', title: 'Create a new file or folder',
message: '<a href="#" id="new_type_file" class="radio_btn selected"><span>File</span></a>' + message: '<a href="#" id="new_type_file" class="radio_btn selected"><span>File</span></a>' +
'<a href="#" id="new_type_folder" class="radio_btn"><span>Folder</span></a>' + '<a href="#" id="new_type_folder" class="radio_btn"><span>Folder</span></a>' +
@ -470,10 +473,10 @@ var Sidebar = module.exports = new Class({
callback: function promptNewFile_callback() { callback: function promptNewFile_callback() {
// get data // get data
var fname_ = path + dom.$('new_file').get('value'), var fname_ = path + dom.$('new_file').get('value'),
pack = fd.item; pack = fd().item;
if (!filename) { if (!filename) {
fd.error.alert( fd().error.alert(
'Filename can\'t be empty', 'Filename can\'t be empty',
'Please provide the name of the module'); 'Please provide the name of the module');
return; return;
@ -494,14 +497,14 @@ var Sidebar = module.exports = new Class({
} }
if (!isFolder && pack.moduleExists(fname_)) { if (!isFolder && pack.moduleExists(fname_)) {
fd.error.alert('Filename has to be unique', 'You already have the module with that name'); fd().error.alert('Filename has to be unique', 'You already have the module with that name');
return; return;
} else if (isFolder && pack.folderExists(fname_, Folder.ROOT_DIR_LIB)) { } else if (isFolder && pack.folderExists(fname_, Folder.ROOT_DIR_LIB)) {
fd.error.alert('Folder has to be unique', 'You already have the folder with that name'); fd().error.alert('Folder has to be unique', 'You already have the folder with that name');
return; return;
} }
if (['-', ''].contains(fname_.get_basename(isFolder))) { if (['-', ''].contains(fname_)) {
fd.error.alert( fd().error.alert(
'ERROR', 'ERROR',
'Please use alphanumeric characters for filename'); 'Please use alphanumeric characters for filename');
return; return;
@ -538,13 +541,13 @@ var Sidebar = module.exports = new Class({
promptAttachment: function(folder) { promptAttachment: function(folder) {
var basename, var basename,
that = this, that = this,
pack = fd.item, pack = fd().item,
isFolder = false, isFolder = false,
path = (folder && folder.get('path')) || ''; path = (folder && folder.get('path')) || '';
if (path) { if (path) {
path += '/'; path += '/';
} }
fd.showQuestion({ fd().showQuestion({
title: 'Create or Upload an Attachment', title: 'Create or Upload an Attachment',
message: ''+ message: ''+
'<form id="upload_attachment_form" method="post" enctype="multipart/form-data" action="'+ '<form id="upload_attachment_form" method="post" enctype="multipart/form-data" action="'+
@ -576,7 +579,7 @@ var Sidebar = module.exports = new Class({
//validation //validation
if(!(files && files.length) && !fname_ && !(url && fname_)) { if(!(files && files.length) && !fname_ && !(url && fname_)) {
fd.error.alert('No file was selected.', fd().error.alert('No file was selected.',
'Please select a file to upload.'); 'Please select a file to upload.');
return; return;
} }
@ -585,8 +588,8 @@ var Sidebar = module.exports = new Class({
var fname = filename.basename(files[f].name), var fname = filename.basename(files[f].name),
ex = filename.extname(files[f].name); ex = filename.extname(files[f].name);
if (fd.item.attachmentExists(fname +'.'+ ex)) { if (fd().item.attachmentExists(fname +'.'+ ex)) {
fd.error.alert('Filename has to be unique', fd().error.alert('Filename has to be unique',
'You already have an attachment with that name.'); 'You already have an attachment with that name.');
return; return;
} }
@ -628,8 +631,8 @@ var Sidebar = module.exports = new Class({
} }
// basename should have a meaning after replacing all // basename should have a meaning after replacing all
// non alphanumeric characters // non alphanumeric characters
if (['-', ''].contains(fname_.get_basename(isFolder))) { if (['-', ''].contains(fname_)) {
fd.error.alert( fd().error.alert(
'ERROR', 'ERROR',
'Please use alphanumeric characters for filename'); 'Please use alphanumeric characters for filename');
return; return;
@ -668,7 +671,7 @@ var Sidebar = module.exports = new Class({
}, },
promptPlugin: function() { promptPlugin: function() {
var modal = fd.showQuestion({ var modal = fd().showQuestion({
title: 'Add a Library', title: 'Add a Library',
message: '<input type="text" name="new_library" id="new_library" placeholder="Search for libraries to include" />' + message: '<input type="text" name="new_library" id="new_library" placeholder="Search for libraries to include" />' +
'<input type="hidden" name="library_id_number" id="library_id_number" />', '<input type="hidden" name="library_id_number" id="library_id_number" />',
@ -677,11 +680,11 @@ var Sidebar = module.exports = new Class({
callback: function() { callback: function() {
var lib_id = dom.$('library_id_number').get('value'); var lib_id = dom.$('library_id_number').get('value');
if(!lib_id) { if(!lib_id) {
fd.error.alert('No Library found!', 'Please enter the name of an existing Library'); fd().error.alert('No Library found!', 'Please enter the name of an existing Library');
return; return;
} }
fd.item.assignLibrary(lib_id); fd().item.assignLibrary(lib_id);
} }
}); });
@ -724,7 +727,7 @@ var Sidebar = module.exports = new Class({
promptPluginUpdate: function(li) { promptPluginUpdate: function(li) {
var that = this, var that = this,
file = li.retrieve('file'); file = li.retrieve('file');
fd.item.updateLibrary(file, function(response) { fd().item.updateLibrary(file, function(response) {
that.removePluginUpdate(file); that.removePluginUpdate(file);
//TODO: Somehow here rename the item //TODO: Somehow here rename the item
}); });

Просмотреть файл

@ -19,7 +19,7 @@ module.exports = new Class({
setState: function(element, state){ setState: function(element, state){
this.parent(element, state); this.parent(element, state);
localStorage.setItem(this.key, JSON.encode(this.state)); localStorage.setItem(this.key, JSON.stringify(this.state));
return this; return this;
} }

Просмотреть файл

@ -25,7 +25,7 @@ module.exports = new Class({
prepare: function(){ prepare: function(){
var obj = this.state; var obj = this.state;
this.element.getElements(this.options.listSelector).each(function(element){ this.element.getElements(this.options.listSelector).forEach(function(element){
if (!element.getElement(this.options.childSelector)) { if (!element.getElement(this.options.childSelector)) {
return; return;
} }

Просмотреть файл

@ -241,7 +241,7 @@ module.exports = new Class({
} }
var result = {}; var result = {};
base.getChildren('li').each(function(el) { base.getChildren('li').forEach(function(el) {
var child = el.getElement('ul'); var child = el.getElement('ul');
result[fn(el)] = child ? this.serialize(fn, child) : true; result[fn(el)] = child ? this.serialize(fn, child) : true;
}, this); }, this);

@ -1 +1 @@
Subproject commit fa8afd28ea7518d57dad97961488b1aff981cb0f Subproject commit 5c8eeffd271118b7ad0460fffa4e290840a84b76