Merge branch 'master' of dev.sourcefabric.org:campcaster

This commit is contained in:
mkonecny 2011-01-19 11:38:01 -05:00
commit 6eb43e7478
3 changed files with 23 additions and 74 deletions

View File

@ -1,8 +1,8 @@
<div id="spl_cue_in_<?php echo $this->pos; ?>" class="spl_cue_in">
<span>Cue In:</span>
<span class="spl_text_input"><?php echo $this->cueIn; ?></span>
<span class="spl_text_input" contenteditable="true"><?php echo $this->cueIn; ?></span>
</div>
<div id="spl_cue_out_<?php echo $this->pos; ?>" class="spl_cue_out">
<span>Cue Out:</span>
<span class="spl_text_input"><?php echo $this->cueOut; ?></span>
<span class="spl_text_input" contenteditable="true"><?php echo $this->cueOut; ?></span>
</div>

View File

@ -1,8 +1,8 @@
<div id="spl_fade_out_<?php echo $this->pos; ?>" class="spl_fade_out">
<span>Fade Out:</span>
<span class="spl_text_input"><?php echo $this->fadeOut; ?></span>
<span class="spl_text_input" contenteditable="true"><?php echo $this->fadeOut; ?></span>
</div>
<div id="spl_fade_in_<?php echo $this->pos; ?>" class="spl_fade_in">
<span>Fade In:</span>
<span class="spl_text_input"><?php echo $this->fadeIn; ?></span>
<span class="spl_text_input" contenteditable="true"><?php echo $this->fadeIn; ?></span>
</div>

View File

@ -13,16 +13,9 @@ function isTimeValid(time) {
return true;
}
function revertEditorValue(el) {
var oldValue = $("#pl_tmp_time").val();
el.empty()
.append(oldValue)
.click(addTextInput);;
}
function displayEditorError(error) {
$("#spl_error")
.empty()
.append('<span class="ui-icon ui-icon-alert"></span>')
.append(error)
.show();
@ -43,30 +36,22 @@ function cueSetUp(pos, json) {
$("#spl_length")
.empty()
.append(json.response.length);
$(".spl_cue_in span:last, .spl_cue_out span:last").click(addTextInput);
}
function fadeSetUp() {
$(".spl_fade_in span:last, .spl_fade_out span:last").click(addTextInput);
}
function changeCueIn() {
var pos, url, cueIn, div;
span = $(this).parent();
span = $(this);
pos = span.parent().attr("id").split("_").pop();
url = "/Playlist/set-cue/format/json";
cueIn = $(this).val().trim();
cueIn = span.text().trim();
if(!isTimeValid(cueIn)){
revertEditorValue(span);
return;
}
$.post(url, {cueIn: cueIn, pos: pos}, function(json){
if(json.response.error) {
revertEditorValue(span);
displayEditorError(json.response.error);
return;
}
@ -83,19 +68,17 @@ function changeCueIn() {
function changeCueOut() {
var pos, url, cueOut, div;
span = $(this).parent();
span = $(this);
pos = span.parent().attr("id").split("_").pop();
url = "/Playlist/set-cue/format/json";
cueOut = $(this).val().trim();
cueOut = span.text().trim();
if(!isTimeValid(cueOut)){
revertEditorValue(span);
return;
}
$.post(url, {cueOut: cueOut, pos: pos}, function(json){
if(json.response.error) {
revertEditorValue(span);
displayEditorError(json.response.error);
return;
}
@ -112,19 +95,17 @@ function changeCueOut() {
function changeFadeIn() {
var pos, url, fadeIn, div;
span = $(this).parent();
span = $(this);
pos = span.parent().attr("id").split("_").pop();
url = "/Playlist/set-fade/format/json";
fadeIn = $(this).val().trim();
fadeIn = span.text().trim();
if(!isTimeValid(fadeIn)){
revertEditorValue(span);
return;
}
$.post(url, {fadeIn: fadeIn, pos: pos}, function(json){
if(json.response.error) {
revertEditorValue(span);
displayEditorError(json.response.error);
return;
}
@ -134,26 +115,23 @@ function changeFadeIn() {
span.empty()
.append(json.response.fadeIn);
fadeSetUp();
});
}
function changeFadeOut() {
var pos, url, fadeOut, div;
span = $(this).parent();
span = $(this);
pos = span.parent().attr("id").split("_").pop() - 1;
url = "/Playlist/set-fade/format/json";
fadeOut = $(this).val().trim();
fadeOut = span.text().trim();
if(!isTimeValid(fadeOut)){
revertEditorValue(span);
return;
}
$.post(url, {fadeOut: fadeOut, pos: pos}, function(json){
if(json.response.error) {
revertEditorValue(span);
displayEditorError(json.response.error);
return;
}
@ -163,48 +141,14 @@ function changeFadeOut() {
span.empty()
.append(json.response.fadeOut);
fadeSetUp();
});
}
function addTextInput(){
var time = $(this).text().trim();
var input = $("<input type='text' value="+time+" size='13' maxlength='15'/>");
//Firefox seems to have problems losing focus otherwise, Chrome is fine.
$(":input").blur();
$(this).empty();
$(this).append(input);
input.focus();
var parent = $(this).parent();
if( parent.hasClass('spl_cue_in') ){
input.blur(changeCueIn);
function submitOnEnter(event) {
//enter was pressed
if(event.keyCode === 13) {
$(this).blur();
}
else if( parent.hasClass('spl_cue_out') ){
input.blur(changeCueOut);
}
else if( parent.hasClass('spl_fade_in') ){
input.blur(changeFadeIn);
}
else if( parent.hasClass('spl_fade_out') ){
input.blur(changeFadeOut);
}
input.keypress(function(ev){
//don't want enter to submit.
if (ev.keyCode === 13) {
ev.preventDefault();
$(this).blur();
}
});
input = $("<input type='hidden' value="+time+" size='10' id='pl_tmp_time'/>");
$(this).append(input);
$(this).unbind('click');
}
function setEditorContent(json) {
@ -214,7 +158,12 @@ function setEditorContent(json) {
clearEditorError();
$(".spl_cue_in span:last, .spl_cue_out span:last, .spl_fade_in span:last, .spl_fade_out span:last").click(addTextInput);
$(".spl_cue_in span:last").blur(changeCueIn);
$(".spl_cue_out span:last").blur(changeCueOut);
$(".spl_fade_in span:last").blur(changeFadeIn);
$(".spl_fade_out span:last").blur(changeFadeOut);
$(".spl_cue_in span:last, .spl_cue_out span:last, .spl_fade_in span:last, .spl_fade_out span:last").keyup(submitOnEnter);
}
function highlightActive(el) {