Editing a programmed clip
This article explains how to obtain from an animation programmed in JavaScript the equivalent effect in a clip and how editing the clip parameters is coded.
See the Programmer's manual.
Click in the text to start the animation.
- <?php $text='Objective.js'; ?>
- <?php $textwidth=12; ?>
- <?php $color='#22aa77'?>
- <?php $font='Slackey'; ?>
- <?php $fontsize=40; ?>
Defines the content of the text which is displayed, the number of characters displayed, the color, the font and the size of the font of the text.
- <?php head('font', $font); ?>
Adds the tag <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Slackey" />
to the <head>
section of the HTML document.
head
is a function of iZend.
Adapt the code to your development environment.
- #teletypetest {
- color: <?php echo $color; ?>;
- font-family: "<?php echo $font; ?>", sans-serif;
- font-size: <?php echo $fontsize; ?>px;
- font-weight: bold;
- white-space: pre;
- cursor: pointer;
- }
Configures the style of the text.
- <div id="teletypetest"> </div>
The text will be displayed in this <div>
. NOTE: The
in the <div>
makes sure the font is loaded by the navigator.
- function teletype(widget, text, width) {
- let pos = 0, len = text.length;
- if (teletypetest.timer)
- clearInterval(teletypetest.timer);
- teletypetest.timer = setInterval(() => {
- widget.innerText = text.substring(pos < width ? 0 : pos-width+1, pos+1);
- if (++pos >= len+width) {
- clearInterval(teletypetest.timer);
- teletypetest.timer = null;
- widget.innerText = text.substring(0, width);
- }
- }, 200);
- }
The function teletype
programs the display character by character at regular intervals of the string text
in the node widget
with a maximum of width
characters .
- const teletypetest = document.getElementById('teletypetest');
Assigns to teletypetest
the display <div>
of the text.
- teletypetest.onclick = () => teletype(teletypetest, '<?php echo $text; ?>', <?php echo $textwidth; ?>);
Calls after a click in the <div>
of the text the function teletype
with in parameters the display <div>
of the text, the text and the maximum number of characters to display.
- teletypetest.click();
Starts the animation as soon as the document is loaded.
Clip
Click in the text to start the animation.
- Model
- ClipModel
- TeletypeModel
- ClipModel
- function TeletypeModel(clipname) {
- ClipModel.call(this, clipname);
- this._value = {
- width: TeletypeModel.defaultWidth,
- height: TeletypeModel.defaultHeight,
- text: TeletypeModel.defaultText,
- textFont: TeletypeModel.defaultTextFont,
- textSize: TeletypeModel.defaultTextSize,
- textBold: TeletypeModel.defaultTextBold,
- textColor: TeletypeModel.defaultTextColor,
- textAlignment: TeletypeModel.defaultTextAlignment,
- textWidth: TeletypeModel.defaultTextWidth,
- interval: TeletypeModel.defaultInterval
- };
- }
- TeletypeModel.prototype = Object.create(ClipModel.prototype);
- Object.defineProperty(TeletypeModel.prototype, 'constructor', { value: TeletypeModel, enumerable: false, writable: true });
- TeletypeModel.defaultWidth = 320;
- TeletypeModel.defaultHeight = 40;
- TeletypeModel.defaultText = ''; // 'Objective.js';
- TeletypeModel.defaultTextFont = 'Open Sans';
- TeletypeModel.defaultTextSize = 22;
- TeletypeModel.defaultTextBold = true;
- TeletypeModel.defaultTextColor = '#cccccc';
- TeletypeModel.defaultTextAlignment = 'left';
- TeletypeModel.defaultTextWidth = 20;
- TeletypeModel.defaultInterval = 200;
- TeletypeModel.minWidth = 120;
- TeletypeModel.maxWidth = 960;
- TeletypeModel.minHeight = 10;
- TeletypeModel.maxHeight = 540;
- TeletypeModel.minTextLength = 0;
- TeletypeModel.maxTextLength = 200;
- TeletypeModel.minTextSize = 10;
- TeletypeModel.maxTextSize = 60;
- TeletypeModel.minTextWidth = 10;
- TeletypeModel.maxTextWidth = 100;
- TeletypeModel.minInterval = 100;
- TeletypeModel.maxInterval = 500;
- TeletypeModel.textAlignmentOptions = Validator.textAlignmentOptions;
- TeletypeModel.prototype.validateValue = function(prop, val) {
- if (prop == 'width')
- return Number.isInteger(val);
- if (prop == 'height')
- return Number.isInteger(val);
- if (prop == 'text')
- return typeof val === 'string' && val.length >= TeletypeModel.minTextLength;
- if (prop == 'textFont')
- return typeof val === 'string';
- if (prop == 'textSize')
- return Number.isInteger(val);
- if (prop == 'textColor')
- return Validator.validateColor(val);
- if (prop == 'textAlignment')
- return Validator.validateTextAlignment(val);
- if (prop == 'textWidth')
- return Number.isInteger(val);
- if (prop == 'interval')
- return Number.isInteger(val);
- return true;
- };
- TeletypeModel.prototype.normalizeValue = function(prop, val) {
- if (prop == 'width') {
- if (val < TeletypeModel.minWidth)
- val = TeletypeModel.minWidth;
- else if (val > TeletypeModel.maxWidth)
- val = TeletypeModel.maxWidth;
- }
- else if (prop == 'height') {
- if (val < TeletypeModel.minHeight)
- val = TeletypeModel.minHeight;
- else if (val > TeletypeModel.maxHeight)
- val = TeletypeModel.maxHeight;
- }
- else if (prop == 'text') {
- if (val.length > TeletypeModel.maxTextLength)
- val = val.substring(0, TeletypeModel.maxTextLength);
- }
- else if (prop == 'textSize') {
- if (val < TeletypeModel.minTextSize)
- val = TeletypeModel.minTextSize;
- else if (val > TeletypeModel.maxTextSize)
- val = TeletypeModel.maxTextSize;
- }
- else if (prop == 'textBold')
- val = val ? true : false;
- else if (prop == 'textColor')
- val = Validator.normalizeColor(val);
- else if (prop == 'textWidth') {
- if (val < TeletypeModel.minTextWidth)
- val = TeletypeModel.minTextWidth;
- else if (val > TeletypeModel.maxTextWidth)
- val = TeletypeModel.maxTextWidth;
- }
- else if (prop == 'interval') {
- if (val < TeletypeModel.minInterval)
- val = TeletypeModel.minInterval;
- else if (val > TeletypeModel.maxInterval)
- val = TeletypeModel.maxInterval;
- }
- return val;
- };
- Responder
- View
- Clip
- ProgramClip
- TeletypeClip
- ProgramClip
- Clip
- View
- function TeletypeClip() {
- ProgramClip.call(this);
- this._text = '';
- this._textWidth = 20;
- this._textWidget = null;
- }
- TeletypeClip.prototype = Object.create(ProgramClip.prototype);
- Object.defineProperty(TeletypeClip.prototype, 'constructor', { value: TeletypeClip, enumerable: false, writable: true });
- Object.defineProperty(TeletypeClip.prototype, 'duration', {
- get: function() {
- return this._text ? (this._text.length + Math.min(this._text.length, this._textWidth) - 1) * this._interval : 0;
- }
- });
- TeletypeClip.prototype.drawWidget = function() {
- if (this._text) {
- let width = Math.min(this._text.length, this._textWidth);
- let pos = Math.floor(this._currentTime / this._interval);
- this._textWidget.innerText = this._text.substring(pos < width ? 0 : pos - width + 1, pos + 1);
- }
- return this;
- };
- TeletypeClip.prototype.setWidget = function(w) {
- const span = document.createElement('span');
- w.appendChild(span);
- ProgramClip.prototype.setWidget.call(this, w);
- this._textWidget = span;
- return this;
- };
- TeletypeClip.prototype.set = function(options) {
- const {width, height, text, textFont, textSize, textBold, textColor, textAlignment, textWidth, interval} = options;
- this.setWidth(width);
- this.setHeight(height);
- this.setText(text);
- this.setTextFont(textFont);
- this.setTextSize(textSize);
- this.setTextBold(textBold);
- this.setTextColor(textColor);
- this.setTextAlignment(textAlignment);
- this.setTextWidth(textWidth);
- this.setInterval(interval);
- return this;
- };
- TeletypeClip.prototype.setValue = function(prop, val) {
- if (prop == 'width')
- this.setWidth(val);
- else if (prop == 'height')
- this.setHeight(val);
- else if (prop == 'text')
- this.setText(val);
- else if (prop == 'textFont')
- this.setTextFont(val);
- else if (prop == 'textSize')
- this.setTextSize(val);
- else if (prop == 'textBold')
- this.setTextBold(val);
- else if (prop == 'textColor')
- this.setTextColor(val);
- else if (prop == 'textAlignment')
- this.setTextAlignment(val);
- else if (prop == 'textWidth')
- this.setTextWidth(val);
- else if (prop == 'interval')
- this.setInterval(val);
- return this;
- };
- TeletypeClip.prototype.setWidth = function(px) {
- this.setStyle('width', `${px}px`);
- this._width = px;
- return this;
- };
- TeletypeClip.prototype.setHeight = function(px) {
- this.setStyle('height', `${px}px`);
- this._height = px;
- return this;
- };
- TeletypeClip.prototype.setText = function(text) {
- this._text = text;
- if (!this._timer)
- this.showText();
- return this;
- };
- TeletypeClip.prototype.setTextFont = function(font) {
- this.addFont(font).setStyle('fontFamily', `"${font}", sans-serif`);
- return this;
- };
- TeletypeClip.prototype.setTextSize = function(px) {
- this.setStyle('fontSize', `${px}px`);
- return this;
- };
- TeletypeClip.prototype.setTextBold = function(bold) {
- this.setStyle('fontWeight', bold ? 'bold' : 'normal');
- return this;
- };
- TeletypeClip.prototype.setTextColor = function(color) {
- this.setStyle('color', color);
- return this;
- };
- TeletypeClip.prototype.setTextAlignment = function(alignment) {
- this._textWidget.style.textAlign = alignment;
- return this;
- };
- TeletypeClip.prototype.setTextWidth = function(w) {
- this._textWidth = w;
- if (!this._timer)
- this.showText();
- return this;
- };
- TeletypeClip.prototype.showText = function() {
- this._textWidget.innerText = this._text ? this._text.substring(0, this._textWidth) : '';
- return this;
- };
- <?php $debug=false; ?>
Setting $debug
to true
gives access in the console of the navigator to all the components of the interface.
If $debug
is false
, all the code in JavaScript is protected by a closure function.
- <?php $text='Objective.js'; ?>
- <?php $textwidth=12; ?>
- <?php $color='#22aa77'?>
- <?php $font='Slackey'; ?>
- <?php $fontsize=40; ?>
Defines the content of the text, its width and its color, the character font of the text and its size.
- <?php head('font', $font); ?>
Adds the tag <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Slackey" />
to the <head>
section of the HTML document.
REMINDER: head
is a function of iZend.
Adapt the code to your development environment.
- <?php $id=uniqid('id'); ?>
Defines the identifier of the <div>
which surrounds the HTML of the interface.
- .teletype {
- display: flex;
- align-items: center;
- user-select: none;
- }
- .teletype span {
- flex: 1 1 auto;
- white-space: pre;
- }
Configures the CSS of the animated text.
- <div id="<?php echo $id; ?>" class="clip">
- <div class="teletype"></div>
- </div>
Creates the <div>
which displays the animated text.
- <?php head('javascript', '/objectivejs/Objective.js'); ?>
- <?php head('javascript', '/objectivejs/Responder.js'); ?>
- <?php head('javascript', '/objectivejs/View.js'); ?>
- <?php head('javascript', '/objectivejs/Clip.js'); ?>
- <?php head('javascript', '/objectivejs/Model.js'); ?>
- <?php head('javascript', '/objectivejs/Validator.js'); ?>
- <?php head('javascript', '/objectivejs/ClipModel.js'); ?>
- <?php head('javascript', '/objectivejs/ClipController.js'); ?>
- <?php head('javascript', '/objectivejs/ProgramClip.js'); ?>
- <?php head('javascript', '/objectivejs/tests/TeletypeModel.js'); ?>
- <?php head('javascript', '/objectivejs/tests/TeletypeClip.js'); ?>
Includes the code of all the necessary classes.
- function TeleTypeClipController() {
- ClipController.apply(this, arguments);
- }
- TeleTypeClipController.prototype = Object.create(ClipController.prototype);
- Object.defineProperty(TeleTypeClipController.prototype, 'constructor', { value: TeleTypeClipController, enumerable: false, writable: true });
- TeleTypeClipController.prototype.clipEnded = function(sender) {
- sender.showText();
- }
Creates the class TeleTypeClipController. An instance of TeleTypeClipController is an instance of ClipController which in addition to configuring a clip as soon as a model has been changed, displays the entire text in the clip when the clip has finished its animation.
- <?php if (!$debug): ?>
- (function() {
- <?php endif; ?>
Isolates all the code in JavaScript in a closure function if $debug
is false
.
- const clip = new TeletypeClip();
- const model = new TeletypeModel();
- const container = document.querySelector('#<?php echo $id; ?>');
- clip.setManagedWidget(container.querySelector('.teletype')).reset();
- clip.enablePlayer();
- const controller = new TeleTypeClipController(clip, model);
- const options = {
- width: 320,
- height: 60,
- text: '<?php echo $text; ?>',
- textWidth: <?php echo $textwidth; ?>,
- textColor: '<?php echo $color; ?>',
- textFont: '<?php echo $font; ?>',
- textSize: <?php echo $fontsize; ?>
- };
- model.set(options);
Creates the clip, the model of the clip and its interface. Enables the keyboard and the mouse controls of the clip. Creates a simple controller which configures the clip when the model has been set. Configures the model of the clip.
- <?php if (empty($debug)): ?>
- })();
- <?php endif; ?>
Closes the function which isolates the code in JavaScript if $debug
is false
.
Editor
Type in a slogan, e.g. Objective.js • Programming object oriented interfaces and animations in JavaScript
.
Press Enter to validate the text.
Modify the size of the font.
Check the box to show the text in bold.
Change the font of the text by entering the name of a font from Google Fonts, e.g. Slackey
or Special Elite
.
Choose the color of the text, e.g. #2A7
.
Adjust the width and the height of the clip.
Change how fast each character is displayed in ms.
Decide how many characters are displayed. The bar to the right of the display lets you see if some characters overflow.
Try to animate the text from the left, from the right or at the center of the display.
The total duration of the clip is computed from the length of the text, the number of characters displayed and the speed at which each character is displayed.
Click on the text to start the animation. Click again to pause it, to continue to play it. NOTE: When the animation is completed, the editor fills the display with the text.
Reload the page. The modifications are saved.
See Architecture of an editor.
- <?php $debug=false; ?>
Setting $debug
to true
gives access in the console of the navigator to all the components of the interface.
If $debug
is false
, all the code in JavaScript is protected by a closure function.
- <?php $editor=true; ?>
- <?php $player=true; ?>
Setting $editor
to true
displays the editor of the clip.
Setting $player
to true
activates the controls of the clip.
Try setting each option to false
.
- <?php $clipname='teletype'; ?>
Defines the name of the model which defines the name of the cookie which records the data of the model.
- <?php head('javascript', 'js.cookie.js'); ?>
Adds the tag <script src="/js/js.cookie.js"></script>
to the <head>
section of the document in HTML.
REMINDER: The function head is provided by iZend.
Adapt the code to your development environment.
- <?php if ($editor): ?>
- <?php head('javascript', 'jquery.minicolors'); ?>
- <?php head('stylesheet', 'jquery.minicolors', 'screen'); ?>
- <?php endif; ?>
If the editor is displayed, adds the tags <script src="/js/jquery.minicolors.js"/>
and <link rel="stylesheet" href="/css/jquery.minicolors.css" media="screen"/>
to the <head>
section of the HTML document to load the code and the style sheet of MiniColors in jQuery.
- <?php $id=uniqid('id'); ?>
Defines the identifier of the <div>
which surrounds the HTML of the interface.
- .teletype {
- display: flex;
- align-items: center;
- user-select: none;
- }
- .teletype span {
- flex: 1 1 auto;
- white-space: pre;
- }
Configures the CSS of the animated text.
- #<?php echo $id; ?> .teletype {
- border-right: 4px dotted #ccc;
- }
- #<?php echo $id; ?>_teletype_text {
- width: 30em;
- }
- #<?php echo $id; ?>_teletype_textsize {
- width: 3em;
- }
- #<?php echo $id; ?>_teletype_textbold {
- line-height: 14px;
- }
- #<?php echo $id; ?>_teletype_textwidth {
- width: 3em;
- }
- <div id="<?php echo $id; ?>" class="clip">
- <?php if ($editor): ?>
- <div class="ojs">
- <div>
- <div class="ojs_undo">
- <button type="submit" class="ojs_button narrow control_undo" disabled><i class="fas fa-undo"></i></button>
- <button type="submit" class="ojs_button narrow control_redo" disabled><i class="fas fa-redo"></i></button>
- </div>
- <span>
- <input class="ojs_width" type="number" min="120" max="960" step="10"/> <i class="fas fa-arrows-alt-h small"></i>
- <input class="ojs_height" type="number" min="10" max="540" step="10"/> <i class="fas fa-arrows-alt-v small"></i>
- </span>
- </div>
- <input id="<?php echo $id; ?>_teletype_text" type="text" size="40" spellcheck="false"/>
- <div>
- <span><input id="<?php echo $id; ?>_teletype_textsize" type="number" min="10" max="60" step="1"/> <i class="fas fa-text-height small"></i></span>
- <span><input id="<?php echo $id; ?>_teletype_textbold" type="checkbox" /> <i class="fas fa-bold small"></i></span>
- <span id="<?php echo $id; ?>_teletype_textcolor"></span>
- <span id="<?php echo $id; ?>_teletype_textalignment">
- <input type="radio" id="<?php echo $id; ?>_teletype_textalignment_left" name="teletype_textalignment" value="left" checked><label for="<?php echo $id; ?>_teletype_textalignment_left"><i class="fas fa-align-left small"></i></label>
- <input type="radio" id="<?php echo $id; ?>_teletype_textalignment_center" name="teletype_textalignment" value="center"><label for="<?php echo $id; ?>_teletype_textalignment_center"><i class="fas fa-align-center small"></i></label>
- <input type="radio" id="<?php echo $id; ?>_teletype_textalignment_right" name="teletype_textalignment" value="right"><label for="<?php echo $id; ?>_teletype_textalignment_right"><i class="fas fa-align-right small"></i></label>
- </span>
- </div>
- <div>
- <span>
- <input id="<?php echo $id; ?>_teletype_textfont" type="text" size="20" spellcheck="false"/> <i class="fas fa-font small"></i>
- </span>
- </div>
- <fieldset class="ojs_animation">
- <legend><i class="fas fa-history"></i> <span class="ojs_timing">0</span></legend>
- <input class="ojs_interval" type="number" min="100" max="500" step="50"/> <i class="fas fa-tachometer-alt small"></i>
- <input id="<?php echo $id; ?>_teletype_textwidth" type="number" min="10" max="100" step="1"/> <i class="fas fa-text-width small"></i>
- </fieldset>
- </div>
- <?php endif; ?>
- <div class="teletype"></div>
- </div>
Creates the widgets of the interface.
- <?php head('javascript', '/objectivejs/Objective.js'); ?>
- <?php head('javascript', '/objectivejs/Responder.js'); ?>
- <?php head('javascript', '/objectivejs/View.js'); ?>
- <?php head('javascript', '/objectivejs/Clip.js'); ?>
- <?php head('javascript', '/objectivejs/Model.js'); ?>
- <?php head('javascript', '/objectivejs/Validator.js'); ?>
- <?php if ($editor): ?>
- <?php head('javascript', '/objectivejs/Editor.js'); ?>
- <?php head('javascript', '/objectivejs/ClipEditor.js'); ?>
- <?php head('javascript', '/objectivejs/Inspector.js'); ?>
- <?php head('javascript', '/objectivejs/BooleanInspector.js'); ?>
- <?php head('javascript', '/objectivejs/ColorInspector.js'); ?>
- <?php head('javascript', '/objectivejs/NumberInspector.js'); ?>
- <?php head('javascript', '/objectivejs/StringInspector.js'); ?>
- <?php head('javascript', '/objectivejs/SelectInspector.js'); ?>
- <?php head('javascript', '/objectivejs/OptionInspector.js'); ?>
- <?php head('javascript', '/objectivejs/Undo.js'); ?>
- <?php head('javascript', '/objectivejs/Panel.js'); ?>
- <?php head('javascript', '/objectivejs/UndoPanel.js'); ?>
- <?php else: ?>
- <?php head('javascript', '/objectivejs/ClipController.js'); ?>
- <?php endif; ?>
- <?php head('javascript', '/objectivejs/ClipModel.js'); ?>
- <?php head('javascript', '/objectivejs/ProgramClip.js'); ?>
- <?php head('javascript', '/objectivejs/ModelCookieDelegate.js'); ?>
- <?php head('javascript', '/objectivejs/tests/TeletypeModel.js'); ?>
- <?php head('javascript', '/objectivejs/tests/TeletypeClip.js'); ?>
Includes the code of all the necessary classes. If the editor isn't displayed, a simple controller configures the clip when the model has been set.
- function TeleTypeClipEditor() {
- ClipEditor.apply(this, arguments);
- }
- TeleTypeClipEditor.prototype = Object.create(ClipEditor.prototype);
- Object.defineProperty(TeleTypeClipEditor.prototype, 'constructor', { value: TeleTypeClipEditor, enumerable: false, writable: true });
- TeleTypeClipEditor.prototype.clipEnded = function(sender) {
- sender.showText();
- }
Creates the class TeleTypeClipController. An instance of TeleTypeClipController is an instance of ClipController which in addition to configuring a clip as soon as a model has been changed, displays the entire text in the clip when the clip has finished its animation.
- <?php if (!$debug): ?>
- (function() {
- <?php endif; ?>
Isolates all the code in JavaScript in a closure function if $debug
is false
.
- const clip = new TeletypeClip();
- const model = new TeletypeModel('<?php echo $clipname; ?>');
- const container = document.querySelector('#<?php echo $id; ?>');
- clip.setManagedWidget(container.querySelector('.teletype'));
- clip.set(model.get());
Creates the clip and the data model to be edited.
Retrieves the <div>
which surrounds the HTML of the program.
Configures the interface of the clip.
Initializes the clip with the data of the model.
- clip.enablePlayer();
Enables the keyboard and the mouse controls of the clip if $player
is true
.
- const panel = new UndoPanel();
- panel.setManagedWidget(container.querySelector('.ojs_undo')).resetWidget();
- const widthInspector = new NumberInspector(model.getValue('width'), {min: TeletypeModel.minWidth, max: TeletypeModel.maxWidth});
- widthInspector.setManagedWidget(container.querySelector('.ojs_width')).resetWidget();
- const heightInspector = new NumberInspector(model.getValue('height'), {min: TeletypeModel.minHeight, max: TeletypeModel.maxHeight});
- heightInspector.setManagedWidget(container.querySelector('.ojs_height')).resetWidget();
- const textInspector = new StringInspector(model.getValue('text'), {min: TeletypeModel.minTextLength, max: TeletypeModel.maxTextLength, trim: false, required: false});
- textInspector.setManagedWidget(container.querySelector('#<?php echo $id; ?>_teletype_text')).resetWidget();
- const textSizeInspector = new NumberInspector(model.getValue('textSize'), {min: TeletypeModel.minTextSize, max: TeletypeModel.maxTextSize});
- textSizeInspector.setManagedWidget(container.querySelector('#<?php echo $id; ?>_teletype_textsize')).resetWidget();
- const textBoldInspector = new BooleanInspector(model.getValue('textBold'));
- textBoldInspector.setManagedWidget(container.querySelector('#<?php echo $id; ?>_teletype_textbold')).resetWidget();
- const textColorInspector = new ColorInspector(model.getValue('textColor'));
- textColorInspector.createManagedWidget(container.querySelector('#<?php echo $id; ?>_teletype_textcolor'));
- const textFontInspector = new StringInspector(model.getValue('textFont'));
- textFontInspector.setManagedWidget(container.querySelector('#<?php echo $id; ?>_teletype_textfont')).resetWidget();
- const textAlignmentInspector = new OptionInspector(model.getValue('textAlignment'), {tags: TeletypeModel.textAlignmentOptions});
- textAlignmentInspector.setManagedWidget(container.querySelector('#<?php echo $id; ?>_teletype_textalignment')).resetWidget();
- const textWidthInspector = new NumberInspector(model.getValue('textWidth'));
- textWidthInspector.setManagedWidget(container.querySelector('#<?php echo $id; ?>_teletype_textwidth')).resetWidget();
- const intervalInspector = new NumberInspector(model.getValue('interval'), {min: TeletypeModel.minInterval, max: TeletypeModel.maxInterval});
- intervalInspector.setManagedWidget(container.querySelector('.ojs_interval')).resetWidget();
- const timing = new View();
- timing.setManagedWidget(container.querySelector('.ojs_timing'));
- const inspectors = {
- width: widthInspector,
- height: heightInspector,
- text: textInspector,
- textFont: textFontInspector,
- textSize: textSizeInspector,
- textBold: textBoldInspector,
- textColor: textColorInspector,
- textAlignment: textAlignmentInspector,
- textWidth: textWidthInspector,
- interval: intervalInspector
- };
- const editor = new TeleTypeClipEditor(model, clip, inspectors, panel, timing);
If $editor
is true
, creates the panel with the buttons to undo and redo a modification, creates the inspectors for all the parameters of the clip, creates the view which displays the duration of the clip, creates the editor.
- const controller = new ClipController(clip, model);
Enables the keyboard and the mouse controls of the clip if $player
is true
.
- model.setDelegate(new ModelCookieDelegate());
- if (model.isSaved())
- model.readIn();
- else
- model.setValue('text', 'Objective.js');
- model.enableSync();
Associates the model to a delegate in charge of saving its data in a cookie. Configures the model with the data already saved or initializes it with the content of a text by default. Enables saving the data of the model whenever it is changed.
- <?php if (!$debug): ?>
- })();
- <?php endif; ?>
Closes the function which isolates the code in JavaScript if $debug
is false
.
A clip can always be converted into a video.
Click in the video to start it. Click again to pause it.
SEE ALSO
Objective, Model, Clip, ProgramClip, Inspector, ModelCookieDelegate, Editor, Architecture of an editor, Editing an animated clip, Editing a video clip, Write data on a server
Comments