2018-07-12 20:03:31 +02:00
< ? php defined ( 'BLUDIT' ) or die ( 'Bludit CMS.' ); ?>
2018-05-02 19:59:45 +02:00
<!-- TABS -->
< ul class = " nav nav-tabs " id = " dynamicTab " role = " tablist " >
< li class = " nav-item " >
2018-08-05 17:54:20 +02:00
< a class = " nav-link active " id = " content-tab " data - toggle = " tab " href = " #content " role = " tab " aria - controls = " content " aria - selected = " true " >< ? php $L -> p ( 'Editor' ) ?> </a>
2018-05-02 19:59:45 +02:00
</ li >
< li class = " nav-item " >
2018-08-05 17:54:20 +02:00
< a class = " nav-link " id = " images-tab " data - toggle = " tab " href = " #images " role = " tab " aria - controls = " images " aria - selected = " false " >< ? php $L -> p ( 'Images' ) ?> </a>
2018-05-02 19:59:45 +02:00
</ li >
< li class = " nav-item " >
2018-08-05 17:54:20 +02:00
< a class = " nav-link " id = " options-tab " data - toggle = " tab " href = " #options " role = " tab " aria - controls = " options " aria - selected = " false " >< ? php $L -> p ( 'Options' ) ?> </a>
2018-05-02 19:59:45 +02:00
</ li >
</ ul >
< ? php
2018-05-08 00:15:40 +02:00
echo Bootstrap :: formOpen ( array (
'id' => 'jsform' ,
2018-06-03 21:51:47 +02:00
'class' => 'tab-content mt-1'
2018-05-08 00:15:40 +02:00
));
2018-05-02 19:59:45 +02:00
// Token CSRF
echo Bootstrap :: formInputHidden ( array (
'name' => 'tokenCSRF' ,
2018-07-17 19:13:01 +02:00
'value' => $security -> getTokenCSRF ()
2018-05-02 19:59:45 +02:00
));
2017-07-05 22:55:03 +02:00
2018-05-02 19:59:45 +02:00
// Parent
echo Bootstrap :: formInputHidden ( array (
2017-07-05 22:55:03 +02:00
'name' => 'parent' ,
2018-05-02 19:59:45 +02:00
'value' => $page -> parent ()
2017-07-05 22:55:03 +02:00
));
2015-10-19 00:45:58 +02:00
2018-05-08 00:15:40 +02:00
// UUID
echo Bootstrap :: formInputHidden ( array (
'name' => 'uuid' ,
2018-05-08 23:25:18 +02:00
'value' => $page -> uuid ()
2018-05-08 00:15:40 +02:00
));
2018-05-02 19:59:45 +02:00
// Status = published, draft, sticky, static
echo Bootstrap :: formInputHidden ( array (
2018-07-17 19:13:01 +02:00
'name' => 'type' ,
'value' => $page -> type ()
2018-05-02 19:59:45 +02:00
));
2015-10-19 00:45:58 +02:00
2018-05-02 19:59:45 +02:00
// Page current key
echo Bootstrap :: formInputHidden ( array (
'name' => 'key' ,
'value' => $page -> key ()
));
2018-05-08 23:25:18 +02:00
// Cover image
echo Bootstrap :: formInputHidden ( array (
'name' => 'coverImage' ,
'value' => $page -> coverImage ()
));
2018-07-03 23:04:08 +02:00
// Content
echo Bootstrap :: formInputHidden ( array (
'name' => 'content' ,
2018-07-07 12:04:34 +02:00
'value' => ''
2018-07-03 23:04:08 +02:00
));
2018-05-02 19:59:45 +02:00
?>
<!-- TABS CONTENT -->
< div class = " tab-pane show active " id = " content " role = " tabpanel " aria - labelledby = " content-tab " >
2018-06-03 21:51:47 +02:00
< div class = " form-group m-0 " >
2018-08-05 17:54:20 +02:00
< input value = " <?php echo $page->title () ?> " class = " form-control form-control-lg rounded-0 " id = " jstitle " name = " title " placeholder = " <?php $L->p ('Enter title') ?> " type = " text " >
2018-06-03 21:51:47 +02:00
</ div >
2018-05-02 19:59:45 +02:00
2018-07-07 12:04:34 +02:00
< div class = " form-group m-0 mt-1 " >
2018-08-05 17:54:20 +02:00
< button id = " jsmediaManagerButton " type = " button " class = " btn btn-form btn-sm " data - toggle = " modal " data - target = " #jsbluditMediaModal " >< span class = " oi oi-image " ></ span > < ? php $L -> p ( 'Media Manager' ) ?> </button>
< button id = " jscategoryButton " type = " button " class = " btn btn-form btn-sm " data - toggle = " modal " data - target = " #jscategoryModal " >< span class = " oi oi-tag " ></ span > < ? php $L -> p ( 'Category' ) ?> : <span class="option">-</span></button>
< button id = " jsdescriptionButton " type = " button " class = " btn btn-form btn-sm " data - toggle = " modal " data - target = " #jsdescriptionModal " >< span class = " oi oi-tag " ></ span > < ? php $L -> p ( 'Description' ) ?> : <span class="option">-</span></button>
2018-07-07 12:04:34 +02:00
</ div >
2018-06-03 21:51:47 +02:00
< div class = " form-group mt-1 " >
2018-07-07 12:04:34 +02:00
< textarea id = " jseditor " style = " display:none; " >< ? php echo $page -> contentRaw ( false ) ?> </textarea>
2018-05-02 19:59:45 +02:00
</ div >
2018-07-13 18:30:42 +02:00
< ? php if ( $page -> draft ()) : ?>
2018-08-05 17:54:20 +02:00
< div class = " alert alert-primary mt-2 mb-2 " >< ? php $L -> p ( 'The content is saved as a draft. To publish it click on the button <b>Publish</b> or if you still working on it click on <b>Save as draft</b>.' ) ?> </div>
2018-07-13 18:30:42 +02:00
< ? php endif ; ?>
2018-05-02 19:59:45 +02:00
2018-07-17 19:13:01 +02:00
< div class = " form-group mt-2 " >
2018-08-05 17:54:20 +02:00
< button type = " button " class = " jsbuttonSave btn btn-primary " >< ? php echo ( $page -> draft () ? $L -> g ( 'Publish' ) : $L -> g ( 'Save' )) ?> </button>
< button type = " button " class = " jsbuttonDraft btn btn-secondary " >< ? php $L -> p ( 'Save as draft' ) ?> </button>
< a href = " <?php echo HTML_PATH_ADMIN_ROOT ?>dashboard " class = " btn btn-secondary " >< ? php $L -> p ( 'Cancel' ) ?> </a>
2018-07-17 19:13:01 +02:00
< ? php
if ( count ( $page -> children ()) === 0 ) {
2018-07-25 23:42:00 +02:00
echo '<button type="button" class="btn btn-secondary" data-toggle="modal" data-target="#jsdeletePageModal">' . $L -> g ( 'Delete' ) . '</button>' ;
2018-07-17 19:13:01 +02:00
}
?>
</ div >
2018-05-02 19:59:45 +02:00
</ div >
<!-- TABS IMAGES -->
< div class = " tab-pane " id = " images " role = " tabpanel " aria - labelledby = " images-tab " >
2018-07-17 19:13:01 +02:00
< div >
< div class = " float-right " >
2018-08-05 17:54:20 +02:00
< button type = " button " class = " jsbuttonSave btn btn-primary btn-sm " >< ? php echo ( $page -> draft () ? $L -> g ( 'Publish' ) : $L -> g ( 'Save' )) ?> </button>
< button type = " button " class = " jsbuttonDraft btn btn-secondary btn-sm " >< ? php $L -> p ( 'Save as draft' ) ?> </button>
2018-07-17 19:13:01 +02:00
</ div >
2018-08-05 17:54:20 +02:00
< h4 class = " mt-4 mb-4 font-weight-normal " >< ? php $L -> p ( 'Cover image' ) ?> </h4>
2018-07-17 19:13:01 +02:00
</ div >
2018-05-02 19:59:45 +02:00
2018-07-17 19:13:01 +02:00
< ? php
2018-05-02 19:59:45 +02:00
$coverImage = $page -> coverImage ( false );
$externalCoverImage = '' ;
if ( filter_var ( $coverImage , FILTER_VALIDATE_URL )) {
$coverImage = '' ;
$externalCoverImage = $page -> coverImage ( false );
}
?>
2018-07-01 14:17:24 +02:00
< img id = " jscoverImagePreview " style = " width: 350px; height: 200px; " class = " img-thumbnail " alt = " coverImagePreview " src = " <?php echo HTML_PATH_ADMIN_THEME_IMG ?>default.svg " />
2018-05-02 19:59:45 +02:00
< ? php
2018-08-05 17:54:20 +02:00
echo Bootstrap :: formTitle ( array ( 'title' => $L -> g ( 'External Cover image' )));
2018-05-02 19:59:45 +02:00
echo Bootstrap :: formInputTextBlock ( array (
'name' => 'externalCoverImage' ,
'placeholder' => 'https://' ,
'value' => $externalCoverImage ,
2018-08-05 17:54:20 +02:00
'tip' => $L -> g ( 'Set a cover image from external URL, such as a CDN or some server dedicated for images.' )
2018-05-02 19:59:45 +02:00
));
?>
</ div >
<!-- TABS OPTIONS -->
< div class = " tab-pane " id = " options " role = " tabpanel " aria - labelledby = " options-tab " >
2018-07-17 19:13:01 +02:00
< div >
< div class = " float-right " >
2018-08-05 17:54:20 +02:00
< button type = " button " class = " jsbuttonSave btn btn-primary btn-sm " >< ? php echo ( $page -> draft () ? $L -> g ( 'Publish' ) : $L -> g ( 'Save' )) ?> </button>
< button type = " button " class = " jsbuttonDraft btn btn-secondary btn-sm " >< ? php $L -> p ( 'Save as draft' ) ?> </button>
2018-07-17 19:13:01 +02:00
</ div >
2018-08-05 17:54:20 +02:00
< h4 class = " mt-4 mb-4 font-weight-normal " >< ? php $L -> p ( 'General' ) ?> </h4>
2018-07-17 19:13:01 +02:00
</ div >
2018-05-02 19:59:45 +02:00
2018-07-17 19:13:01 +02:00
< ? php
2018-07-28 18:33:37 +02:00
// Username
echo Bootstrap :: formInputText ( array (
'name' => '' ,
2018-08-05 17:54:20 +02:00
'label' => $L -> g ( 'User' ),
2018-07-28 18:33:37 +02:00
'placeholder' => '' ,
'value' => $page -> username (),
'tip' => '' ,
'disabled' => true
));
2018-05-02 19:59:45 +02:00
// Date
echo Bootstrap :: formInputText ( array (
'name' => 'date' ,
2018-08-05 17:54:20 +02:00
'label' => $L -> g ( 'Date' ),
2018-07-12 20:03:31 +02:00
'placeholder' => '' ,
2018-07-17 19:13:01 +02:00
'value' => $page -> dateRaw (),
2018-08-05 17:54:20 +02:00
'tip' => $L -> g ( 'Date format: <code>YYYY-MM-DD Hours:Minutes:Seconds</code>' )
2018-05-02 19:59:45 +02:00
));
// Type
echo Bootstrap :: formSelect ( array (
2018-07-17 19:13:01 +02:00
'name' => 'typeTMP' ,
2018-08-05 17:54:20 +02:00
'label' => $L -> g ( 'Type' ),
2018-07-12 20:03:31 +02:00
'selected' => $page -> type (),
2018-05-02 19:59:45 +02:00
'options' => array (
2018-08-05 17:54:20 +02:00
'published' => '- ' . $L -> g ( 'Default' ) . ' -' ,
'sticky' => $L -> g ( 'Sticky' ),
'static' => $L -> g ( 'Static' )
2018-07-12 20:03:31 +02:00
),
2018-08-05 17:54:20 +02:00
'tip' => ''
2018-05-02 19:59:45 +02:00
));
// Parent
2018-07-18 21:48:37 +02:00
try {
$parentKey = $page -> parent ();
2018-08-02 17:06:53 +02:00
$parent = new Page ( $parentKey );
2018-07-18 21:48:37 +02:00
$parentOption = $parent -> title ();
} catch ( Exception $e ) {
$parentOption = '' ;
}
2018-05-02 19:59:45 +02:00
echo Bootstrap :: formInputText ( array (
'name' => 'parentTMP' ,
2018-07-12 20:03:31 +02:00
'label' => $L -> g ( 'Parent' ),
'placeholder' => '' ,
2018-08-05 17:54:20 +02:00
'tip' => $L -> g ( 'Start typing a page title to see a list of suggestions.' ),
2018-07-18 21:48:37 +02:00
'value' => $parentOption
2018-05-02 19:59:45 +02:00
));
// Position
echo Bootstrap :: formInputText ( array (
'name' => 'position' ,
2018-07-12 20:03:31 +02:00
'label' => $L -> g ( 'Position' ),
2018-08-05 17:54:20 +02:00
'tip' => $L -> g ( 'Field used when ordering content by position' ),
2018-05-02 19:59:45 +02:00
'value' => $page -> position ()
));
2018-07-12 20:03:31 +02:00
// Template
echo Bootstrap :: formInputText ( array (
'name' => 'template' ,
2018-08-05 17:54:20 +02:00
'label' => $L -> g ( 'Template' ),
2018-07-12 20:03:31 +02:00
'placeholder' => '' ,
'value' => $page -> template (),
2018-08-05 17:54:20 +02:00
'tip' => $L -> g ( 'Write a template name to filter the page in the theme and change the style of the page.' )
2018-07-12 20:03:31 +02:00
));
echo Bootstrap :: formTitle ( array ( 'title' => 'SEO' ));
// Tags
echo Bootstrap :: formInputText ( array (
'name' => 'tags' ,
2018-08-05 17:54:20 +02:00
'label' => $L -> g ( 'Tags' ),
2018-07-12 20:03:31 +02:00
'placeholder' => '' ,
'value' => $page -> tags (),
2018-08-05 17:54:20 +02:00
'tip' => $L -> g ( 'Write the tags separated by comma' )
2018-07-12 20:03:31 +02:00
));
2018-05-02 19:59:45 +02:00
// Friendly URL
echo Bootstrap :: formInputText ( array (
'name' => 'slug' ,
2018-07-12 20:03:31 +02:00
'tip' => $L -> g ( 'URL associated with the content' ),
'label' => $L -> g ( 'Friendly URL' ),
2018-08-05 17:54:20 +02:00
'placeholder' => $L -> g ( 'Leave empty for autocomplete by Bludit.' ),
2018-07-12 20:03:31 +02:00
'value' => $page -> slug ()
2018-05-02 19:59:45 +02:00
));
2018-07-12 20:03:31 +02:00
echo Bootstrap :: formCheckbox ( array (
'name' => 'noindex' ,
'label' => 'Robots' ,
2018-08-05 17:54:20 +02:00
'labelForCheckbox' => $L -> g ( 'Apply <code>noindex</code> to this page' ),
2018-05-08 00:15:40 +02:00
'placeholder' => '' ,
2018-07-12 20:03:31 +02:00
'class' => 'mt-4' ,
'checked' => $page -> noindex (),
2018-08-05 17:54:20 +02:00
'tip' => $L -> g ( 'This tells search engines not to show this page in their search results.' )
2018-05-02 19:59:45 +02:00
));
2018-07-12 20:03:31 +02:00
echo Bootstrap :: formCheckbox ( array (
'name' => 'nofollow' ,
'label' => '' ,
2018-08-05 17:54:20 +02:00
'labelForCheckbox' => $L -> g ( 'Apply <code>nofollow</code> to this page' ),
2018-07-12 20:03:31 +02:00
'placeholder' => '' ,
'checked' => $page -> nofollow (),
2018-08-05 17:54:20 +02:00
'tip' => $L -> g ( 'This tells search engines not to follow links on this page.' )
2018-07-12 20:03:31 +02:00
));
echo Bootstrap :: formCheckbox ( array (
'name' => 'noarchive' ,
'label' => '' ,
2018-08-05 17:54:20 +02:00
'labelForCheckbox' => $L -> g ( 'Apply <code>noarchive</code> to this page' ),
2018-07-12 20:03:31 +02:00
'placeholder' => '' ,
'checked' => $page -> noarchive (),
2018-08-05 17:54:20 +02:00
'tip' => $L -> g ( 'This tells search engines not to save a cached copy of this page.' )
2018-07-12 20:03:31 +02:00
));
2018-05-02 19:59:45 +02:00
?>
2018-07-07 12:04:34 +02:00
</ div >
2018-07-25 23:42:00 +02:00
<!-- Modal for delete page -->
< ? php echo Bootstrap :: modal ( array (
2018-08-05 17:54:20 +02:00
'buttonPrimary' => $L -> g ( 'Delete' ),
2018-07-25 23:42:00 +02:00
'buttonPrimaryClass' => 'jsbuttonDeleteAccept' ,
2018-08-05 17:54:20 +02:00
'buttonSecondary' => $L -> g ( 'Cancel' ),
2018-07-25 23:42:00 +02:00
'buttonSecondaryClass' => '' ,
2018-08-05 17:54:20 +02:00
'modalTitle' => $L -> g ( 'Delete content' ),
'modalText' => $L -> g ( 'Are you sure you want to delete this page' ),
2018-07-25 23:42:00 +02:00
'modalId' => 'jsdeletePageModal'
));
?>
< script >
$ ( document ) . ready ( function () {
// Delete content
$ ( " .jsbuttonDeleteAccept " ) . on ( " click " , function () {
$ ( " #jstype " ) . val ( " delete " );
$ ( " #jscontent " ) . val ( " " );
$ ( " #jsform " ) . submit ();
});
});
</ script >
2018-07-07 12:04:34 +02:00
<!-- Modal for Categories -->
< div id = " jscategoryModal " class = " modal fade " tabindex = " -1 " role = " dialog " >
< div class = " modal-dialog " >
< div class = " modal-content " >
< div class = " modal-header " >
2018-08-05 17:54:20 +02:00
< h5 class = " modal-title " >< ? php $L -> p ( 'Category' ) ?> </h5>
2018-07-07 12:04:34 +02:00
</ div >
< div class = " modal-body " >
< ? php
echo Bootstrap :: formSelectBlock ( array (
'name' => 'category' ,
'label' => '' ,
'selected' => $page -> categoryKey (),
'class' => '' ,
2018-08-05 17:54:20 +02:00
'emptyOption' => '- ' . $L -> g ( 'Uncategorized' ) . ' -' ,
2018-08-02 22:33:53 +02:00
'options' => $categories -> getKeyNameArray ()
2018-07-07 12:04:34 +02:00
));
?>
</ div >
< div class = " modal-footer " >
2018-08-05 17:54:20 +02:00
< button type = " button " class = " btn btn-primary " data - dismiss = " modal " >< ? php $L -> p ( 'Done' ) ?> </button>
2018-07-07 12:04:34 +02:00
</ div >
</ div >
</ div >
</ div >
< script >
2018-07-12 20:03:31 +02:00
$ ( document ) . ready ( function () {
function setCategoryBox ( value ) {
var selected = $ ( " #jscategory option:selected " );
var value = selected . val () . trim ();
if ( value ) {
$ ( " #jscategoryButton " ) . find ( " span.option " ) . html ( selected . text ());
} else {
$ ( " #jscategoryButton " ) . find ( " span.option " ) . html ( " - " );
2018-07-07 12:04:34 +02:00
}
2018-07-12 20:03:31 +02:00
}
2018-05-02 19:59:45 +02:00
2018-07-12 20:03:31 +02:00
// Set the current category selected
setCategoryBox ();
2018-07-07 12:04:34 +02:00
2018-07-12 20:03:31 +02:00
// When the user select the category update the category button
$ ( " #jscategory " ) . on ( " change " , function () {
setCategoryBox ();
2018-07-07 12:04:34 +02:00
});
2018-07-12 20:03:31 +02:00
});
2018-07-07 12:04:34 +02:00
</ script >
<!-- Modal for Description -->
< div id = " jsdescriptionModal " class = " modal fade " tabindex = " -1 " role = " dialog " >
< div class = " modal-dialog " >
< div class = " modal-content " >
< div class = " modal-header " >
2018-08-05 17:54:20 +02:00
< h5 class = " modal-title " >< ? php $L -> p ( 'Description' ) ?> </h5>
2018-07-07 12:04:34 +02:00
</ div >
< div class = " modal-body " >
< ? php
echo Bootstrap :: formTextareaBlock ( array (
'name' => 'description' ,
'label' => '' ,
'selected' => '' ,
'class' => '' ,
'value' => $page -> description (),
'rows' => 3 ,
2018-08-05 17:54:20 +02:00
'placeholder' => $L -> get ( 'this-field-can-help-describe-the-content' )
2018-07-07 12:04:34 +02:00
));
?>
</ div >
< div class = " modal-footer " >
2018-08-05 17:54:20 +02:00
< button type = " button " class = " btn btn-primary " data - dismiss = " modal " >< ? php $L -> p ( 'Done' ) ?> </button>
2018-07-07 12:04:34 +02:00
</ div >
</ div >
</ div >
2018-05-02 19:59:45 +02:00
</ div >
2018-07-07 12:04:34 +02:00
< script >
2018-07-12 20:03:31 +02:00
$ ( document ) . ready ( function () {
function setDescriptionBox ( value ) {
var value = $ ( " #jsdescription " ) . val ();
if ( ! value ) {
value = '-' ;
} else {
value = jQuery . trim ( value ) . substring ( 0 , 60 ) . split ( " " ) . slice ( 0 , - 1 ) . join ( " " ) + " ... " ;
2018-07-07 12:04:34 +02:00
}
2018-07-12 20:03:31 +02:00
$ ( " #jsdescriptionButton " ) . find ( " span.option " ) . html ( value );
}
2018-07-07 12:04:34 +02:00
2018-07-12 20:03:31 +02:00
// Set the current description
setDescriptionBox ();
2018-07-07 12:04:34 +02:00
2018-07-12 20:03:31 +02:00
// When the user write the description update the description button
$ ( " #jsdescription " ) . on ( " change " , function () {
setDescriptionBox ();
2018-07-07 12:04:34 +02:00
});
2018-07-12 20:03:31 +02:00
});
2018-07-07 12:04:34 +02:00
</ script >
2018-05-02 19:59:45 +02:00
</ form >
2015-05-05 03:00:01 +02:00
2018-07-10 18:37:46 +02:00
<!-- Modal for Media Manager -->
< ? php include ( PATH_ADMIN_THEMES . 'booty/html/media.php' ); ?>
2015-05-05 03:00:01 +02:00
< script >
2018-05-02 19:59:45 +02:00
$ ( document ) . ready ( function () {
2017-01-10 17:43:38 +01:00
2018-07-12 20:03:31 +02:00
// Datepicker
$ ( " #jsdate " ) . datetimepicker ({ format : DB_DATE_FORMAT });
2018-05-08 23:25:18 +02:00
// Button Save
2018-07-17 19:13:01 +02:00
$ ( " .jsbuttonSave " ) . on ( " click " , function () {
var type = $ ( " #jstypeTMP option:selected " ) . val ();
$ ( " #jstype " ) . val ( type );
2018-07-03 23:04:08 +02:00
$ ( " #jscontent " ) . val ( editorGetContent () );
2018-05-08 23:25:18 +02:00
$ ( " #jsform " ) . submit ();
});
2017-01-10 17:43:38 +01:00
// Button Save as draft
2018-07-17 19:13:01 +02:00
$ ( " .jsbuttonDraft " ) . on ( " click " , function () {
$ ( " #jstype " ) . val ( " draft " );
2018-07-03 23:04:08 +02:00
$ ( " #jscontent " ) . val ( editorGetContent () );
2018-05-08 23:25:18 +02:00
$ ( " #jsform " ) . submit ();
2017-01-10 17:43:38 +01:00
});
2018-05-08 23:25:18 +02:00
// External cover image
$ ( " #jsexternalCoverImage " ) . change ( function () {
$ ( " #jscoverImage " ) . val ( $ ( this ) . val () );
});
// Autosave interval
2018-07-12 20:03:31 +02:00
// Autosave works when the content of the page is bigger than 100 characters
2018-05-08 23:25:18 +02:00
setInterval ( function () {
2018-05-08 00:15:40 +02:00
var uuid = $ ( " #jsuuid " ) . val ();
var title = $ ( " #jstitle " ) . val ();
2018-05-08 23:25:18 +02:00
var content = editorGetContent ();
var ajax = new bluditAjax ();
// showAlert is the function to display an alert defined in alert.php
ajax . autosave ( uuid , title , content , showAlert );
2018-07-07 12:04:34 +02:00
}, 1000 * 60 * AUTOSAVE_INTERVAL );
2018-05-08 00:15:40 +02:00
2018-05-02 19:59:45 +02:00
// Template autocomplete
$ ( 'input[name="template"]' ) . autoComplete ({
minChars : 2 ,
source : function ( term , suggest ){
term = term . toLowerCase ();
var choices = [ 'ActionScript' , 'Acti' , 'Asp' ];
var matches = [];
for ( i = 0 ; i < choices . length ; i ++ )
if ( ~ choices [ i ] . toLowerCase () . indexOf ( term )) matches . push ( choices [ i ]);
suggest ( matches );
2017-01-10 17:43:38 +01:00
}
});
2015-07-04 02:14:58 +02:00
2018-05-02 19:59:45 +02:00
// Parent autocomplete
var parentsXHR ;
var parentsList ; // Keep the parent list returned to get the key by the title page
$ ( " #jsparentTMP " ) . autoComplete ({
2018-07-12 20:03:31 +02:00
minChars : 1 ,
2018-05-02 19:59:45 +02:00
source : function ( term , response ) {
// Prevent call inmediatly another ajax request
try { parentsXHR . abort (); } catch ( e ){}
2018-07-12 20:03:31 +02:00
parentsXHR = $ . getJSON ( HTML_PATH_ADMIN_ROOT + " ajax/get-parents " , { query : term },
2018-05-02 19:59:45 +02:00
function ( data ) {
parentsList = data ;
term = term . toLowerCase ();
var matches = [];
for ( var title in data ) {
if ( ~ title . toLowerCase () . indexOf ( term ))
matches . push ( title );
}
response ( matches );
});
},
onSelect : function ( e , term , item ) {
2018-07-12 20:03:31 +02:00
// parentsList = array( pageTitle => pageKey )
2018-05-02 19:59:45 +02:00
var parentKey = parentsList [ term ];
$ ( " #jsparent " ) . attr ( " value " , parentKey );
2018-01-21 23:23:22 +01:00
}
});
2015-05-05 03:00:01 +02:00
});
2018-05-02 19:59:45 +02:00
</ script >