| @@ -1,143 +1,143 @@ | ||
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Section item template. | |
| 4 | - * | |
| 5 | - * @since 3.0.0 | |
| 6 | - */ | |
| 7 | -?> | |
| 8 | - | |
| 9 | -<script type="text/x-template" id="tmpl-lp-section-item"> | |
| 10 | - <li :class="['section-item',item.type, isEmptyItem() ? 'empty-item' : '', {updating: updating, removing: removing}]" | |
| 11 | - :data-item-id="item.id" | |
| 12 | - :data-item-order="order"> | |
| 13 | - <div class="drag lp-sortable-handle"> | |
| 14 | - <?php learn_press_admin_view( 'svg-icon' ); ?> | |
| 15 | - </div> | |
| 16 | - <div class="icon"></div> | |
| 17 | - <div class="title"> | |
| 18 | - <input v-model="item.title" type="text" @change="changeTitle" @blur="updateTitle" @keyup.enter="updateTitle" @keyup="keyUp"> | |
| 19 | - </div> | |
| 20 | - | |
| 21 | - <div class="item-actions"> | |
| 22 | - <div class="actions"> | |
| 23 | - <?php do_action( 'learn_press_before_display_item_actions' ); ?> | |
| 24 | - <div class="action preview-item lp-title-attr-tip" data-content-tip="<?php esc_attr_e( 'Enable/Disable Preview', 'learnpress' ); ?>"> | |
| 25 | - <a class="lp-btn-icon dashicons" :class="previewClass" @click="togglePreview"></a> | |
| 26 | - </div> | |
| 27 | - <div class="action edit-item lp-title-attr-tip" data-content-tip="<?php esc_attr_e( 'Edit an item', 'learnpress' ); ?>"> | |
| 28 | - <a :href="url" target="_blank" class="lp-btn-icon dashicons dashicons-edit"></a> | |
| 29 | - </div> | |
| 30 | - <div class="action delete-item" v-if="!disableCurriculum"> | |
| 31 | - <a class="lp-btn-icon dashicons dashicons-trash" @click.prevent="remove"></a> | |
| 32 | - <ul> | |
| 33 | - <li> | |
| 34 | - <a @click.prevent="remove"><?php esc_html_e( 'Remove from the course', 'learnpress' ); ?></a> | |
| 35 | - </li> | |
| 36 | - <li> | |
| 37 | - <a @click.prevent="deletePermanently" class="delete-permanently"><?php esc_html_e( 'Move to trash', 'learnpress' ); ?></a> | |
| 38 | - </li> | |
| 39 | - </ul> | |
| 40 | - </div> | |
| 41 | - <?php do_action( 'learn_press_after_display_item_actions' ); ?> | |
| 42 | - </div> | |
| 43 | - </div> | |
| 44 | - </li> | |
| 45 | -</script> | |
| 46 | - | |
| 47 | -<script type="text/javascript"> | |
| 48 | - window.$Vue = window.$Vue || Vue; | |
| 49 | - | |
| 50 | - jQuery( function( $ ) { | |
| 51 | - ( function( $store ) { | |
| 52 | - $Vue.component('lp-section-item', { | |
| 53 | - template: '#tmpl-lp-section-item', | |
| 54 | - props: ['item', 'order', 'disableCurriculum'], | |
| 55 | - data: function() { | |
| 56 | - return { | |
| 57 | - title: this.item.title, | |
| 58 | - changed: false, | |
| 59 | - removing: false | |
| 60 | - }; | |
| 61 | - }, | |
| 62 | - created: function() { | |
| 63 | - this.$ = jQuery; | |
| 64 | - }, | |
| 65 | - mounted: function() { | |
| 66 | - this.$nextTick( function() { | |
| 67 | - var $ = jQuery; | |
| 68 | - | |
| 69 | - $( this.$el ).find( '.lp-title-attr-tip' ).LP( 'QuickTip', { | |
| 70 | - closeInterval: 0, | |
| 71 | - arrowOffset: 'el', | |
| 72 | - tipClass: 'preview-item-tip' | |
| 73 | - }); | |
| 74 | - }); | |
| 75 | - }, | |
| 76 | - computed: { | |
| 77 | - url: function() { | |
| 78 | - return $store.getters['ss/urlEdit'] + this.item.id; | |
| 79 | - }, | |
| 80 | - updating: function() { | |
| 81 | - return this.removing || this.saving; | |
| 82 | - }, | |
| 83 | - status: function() { | |
| 84 | - return $store.getters['ss/statusUpdateSectionItem'][this.item.id] || ''; | |
| 85 | - }, | |
| 86 | - saving: function() { | |
| 87 | - return this.status === 'updating'; | |
| 88 | - }, | |
| 89 | - previewClass: function() { | |
| 90 | - return { | |
| 91 | - 'dashicons-visibility': this.item.preview, | |
| 92 | - 'dashicons-hidden': !this.item.preview | |
| 93 | - } | |
| 94 | - } | |
| 95 | - }, | |
| 96 | - methods: { | |
| 97 | - isEmptyItem: function() { | |
| 98 | - return isNaN(this.item.id) | |
| 99 | - }, | |
| 100 | - changeTitle: function() { | |
| 101 | - this.changed = true; | |
| 102 | - }, | |
| 103 | - updateTitle: function() { | |
| 104 | - if ( this.changed ) { | |
| 105 | - this.$emit( 'update', this.item ); | |
| 106 | - this.changed = false; | |
| 107 | - } | |
| 108 | - }, | |
| 109 | - remove: function() { | |
| 110 | - if ( ! confirm( $store.getters['i18n/all'].confirm_remove_item.replace( '{{ITEM_NAME}}', this.item.title ) ) ) { | |
| 111 | - return; | |
| 112 | - } | |
| 113 | - this.item.temp_id = LP.uniqueId(); | |
| 114 | - this.$emit( 'remove', this.item ); | |
| 115 | - }, | |
| 116 | - deletePermanently: function() { | |
| 117 | - if ( ! confirm( $store.getters['i18n/all'].confirm_trash_item.replace( '{{ITEM_NAME}}', this.item.title ) ) ) { | |
| 118 | - return; | |
| 119 | - } | |
| 120 | - this.item.temp_id = LP.uniqueId(); | |
| 121 | - this.$emit('delete', this.item); | |
| 122 | - }, | |
| 123 | - keyUp: function( event ) { | |
| 124 | - var keyCode = event.keyCode; | |
| 125 | - | |
| 126 | - if ( keyCode === 27 ) { | |
| 127 | - this.item.title = this.title; | |
| 128 | - } else { | |
| 129 | - this.$emit( 'nav', { key: event.keyCode, order: this.order } ); | |
| 130 | - } | |
| 131 | - }, | |
| 132 | - togglePreview: function( evt ) { | |
| 133 | - this.item.preview = ! this.item.preview; | |
| 134 | - | |
| 135 | - this.changed = true; | |
| 136 | - this.updateTitle(); | |
| 137 | - } | |
| 138 | - <?php do_action( 'learn_press_after_section_item_script' ); ?> | |
| 139 | - } | |
| 140 | - }); | |
| 141 | - })( LP_Curriculum_Store ); | |
| 142 | - }); | |
| 143 | -</script> | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Section item template. | |
| 4 | + * | |
| 5 | + * @since 3.0.0 | |
| 6 | + */ | |
| 7 | +?> | |
| 8 | + | |
| 9 | +<script type="text/x-template" id="tmpl-lp-section-item"> | |
| 10 | + <li :class="['section-item',item.type, isEmptyItem() ? 'empty-item' : '', {updating: updating, removing: removing}]" | |
| 11 | + :data-item-id="item.id" | |
| 12 | + :data-item-order="order"> | |
| 13 | + <div class="drag lp-sortable-handle"> | |
| 14 | + <?php learn_press_admin_view( 'svg-icon' ); ?> | |
| 15 | + </div> | |
| 16 | + <div class="icon"></div> | |
| 17 | + <div class="title"> | |
| 18 | + <input v-model="item.title" type="text" @change="changeTitle" @blur="updateTitle" @keyup.enter="updateTitle" @keyup="keyUp"> | |
| 19 | + </div> | |
| 20 | + | |
| 21 | + <div class="item-actions"> | |
| 22 | + <div class="actions"> | |
| 23 | + <?php do_action( 'learn_press_before_display_item_actions' ); ?> | |
| 24 | + <div class="action preview-item lp-title-attr-tip" data-content-tip="<?php esc_attr_e( 'Enable/Disable Preview', 'learnpress' ); ?>"> | |
| 25 | + <a class="lp-btn-icon dashicons" :class="previewClass" @click="togglePreview"></a> | |
| 26 | + </div> | |
| 27 | + <div class="action edit-item lp-title-attr-tip" data-content-tip="<?php esc_attr_e( 'Edit an item', 'learnpress' ); ?>"> | |
| 28 | + <a :href="url" target="_blank" class="lp-btn-icon dashicons dashicons-edit"></a> | |
| 29 | + </div> | |
| 30 | + <div class="action delete-item" v-if="!disableCurriculum"> | |
| 31 | + <a class="lp-btn-icon dashicons dashicons-trash" @click.prevent="remove"></a> | |
| 32 | + <ul> | |
| 33 | + <li> | |
| 34 | + <a @click.prevent="remove"><?php esc_html_e( 'Remove from the course', 'learnpress' ); ?></a> | |
| 35 | + </li> | |
| 36 | + <li> | |
| 37 | + <a @click.prevent="deletePermanently" class="delete-permanently"><?php esc_html_e( 'Move to trash', 'learnpress' ); ?></a> | |
| 38 | + </li> | |
| 39 | + </ul> | |
| 40 | + </div> | |
| 41 | + <?php do_action( 'learn_press_after_display_item_actions' ); ?> | |
| 42 | + </div> | |
| 43 | + </div> | |
| 44 | + </li> | |
| 45 | +</script> | |
| 46 | + | |
| 47 | +<script type="text/javascript"> | |
| 48 | + window.$Vue = window.$Vue || Vue; | |
| 49 | + | |
| 50 | + jQuery( function( $ ) { | |
| 51 | + ( function( $store ) { | |
| 52 | + $Vue.component('lp-section-item', { | |
| 53 | + template: '#tmpl-lp-section-item', | |
| 54 | + props: ['item', 'order', 'disableCurriculum'], | |
| 55 | + data: function() { | |
| 56 | + return { | |
| 57 | + title: this.item.title, | |
| 58 | + changed: false, | |
| 59 | + removing: false | |
| 60 | + }; | |
| 61 | + }, | |
| 62 | + created: function() { | |
| 63 | + this.$ = jQuery; | |
| 64 | + }, | |
| 65 | + mounted: function() { | |
| 66 | + this.$nextTick( function() { | |
| 67 | + var $ = jQuery; | |
| 68 | + | |
| 69 | + $( this.$el ).find( '.lp-title-attr-tip' ).LP( 'QuickTip', { | |
| 70 | + closeInterval: 0, | |
| 71 | + arrowOffset: 'el', | |
| 72 | + tipClass: 'preview-item-tip' | |
| 73 | + }); | |
| 74 | + }); | |
| 75 | + }, | |
| 76 | + computed: { | |
| 77 | + url: function() { | |
| 78 | + return $store.getters['ss/urlEdit'] + this.item.id; | |
| 79 | + }, | |
| 80 | + updating: function() { | |
| 81 | + return this.removing || this.saving; | |
| 82 | + }, | |
| 83 | + status: function() { | |
| 84 | + return $store.getters['ss/statusUpdateSectionItem'][this.item.id] || ''; | |
| 85 | + }, | |
| 86 | + saving: function() { | |
| 87 | + return this.status === 'updating'; | |
| 88 | + }, | |
| 89 | + previewClass: function() { | |
| 90 | + return { | |
| 91 | + 'dashicons-visibility': this.item.preview, | |
| 92 | + 'dashicons-hidden': !this.item.preview | |
| 93 | + } | |
| 94 | + } | |
| 95 | + }, | |
| 96 | + methods: { | |
| 97 | + isEmptyItem: function() { | |
| 98 | + return isNaN(this.item.id) | |
| 99 | + }, | |
| 100 | + changeTitle: function() { | |
| 101 | + this.changed = true; | |
| 102 | + }, | |
| 103 | + updateTitle: function() { | |
| 104 | + if ( this.changed ) { | |
| 105 | + this.$emit( 'update', this.item ); | |
| 106 | + this.changed = false; | |
| 107 | + } | |
| 108 | + }, | |
| 109 | + remove: function() { | |
| 110 | + if ( ! confirm( $store.getters['i18n/all'].confirm_remove_item.replace( '{{ITEM_NAME}}', this.item.title ) ) ) { | |
| 111 | + return; | |
| 112 | + } | |
| 113 | + this.item.temp_id = LP.uniqueId(); | |
| 114 | + this.$emit( 'remove', this.item ); | |
| 115 | + }, | |
| 116 | + deletePermanently: function() { | |
| 117 | + if ( ! confirm( $store.getters['i18n/all'].confirm_trash_item.replace( '{{ITEM_NAME}}', this.item.title ) ) ) { | |
| 118 | + return; | |
| 119 | + } | |
| 120 | + this.item.temp_id = LP.uniqueId(); | |
| 121 | + this.$emit('delete', this.item); | |
| 122 | + }, | |
| 123 | + keyUp: function( event ) { | |
| 124 | + var keyCode = event.keyCode; | |
| 125 | + | |
| 126 | + if ( keyCode === 27 ) { | |
| 127 | + this.item.title = this.title; | |
| 128 | + } else { | |
| 129 | + this.$emit( 'nav', { key: event.keyCode, order: this.order } ); | |
| 130 | + } | |
| 131 | + }, | |
| 132 | + togglePreview: function( evt ) { | |
| 133 | + this.item.preview = ! this.item.preview; | |
| 134 | + | |
| 135 | + this.changed = true; | |
| 136 | + this.updateTitle(); | |
| 137 | + } | |
| 138 | + <?php do_action( 'learn_press_after_section_item_script' ); ?> | |
| 139 | + } | |
| 140 | + }); | |
| 141 | + })( LP_Curriculum_Store ); | |
| 142 | + }); | |
| 143 | +</script> | |