created backbone modal dialog

This commit is contained in:
claudiosmweb 2014-07-15 19:56:07 -03:00
parent 29bb05f51c
commit 3ca145ac85
5 changed files with 143 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -3298,8 +3298,8 @@ table.bar_chart {
----------------------------------*/
.chosen-container-single .chosen-single {
height: 26px;
line-height: 26px;
margin-top:1px;
line-height: 26px;
margin-top:1px;
}
.chosen-container-single .chosen-single div b {
background: url('../images/chosen-sprite.png') no-repeat 0 4px !important;
@ -3400,14 +3400,87 @@ table.bar_chart {
}
#woocommerce-product-data .checkbox {
width: 25px;
width: 25px;
}
}
@import 'chosen.less';
.chosen-container-single .chosen-single {
abbr {
top: 8px;
}
abbr {
top: 8px;
}
}
/* Backbone modal dialog
----------------------------------*/
.wc-backbone-modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 160000;
* {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.wc-backbone-modal-content {
position: absolute;
top: 50%;
left: 50%;
height: 300px;
width: 400px;
background: #fff;
margin: -150px 0 0 -200px;
}
}
.wc-backbone-modal-backdrop {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
min-height: 360px;
background: #000;
opacity: .7;
z-index: 159900;
}
.wc-backbone-modal-main {
header,
article {
display: block;
position: relative;
padding: 4px 16px;
}
h1 {
font-size: 22px;
font-weight: 200;
line-height: 45px;
margin: 0;
}
footer {
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 30px;
z-index: 100;
padding: 10px 0px;
border: 0 solid #dfdfdf;
border-width: 1px 0 0 0;
box-shadow: 0 -4px 4px -4px rgba(0,0,0,0.1);
}
footer .inner {
padding: 0 10px;
text-align: right;
}
}

View File

@ -0,0 +1,61 @@
/*global jQuery, Backbone, _ */
( function ( $, Backbone, _ ) {
'use strict';
window.WCBackbone = {
Modal: {
__instance: undefined
}
};
window.WCBackbone.Modal.View = Backbone.View.extend({
tagName: 'div',
id: 'wc-backbone-modal-dialog',
_target: undefined,
events: {
'click #btn-cancel': 'closeButton',
'click #btn-ok': 'addButton',
},
initialize: function ( data ) {
this._target = data.target;
_.bindAll( this, 'render' );
this.render();
},
render: function () {
this.$el.attr( 'tabindex' , '0' ).append( $( this._target ).html() );
$( 'body' ).css({
'overflow': 'hidden'
}).append( this.$el );
},
closeButton: function ( e ) {
e.preventDefault();
this.undelegateEvents();
$( document ).off( 'focusin' );
$( 'body' ).css({
'overflow': 'auto'
});
this.remove();
window.WCBackbone.Modal.__instance = undefined;
},
addButton: function ( e ) {
$( 'body' ).trigger( 'wc_backbone_modal_response', this.getFormData() );
this.closeButton( e );
},
getFormData: function () {
var data = {};
$.each( $( 'form', this.$el ).serializeArray(), function( index, item ) {
if ( data.hasOwnProperty( item.name ) ) {
data[ item.name ] = $.makeArray( data[ item.name ] );
data[ item.name ].push( item.value );
}
else {
data[ item.name ] = item.value;
}
});
return data;
}
});
}( jQuery, Backbone, _ ));

View File

@ -0,0 +1 @@
!function(a,b,c){"use strict";window.WCBackbone={Modal:{__instance:void 0}},window.WCBackbone.Modal.View=b.View.extend({tagName:"div",id:"wc-backbone-modal-dialog",_target:void 0,events:{"click #btn-cancel":"closeButton","click #btn-ok":"addButton"},initialize:function(a){this._target=a.target,c.bindAll(this,"render"),this.render()},render:function(){this.$el.attr("tabindex","0").append(a(this._target).html()),a("body").css({overflow:"hidden"}).append(this.$el)},closeButton:function(b){b.preventDefault(),this.undelegateEvents(),a(document).off("focusin"),a("body").css({overflow:"auto"}),this.remove(),window.WCBackbone.Modal.__instance=void 0},addButton:function(b){a("body").trigger("wc_backbone_modal_response",this.getFormData()),this.closeButton(b)},getFormData:function(){var b={};return a.each(a("form",this.$el).serializeArray(),function(c,d){b.hasOwnProperty(d.name)?(b[d.name]=a.makeArray(b[d.name]),b[d.name].push(d.value)):b[d.name]=d.value}),b}})}(jQuery,Backbone,_);

View File

@ -155,6 +155,7 @@ class WC_Admin_Assets {
}
if ( in_array( str_replace( 'edit-', '', $screen->id ), wc_get_order_types( 'order-meta-boxes' ) ) ) {
wp_enqueue_script( 'wc-admin-order-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-order' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), WC_VERSION );
wp_enqueue_script( 'wc-admin-order-meta-boxes-modal', WC()->plugin_url() . '/assets/js/admin/order-backbone-modal' . $suffix . '.js', array( 'underscore', 'backbone', 'wc-admin-order-meta-boxes' ), WC_VERSION );
}
if ( in_array( $screen->id, array( 'shop_coupon', 'edit-shop_coupon' ) ) ) {
wp_enqueue_script( 'wc-admin-coupon-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-coupon' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), WC_VERSION );