Browse files

fix dialog2

git-svn-id: https://plugs.googlecode.com/svn/trunk@218 912515bb-fe1b-d127-1567-e02edd584596
  • Loading branch information...
1 parent 4d4b121 commit b44a01c7c7f8133711440d871354715da77fcc32 limodou committed Jun 26, 2012
View
12 plugs/ui/bootstrap/static/bootstrap/jquery.dialog2/jquery.dialog2.css
@@ -1,7 +1,13 @@
.modal {
- display: none;
- top: 20%;
- margin: 0 0 0 -280px;
+ display: none;
+ top: 20%;
+ margin: 0 0 0 -280px;
+ overflow: hidden;
+}
+
+.wide-modal {
+ width: 800px;
+ margin: 0 0 0 -400px;
}
.modal .modal-header h3 {
View
50 plugs/ui/bootstrap/static/bootstrap/jquery.dialog2/jquery.dialog2.js
@@ -48,6 +48,15 @@
this.trigger("dialog2.content-update");
}, handle);
+ this.__ajaxFormSuccessTrigger = $.proxy(function(data) {
+ if(options.ajaxFormOptions.onSuccess){
+ options.ajaxFormOptions.onSuccess.call(element, data);
+ }
+ this.trigger("dialog2.ajax-complete", data);
+ if(options.ajaxFormOptions.dataType != 'json')
+ this.trigger("dialog2.content-update");
+ }, handle);
+
this.__ajaxStartTrigger = $.proxy(function() {
this.trigger("dialog2.ajax-start");
}, handle);
@@ -67,12 +76,12 @@
this.__removeDialog = $.proxy(this.__remove, this);
handle.bind("dialog2.ajax-start", function() {
- dialog.options({buttons: options.autoAddCancelButton ? localizedCancelButton() : {}});
+ dialog.options({buttons: options.autoAddCancelButton ? localizedCancelButton() : null});
handle.parent().addClass("loading");
});
handle.bind("dialog2.content-update", function() {
- dialog.__ajaxify();
+ dialog.__ajaxify(options);
dialog.__updateMarkup();
dialog.__focus();
});
@@ -83,7 +92,12 @@
// Apply options to make title and stuff shine
this.options(options);
-
+
+ //add load content process
+ if (options.url){
+ this.load(options.url);
+ }
+
// We will ajaxify its contents when its new
// aka apply ajax styles in case this is a inpage dialog
handle.trigger("dialog2.content-update");
@@ -166,6 +180,7 @@
this.__overlay = handle.parent().prev(".modal-backdrop");
this.__addFocusCatchers(parentHtml);
+
},
__addFocusCatchers: function(parentHandle) {
@@ -179,7 +194,7 @@
__updateMarkup: function() {
var dialog = this;
var e = dialog.__handle;
-
+
e.trigger("dialog2.before-update-markup");
// New options for dialog
@@ -231,7 +246,7 @@
/**
* Apply ajax specific dialog behavior to the dialogs contents
*/
- __ajaxify: function() {
+ __ajaxify: function(options) {
var dialog = this;
var e = this.__handle;
@@ -246,19 +261,19 @@
// Make submitable for an ajax form
// if the jquery.form plugin is provided
if ($.fn.ajaxForm) {
- var options = {
+ var opts = $.extend({
target: e,
- success: dialog.__ajaxCompleteTrigger,
+ success: dialog.__ajaxFormSuccessTrigger,
beforeSubmit: dialog.__ajaxStartTrigger,
beforeSend: dialog.__ajaxBeforeSend,
error: function() {
throw dialogError("Form submit failed: " + $.makeArray(arguments));
}
- };
-
+ }, options.ajaxFormOptions || {});
+
$("form.ajax", e)
.removeClass("ajax")
- .ajaxForm(options);
+ .ajaxForm(opts);
}
e.trigger("dialog2.after-ajaxify");
@@ -279,7 +294,9 @@
*
* @param backwards whether to focus backwards or not
*/
- __focus: function(backwards) {
+ __focus: function(backwards, focus) {
+ if (!(focus ||this.options.autoFocus)) return;
+
var dialog = this.__handle;
// Focus first focusable element in dialog
@@ -310,7 +327,7 @@
* focusable element in it (e.g. a link or a button on the button bar).
*/
focus: function() {
- return this.__focus();
+ return this.__focus('first', true);
},
/**
@@ -324,6 +341,7 @@
overlay.hide();
dialog
+ .trigger("dialog2.beforeClose")
.parent().hide().end()
.trigger("dialog2.closed")
.removeClass("opened");
@@ -389,7 +407,6 @@
*/
removeButton: function(name) {
var footer = this.__handle.siblings(".modal-footer");
-
footer
.find("a.btn")
.filter(function(i, e) {return $(e).text() == name;})
@@ -494,7 +511,7 @@
this.load(options.content);
}
- delete options.buttons;
+ //delete options.buttons;
options = $.extend(true, {}, storedOptions, options);
this.__handle.data("options", options);
@@ -657,7 +674,10 @@
showCloseHandle: true,
initialLoadText: "",
closeOnEscape: true,
- beforeSend: null
+ beforeSend: null,
+ autoFocus: true,
+ url: null,
+ ajaxFormOptions: null
};
/***********************************************************************
View
65 plugs/ui/bootstrap/templates/inc_jquery_dialog2.html
@@ -1,5 +1,70 @@
{{use "jqdialog2"}}
+{{use "poshytip"}}
<script>
+
+ common_ajaxForm_success = function(options){
+ return function(r){
+ var opts = {
+ success:null,
+ message: show_message,
+ done:null,
+ error:null,
+ message_type:'bootstrap'
+ };
+ if (typeof options === 'function'){
+ opts.success = options;
+ }else{
+ opts = $.extend(opts, options);
+ }
+ if (r.success){
+ opts.message(r.message||'');
+ if(opts.success) opts.success.call(this, r);
+ if(opts.done) opts.done.call(this, r);
+ }else{
+ if(opts.error) opts.error.call(this, r);
+ else{
+ if(opts.message_type == 'bootstrap'){
+ $('div.control-group').removeClass('error').find('.help-block.error').remove();
+ opts.message(r.message, 'error');
+ $.each(r.data, function(key, value){
+ var f, t;
+ f = '#div_field_' + key;
+ t = $(f).addClass('error');
+ t.find('.controls').append('<p class="help-block error">'+value+'</p>');
+ });
+ }else if(opts.message_type == 'tip'){
+ var t = $(this);
+ $('body').on('dialog2.beforeClose', t, function(e){
+ t.find('input, select, textarea').poshytip('hide');
+ });
+ t.find('input, select, textarea').poshytip('hide');
+ $.each(r.data, function(key, value){
+ var el = t.find('input[name='+key+'],select[name='+key+'],textarea[name='+key+']');
+ if (el.is(':hidden')){
+ el = el.parent();
+ }
+ $(el).poshytip({
+ className: 'tip-yellowsimple',
+ content: value,
+ showOn: 'none',
+ alignTo: 'target',
+ alignX: 'inner-left',
+ offsetX: 0,
+ offsetY: 5,
+ closeButton: true
+ });
+ $(el).poshytip('show');
+ $(el).focus(function(){
+ $(this).poshytip('hide');
+ });
+ });
+ }
+ }
+ }
+ };
+ }
+
+
$(function(){
$(document).controls();
View
3 plugs/ui/jquery/jqutils/static/jqutils/jqrselect.js
@@ -138,7 +138,8 @@
this.element.val('');
},
options:{
- showRemoveable:true
+ showRemoveable:true,
+ url:null
},
destroy: function() {
this.input.remove();
View
2 plugs/ui/jquery/poshytip/static/poshytip/tip-darkgray/tip-darkgray.css
@@ -1,6 +1,6 @@
.tip-darkgray {
opacity:0.95;
- z-index:1000;
+ z-index:2000;
text-align:left;
text-shadow:#444 0 1px 1px;
border:1px solid #888;
View
2 plugs/ui/jquery/poshytip/static/poshytip/tip-green/tip-green.css
@@ -1,5 +1,5 @@
.tip-green {
- z-index:1000;
+ z-index:2000;
text-align:left;
border:1px solid #bdde98;
padding:7px 10px;
View
2 plugs/ui/jquery/poshytip/static/poshytip/tip-skyblue/tip-skyblue.css
@@ -1,5 +1,5 @@
.tip-skyblue {
- z-index:1000;
+ z-index:2000;
text-align:left;
padding:8px 10px;
min-width:50px;
View
2 plugs/ui/jquery/poshytip/static/poshytip/tip-twitter/tip-twitter.css
@@ -1,6 +1,6 @@
.tip-twitter {
opacity:0.8;
- z-index:1000;
+ z-index:2000;
text-align:left;
border-radius:4px;
-moz-border-radius:4px;
View
2 plugs/ui/jquery/poshytip/static/poshytip/tip-violet/tip-violet.css
@@ -1,5 +1,5 @@
.tip-violet {
- z-index:1000;
+ z-index:2000;
text-align:left;
border:1px solid #afafaf;
padding:7px;
View
2 plugs/ui/jquery/poshytip/static/poshytip/tip-yellow/tip-yellow.css
@@ -1,5 +1,5 @@
.tip-yellow {
- z-index:1000;
+ z-index:2000;
text-align:left;
border:1px solid #939393;
padding:7px;
View
2 plugs/ui/jquery/poshytip/static/poshytip/tip-yellowsimple/tip-yellowsimple.css
@@ -1,5 +1,5 @@
.tip-yellowsimple {
- z-index:1000;
+ z-index:2000;
text-align:left;
border:1px solid #c7bf93;
border-radius:4px;

0 comments on commit b44a01c

Please sign in to comment.