diff --git a/public/src/editor/base-editor.js b/public/src/editor/base-editor.js index 40bece51d..536fdc81c 100644 --- a/public/src/editor/base-editor.js +++ b/public/src/editor/base-editor.js @@ -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 ) { 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 = []; @@ -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 @@ -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 ) { diff --git a/public/src/editor/default.js b/public/src/editor/default.js index c4afb31e8..6b439c78d 100644 --- a/public/src/editor/default.js +++ b/public/src/editor/default.js @@ -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 || {}; @@ -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; @@ -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 }; diff --git a/public/src/editor/editor.js b/public/src/editor/editor.js index ab28fcf9a..69bf5f836 100644 --- a/public/src/editor/editor.js +++ b/public/src/editor/editor.js @@ -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; @@ -149,7 +149,7 @@ define( [ "util/lang", "util/xhr", } } - return new description.create( compiledLayout, butter, completeLayout ); + return new description.create( compiledLayout, butter, parentElement, completeLayout ); }, /** diff --git a/public/src/editor/media-gallery-editor.js b/public/src/editor/media-gallery-editor.js index 2795bf64c..5e16a02eb 100644 --- a/public/src/editor/media-gallery-editor.js +++ b/public/src/editor/media-gallery-editor.js @@ -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; @@ -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 ); }, diff --git a/public/src/editor/module.js b/public/src/editor/module.js index 267146496..d6605eb44 100644 --- a/public/src/editor/module.js +++ b/public/src/editor/module.js @@ -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 ); }); diff --git a/public/src/editor/project-editor.js b/public/src/editor/project-editor.js index 31ac47ef2..2575bf46b 100644 --- a/public/src/editor/project-editor.js +++ b/public/src/editor/project-editor.js @@ -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" ), @@ -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; diff --git a/public/src/editor/trackevent-editor.js b/public/src/editor/trackevent-editor.js index fca60a8f1..e2abdbad8 100644 --- a/public/src/editor/trackevent-editor.js +++ b/public/src/editor/trackevent-editor.js @@ -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" ), @@ -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 ); diff --git a/public/src/editor/ui-kit.js b/public/src/editor/ui-kit.js index 74d552d87..1763f71f6 100644 --- a/public/src/editor/ui-kit.js +++ b/public/src/editor/ui-kit.js @@ -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" ); diff --git a/public/src/plugin/plugin-list.js b/public/src/plugin/plugin-list.js index f0d6bbf79..729359cb7 100644 --- a/public/src/plugin/plugin-list.js +++ b/public/src/plugin/plugin-list.js @@ -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() { diff --git a/public/src/timeline/track-container.js b/public/src/timeline/track-container.js index 8990455b3..d2cef1daa 100644 --- a/public/src/timeline/track-container.js +++ b/public/src/timeline/track-container.js @@ -45,7 +45,7 @@ define( [ "core/logger", "util/dragndrop", "./ghost-manager" ], _vScrollbar.update(); }); - _container.addEventListener( "mousedown", function() { + _container.addEventListener( "click", function() { butter.deselectAllTrackEvents(); }, false ); diff --git a/public/src/util/dragndrop.js b/public/src/util/dragndrop.js index c9ea84862..8893f2feb 100644 --- a/public/src/util/dragndrop.js +++ b/public/src/util/dragndrop.js @@ -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() { diff --git a/public/templates/assets/editors/googlemap/googlemap-editor.js b/public/templates/assets/editors/googlemap/googlemap-editor.js index 7b3e4f847..5c0838852 100644 --- a/public/templates/assets/editors/googlemap/googlemap-editor.js +++ b/public/templates/assets/editors/googlemap/googlemap-editor.js @@ -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; @@ -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; diff --git a/public/templates/assets/editors/image/image-editor.js b/public/templates/assets/editors/image/image-editor.js index c195c645d..2d4e72af5 100644 --- a/public/templates/assets/editors/image/image-editor.js +++ b/public/templates/assets/editors/image/image-editor.js @@ -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" ), @@ -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; diff --git a/public/templates/assets/editors/popup/popup-editor.js b/public/templates/assets/editors/popup/popup-editor.js index a21227d93..488adeb55 100644 --- a/public/templates/assets/editors/popup/popup-editor.js +++ b/public/templates/assets/editors/popup/popup-editor.js @@ -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; @@ -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 ); diff --git a/public/templates/assets/editors/text/text-editor.js b/public/templates/assets/editors/text/text-editor.js index 99e411bc1..102c973b4 100644 --- a/public/templates/assets/editors/text/text-editor.js +++ b/public/templates/assets/editors/text/text-editor.js @@ -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; @@ -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 ); diff --git a/public/templates/assets/editors/twitter/twitter-editor.js b/public/templates/assets/editors/twitter/twitter-editor.js index bfd4e48fd..871cad721 100644 --- a/public/templates/assets/editors/twitter/twitter-editor.js +++ b/public/templates/assets/editors/twitter/twitter-editor.js @@ -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, @@ -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 ); diff --git a/public/test/editor/editor-createStartEndInputs.html b/public/test/editor/editor-createStartEndInputs.html index 284ec491b..c863d66f8 100644 --- a/public/test/editor/editor-createStartEndInputs.html +++ b/public/test/editor/editor-createStartEndInputs.html @@ -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; diff --git a/public/test/editor/editor-custom.html b/public/test/editor/editor-custom.html index c715901c2..1767b1ca6 100644 --- a/public/test/editor/editor-custom.html +++ b/public/test/editor/editor-custom.html @@ -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({