3 'remoto!stdlib:js/panes/pane.js',
4 'remoto!stdlib:js/paneManager/paneManager.js',
5 'remoto!stdlib:js/include/objectRegistry.js',
6 'remoto!stdlib:js/include/utils.js',
8 'remoto!stdlib:js/panes/panes/contentSelector.css',
38 pane.call(
this, layout);
40 this._type =
"contentSelector";
42 this._transitioner =
null;
45 this._mediaTracker =
null;
46 this._playing =
false;
51 this._mediaItems = [];
66 if (this._html)
return this._html;
70 this._content.addClass(
"contentSelector");
71 this._content.on(
"click",
".contentSelectorImage", this.
imageClick.bind(
this) );
75 this._content.bind(
"mousedown", (e) => {
78 var nn = e.target.nodeName.toLowerCase();
82 var slider = this._content[0];
86 var scrollTop = slider.scrollTop;
87 $(
"body").bind(
"mousemove", (e) => {
91 slider.scrollTop = scrollTop + (startY-
y);
92 THIS._scrolling =
true;
95 $(
"body").bind(
"mouseup", (e) => {
96 $(
"body").unbind(
"mousemove");
97 $(
"body").unbind(
"mouseup");
98 setTimeout(
function() {
99 THIS._scrolling =
false;
106 var events =
"click touchstart";
107 this._content.on( events,
".contentSelectorMovie", this.
movieClick.bind(
this) );
108 this._content.on( events,
".contentSelectorMovieChapter", this.
movieChapterClick.bind(
this) );
109 this._content.on( events,
".contentSelectorMoviePlaystate", this.
moviePlaystateClick.bind(
this) );
111 this._content.on(
"change input",
".contentSelectorMovieVolume", this.
movieVolumeChange.bind(
this) );
112 this._content.on(
"click",
".contentSelectorButton:not(.contentSelectorButtonInactive)",
156 if (this._subscribed)
159 this._subscribed =
true;
162 this._transitioner = data.paneTransitioner;
165 this._content.addClass(data.class);
167 if (this._transitioner)
174 this._content.empty();
176 for (var i=0; i<diff.children.length; i++)
178 var block = $(
"<div class='contentSelectorGroup'>").appendTo(this._content);
180 if (diff.children[i][
"class"])
181 block.addClass(diff.children[i][
"class"])
183 switch(diff.children[i].type)
185 case "movies": var imgh = $(
"<h1>").appendTo(block).append(diff.children[i].name);
187 var movies = $(
"<div class='contentSelectorMovies'>").appendTo(block);
188 var chapters = $(
"<div class='contentSelectorMovieChapters'>").appendTo(block);
189 var controls = $(
"<div class='contentSelectorMovieControls'>").appendTo(block);
191 var _movies = diff.children[i].children;
192 for (var j=0; j<_movies.length; j++)
196 var md = $(
"<div class='contentSelectorMovie'>").appendTo(movies);
198 md.append(
"<img src='"+_movies[j].thumb+
"'>");
200 md.append(_movies[j].
text);
201 md.attr(
"value",_movies[j].
value);
202 md.attr(
"m_id", m_id );
204 md.attr(
"video",_movies[j].video || _movies[j].
value);
206 if (_movies[j].video) this._video = _movies[j].video;
209 this._mediaItems.push( _movies[j].
value );
212 var ch = _movies[j].chapters;
215 var mcg = $(
"<div class='contentSelectorMovieChaptersGroup'>").appendTo(chapters);
216 mcg.append(
"Chapters:<br>");
217 mcg.attr(
"m_id", m_id );
218 for (var k=0; k<ch.length; k++)
220 var mcgc = $(
"<div class='contentSelectorMovieChapter'>").appendTo(mcg);
221 mcgc.append(
"<img src='"+ch[k].thumb+
"'>");
223 mcgc.append(ch[k].
text);
224 mcgc.attr(
"value",ch[k].
value);
234 if (_movies[j].
html.trim() !==
'')
236 var
text = $(
"<div class='contentSelectorMovieText'>").appendTo(block);
237 var mt = $(
"<div class='contentSelectorMovieTextGroup'>").appendTo(
text);
238 mt.attr(
"m_id", m_id );
239 mt.append(_movies[j].
html);
245 controls.append(
"<div class='contentSelectorMoviePlaystate'>▶︎ PLAY</div>");
246 controls.append(
"<input class='contentSelectorMovieVolume' type='range' min='0' max='1' step='.01'>");
250 case "images": var imgh = $(
"<h1>").appendTo(block);
251 imgh.append(diff.children[i].name);
252 var imgs = diff.children[i].children;
253 for (var j=0; j<imgs.length; j++)
255 var imgd = $(
"<div class='contentSelectorImage'>").appendTo(block);
257 $(
"<img src='"+imgs[j].thumb+
"'>").appendTo(imgd);
258 imgd.append(
"<br>"+imgs[j].
text);
259 imgd.attr(
"value",imgs[j].
value);
261 block.append(
"<br>");
262 block.append(diff.children[i].text);
267 block.append(diff.children[i].html);
273 this._mediaItems.push( diff.children[i].value );
277 default: block.append(
"Unknown contentSelector type: "+diff.children[i].type);
278 console.log(diff.children[i]);
283 if (movieCount !== 1)
310 if (diff.attributes && diff.attributes.state)
311 { this.value = diff.attributes.state.value;
319 { this.value = diff.value;
359 if (this._transitioner)
363 this._mediaItems = [];
381 var t = $(evt.currentTarget);
382 var r = JSON.parse( t.attr(
"trigger") );
385 this._html.trigger(tr,r[tr]);
403 var mov = $(evt.currentTarget);
405 var
value = mov.attr(
"value");
408 this._video = mov.attr(
"video");
433 var
chapter = $(evt.currentTarget);
436 var u = { attributes: {} };
437 u.attributes.play = {
value:
true };
438 u.attributes.chapter = {
value: chapterValue };
460 var v = $(evt.currentTarget).val();
481 var u = { attributes: {} };
482 u.attributes.play = {
value: !this._playing };
484 this.
play = !this._playing;
505 var img = $(evt.currentTarget);
506 var
value = img.attr(
"value");
532 if (v !== this._value)
534 if (this._mediaTracker)
535 { this._mediaTracker.destroy();
536 this._mediaTracker =
null;
543 this._content.
find(
".contentSelectorImageSelected").removeClass(
"contentSelectorImageSelected");
544 this._content.find(
".contentSelectorImage[value='"+v+
"']").addClass(
"contentSelectorImageSelected");
546 this._content.find(
".contentSelectorMovieSelected").removeClass(
"contentSelectorMovieSelected");
547 this._content.find(
".contentSelectorMovieControls").
hide();
548 this._content.find(
".contentSelectorMovieTextGroup").
hide();
549 this._content.find(
".contentSelectorMovieChaptersGroup").
hide();
550 var m = this._content.find(
".contentSelectorMovie[value='"+v+
"']").addClass(
"contentSelectorMovieSelected");
553 var m_id = m.attr(
"m_id");
554 this._content.find(
"[m_id='"+m_id+
"']").show();
555 this._content.find(
".contentSelectorMovieControls").show();
558 if (this._value && this._mediaItems.indexOf(
this._value) > -1)
559 { this._mediaTracker = new mediaTracker(this._value,this);
577 this._content.find(
".contentSelectorMovieChapterSelected").removeClass(
"contentSelectorMovieChapterSelected");
579 this._content.find(
".contentSelectorMovieChaptersGroup").find(
".contentSelectorMovieChapter[value='"+c+
"']").addClass(
"contentSelectorMovieChapterSelected");
592 if (
play.value === undefined) {
602 this._content.find(
".contentSelectorMoviePlaystate" ).html(
"<span class='video-pause'>PAUSE</span>");
606 this._content.find(
".contentSelectorMoviePlaystate" ).html(
"<span class='video-play'>PLAY</span>");
618 var vol = Math.min( Math.max( v.value, 0 ), 1 );
622 this._content.find(
".contentSelectorMovieVolume" ).val(vol);
652 target = target || this._transitioner;
655 var u1 = { attributes: {
state: {
value: v } } };
656 var u2 = {
value: v };
711 for (var b in buttons.buttons)
713 var button = buttons.buttons[b];
715 var t = $(
"<div class='contentSelectorButton'>");
716 t.text( button.name );
718 var c = [
"height",
"width",
"top",
"bottom",
"left",
"right"];
719 for (var i=0;i<c.length;i++)
720 if (button.hasOwnProperty(c[i]))
721 t.css( c[i], button[c[i]] );
723 t.addClass( button[
"class"] );
724 t.attr(
"attribute", button.attribute );
725 t.attr(
"value", button.value );
727 t.attr(
"data-light",button.data);
737 var m = $(
"<div class='contentSelectorModalContent'>");
739 m.append( button.modalHTML );
742 t.attr(
"modal",m_id);
746 t.attr(
"toggle",button.toggle);
749 t.attr(
"trigger", JSON.stringify(button.trigger) );
751 if (!button.enabled) t.addClass(
"contentSelectorButtonInactive" );
754 if (button.top && button.top + button.height > max)
755 max = button.top + button.height;
756 if (button.bottom && button.bottom + button.height > max)
757 max = button.bottom + button.height;
760 block.css( {
"height": max+
"px" } );
762 for (var g in buttons.groups)
804 if (typeof(
state)==
"object")
805 for (var attr in
state)
809 var v =
state[attr].value;
811 this._content.find(
".contentSelectorButton[attribute='"+attr+
"']").removeClass(
"contentSelectorButtonSelected");
812 this._content.find(
".contentSelectorButton[attribute='"+attr+
"'][value='"+v+
"']").addClass(
"contentSelectorButtonSelected");
832 var t = $(evt.currentTarget);
833 var attrs = t.attr(
"attribute");
834 var target = t.attr(
"target");
835 var modalID = t.attr(
"modal");
836 var toggle = t.attr(
"toggle");
837 var val = t.attr(
"value");
840 attrs = attrs ? attrs.split(
",") : [];
843 var u = { attributes:{} };
844 var u2 = {
value: {} };
846 for (var i=0; i<attrs.length; i++)
855 if (this._value && this._value[attr])
856 { val = this._value[attr].value ==
"true" || this._value[attr].value ===
true ? false :
true;
857 this._value[attr].value = val;
863 u.attributes[attr] = {
value: val };
864 u2.value[attr] = {
value:val };
869 update[ this._path ] = u2;
880 exec:
function(_modal)
882 var mount = _modal._center;
885 var m = $(
"<div class='contentSelectorModal'/>").appendTo(mount);
887 m.append( $(
"#"+modalID).clone().show() );
889 var bs = $(
"<div class='contentSelectorModalButtons'>").appendTo(m);
890 var b = $(
"<button>").
text(
"Close");
891 b.bind(
"click",
function() { _modal.execEvent(
"close");
return false; });
894 setTimeout(
function() {
895 mount.bind(
"click",
function() { _modal.execEvent(
"close");
return false; });
898 m.bind(
"click",
false);
900 m.on(
"click",
"div.contentSelectorImage",
function(e) {
902 console.log(
"allowing event to bubble!");
904 $(e.target).parent().siblings().children().removeClass(
"active");
905 $(e.target).addClass(
"active");
911 $(window).trigger(
"modalOpen");
918 modal.exec( bModal, {
"close":
false } );
946 this._subscribed =
false;
948 this._selector = selector;
967 this._selector =
null;
1004 switch( this._type )
1008 if (diff.attributes)
1009 for (var a in diff.attributes)
1010 if (this._selector.__proto__.hasOwnProperty(a))
1011 this._selector[a] = diff.attributes[a];
1016 case "requireModule":
1018 if (diff.attributes)
1019 this._selector.setButtonStates(diff.attributes);
getter html
Get the html color representation of this object.
drawButtons(buttons, block)
setter play
a setter DOCME
setter chapter
a setter DOCME
setter value
a setter DOCME
applySubscription(data, metadata)
setter volume
a setter DOCME
find(id, type)
Find a registered object, optionally by type.
registerObject(id, o, nosubscribe)
Register an object in the registry, and call the pathAddedCallback.
unregisterObject(id, o, silent, nounsubscribe, now)
Unregister an object from the registry.
setter postUpdate
Assign a callback to the paneFactory class for VFS_node::submit() commands.
Create a pane which will be mounted into a paneManager layout.
The paneManager manages panes in a user layout.
getter path
a getter DOCME
getter state
a getter DOCME
update(dirty)
Process the _queue and apply the settings.
Utility functions for javascript clients.
uuid()
Generate a universally unique identifier.
cleanPath(path)
Clean and normalize a resource path.