<?php $this->beginWidget('bootstrap.widgets.TbModal', array(
        'id'=>'newCalendarModal',
        'htmlOptions'=>array('style'=>'display:none'),
    )
); ?>

<div class="modal-header">
    <a class="close" data-dismiss="modal">&times;</a>
    <h4 id="modalHeader" data-translation-target="CALENDAR_MODAL_HEADER_TITLES"><?php echo __('CALENDAR_HEADER_CREATE'); ?></h4>
    <?php 
            if (Yii::app()->user->translateMode){
                echo '<i data-translation-id="CALENDAR_HEADER_CREATE" data-translation-target="CALENDAR_MODAL_HEADER_TITLES"></i>';
                echo '<i data-translation-id="CALENDAR_HEADER_UPDATE" data-translation-target="CALENDAR_MODAL_HEADER_TITLES"></i>';
            } 
    ?>
</div>

<div class="modal-body">
    <?php #echo $this->renderPartial('_form', array('model'=>$model)); ?>
</div>

<div class="modal-footer">
<text class="note" style="text-align:right;" data-translation-id="GLOBAL_FIELDS_WITH"><?php echo __("GLOBAL_FIELDS_WITH") ?></text>
<span class="required">*</span>
<text class="note" style="text-align:right;" data-translation-id="GLOBAL_ARE_REQUIRED"><?php echo __("GLOBAL_ARE_REQUIRED") ?></text> 

    <?php $this->widget('bootstrap.widgets.TbButton', array(
    'buttonType'=>'button',
    'type'=>'primary',
    'label'=>__('GLOBAL_SAVE_BUTTON'),
    'loadingText'=>'loading...',
    'htmlOptions'=>array(
        'id'=>'saveNewCalendarButton',
        'data-translation-id'=>'GLOBAL_SAVE_BUTTON',
    ),
    
));?>

    <?php $this->widget('bootstrap.widgets.TbButton', array(
        'label'=>__('GLOBAL_CANCEL_BUTTON'),
        'url'=>'#',
        'htmlOptions'=>array(
            'data-dismiss'=>'modal',
            'data-translation-id'=>'GLOBAL_CANCEL_BUTTON',
        ),
        
    )); ?>
</div>
<script>
$('#saveNewCalendarButton').click(function() {
    var btn = $(this);
    btn.button('loading'); // call the loading function
    $("#calendarSaveAction").click();  
    
    //setTimeout(function() {
    //    btn.button('reset'); // call the reset function
    //}, 30000);
});


$('#newCalendarModal').on('hidden', function () {
    // clear form
    $("#calendar-form").find(":input").each(function(){
        var type = this.type, tag = this.tagName.toLowerCase();
        if (type == "text" || type == "password" || tag == "textarea")
            this.value = "";
        else if (type == "checkbox" || type == "radio")
            this.checked = false;
        else if (tag == "select")
            this.selectedIndex = -1;
        });
})

$('#newCalendarModal').on('shown', function () {
    $("#newCalendarModal :input:visible:enabled:first").focus();
})
</script>
<?php $this->endWidget(); ?>