diff --git a/assets/libs/um-confirm/um-confirm.css b/assets/libs/um-confirm/um-confirm.css new file mode 100755 index 00000000..bb7ff4f1 --- /dev/null +++ b/assets/libs/um-confirm/um-confirm.css @@ -0,0 +1,65 @@ +#um_confirm_block { + display: none; +} + +#um_confirm_block_back { + background-color: rgba( 0,0,0, 0.2); + width: 100%; + height: 100%; + position: fixed; + left: 0; + top: 0; + z-index: 2147483646; +} + +.um_confirm { + position: fixed; + color: #fff; + width: 400px; + background-color: rgb( 0,0,0); + left: 50%; + top: 50%; + z-index: 2147483647; + /*display: none;*/ +} + +.um_confirm #um_confirm_title { + background-color: rgba(0, 0, 0, 0.4); + border-bottom: 1px solid #5c5c5c; + color: #cccccc; + font-weight: bold; + height: 15px; + padding: 10px; + text-align: center; + width: calc(100% - 20px); +} + +.um_confirm #um_confirm_message { + width: calc(100% - 40px); + text-align: center; + padding: 20px; +} + +.um_confirm #um_confirm_buttons { + height: 40px; + width: 100%; +} + +.um_confirm .um_confirm_button { + /*font-family: verdana, arial;*/ + border-top: 1px solid #5c5c5c; + color: #aaa; + font-size: 15px; + font-weight: bold; + float: left; + line-height: 40px; + text-align: center; + width: 50%; + cursor: pointer; +} + +.um_confirm .um_confirm_button:hover { + background-color: rgba(0, 0, 0, 0.6); + border-top: 1px solid #fff; + color: #fff; +} diff --git a/assets/libs/um-confirm/um-confirm.js b/assets/libs/um-confirm/um-confirm.js new file mode 100755 index 00000000..559b8f55 --- /dev/null +++ b/assets/libs/um-confirm/um-confirm.js @@ -0,0 +1,154 @@ +/* + * WPO Confirm Plugin + * Open dialog popup (YES/NO) + */ + +(function( $, undefined ) { + var options; + + var default_options = { + 'message' : '', + 'yes_label' : 'Yes', + 'no_label' : 'No' + }; + + var methods = { + init : function( settings ) { + //merge default & current options + options = $.extend( {}, default_options, settings ); + + $( this ).each( function() { + + $( this ).data( 'options', options ); + + methods.build.apply( $( this ), [options] ); + + //init links clicks for show confirm + $( this ).click( function(e) { + var options = $( this ).data( 'options' ); + $( '#um_confirm_message' ).html( options.message ); + $( '#um_confirm_button_yes' ).html( options.yes_label ); + $( '#um_confirm_button_no' ).html( options.no_label ); + + methods.show.apply( this ); + + e.stopPropagation(); + }); + + }); + + }, + build : function( settings ) { + + if( !methods.is_builded.apply( this ) ) { + + var obj = $( '
').appendTo( 'body' ).html( '
' + + '
Confirmation
' + + '
' + + '
' + + '
Yes
' + + '
No
' + + '
' + + '
' + + '
' ); + + $( document ).on( 'click', '#um_confirm_button_yes', function() { + var obj = $( '#um_confirm_block').data( 'obj' ); + methods.yes.apply( obj ); + }); + + $( document ).on( 'click', '#um_confirm_button_no', function() { + var obj = $( '#um_confirm_block').data( 'obj' ); + methods.no.apply( obj ); + }); + + $( document ).on( 'click', '#um_confirm_block_back', function() { + var obj = $( '#um_confirm_block').data( 'obj' ); + methods.close.apply( obj ); + }); + + + } + }, + is_builded : function() { + //return confirm already exists + return $('#um_confirm_block').length; + }, + show : function() { + $( '#um_confirm_block').data( 'obj', this ).show(); + var width = $('.um_confirm').width(); + var height = $('.um_confirm').height(); + $('.um_confirm').css('margin', '-' + height/2 + 'px 0 0 -' + width/2 + 'px' ); + }, + close : function() { + var opt = $( this ).data( 'options' ); + + $( '#um_confirm_message' ).html( '' ); + $( '#um_confirm_block' ).hide(); + + if( typeof opt.onClose === "function" ) { + opt.onClose.apply( this ); + } + }, + yes : function() { + var opt = $( this ).data( 'options' ); + + var data = {}; + if( $( '#um_confirm_block').find('form').length ) { + var temp = $( '#um_confirm_block').find('form').serializeArray(); + for( key in temp ) { + data[ temp[ key ]['name'] ] = temp[ key ]['value']; + } + } + + methods.close.apply( this ); + + if( typeof opt.onYes === "function" ) { + opt.onYes.apply( this, [ data ] ); + } + }, + no : function() { + var opt = $( this ).data( 'options' ); + + var data = {}; + if( $( '#um_confirm_block').find('form').length ) { + var temp = $( '#um_confirm_block').find('form').serializeArray(); + for( key in temp ) { + data[ temp[ key ]['name'] ] = temp[ key ]['value']; + } + } + + methods.close.apply( this ); + + if( typeof opt.onNo === "function" ) { + opt.onNo.apply( this, [ data ] ); + } + } + }; + + $.fn.um_confirm = function( method ) { + if( methods[method] ) { + return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ) ); + } else if ( typeof method === 'object' || ! method ) { + return methods.init.apply( this, arguments ); + } else { + $.error( 'Method ' + method + ' does not exist for jQuery.um_confirm plugin' ); + } + }; + + $.um_confirm = function( settings ) { + options = $.extend( {}, default_options, settings ); + $( settings.object ).data( 'options', options ); + + + methods.build.apply( $( settings.object ), [options] ); + if ( options.title ) { + $( '#um_confirm_title' ).html( options.title ); + } + $( '#um_confirm_message' ).html( options.message ); + $( '#um_confirm_button_yes' ).html( options.yes_label ); + $( '#um_confirm_button_no' ).html( options.no_label ); + methods.show.apply( settings.object ); + } + +})( jQuery ); diff --git a/assets/libs/um-confirm/um-confirm.min.css b/assets/libs/um-confirm/um-confirm.min.css new file mode 100755 index 00000000..f574725d --- /dev/null +++ b/assets/libs/um-confirm/um-confirm.min.css @@ -0,0 +1 @@ +#um_confirm_block{display:none}#um_confirm_block_back{background-color:rgba(0,0,0,.2);width:100%;height:100%;position:fixed;left:0;top:0;z-index:2147483646}.um_confirm{position:fixed;color:#fff;width:400px;background-color:#000;left:50%;top:50%;z-index:2147483647}.um_confirm #um_confirm_title{background-color:rgba(0,0,0,.4);border-bottom:1px solid #5c5c5c;color:#ccc;font-weight:700;height:15px;padding:10px;text-align:center;width:calc(100% - 20px)}.um_confirm #um_confirm_message{width:calc(100% - 40px);text-align:center;padding:20px}.um_confirm #um_confirm_buttons{height:40px;width:100%}.um_confirm .um_confirm_button{border-top:1px solid #5c5c5c;color:#aaa;font-size:15px;font-weight:700;float:left;line-height:40px;text-align:center;width:50%;cursor:pointer}.um_confirm .um_confirm_button:hover{background-color:rgba(0,0,0,.6);border-top:1px solid #fff;color:#fff} \ No newline at end of file diff --git a/assets/libs/um-confirm/um-confirm.min.js b/assets/libs/um-confirm/um-confirm.min.js new file mode 100755 index 00000000..41b9aff5 --- /dev/null +++ b/assets/libs/um-confirm/um-confirm.min.js @@ -0,0 +1 @@ +!function(t){var i,n={message:"",yes_label:"Yes",no_label:"No"},m={init:function(o){i=t.extend({},n,o),t(this).each(function(){t(this).data("options",i),m.build.apply(t(this),[i]),t(this).click(function(o){var i=t(this).data("options");t("#um_confirm_message").html(i.message),t("#um_confirm_button_yes").html(i.yes_label),t("#um_confirm_button_no").html(i.no_label),m.show.apply(this),o.stopPropagation()})})},build:function(o){m.is_builded.apply(this)||(t('
').appendTo("body").html('
Confirmation
Yes
No
'),t(document).on("click","#um_confirm_button_yes",function(){var o=t("#um_confirm_block").data("obj");m.yes.apply(o)}),t(document).on("click","#um_confirm_button_no",function(){var o=t("#um_confirm_block").data("obj");m.no.apply(o)}),t(document).on("click","#um_confirm_block_back",function(){var o=t("#um_confirm_block").data("obj");m.close.apply(o)}))},is_builded:function(){return t("#um_confirm_block").length},show:function(){t("#um_confirm_block").data("obj",this).show();var o=t(".um_confirm").width(),i=t(".um_confirm").height();t(".um_confirm").css("margin","-"+i/2+"px 0 0 -"+o/2+"px")},close:function(){var o=t(this).data("options");t("#um_confirm_message").html(""),t("#um_confirm_block").hide(),"function"==typeof o.onClose&&o.onClose.apply(this)},yes:function(){var o=t(this).data("options"),i={};if(t("#um_confirm_block").find("form").length){var n=t("#um_confirm_block").find("form").serializeArray();for(key in n)i[n[key].name]=n[key].value}m.close.apply(this),"function"==typeof o.onYes&&o.onYes.apply(this,[i])},no:function(){var o=t(this).data("options"),i={};if(t("#um_confirm_block").find("form").length){var n=t("#um_confirm_block").find("form").serializeArray();for(key in n)i[n[key].name]=n[key].value}m.close.apply(this),"function"==typeof o.onNo&&o.onNo.apply(this,[i])}};t.fn.um_confirm=function(o){return m[o]?m[o].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof o&&o?void t.error("Method "+o+" does not exist for jQuery.um_confirm plugin"):m.init.apply(this,arguments)},t.um_confirm=function(o){i=t.extend({},n,o),t(o.object).data("options",i),m.build.apply(t(o.object),[i]),t("#um_confirm_message").html(i.message),t("#um_confirm_button_yes").html(i.yes_label),t("#um_confirm_button_no").html(i.no_label),m.show.apply(o.object)}}(jQuery); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 12039bd5..7f87ebbf 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -265,6 +265,16 @@ function defaultTask( done ) { .pipe( rename({ suffix: '.min' }) ) .pipe( dest( 'assets/libs/tipsy/' ) ); + // UM Confirm lib + src(['assets/libs/um-confirm/*.css', '!assets/libs/um-confirm/*.min.css',]) + .pipe( cleanCSS() ) + .pipe( rename( { suffix: '.min' } ) ) + .pipe( dest( 'assets/libs/um-confirm/' ) ); + src(['assets/libs/um-confirm/*.js', '!assets/libs/um-confirm/*.min.js',]) + .pipe( uglify() ) + .pipe( rename({ suffix: '.min' }) ) + .pipe( dest( 'assets/libs/um-confirm/' ) ); + // Pickadate lib src(['assets/libs/pickadate/*.css', '!assets/libs/pickadate/*.min.css',]) .pipe( cleanCSS() ) diff --git a/includes/common/class-enqueue.php b/includes/common/class-enqueue.php index 55bd5a8e..5b7476ef 100644 --- a/includes/common/class-enqueue.php +++ b/includes/common/class-enqueue.php @@ -260,6 +260,9 @@ class Enqueue { wp_register_script( 'um_tipsy', $libs_url . 'tipsy/tipsy' . $suffix . '.js', array( 'jquery' ), '1.0.0a', true ); wp_register_style( 'um_tipsy', $libs_url . 'tipsy/tipsy' . $suffix . '.css', array(), '1.0.0a' ); + wp_register_script( 'um_confirm', $libs_url . 'um-confirm/um-confirm' . $suffix . '.js', array( 'jquery' ), '1.0', true ); + wp_register_style( 'um_confirm', $libs_url . 'um-confirm/um-confirm' . $suffix . '.css', array(), '1.0' ); + // Raty JS for rating field-type. wp_register_script( 'um_raty', $libs_url . 'raty/um-raty' . $suffix . '.js', array( 'jquery', 'wp-i18n' ), '2.6.0', true ); wp_set_script_translations( 'um_raty', 'ultimate-member' ); @@ -273,7 +276,7 @@ class Enqueue { // @todo new version // First install set this option to true by default and use new FontAwesome icons wp_register_style( 'um_fontawesome', $css_url . 'um-fontawesome' . $suffix . '.css', array(), self::$fa_version ); // New FontAwesome - $fonticons_handlers[] = 'um_fontawesome'; + $fonticons_handlers[] = 'um_fontawesome'; self::$fonticons_handlers = $fonticons_handlers; // Select2 JS. @@ -284,7 +287,7 @@ class Enqueue { wp_register_script( 'um_datetime_date', $libs_url . 'pickadate/picker.date' . $suffix . '.js', array( 'um_datetime' ), '3.6.2', true ); wp_register_script( 'um_datetime_time', $libs_url . 'pickadate/picker.time' . $suffix . '.js', array( 'um_datetime' ), '3.6.2', true ); - $common_js_deps = array( 'jquery', 'wp-util', 'wp-hooks', 'wp-i18n', 'um_tipsy', 'um_datetime_date', 'um_datetime_time' ); + $common_js_deps = array( 'jquery', 'wp-util', 'wp-hooks', 'wp-i18n', 'um_tipsy', 'um_confirm', 'um_datetime_date', 'um_datetime_time' ); // Load a localized version for date/time. $locale = $this->get_pickadate_locale(); @@ -326,7 +329,7 @@ class Enqueue { $um_common_variables = apply_filters( 'um_common_js_variables', $um_common_variables ); wp_localize_script( 'um_common', 'um_common_variables', $um_common_variables ); - $common_css_deps = array_merge( array( 'um_tipsy', 'um_datetime_date', 'um_datetime_time' ), self::$fonticons_handlers ); + $common_css_deps = array_merge( array( 'um_tipsy', 'um_confirm', 'um_datetime_date', 'um_datetime_time' ), self::$fonticons_handlers ); wp_register_style( 'um_common', $css_url . 'common' . $suffix . '.css', $common_css_deps, UM_VERSION ); } }