| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage com_vikbooking |
| 5 |
* @author Alessio Gaggii - e4j - Extensionsforjoomla.com |
| 6 |
* @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved. |
| 7 |
* @license GNU General Public License version 2 or later; see LICENSE |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 12 |
|
| 13 |
$vbo_app = VikBooking::getVboApplication(); |
| 14 |
|
| 15 |
if (VBOPlatformDetection::isWordPress() && function_exists('wp_enqueue_code_editor')) { |
| 16 |
/** |
| 17 |
* @wponly - cannot load iFrame with FancyBox, so we use the BS's Modal |
| 18 |
* WP >= 4.9.0 |
| 19 |
*/ |
| 20 |
wp_enqueue_code_editor(array('type' => 'php')); |
| 21 |
} |
| 22 |
|
| 23 |
echo $vbo_app->getJmodalScript($suffix = 'VboTplfiles', $hide_js = "VBOCore.emitEvent('vbo-dismiss-modal-tmplfile');"); |
| 24 |
echo $vbo_app->getJmodalHtml('VboTplfiles', JText::translate('VBOCONFIGEDITTMPLFILE')); |
| 25 |
|
| 26 |
$editor = JEditor::getInstance(JFactory::getApplication()->get('editor')); |
| 27 |
$document = JFactory::getDocument(); |
| 28 |
$document->addStyleSheet(VBO_SITE_URI.'resources/jquery.fancybox.css'); |
| 29 |
$document->addStyleSheet(VBO_ADMIN_URI.'resources/js_upload/colorpicker.css'); |
| 30 |
JHtml::fetch('script', VBO_SITE_URI.'resources/jquery.fancybox.js'); |
| 31 |
JHtml::fetch('script', VBO_ADMIN_URI.'resources/js_upload/colorpicker.js'); |
| 32 |
JHtml::fetch('script', VBO_ADMIN_URI.'resources/js_upload/eye.js'); |
| 33 |
JHtml::fetch('script', VBO_ADMIN_URI.'resources/js_upload/utils.js'); |
| 34 |
|
| 35 |
$themesel = '<select name="theme">'; |
| 36 |
$themesel .= '<option value="default">default</option>'; |
| 37 |
$themes = glob(VBO_SITE_PATH.DS.'themes'.DS.'*'); |
| 38 |
$acttheme = VikBooking::getTheme(); |
| 39 |
if (count($themes) > 0) { |
| 40 |
$strip = VBO_SITE_PATH.DS.'themes'.DS; |
| 41 |
foreach ($themes as $th) { |
| 42 |
if (is_dir($th)) { |
| 43 |
$tname = str_replace($strip, '', $th); |
| 44 |
if ($tname != 'default') { |
| 45 |
$themesel .= '<option value="'.$tname.'"'.($tname == $acttheme ? ' selected="selected"' : '').'>'.$tname.'</option>'; |
| 46 |
} |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
$themesel .= '</select>'; |
| 51 |
$firstwday = VikBooking::getFirstWeekDay(true); |
| 52 |
?> |
| 53 |
<div class="vbo-config-maintab-left"> |
| 54 |
<fieldset class="adminform"> |
| 55 |
<div class="vbo-params-wrap"> |
| 56 |
<legend class="adminlegend"><?php echo JText::translate('VBOCPARAMLAYOUT'); ?></legend> |
| 57 |
<div class="vbo-params-container"> |
| 58 |
<div class="vbo-param-container"> |
| 59 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGFIRSTWDAY'); ?></div> |
| 60 |
<div class="vbo-param-setting"><select name="firstwday"><option value="0"<?php echo $firstwday == '0' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBSUNDAY'); ?></option><option value="1"<?php echo $firstwday == '1' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBMONDAY'); ?></option><option value="2"<?php echo $firstwday == '2' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBTUESDAY'); ?></option><option value="3"<?php echo $firstwday == '3' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBWEDNESDAY'); ?></option><option value="4"<?php echo $firstwday == '4' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBTHURSDAY'); ?></option><option value="5"<?php echo $firstwday == '5' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBFRIDAY'); ?></option><option value="6"<?php echo $firstwday == '6' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBSATURDAY'); ?></option></select></div> |
| 61 |
</div> |
| 62 |
<div class="vbo-param-container"> |
| 63 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGTHREETEN'); ?></div> |
| 64 |
<div class="vbo-param-setting"><input type="number" name="numcalendars" value="<?php echo VikBooking::numCalendars(); ?>" min="0" max="24"/></div> |
| 65 |
</div> |
| 66 |
<div class="vbo-param-container"> |
| 67 |
<div class="vbo-param-label"><?php echo JText::translate('VBOCONFIGTHUMBSIZE'); ?></div> |
| 68 |
<div class="vbo-param-setting"><input type="number" name="thumbsize" value="<?php echo VikBooking::getThumbSize(true); ?>" min="20" max="1000"/></div> |
| 69 |
</div> |
| 70 |
<div class="vbo-param-container"> |
| 71 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGTHREENINE'); ?></div> |
| 72 |
<div class="vbo-param-setting"><?php echo $vbo_app->printYesNoButtons('showpartlyreserved', JText::translate('VBYES'), JText::translate('VBNO'), (VikBooking::showPartlyReserved() ? 'yes' : 0), 'yes', 0); ?></div> |
| 73 |
</div> |
| 74 |
<div class="vbo-param-container"> |
| 75 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGTHREECHECKINOUTSTAT'); ?></div> |
| 76 |
<div class="vbo-param-setting"><?php echo $vbo_app->printYesNoButtons('showcheckinoutonly', JText::translate('VBYES'), JText::translate('VBNO'), (VikBooking::showStatusCheckinoutOnly() ? 1 : 0), 1, 0); ?></div> |
| 77 |
</div> |
| 78 |
|
| 79 |
<div class="vbo-param-container"> |
| 80 |
<div class="vbo-param-label"><?php echo JText::translate('VBOCONFIGEMAILTEMPLATE'); ?></div> |
| 81 |
<div class="vbo-param-setting"> |
| 82 |
<div class="btn-wrapper input-append"> |
| 83 |
<button type="button" class="btn vbo-edit-tmpl" data-tmpl-path="<?php echo urlencode(VBO_SITE_PATH.DS.'helpers'.DS.'email_tmpl.php'); ?>"><i class="icon-edit"></i> <?php echo JText::translate('VBOCONFIGEDITTMPLFILE'); ?></button> |
| 84 |
<button type="button" class="btn vbo-inspector-btn" title="<?php echo addslashes(JText::translate('VBO_INSPECTOR_START')); ?>" data-inspectfile="email_tmpl.php"><?php VikBookingIcons::e('paint-brush'); ?></button> |
| 85 |
<button type="button" class="btn vbo-edit-tmpl vbo-preview-btn" title="<?php echo addslashes(JText::translate('VBOPREVIEW')); ?>" data-prew-type="email_tmpl.php" data-prew-path="<?php echo urlencode(VBO_SITE_PATH.DS.'helpers'.DS.'email_tmpl.php'); ?>"><?php VikBookingIcons::e('eye'); ?></button> |
| 86 |
</div> |
| 87 |
</div> |
| 88 |
</div> |
| 89 |
<div class="vbo-param-container"> |
| 90 |
<div class="vbo-param-label"><?php echo JText::translate('VBOCONFIGINVOICETEMPLATE'); ?></div> |
| 91 |
<div class="vbo-param-setting"> |
| 92 |
<div class="btn-wrapper input-append"> |
| 93 |
<button type="button" class="btn vbo-edit-tmpl" data-tmpl-path="<?php echo urlencode(VBO_SITE_PATH.DS.'helpers'.DS.'invoices'.DS.'invoice_tmpl.php'); ?>"><i class="icon-edit"></i> <?php echo JText::translate('VBOCONFIGEDITTMPLFILE'); ?></button> |
| 94 |
<button type="button" class="btn vbo-inspector-btn" title="<?php echo addslashes(JText::translate('VBO_INSPECTOR_START')); ?>" data-inspectfile="invoice_tmpl.php"><?php VikBookingIcons::e('paint-brush'); ?></button> |
| 95 |
</div> |
| 96 |
</div> |
| 97 |
</div> |
| 98 |
<div class="vbo-param-container"> |
| 99 |
<div class="vbo-param-label"><?php echo JText::translate('VBOMANUALINVOICE'); ?></div> |
| 100 |
<div class="vbo-param-setting"><button type="button" class="btn vbo-edit-tmpl" data-tmpl-path="<?php echo urlencode(VBO_SITE_PATH.DS.'helpers'.DS.'invoices'.DS.'custom_invoice_tmpl.php'); ?>"><i class="icon-edit"></i> <?php echo JText::translate('VBOCONFIGEDITTMPLFILE'); ?></button></div> |
| 101 |
</div> |
| 102 |
<div class="vbo-param-container"> |
| 103 |
<div class="vbo-param-label"><?php echo JText::translate('VBOCONFIGCHECKINTEMPLATE'); ?></div> |
| 104 |
<div class="vbo-param-setting"> |
| 105 |
<div class="btn-wrapper input-append"> |
| 106 |
<button type="button" class="btn vbo-edit-tmpl" data-tmpl-path="<?php echo urlencode(VBO_SITE_PATH.DS.'helpers'.DS.'checkins'.DS.'checkin_tmpl.php'); ?>"><i class="icon-edit"></i> <?php echo JText::translate('VBOCONFIGEDITTMPLFILE'); ?></button> |
| 107 |
<button type="button" class="btn vbo-inspector-btn" title="<?php echo addslashes(JText::translate('VBO_INSPECTOR_START')); ?>" data-inspectfile="checkin_tmpl.php"><?php VikBookingIcons::e('paint-brush'); ?></button> |
| 108 |
</div> |
| 109 |
</div> |
| 110 |
</div> |
| 111 |
<div class="vbo-param-container"> |
| 112 |
<div class="vbo-param-label"><?php echo JText::translate('VBOCONFIGCUSTCSSTPL'); ?></div> |
| 113 |
<div class="vbo-param-setting"> |
| 114 |
<?php |
| 115 |
if (VBOPlatformDetection::isWordPress()) { |
| 116 |
/** |
| 117 |
* @wponly the path of the file is different in WP, it's inside /resources |
| 118 |
*/ |
| 119 |
?> |
| 120 |
<button type="button" class="btn vbo-edit-tmpl" data-tmpl-path="<?php echo urlencode(VBO_SITE_PATH.DS.'resources'.DS.'vikbooking_custom.css'); ?>"><i class="icon-edit"></i> <?php echo JText::translate('VBOCONFIGEDITTMPLFILE'); ?></button> |
| 121 |
<?php |
| 122 |
} else { |
| 123 |
?> |
| 124 |
<button type="button" class="btn vbo-edit-tmpl" data-tmpl-path="<?php echo urlencode(VBO_SITE_PATH.DS.'vikbooking_custom.css'); ?>"><i class="icon-edit"></i> <?php echo JText::translate('VBOCONFIGEDITTMPLFILE'); ?></button> |
| 125 |
<?php |
| 126 |
} |
| 127 |
?> |
| 128 |
</div> |
| 129 |
</div> |
| 130 |
<div class="vbo-param-container"> |
| 131 |
<div class="vbo-param-label"><?php echo JText::translate('VBOCONFIGCUSTBACKCSSTPL'); ?></div> |
| 132 |
<div class="vbo-param-setting"><button type="button" class="btn vbo-edit-tmpl" data-tmpl-path="<?php echo urlencode(VBO_ADMIN_PATH.DS.'resources'.DS.'vikbooking_backendcustom.css'); ?>"><i class="icon-edit"></i> <?php echo JText::translate('VBOCONFIGEDITTMPLFILE'); ?></button></div> |
| 133 |
</div> |
| 134 |
<div class="vbo-param-container"> |
| 135 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGTHREESIX'); ?></div> |
| 136 |
<div class="vbo-param-setting"><?php echo $vbo_app->printYesNoButtons('showfooter', JText::translate('VBYES'), JText::translate('VBNO'), (VikBooking::showFooter() ? 'yes' : 0), 'yes', 0); ?></div> |
| 137 |
</div> |
| 138 |
<div class="vbo-param-container"> |
| 139 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGTHEME'); ?></div> |
| 140 |
<div class="vbo-param-setting"><?php echo $themesel; ?></div> |
| 141 |
</div> |
| 142 |
<div class="vbo-param-container vbo-param-container-full"> |
| 143 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGTHREESEVEN'); ?></div> |
| 144 |
<div class="vbo-param-setting"> |
| 145 |
<?php |
| 146 |
if (interface_exists('Throwable')) { |
| 147 |
/** |
| 148 |
* With PHP >= 7 supporting throwable exceptions for Fatal Errors |
| 149 |
* we try to avoid issues with third party plugins that make use of |
| 150 |
* the WP native function get_current_screen() or any Joomla plugin. |
| 151 |
*/ |
| 152 |
try { |
| 153 |
echo $editor->display( "intromain", VikBooking::getIntroMain(), '100%', 350, 70, 20 ); |
| 154 |
} catch (Throwable $t) { |
| 155 |
echo $t->getMessage() . ' in ' . $t->getFile() . ':' . $t->getLine() . '<br/>'; |
| 156 |
} |
| 157 |
} else { |
| 158 |
// we cannot catch Fatal Errors in PHP 5.x |
| 159 |
echo $editor->display( "intromain", VikBooking::getIntroMain(), '100%', 350, 70, 20 ); |
| 160 |
} |
| 161 |
?> |
| 162 |
</div> |
| 163 |
</div> |
| 164 |
<div class="vbo-param-container"> |
| 165 |
<div class="vbo-param-label"><?php echo JText::translate('VBCONFIGTHREEEIGHT'); ?></div> |
| 166 |
<div class="vbo-param-setting"><textarea name="closingmain" rows="5" cols="60" style="min-width: 400px;"><?php echo htmlspecialchars(VikBooking::getClosingMain()); ?></textarea></div> |
| 167 |
</div> |
| 168 |
</div> |
| 169 |
</div> |
| 170 |
</fieldset> |
| 171 |
</div> |
| 172 |
|
| 173 |
<div class="vbo-config-maintab-right"> |
| 174 |
|
| 175 |
<?php |
| 176 |
/** |
| 177 |
* Preferred colors for CSS styling |
| 178 |
* |
| 179 |
* @since 1.14 (J) - 1.4.0 (WP) |
| 180 |
*/ |
| 181 |
$preferred_colors = VikBooking::getPreferredColors(); |
| 182 |
?> |
| 183 |
<fieldset class="adminform"> |
| 184 |
<div class="vbo-params-wrap"> |
| 185 |
<legend class="adminlegend"> |
| 186 |
<?php |
| 187 |
echo $vbo_app->createPopover(array('title' => JText::translate('VBO_PREF_COLORS'), 'content' => JText::translate('VBO_PREF_COLORS_HELP'))); |
| 188 |
echo ' ' . JText::translate('VBO_PREF_COLORS'); |
| 189 |
?> |
| 190 |
</legend> |
| 191 |
<div class="vbo-params-container"> |
| 192 |
<div class="vbo-param-container"> |
| 193 |
<div class="vbo-param-label"><?php echo JText::translate('VBO_PREF_COLOR_TEXTS'); ?></div> |
| 194 |
<div class="vbo-param-setting"> |
| 195 |
<span class="vbo-inspector-colorpicker-wrap"> |
| 196 |
<span class="vbo-inspector-colorpicker vbo-prefcolorpicker-trig" data-prefcolortype="textcolor" style="background-color: <?php echo !empty($preferred_colors['textcolor']) ? $preferred_colors['textcolor'] : '#ffffff'; ?>;"><?php VikBookingIcons::e('palette'); ?></span> |
| 197 |
</span> |
| 198 |
<input type="hidden" name="pref_textcolor" id="vbo-pref-textcolor" value="<?php echo $preferred_colors['textcolor']; ?>" /> |
| 199 |
</div> |
| 200 |
</div> |
| 201 |
<div class="vbo-param-container"> |
| 202 |
<div class="vbo-param-label"><?php echo JText::translate('VBO_PREF_COLOR_BKGROUND'); ?></div> |
| 203 |
<div class="vbo-param-setting"> |
| 204 |
<div class="vbo-param-setting-top"> |
| 205 |
<span class="vbo-inspector-colorpicker-wrap"> |
| 206 |
<span class="vbo-inspector-colorpicker vbo-prefcolorpicker-trig" data-prefcolortype="bgcolor" style="background-color: <?php echo !empty($preferred_colors['bgcolor']) ? $preferred_colors['bgcolor'] : '#ffffff'; ?>;"><?php VikBookingIcons::e('palette'); ?></span> |
| 207 |
</span> |
| 208 |
<span class="vbo-colorpicker-label"><?php echo JText::translate('VBO_BKGROUND_COL'); ?></span> |
| 209 |
<input type="hidden" name="pref_bgcolor" id="vbo-pref-bgcolor" value="<?php echo $preferred_colors['bgcolor']; ?>" /> |
| 210 |
</div> |
| 211 |
<div class="vbo-param-setting-bottom"> |
| 212 |
<span class="vbo-inspector-colorpicker-wrap"> |
| 213 |
<span class="vbo-inspector-colorpicker vbo-prefcolorpicker-trig" data-prefcolortype="fontcolor" style="background-color: <?php echo !empty($preferred_colors['fontcolor']) ? $preferred_colors['fontcolor'] : '#ffffff'; ?>;"><?php VikBookingIcons::e('palette'); ?></span> |
| 214 |
</span> |
| 215 |
<span class="vbo-colorpicker-label"><?php echo JText::translate('VBO_FONT_COL'); ?></span> |
| 216 |
<input type="hidden" name="pref_fontcolor" id="vbo-pref-fontcolor" value="<?php echo $preferred_colors['fontcolor']; ?>" /> |
| 217 |
</div> |
| 218 |
</div> |
| 219 |
</div> |
| 220 |
<div class="vbo-param-container"> |
| 221 |
<div class="vbo-param-label"><?php echo JText::translate('VBO_PREF_COLOR_BKGROUNDHOV'); ?></div> |
| 222 |
<div class="vbo-param-setting"> |
| 223 |
<div class="vbo-param-setting-top"> |
| 224 |
<span class="vbo-inspector-colorpicker-wrap"> |
| 225 |
<span class="vbo-inspector-colorpicker vbo-prefcolorpicker-trig" data-prefcolortype="bgcolorhov" style="background-color: <?php echo !empty($preferred_colors['bgcolorhov']) ? $preferred_colors['bgcolorhov'] : '#ffffff'; ?>;"><?php VikBookingIcons::e('palette'); ?></span> |
| 226 |
</span> |
| 227 |
<span class="vbo-colorpicker-label"><?php echo JText::translate('VBO_BKGROUND_COL'); ?></span> |
| 228 |
<input type="hidden" name="pref_bgcolorhov" id="vbo-pref-bgcolorhov" value="<?php echo $preferred_colors['bgcolorhov']; ?>" /> |
| 229 |
</div> |
| 230 |
<div class="vbo-param-setting-bottom"> |
| 231 |
<span class="vbo-inspector-colorpicker-wrap"> |
| 232 |
<span class="vbo-inspector-colorpicker vbo-prefcolorpicker-trig" data-prefcolortype="fontcolorhov" style="background-color: <?php echo !empty($preferred_colors['fontcolorhov']) ? $preferred_colors['fontcolorhov'] : '#ffffff'; ?>;"><?php VikBookingIcons::e('palette'); ?></span> |
| 233 |
</span> |
| 234 |
<span class="vbo-colorpicker-label"><?php echo JText::translate('VBO_FONT_COL'); ?></span> |
| 235 |
<input type="hidden" name="pref_fontcolorhov" id="vbo-pref-fontcolorhov" value="<?php echo $preferred_colors['fontcolorhov']; ?>" /> |
| 236 |
</div> |
| 237 |
</div> |
| 238 |
</div> |
| 239 |
<div id="vbo-pref-color-examples" class="vbo-param-container" style="display: none;"> |
| 240 |
<div class="vbo-param-label"><?php echo JText::translate('VBO_PREF_COLOR_EXAMPLERES'); ?></div> |
| 241 |
<div class="vbo-param-setting"> |
| 242 |
<div class="vbo-pref-color-example"> |
| 243 |
<h4><?php echo JText::translate('VBO_PREF_COLOR_TEXTS'); ?></h4> |
| 244 |
</div> |
| 245 |
<div class="vbo-pref-color-example"> |
| 246 |
<button type="button" class="btn btn-small"><?php echo JText::translate('VBO_PREF_COLOR_BKGROUND'); ?></button> |
| 247 |
</div> |
| 248 |
</div> |
| 249 |
</div> |
| 250 |
</div> |
| 251 |
</div> |
| 252 |
</fieldset> |
| 253 |
|
| 254 |
<script type="text/javascript"> |
| 255 |
|
| 256 |
/** |
| 257 |
* Composes the necessary inline style tag for the styles examples. |
| 258 |
*/ |
| 259 |
function vboPrefColorsApplyExample() { |
| 260 |
// compose inline style tag |
| 261 |
var style = ''; |
| 262 |
style += '<style type="text/css" id="vbo-pref-color-livecss">'; |
| 263 |
style += '.vbo-pref-color-example h4 { color: ' + jQuery('#vbo-pref-textcolor').val() + '; }' + "\n"; |
| 264 |
style += '.vbo-pref-color-example button { background-color: ' + jQuery('#vbo-pref-bgcolor').val() + '; color: ' + jQuery('#vbo-pref-fontcolor').val() + '; }' + "\n"; |
| 265 |
style += '.vbo-pref-color-example button:hover { background-color: ' + jQuery('#vbo-pref-bgcolorhov').val() + '; color: ' + jQuery('#vbo-pref-fontcolorhov').val() + '; }' + "\n"; |
| 266 |
style += '</style>'; |
| 267 |
if (jQuery('#vbo-pref-color-livecss').length) { |
| 268 |
// remove current inline style tag |
| 269 |
jQuery('#vbo-pref-color-livecss').remove(); |
| 270 |
} |
| 271 |
// append styling to example window and show it |
| 272 |
jQuery('#vbo-pref-color-examples').append(style).show(); |
| 273 |
} |
| 274 |
|
| 275 |
jQuery(function() { |
| 276 |
/** |
| 277 |
* Register color-picker for preferred colors. |
| 278 |
*/ |
| 279 |
jQuery('.vbo-prefcolorpicker-trig').ColorPicker({ |
| 280 |
color: '#ffffff', |
| 281 |
onShow: function(colpkr, el) { |
| 282 |
var cur_color = jQuery(el).css('backgroundColor'); |
| 283 |
jQuery(el).ColorPickerSetColor(vboRgb2Hex(cur_color)); |
| 284 |
jQuery(colpkr).show(); |
| 285 |
return false; |
| 286 |
}, |
| 287 |
onChange: function(hsb, hex, rgb, el) { |
| 288 |
var element = jQuery(el); |
| 289 |
var el_type = element.attr('data-prefcolortype'); |
| 290 |
element.css('backgroundColor', '#'+hex); |
| 291 |
if (el_type && jQuery('#vbo-pref-' + el_type).length) { |
| 292 |
jQuery('#vbo-pref-' + el_type).val('#'+hex); |
| 293 |
} |
| 294 |
vboPrefColorsApplyExample(); |
| 295 |
}, |
| 296 |
onSubmit: function(hsb, hex, rgb, el) { |
| 297 |
var element = jQuery(el); |
| 298 |
var el_type = element.attr('data-prefcolortype'); |
| 299 |
element.css('backgroundColor', '#'+hex); |
| 300 |
if (el_type && jQuery('#vbo-pref-' + el_type).length) { |
| 301 |
jQuery('#vbo-pref-' + el_type).val('#'+hex); |
| 302 |
} |
| 303 |
element.ColorPickerHide(); |
| 304 |
vboPrefColorsApplyExample(); |
| 305 |
} |
| 306 |
}); |
| 307 |
}); |
| 308 |
|
| 309 |
</script> |
| 310 |
|
| 311 |
<?php |
| 312 |
$colortags = VikBooking::loadBookingsColorTags(); |
| 313 |
$tagsrules = VikBooking::loadColorTagsRules(); |
| 314 |
$opt_js_rules = ''; |
| 315 |
foreach ($tagsrules as $tagk => $tagv) { |
| 316 |
$opt_js_rules .= '<option value=\"'.$tagk.'\">'.addslashes(JText::translate($tagv)).'</option>'; |
| 317 |
} |
| 318 |
?> |
| 319 |
<fieldset class="adminform"> |
| 320 |
<div class="vbo-params-wrap"> |
| 321 |
<legend class="adminlegend"><?php echo JText::translate('VBOCPARAMBOOKTAGS'); ?></legend> |
| 322 |
<div class="vbo-params-container"> |
| 323 |
<?php |
| 324 |
foreach ($colortags as $ctagk => $ctagv) { |
| 325 |
?> |
| 326 |
<div class="vbo-param-container"> |
| 327 |
<div class="vbo-param-label"><?php echo JText::translate($ctagv['name']); ?></div> |
| 328 |
<div class="vbo-param-setting"> |
| 329 |
<div class="vbo-colortag-square" style="background-color: <?php echo $ctagv['color']; ?>; color: <?php echo VikBooking::getBestColorContrast($ctagv['color']); ?>;"><i class="vboicn-price-tags"></i></div> |
| 330 |
<input type="hidden" name="bctagname[]" class="bctagname" value="<?php echo $ctagv['name']; ?>" /> |
| 331 |
<input type="hidden" name="bctagcolor[]" class="bctagcolor" value="<?php echo $ctagv['color']; ?>" /> |
| 332 |
<select name="bctagrule[]" style="margin: 0; vertical-align: top;"> |
| 333 |
<?php |
| 334 |
foreach ($tagsrules as $tagk => $tagv) { |
| 335 |
?> |
| 336 |
<option value="<?php echo $tagk; ?>"<?php echo !empty($tagk) && $tagk == $ctagv['rule'] ? ' selected="selected"' : ''; ?>><?php echo JText::translate($tagv); ?></option> |
| 337 |
<?php |
| 338 |
} |
| 339 |
?> |
| 340 |
</select> |
| 341 |
<div style="float: right;"><button class="btn btn-danger vbo-colortag-rm" type="button">×</button></div> |
| 342 |
</div> |
| 343 |
</div> |
| 344 |
<?php |
| 345 |
} |
| 346 |
?> |
| 347 |
<div class="vbo-param-container" id="vbo-colortag-lasttr"> |
| 348 |
<div class="vbo-param-label"><button class="btn vbo-colortag-add" type="button"><?php VikBookingIcons::e('plus-circle'); ?> <?php echo JText::translate('VBOCOLORTAGADD'); ?></button></div> |
| 349 |
<div class="vbo-param-setting"> </div> |
| 350 |
</div> |
| 351 |
<div class="vbo-param-container"> |
| 352 |
<div class="vbo-param-label"><a class="btn btn-danger" href="index.php?option=com_vikbooking&task=config&reset_tags=1" onclick="return confirm('<?php echo addslashes(JText::translate('VBDELCONFIRM')); ?>');"><i class="icon-remove"></i> <?php echo JText::translate('VBOCOLORTAGRMALL'); ?></a></div> |
| 353 |
<div class="vbo-param-setting"> </div> |
| 354 |
</div> |
| 355 |
</div> |
| 356 |
</a> |
| 357 |
</fieldset> |
| 358 |
</div> |
| 359 |
|
| 360 |
<script type="text/javascript"> |
| 361 |
var vboHexDigits = new Array ("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"); |
| 362 |
|
| 363 |
function vboRgb2Hex(rgb) { |
| 364 |
var rgb_match = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([0-9.]+))?\)$/); |
| 365 |
if (!rgb_match) { |
| 366 |
return rgb; |
| 367 |
} |
| 368 |
return "#" + vboHex(rgb_match[1]) + vboHex(rgb_match[2]) + vboHex(rgb_match[3]); |
| 369 |
} |
| 370 |
|
| 371 |
function vboHex(x) { |
| 372 |
return isNaN(x) ? "00" : vboHexDigits[(x - x % 16) / 16] + vboHexDigits[x % 16]; |
| 373 |
} |
| 374 |
|
| 375 |
jQuery(function() { |
| 376 |
|
| 377 |
jQuery(".vbo-edit-tmpl").click(function() { |
| 378 |
var vbo_tmpl_path = jQuery(this).attr("data-tmpl-path"); |
| 379 |
var vbo_prew_path = jQuery(this).attr("data-prew-path"); |
| 380 |
if (!vbo_tmpl_path && !vbo_prew_path) { |
| 381 |
return; |
| 382 |
} |
| 383 |
var basetask = !vbo_tmpl_path ? 'tmplfileprew' : 'edittmplfile'; |
| 384 |
var basepath = !vbo_tmpl_path ? vbo_prew_path : vbo_tmpl_path; |
| 385 |
// we use the BS's Modal to open the template files editing page |
| 386 |
vboOpenJModalVboTplfiles('VboTplfiles', "index.php?option=com_vikbooking&task=" + basetask + "&path=" + basepath + "&tmpl=component"); |
| 387 |
}); |
| 388 |
|
| 389 |
jQuery(".vbo-colortag-add").click(function() { |
| 390 |
jQuery("#vbo-colortag-lasttr").before( |
| 391 |
"<div class=\"vbo-param-container\">"+ |
| 392 |
"<div class=\"vbo-param-label\"> <input type=\"text\" name=\"bctagname[]\" class=\"bctagname\" value=\"\" placeholder=\"<?php echo addslashes(JText::translate('VBOCOLORTAGADDPLCHLD')); ?>\" size=\"25\" /> </div>"+ |
| 393 |
"<div class=\"vbo-param-setting\">"+ |
| 394 |
"<div class=\"vbo-colortag-square\" style=\"\"><i class=\"vboicn-price-tags\"></i></div>"+ |
| 395 |
"<input type=\"hidden\" name=\"bctagcolor[]\" class=\"bctagcolor\" value=\"#ffffff\" />"+ |
| 396 |
"<select name=\"bctagrule[]\" style=\"margin: 0; vertical-align: top;\"><?php echo $opt_js_rules; ?></select>"+ |
| 397 |
"<div style=\"float: right;\"><button class=\"btn btn-danger vbo-colortag-rm\" type=\"button\">×</button></div>"+ |
| 398 |
"</div>"+ |
| 399 |
"</div>" |
| 400 |
); |
| 401 |
jQuery('.vbo-colortag-square').ColorPicker({ |
| 402 |
color: '#ffffff', |
| 403 |
onShow: function (colpkr, el) { |
| 404 |
var cur_color = jQuery(el).css('backgroundColor'); |
| 405 |
jQuery(el).ColorPickerSetColor(vboRgb2Hex(cur_color)); |
| 406 |
jQuery(colpkr).show(); |
| 407 |
return false; |
| 408 |
}, |
| 409 |
onChange: function (hsb, hex, rgb, el) { |
| 410 |
jQuery(el).css('backgroundColor', '#'+hex); |
| 411 |
jQuery(el).parent().find('.bctagcolor').val('#'+hex); |
| 412 |
}, |
| 413 |
onSubmit: function(hsb, hex, rgb, el) { |
| 414 |
jQuery(el).css('backgroundColor', '#'+hex); |
| 415 |
jQuery(el).parent().find('.bctagcolor').val('#'+hex); |
| 416 |
jQuery(el).ColorPickerHide(); |
| 417 |
}, |
| 418 |
}); |
| 419 |
}); |
| 420 |
|
| 421 |
jQuery(document.body).on('click', '.vbo-colortag-rm', function() { |
| 422 |
jQuery(this).closest('.vbo-param-container').remove(); |
| 423 |
}); |
| 424 |
|
| 425 |
jQuery('.vbo-colortag-square').ColorPicker({ |
| 426 |
color: '#ffffff', |
| 427 |
onShow: function (colpkr, el) { |
| 428 |
var cur_color = jQuery(el).css('backgroundColor'); |
| 429 |
jQuery(el).ColorPickerSetColor(vboRgb2Hex(cur_color)); |
| 430 |
jQuery(colpkr).show(); |
| 431 |
return false; |
| 432 |
}, |
| 433 |
onChange: function (hsb, hex, rgb, el) { |
| 434 |
jQuery(el).css('backgroundColor', '#'+hex); |
| 435 |
jQuery(el).parent().find('.bctagcolor').val('#'+hex); |
| 436 |
}, |
| 437 |
onSubmit: function(hsb, hex, rgb, el) { |
| 438 |
jQuery(el).css('backgroundColor', '#'+hex); |
| 439 |
jQuery(el).parent().find('.bctagcolor').val('#'+hex); |
| 440 |
jQuery(el).ColorPickerHide(); |
| 441 |
}, |
| 442 |
}); |
| 443 |
}); |
| 444 |
</script> |
| 445 |
|