diff --git a/application/forms/AddShowStyle.php b/application/forms/AddShowStyle.php index faa471f0d..b7000505f 100644 --- a/application/forms/AddShowStyle.php +++ b/application/forms/AddShowStyle.php @@ -12,12 +12,26 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm 'filters' => array('StringTrim') )); + $bg = $this->getElement('add_show_background_color'); + + $bg->setDecorators(array(array('ViewScript', array( + 'viewScript' => 'form/add-show-style.phtml', + 'class' => 'big' + )))); + // Add show color input $this->addElement('text', 'add_show_color', array( 'label' => 'Text Colour', 'class' => 'input_text', 'filters' => array('StringTrim') )); + + $c = $this->getElement('add_show_color'); + + $c->setDecorators(array(array('ViewScript', array( + 'viewScript' => 'form/add-show-style.phtml', + 'class' => 'big' + )))); } diff --git a/application/forms/AddShowWhen.php b/application/forms/AddShowWhen.php index cc37af4d8..5bfb4daeb 100644 --- a/application/forms/AddShowWhen.php +++ b/application/forms/AddShowWhen.php @@ -37,7 +37,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm 'filters' => array('StringTrim'), 'validators' => array( 'NotEmpty', - array('date', false, array('HH:mm')) + array('regex', false, array('([0-2][0-3]:[0-5][0-5])', 'messages' => 'Show must be under 24 hours')) ) )); @@ -51,6 +51,8 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm public function checkReliantFields($formData) { + $valid = true; + $now_timestamp = date("Y-m-d H:i:s"); $start_timestamp = $formData['add_show_start_date']."".$formData['add_show_start_time']; @@ -59,10 +61,15 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm if($start_epoch < $now_epoch) { $this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past')); - return false; + $valid = false; + } + + if(strtotime("23:59") < strtotime($formData["add_show_duration"])) { + $this->getElement('add_show_duration')->setErrors(array('Max show size: 23:59')); + $valid = false; } - return true; + return $valid; } } diff --git a/application/views/scripts/form/add-show-block.phtml b/application/views/scripts/form/add-show-block.phtml index a946a3936..001e0fea6 100644 --- a/application/views/scripts/form/add-show-block.phtml +++ b/application/views/scripts/form/add-show-block.phtml @@ -8,5 +8,8 @@ $this->element->getValue(), $this->element->getAttribs() ) ?> - formErrors($this->element->getMessages()) ?> + element->hasErrors()) { + echo $this->formErrors($this->element->getMessages()); + } + ?> diff --git a/application/views/scripts/form/add-show-style.phtml b/application/views/scripts/form/add-show-style.phtml new file mode 100644 index 000000000..7ab679a6f --- /dev/null +++ b/application/views/scripts/form/add-show-style.phtml @@ -0,0 +1,16 @@ +
+ formLabel($this->element->getName(), + $this->element->getLabel()) ?> +
+
+ {$this->element->helper}( + $this->element->getName(), + $this->element->getValue(), + $this->element->getAttribs() + ) ?> + + element->hasErrors()) { + echo $this->formErrors($this->element->getMessages()); + } + ?> +
diff --git a/public/js/airtime/schedule/add-show.js b/public/js/airtime/schedule/add-show.js index 7c2756273..526f5af7e 100644 --- a/public/js/airtime/schedule/add-show.js +++ b/public/js/airtime/schedule/add-show.js @@ -77,13 +77,20 @@ function setAddShowEvents() { createDateInput(end, endDpSelect); $("#add_show_start_time").timepicker(); + $("#add_show_duration").timepicker({ + amPmText: ['', ''] + }); $("#add_show_hosts_autocomplete").autocomplete({ source: findHosts, - select: autoSelect + select: autoSelect, + delay: 200 }); $("#schedule-show-style input").ColorPicker({ + onChange: function (hsb, hex, rgb, el) { + $(el).val(hex); + }, onSubmit: function(hsb, hex, rgb, el) { $(el).val(hex); $(el).ColorPickerHide(); diff --git a/public/js/colorpicker/js/colorpicker.js b/public/js/colorpicker/js/colorpicker.js index 10a2b2244..29929ddf1 100644 --- a/public/js/colorpicker/js/colorpicker.js +++ b/public/js/colorpicker/js/colorpicker.js @@ -93,7 +93,7 @@ setSelector(col, cal.get(0)); setHue(col, cal.get(0)); setNewColor(col, cal.get(0)); - cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col)]); + cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col), cal.data('colorpicker').el]); }, blur = function (ev) { var cal = $(this).parent().parent(); @@ -454,6 +454,7 @@ } else if (col.r != undefined && col.g != undefined && col.b != undefined) { col = RGBToHSB(col); } else if (col.h != undefined && col.s != undefined && col.b != undefined) { + col = fixHSB(col); } else { return this; @@ -481,4 +482,4 @@ ColorPickerShow: ColorPicker.showPicker, ColorPickerSetColor: ColorPicker.setColor }); -})(jQuery) \ No newline at end of file +})(jQuery)