Big fixes

This commit is contained in:
Hoang Huu
2020-05-04 15:53:09 +07:00
parent 453e78da8b
commit b4db533574
24 changed files with 4837 additions and 4697 deletions

View File

@@ -9,7 +9,6 @@
* GooglemapSearch
*/
var GooglemapSingle = Opalestate.GooglemapSingle = function ( data, id ) {
/**
* Create Google Map In Single Property Only
*/
@@ -42,11 +41,36 @@
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false
};
var propertyMap = new google.maps.Map( document.getElementById( id ), propertyMapOptions );
/**
*
*/
if ( ( typeof opalestateGmap !== 'undefined' ) ) {
switch ( opalestateGmap.style ) {
case 'standard':
propertyMapOptions.styles = GoogleMapStyles.standard;
break;
case 'silver':
propertyMapOptions.styles = GoogleMapStyles.silver;
break;
case 'retro':
propertyMapOptions.styles = GoogleMapStyles.retro;
break;
case 'dark':
propertyMapOptions.styles = GoogleMapStyles.dark;
break;
case 'night':
propertyMapOptions.styles = GoogleMapStyles.night;
break;
case 'aubergine':
propertyMapOptions.styles = GoogleMapStyles.aubergine;
break;
case 'custom':
if ( opalestateGmap.custom_style != '' ) {
propertyMapOptions.styles = $.parseJSON( opalestateGmap.custom_style );
}
break;
}
}
var propertyMap = new google.maps.Map( document.getElementById( id ), propertyMapOptions );
var createMarker = function ( position, icon ) {
@@ -1430,7 +1454,7 @@
} );
$( '.property-preview-street-map' ).show( 100 );
} );
///
///
// auto set height for split google map
$( '.split-maps-container' ).each( function () {
$( '#opalestate-map-preview ' ).height( $( window ).height() );
@@ -1539,12 +1563,12 @@
} );
} );
// // Sortable Change // //
// // Sortable Change // //
$( 'body' ).delegate( '#opalestate-sortable-form select', 'change', function () {
var ps = '';
if ( $( 'form.opalestate-search-form' ).length > 0 ) {
var $form = $( 'form.opalestate-search-form' );
if ( $('body').hasClass( 'archive' ) ) {
if ( $( 'body' ).hasClass( 'archive' ) ) {
ps = 'opalsortable=' + $( this ).val() + '&display=' +
$( '.display-mode a.active' ).data( 'mode' );
} else {
@@ -1561,7 +1585,7 @@
updatePropertiesByParseringHtml( newurl );
}
} else {
if ( history.pushState && $('body').hasClass( 'archive' ) ) {
if ( history.pushState && $( 'body' ).hasClass( 'archive' ) ) {
var newurl = window.location.protocol + '//' + window.location.host + window.location.pathname +
'?' + ps;
window.history.pushState( { path: newurl }, '', newurl );
@@ -1571,7 +1595,7 @@
}
} );
// display mode
// display mode
$( 'body' ).delegate( '.display-mode a', 'click', function () {
if ( $( '.opalesate-properties-results' ).length > 0 ) {
var newurl = $( this ).attr( 'href' );
@@ -1580,7 +1604,7 @@
return false;
}
} );
// check any estate search form is enabled /////////////////
if ( $( '#opalestate-map-preview' ).length > 0 ) {
$( 'body' ).delegate( 'form.opalestate-search-form select', 'change', function () {
var params = $( 'form.opalestate-search-form' ).serialize();
@@ -1603,12 +1627,9 @@
$( 'form.opalestate-search-form' ).submit();
} );
}
/////////// ///////
} );
} )( jQuery );
//// //////
( function ( $ ) {
'use strict';
@@ -1627,8 +1648,11 @@
var latitude = mapInstance.find( '.opal-map-latitude' );
var longitude = mapInstance.find( '.opal-map-longitude' );
google.maps.event.addListener( autocomplete, 'place_changed', function () {
if ( ( typeof opalestateGmap !== 'undefined' ) && opalestateGmap.autocomplete_restrictions ) {
autocomplete.setComponentRestrictions( { 'country': JSON.parse(opalestateGmap.autocomplete_restrictions) } );
}
google.maps.event.addListener( autocomplete, 'place_changed', function () {
var place = autocomplete.getPlace();
if ( !place.geometry ) {
@@ -1657,7 +1681,5 @@
event.preventDefault();
}
} );
}
} )( jQuery );

View File

@@ -13,7 +13,7 @@ window.opalestate_uploader = function() {
* @param {window} The window object.
*
*/
( function( $, window ) {
/**
@@ -26,9 +26,9 @@ window.opalestate_uploader = function() {
function opalestate_uploader() {
$document = $( document );
function is_image_file( file ) {
$document = $( document );
function is_image_file( file ) {
const acceptedImageTypes = ['image/gif', 'image/jpeg', 'image/png'];
return file && acceptedImageTypes.includes(file['type'])
}
@@ -36,14 +36,14 @@ window.opalestate_uploader = function() {
function check_number_files( file , i ) {
if( is_image_file(file) ) {
if( i+1 > opalesateJS.mfile_image ){
return false;
return false;
}
} else {
if( i+1 > opalesateJS.mfile_other ){
return false;
return false;
}
}
return true;
return true;
}
function check_filesize ( file , i ) {
@@ -54,8 +54,8 @@ window.opalestate_uploader = function() {
heading: file.name,
text: opalesateJS.error_upload_size,
icon: 'error',
position: 'bottom-right',
hideAfter: 3500,
position: 'bottom-right',
hideAfter: 3500,
showHideTransition: 'fade'
});
return false;
@@ -63,7 +63,7 @@ window.opalestate_uploader = function() {
return true;
}
} else {
return true;
return true;
}
}
@@ -71,56 +71,57 @@ window.opalestate_uploader = function() {
*
*/
function trigger_button_upload(){
var handleUpload = function ( _container ){
var file_btn = $( 'input.select-file', _container );
var file_btn = $( 'input.select-file', _container );
var allow_files = [];
// var all_selected = [];
var name = $(this).data( 'name' );
var issingle = $(_container).data('single');
var issingle = $(_container).data('single');
var show_icon = $(_container).data( 'show-icon' );
var on_select_files = function ( files, _container ) {
if ( window.File && window.FileList && window.FileReader ) {
$(files).each( function( i, file ){
if( check_number_files( file, i+$(".uploader-item-preview",_container).length ) == false ){
return ;
}
}
if( check_filesize( file, i ) ) {
var picReader = new FileReader();
picReader.addEventListener("load", function ( event ) {
picReader.addEventListener("load", function ( event ) {
var input = '<div class="uploader-item-preview">';
var picFile = event.target;
if ( picFile.result ) {
if( show_icon == 1 ) {
input += '<div class="inner preview-icon"><span class="btn-close"></span><i class="fas fa-paperclip"></i> '+ file.name +' </div>';
input += '<div class="inner preview-icon"><span class="btn-close fa fa-close"></span><i class="fas fa-paperclip"></i> '+ file.name +' </div>';
} else {
input += '<div class="inner preview-image"><span class="btn-close"></span><img src="'+picFile.result+'"></div>';
input += '<div class="inner preview-image"><span class="btn-close' +
' fa fa-close"></span><img src="'+picFile.result+'"></div>';
}
}
input += '</div>';
var a = $(input) ;
input += '</div>';
var a = $(input) ;
if( issingle ){
$( ".uploader-item-preview", _container ).remove();
all_selected = [];
}
$( _container ).prepend( a );
a.prop( 'file', file );
a.prop( 'file', file );
} );
picReader.readAsDataURL( file );
}
} );
}
};
file_btn.on("change", function( event ){
on_select_files( event.target.files, _container, allow_files );
} );
} );
$( _container ).on( "click", ".btn-close", function(){
if( confirm(opalesateJS.confirmed ) ){
@@ -128,14 +129,14 @@ window.opalestate_uploader = function() {
var rinput = $("<input type=\"hidden\" name=\"remove_image_id[]\" value=\""+ $("input", $(this).parent().parent()).val() +"\">");
$(_container).append( rinput );
}
$(this).parent().parent().remove();
}
} );
$( ".button-placehold", _container ).click( function(){
file_btn.trigger("click");
} );
} );
}
$(".cmb2-uploader-files").each( function(){
@@ -145,9 +146,9 @@ window.opalestate_uploader = function() {
// fix for submittion form
window.CMB2 = window.CMB2 || {};
window.CMB2.metabox().find('.cmb-repeatable-group').on( 'cmb2_add_row', function(i, row ) {
var _container = $( row );
var _container = $( row );
if( $(".cmb2-uploader-files", _container ).length ) {
$( ".uploader-item-preview", _container ).remove();
$( ".uploader-item-preview", _container ).remove();
$(".cmb2-uploader-files", _container ).each( function(){
var name = $( 'input', this ).attr('name');
$( this ).attr('data-name', name );
@@ -162,7 +163,7 @@ window.opalestate_uploader = function() {
alert( name );
}
/**
* @summary Sets the autosave time out.
*
@@ -176,13 +177,13 @@ window.opalestate_uploader = function() {
* @returns {void}
*/
$document.on( 'body', function( event, editor ) {
}).ready( function() {
trigger_button_upload();
trigger_button_upload();
});
return {
};
}
@@ -190,4 +191,4 @@ window.opalestate_uploader = function() {
window.wp = window.wp || {};
window.wp.opalestate_uploader = opalestate_uploader();
}( jQuery, window ));
}( jQuery, window ));

View File

@@ -132,7 +132,7 @@ jQuery( document ).ready( function ( $ ) {
} );
}
////////
////////
$( '.opalestate-scroll-elements a' ).on( 'click', function ( e ) {
e.preventDefault();
if ( $( $( this ).attr( 'href' ) ).length ) {
@@ -157,9 +157,9 @@ jQuery( document ).ready( function ( $ ) {
}
} );
////
////
////
////
$( '.opalestate-gallery' ).each( function () { // the containers for all your galleries
$( this ).magnificPopup( {
delegate: 'a', // the selector for gallery item
@@ -219,32 +219,32 @@ jQuery( document ).ready( function ( $ ) {
}
} );
// sticky ////
// sticky ////
// $( '.opalestate-sticky-column' ).stick_in_parent();
var window_width = $( window ).width();
if ( window_width < 768 ) {
$( '.opalestate-sticky-column' ).trigger( 'sticky_kit:detach' );
} else {
make_sticky();
}
$( window ).resize( function () {
window_width = $( window ).width();
if ( window_width < 768 ) {
$( '.opalestate-sticky-column' ).trigger( 'sticky_kit:detach' );
} else {
make_sticky();
}
} );
function make_sticky() {
$( '.opalestate-sticky-column' ).stick_in_parent();
}
// var window_width = $( window ).width();
//
// if ( window_width < 768 ) {
// $( '.opalestate-sticky-column' ).trigger( 'sticky_kit:detach' );
// } else {
// make_sticky();
// }
//
// $( window ).resize( function () {
//
// window_width = $( window ).width();
//
// if ( window_width < 768 ) {
// $( '.opalestate-sticky-column' ).trigger( 'sticky_kit:detach' );
// } else {
// make_sticky();
// }
//
// } );
//
// function make_sticky() {
// $( '.opalestate-sticky-column' ).stick_in_parent();
// }
////
$( '.input-group-number' ).each( function () {
@@ -512,7 +512,7 @@ jQuery( document ).ready( function ( $ ) {
var nummm = wNumb( config_format );
var istart = [ imin, imax ];
if ( mode && mode == 1 && start ) {
if ( mode && mode == 1 && ( start || start == 0 ) ) {
istart = [ start ];
}