| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Template new section. |
| 5 |
* |
| 6 |
* @since 3.0.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
?> |
| 10 |
|
| 11 |
<script type="text/x-template" id="tmpl-lp-new-section"> |
| 12 |
<div class="section new-section"> |
| 13 |
<form @submit.prevent=""> |
| 14 |
<div class="section-head"> |
| 15 |
<span class="creatable"></span> |
| 16 |
<input v-model="section_title" type="text" title="title" class="title-input" placeholder="<?php esc_attr_e( 'Create a new section', 'learnpress' ); ?>" @keyup.enter.prevent="newSection"> |
| 17 |
</div> |
| 18 |
</form> |
| 19 |
</div> |
| 20 |
</script> |
| 21 |
|
| 22 |
<script type="text/javascript"> |
| 23 |
window.$Vue = window.$Vue || Vue; |
| 24 |
|
| 25 |
jQuery( function( $ ) { |
| 26 |
( function( $store ) { |
| 27 |
$Vue.component( 'lp-new-section', { |
| 28 |
template: '#tmpl-lp-new-section', |
| 29 |
data: function() { |
| 30 |
return { |
| 31 |
section_title: '' |
| 32 |
}; |
| 33 |
}, |
| 34 |
methods: { |
| 35 |
draftCourse: function() { |
| 36 |
if ( $store.getters['autoDraft'] ) { |
| 37 |
$store.dispatch( 'draftCourse', { |
| 38 |
title: $('input[name=post_title]').val(), |
| 39 |
content: $('textarea[name=content]').val() |
| 40 |
}); |
| 41 |
} |
| 42 |
}, |
| 43 |
newSection: function() { |
| 44 |
if ( this.section_title ) { |
| 45 |
this.draftCourse(); |
| 46 |
|
| 47 |
$store.dispatch( 'ss/newSection', this.section_title ); |
| 48 |
this.section_title = ''; |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
}); |
| 53 |
})( LP_Curriculum_Store ); |
| 54 |
}); |
| 55 |
</script> |
| 56 |
|