Skip to content
This repository was archived by the owner on Jan 31, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions public/src/editor/base-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ define( [ "core/eventmanager", "util/scrollbars", "ui/widget/tooltip", "ui/widge
* @param {DOMElement} rootElement: The root element to which the editor's content will be attached
* @param {Object} events: Events such as 'open' and 'close' can be defined on this object to be called at the appropriate times
*/
function BaseEditor( extendObject, butter, rootElement, events ) {
function BaseEditor( extendObject, butter, rootElement, parentElement, events ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm wrong, but I'm pretty sure parentElement is always:

<div class="butter-editor-content" >
...
</div>

If I'm right, I'm wondering why it needs to be something passed along the entire way through. Can't it just be a hard coded value? Or is this somehow too risky/rigid of a design?


EventManager.extend( extendObject );

extendObject.butter = butter;
extendObject.rootElement = rootElement;
extendObject.parentElement = null;

extendObject.parentElement = parentElement;
extendObject.rootElement.style.display = "none";
// Attach the editor's root element to the given parentElement.
parentElement.appendChild( rootElement );
// Used when applyExtraHeadTags is called -- see below
var _extraStyleTags = [],
_extraLinkTags = [];
Expand All @@ -40,13 +42,8 @@ define( [ "core/eventmanager", "util/scrollbars", "ui/widget/tooltip", "ui/widge
*
* @param {DOMElement} parentElement: The element to which the editor's root will be attached
*/
extendObject.open = function( parentElement ) {

extendObject.parentElement = parentElement;

// Attach the editor's root element to the given parentElement.
// Do this before calling the open event so that element size and structure are defined.
extendObject.parentElement.appendChild( extendObject.rootElement );
extendObject.open = function() {
extendObject.rootElement.style.display = "block";

// Update scrollbars, add one automatically if an allow-scrollbar class is added
// See .addScrollbar for manual settings
Expand All @@ -73,8 +70,7 @@ define( [ "core/eventmanager", "util/scrollbars", "ui/widget/tooltip", "ui/widge
* Closes the editor
*/
extendObject.close = function() {
// Remove the editor's root element from the element to which it was attached
extendObject.rootElement.parentNode.removeChild( extendObject.rootElement );
extendObject.rootElement.style.display = "none";

// If a close event existed on the events object passed into the constructor, call it
if ( events.close ) {
Expand Down
11 changes: 5 additions & 6 deletions public/src/editor/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ define( [ "text!./default.html", "editor/editor", "util/lang" ],
* @param {Butter} butter: An instance of Butter
* @param {TrackEvent} TrackEvent: The TrackEvent to edit
*/
function DefaultEditor( rootElement, butter, compiledLayout, events ) {

function DefaultEditor( rootElement, butter, parentElement, compiledLayout, events ) {
var _this = this;

events = events || {};
Expand All @@ -33,7 +32,7 @@ define( [ "text!./default.html", "editor/editor", "util/lang" ],
}

// Extend this object to become a TrackEventEditor
events.open = function ( parentElement, trackEvent ) {
events.open = function ( trackEvent ) {
var targetList,
optionsContainer = _rootElement.querySelector( ".editor-options" ),
selectElement;
Expand Down Expand Up @@ -100,14 +99,14 @@ define( [ "text!./default.html", "editor/editor", "util/lang" ],
}
};

Editor.TrackEventEditor.extend( _this, butter, rootElement, events );
Editor.TrackEventEditor.extend( _this, butter, rootElement, parentElement, events );
}

Editor.register( "default", LAYOUT_SRC, DefaultEditor );

return {
extend: function( extendObject, rootElement, butter, compiledLayout, events ){
return DefaultEditor.apply( extendObject, [ rootElement, butter, compiledLayout, events ] );
extend: function( extendObject, rootElement, butter, parentElement, compiledLayout, events ){
return DefaultEditor.apply( extendObject, [ rootElement, butter, parentElement, compiledLayout, events ] );
},
EDITOR_SRC: LAYOUT_SRC
};
Expand Down
4 changes: 2 additions & 2 deletions public/src/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ define( [ "util/lang", "util/xhr",
* @param {String} editorName: Name of the editor to create
* @param {Butter} butter: An instance of Butter
*/
create: function( editorName, butter ) {
create: function( editorName, butter, parentElement ) {
var description = __editors[ editorName ],
completeLayout,
compiledLayout;
Expand All @@ -149,7 +149,7 @@ define( [ "util/lang", "util/xhr",
}
}

return new description.create( compiledLayout, butter, completeLayout );
return new description.create( compiledLayout, butter, parentElement, completeLayout );
},

/**
Expand Down
4 changes: 2 additions & 2 deletions public/src/editor/media-gallery-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ define( [ "util/lang", "util/uri", "util/keys", "util/mediatypes", "editor/edito
}
}

Editor.register( "media-editor", null, function( rootElement, butter ) {
Editor.register( "media-editor", null, function( rootElement, butter, parentElement ) {
rootElement = _parentElement;
_this = this;
_butter = butter;
Expand Down Expand Up @@ -316,7 +316,7 @@ define( [ "util/lang", "util/uri", "util/keys", "util/mediatypes", "editor/edito

setup();

Editor.BaseEditor.extend( _this, butter, rootElement, {
Editor.BaseEditor.extend( _this, butter, rootElement, parentElement, {
open: function() {
setBaseDuration( _media.duration );
},
Expand Down
6 changes: 4 additions & 2 deletions public/src/editor/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ define( [ "core/eventmanager", "core/trackevent", "./editor",
if ( persist && _createdEditors[ editorName ] ) {
_currentEditor = _createdEditors[ editorName ];
} else {
_currentEditor = _createdEditors[ editorName ] = Editor.create( editorName, butter );
_currentEditor = _createdEditors[ editorName ] = Editor.create( editorName,
butter,
_editorContentArea );
}

_currentEditor.open( _editorContentArea, options.openData );
_currentEditor.open( options.openData );
_currentEditor.listen( "back", function() {
_this.openEditor( DEFAULT_EDITOR_NAME );
});
Expand Down
4 changes: 2 additions & 2 deletions public/src/editor/project-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ define([ "editor/editor", "editor/base-editor",
"ui/widget/tooltip" ],
function( Editor, BaseEditor, LAYOUT_SRC, SocialMedia, TextboxWrapper, ToolTip ) {

Editor.register( "project-editor", LAYOUT_SRC, function( rootElement, butter ) {
Editor.register( "project-editor", LAYOUT_SRC, function( rootElement, butter, parentElement ) {
var _rootElement = rootElement,
_socialMedia = new SocialMedia(),
_projectURL = _rootElement.querySelector( ".butter-project-url" ),
Expand Down Expand Up @@ -144,7 +144,7 @@ define([ "editor/editor", "editor/base-editor",
updateEmbed( _project.iframeUrl );
});

Editor.BaseEditor.extend( this, butter, rootElement, {
Editor.BaseEditor.extend( this, butter, rootElement, parentElement, {
open: function() {
_project = butter.project;

Expand Down
6 changes: 3 additions & 3 deletions public/src/editor/trackevent-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ define([ "util/lang", "util/keys", "util/time", "./base-editor", "ui/widget/tool
* @param {DOMElement} rootElement: The root element to which the editor's content will be attached
* @param {Object} events: Events such as 'open' and 'close' can be defined on this object to be called at the appropriate times
*/
function TrackEventEditor( extendObject, butter, rootElement, events ) {
function TrackEventEditor( extendObject, butter, rootElement, parentElement, events ) {
// Wedge a check for scrollbars into the open event if it exists
var _oldOpenEvent = events.open,
_trackEventUpdateErrorCallback = NULL_FUNCTION,
_trackEvent;

events.open = function( parentElement, trackEvent ) {
events.open = function( trackEvent ) {
var basicButton = rootElement.querySelector( ".basic-tab" ),
advancedButton = rootElement.querySelector( ".advanced-tab" ),
basicTab = rootElement.querySelector( ".editor-options" ),
Expand Down Expand Up @@ -109,7 +109,7 @@ define([ "util/lang", "util/keys", "util/time", "./base-editor", "ui/widget/tool

};

BaseEditor.extend( extendObject, butter, rootElement, events );
BaseEditor.extend( extendObject, butter, rootElement, parentElement, events );

extendObject.defaultLayouts = __defaultLayouts.cloneNode( true );

Expand Down
4 changes: 2 additions & 2 deletions public/src/editor/ui-kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ define( [ "editor/editor", "editor/base-editor", "text!layouts/ui-kit.html" ],
}
}

Editor.register( "ui-kit", LAYOUT_SRC, function( rootElement, butter ) {
Editor.BaseEditor.extend( this, butter, rootElement, {
Editor.register( "ui-kit", LAYOUT_SRC, function( rootElement, butter, parentElement ) {
Editor.BaseEditor.extend( this, butter, rootElement, parentElement, {
open: function() {
var radios = rootElement.querySelectorAll( ".butter-btn-radio" ),
checkboxes = rootElement.querySelectorAll( ".butter-btn-checkbox" );
Expand Down
4 changes: 2 additions & 2 deletions public/src/plugin/plugin-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ define( [ "util/dragndrop", "util/lang", "editor/editor", "text!layouts/plugin-l
var _pluginArchetype = _containerElement.querySelector( ".butter-plugin-tile" );
_pluginArchetype.parentNode.removeChild( _pluginArchetype );

Editor.register( "plugin-list", null, function( rootElement, butter ) {
Editor.register( "plugin-list", null, function( rootElement, butter, parentElement ) {
rootElement = _parentElement;

Editor.BaseEditor.extend( this, butter, rootElement, {
Editor.BaseEditor.extend( this, butter, rootElement, parentElement, {
open: function() {
},
close: function() {
Expand Down
2 changes: 1 addition & 1 deletion public/src/timeline/track-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ define( [ "core/logger", "util/dragndrop", "./ghost-manager" ],
_vScrollbar.update();
});

_container.addEventListener( "mousedown", function() {
_container.addEventListener( "click", function() {
butter.deselectAllTrackEvents();
}, false );

Expand Down
4 changes: 4 additions & 0 deletions public/src/util/dragndrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,10 @@ define( [ "core/eventmanager", "util/lang", "util/scroll-group" ],

element.addEventListener( "mousedown", __onDraggableMouseDown, false );

element.addEventListener( "click", function( e ) {
e.stopPropagation();
}, false );

_draggable.droppable = null;

_draggable.destroy = function() {
Expand Down
6 changes: 3 additions & 3 deletions public/templates/assets/editors/googlemap/googlemap-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
( function( Butter ) {

Butter.Editor.register( "googlemap", "load!{{baseDir}}templates/assets/editors/googlemap/googlemap-editor.html",
function( rootElement, butter ) {
function( rootElement, butter, parentElement ) {

var _this = this;

Expand Down Expand Up @@ -284,8 +284,8 @@
}

// Extend this object to become a BaseEditor
Butter.Editor.TrackEventEditor.extend( _this, butter, rootElement, {
open: function( parentElement, trackEvent ) {
Butter.Editor.TrackEventEditor.extend( _this, butter, rootElement, parentElement, {
open: function( trackEvent ) {
var popcornOptions = trackEvent.popcornOptions;

_popcorn = butter.currentMedia.popcorn.popcorn;
Expand Down
6 changes: 3 additions & 3 deletions public/templates/assets/editors/image/image-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
var Editor = Butter.Editor;

Editor.register( "image", "load!{{baseDir}}templates/assets/editors/image/image-editor.html",
function( rootElement, butter, compiledLayout ) {
function( rootElement, butter, parentElement, compiledLayout ) {

var _rootElement = rootElement,
_tagRadio = _rootElement.querySelector( "#image-tag-radio" ),
Expand Down Expand Up @@ -369,8 +369,8 @@
_this.scrollbar.update();
}

Editor.TrackEventEditor.extend( _this, butter, rootElement, {
open: function( parentElement, trackEvent ) {
Editor.TrackEventEditor.extend( _this, butter, rootElement, parentElement, {
open: function( trackEvent ) {
var popcornOptions = trackEvent.popcornOptions,
manifestOpts = trackEvent.popcornTrackEvent._natives.manifest.options;

Expand Down
6 changes: 3 additions & 3 deletions public/templates/assets/editors/popup/popup-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(function( Butter ) {

Butter.Editor.register( "popup", "load!{{baseDir}}templates/assets/editors/popup/popup-editor.html",
function( rootElement, butter ) {
function( rootElement, butter, parentElement ) {

var _this = this;

Expand Down Expand Up @@ -187,8 +187,8 @@
}

// Extend this object to become a TrackEventEditor
Butter.Editor.TrackEventEditor.extend( _this, butter, rootElement, {
open: function( parentElement, trackEvent ) {
Butter.Editor.TrackEventEditor.extend( _this, butter, rootElement, parentElement, {
open: function( trackEvent ) {
var anchorContainer = trackEvent.popcornTrackEvent._container.querySelector( "a" );

anchorClickPrevention( anchorContainer );
Expand Down
6 changes: 3 additions & 3 deletions public/templates/assets/editors/text/text-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(function( Butter ) {

Butter.Editor.register( "text", "load!{{baseDir}}templates/assets/editors/text/text-editor.html",
function( rootElement, butter ) {
function( rootElement, butter, parentElement ) {

var _this = this;

Expand Down Expand Up @@ -162,8 +162,8 @@
}

// Extend this object to become a TrackEventEditor
Butter.Editor.TrackEventEditor.extend( _this, butter, rootElement, {
open: function( parentElement, trackEvent ) {
Butter.Editor.TrackEventEditor.extend( _this, butter, rootElement, parentElement, {
open: function( trackEvent ) {
var anchorContainer = trackEvent.popcornTrackEvent._container.querySelector( "a" );

anchorClickPrevention( anchorContainer );
Expand Down
6 changes: 3 additions & 3 deletions public/templates/assets/editors/twitter/twitter-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(function( Butter ) {

Butter.Editor.register( "twitter", "load!{{baseDir}}templates/assets/editors/twitter/twitter-editor.html",
function( rootElement, butter ) {
function( rootElement, butter, parentElement ) {

var _rootElement = rootElement,
_trackEvent,
Expand Down Expand Up @@ -157,8 +157,8 @@
}

// Extend this object to become a TrackEventEditor
Butter.Editor.TrackEventEditor.extend( _this, butter, rootElement, {
open: function( parentElement, trackEvent ) {
Butter.Editor.TrackEventEditor.extend( _this, butter, rootElement, parentElement, {
open: function( trackEvent ) {
_butter = butter;
// Update properties when TrackEvent is updated
trackEvent.listen( "trackeventupdated", onTrackEventUpdated );
Expand Down
6 changes: 3 additions & 3 deletions public/test/editor/editor-createStartEndInputs.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
}
});

Butter.Editor.register( "text", layoutSrc, function( rootElement, butter ) {
Butter.Editor.TrackEventEditor.extend( this, butter, rootElement, {
open: function( parentElement, trackEvent ) {
Butter.Editor.register( "text", layoutSrc, function( rootElement, butter, parentElement ) {
Butter.Editor.TrackEventEditor.extend( this, butter, rootElement, parentElement, {
open: function( trackEvent ) {
var contentContainer = rootElement.querySelector( ".content-container" ),
startEndElement;

Expand Down
6 changes: 3 additions & 3 deletions public/test/editor/editor-custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
}
});

Butter.Editor.register( "text", layoutSrc, function( rootElement, butter ) {
Butter.Editor.TrackEventEditor.extend( this, butter, rootElement, {
open: function( parentElement, trackEvent ) {
Butter.Editor.register( "text", layoutSrc, function( rootElement, butter, parentElement ) {
Butter.Editor.TrackEventEditor.extend( this, butter, rootElement, parentElement, {
open: function( trackEvent ) {
var contentContainer = rootElement.querySelector( ".content-container" );

this.createPropertiesFromManifest({
Expand Down