active_administration 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +2 -1
- data/active_administration.gemspec +2 -1
- data/app/assets/javascripts/active_administration/README.md +0 -0
- data/app/assets/javascripts/active_administration/metro-accordion.js +70 -0
- data/app/assets/javascripts/active_administration/metro-button-set.js +88 -0
- data/app/assets/javascripts/active_administration/metro-calendar.js +437 -0
- data/app/assets/javascripts/active_administration/metro-carousel.js +304 -0
- data/app/assets/javascripts/active_administration/metro-core.js +39 -0
- data/app/assets/javascripts/active_administration/metro-countdown.js +200 -0
- data/app/assets/javascripts/active_administration/metro-date-format.js +137 -0
- data/app/assets/javascripts/active_administration/metro-datepicker.js +138 -0
- data/app/assets/javascripts/active_administration/metro-dialog.js +221 -0
- data/app/assets/javascripts/active_administration/metro-drag-tile.js +46 -0
- data/app/assets/javascripts/active_administration/metro-dropdown.js +112 -0
- data/app/assets/javascripts/active_administration/metro-fluentmenu.js +57 -0
- data/app/assets/javascripts/active_administration/metro-global.js +4 -0
- data/app/assets/javascripts/active_administration/metro-hint.js +104 -0
- data/app/assets/javascripts/active_administration/metro-initiator.js +271 -0
- data/app/assets/javascripts/active_administration/metro-input-control.js +318 -0
- data/app/assets/javascripts/active_administration/metro-listview.js +53 -0
- data/app/assets/javascripts/active_administration/metro-live-tile.js +162 -0
- data/app/assets/javascripts/active_administration/metro-loader.js +46 -0
- data/app/assets/javascripts/active_administration/metro-locale.js +132 -0
- data/app/assets/javascripts/active_administration/metro-notify.js +120 -0
- data/app/assets/javascripts/active_administration/metro-panel.js +41 -0
- data/app/assets/javascripts/active_administration/metro-plugin-template.js +21 -0
- data/app/assets/javascripts/active_administration/metro-progressbar.js +97 -0
- data/app/assets/javascripts/active_administration/metro-pull.js +38 -0
- data/app/assets/javascripts/active_administration/metro-rating.js +99 -0
- data/app/assets/javascripts/active_administration/metro-scroll.js +756 -0
- data/app/assets/javascripts/active_administration/metro-slider.js +304 -0
- data/app/assets/javascripts/active_administration/metro-stepper.js +105 -0
- data/app/assets/javascripts/active_administration/metro-streamer.js +214 -0
- data/app/assets/javascripts/active_administration/metro-tab-control.js +96 -0
- data/app/assets/javascripts/active_administration/metro-table.js +74 -0
- data/app/assets/javascripts/active_administration/metro-tile-transform.js +65 -0
- data/app/assets/javascripts/active_administration/metro-times.js +190 -0
- data/app/assets/javascripts/active_administration/metro-touch-handler.js +65 -0
- data/app/assets/javascripts/active_administration/metro-treeview.js +64 -0
- data/app/assets/javascripts/active_administration/metro-wizard.js +148 -0
- data/app/assets/stylesheets/active_administration/accordion.less +64 -0
- data/app/assets/stylesheets/active_administration/balloon.less +88 -0
- data/app/assets/stylesheets/active_administration/breadcrumbs.less +118 -0
- data/app/assets/stylesheets/active_administration/buttons.less +383 -0
- data/app/assets/stylesheets/active_administration/calendar.less +123 -0
- data/app/assets/stylesheets/active_administration/carousel.less +118 -0
- data/app/assets/stylesheets/active_administration/colors.less +589 -0
- data/app/assets/stylesheets/active_administration/countdown.less +57 -0
- data/app/assets/stylesheets/active_administration/dataTables.less +134 -0
- data/app/assets/stylesheets/active_administration/fluent-menu.less +231 -0
- data/app/assets/stylesheets/active_administration/forms.less +414 -0
- data/app/assets/stylesheets/active_administration/funcs.less +178 -0
- data/app/assets/stylesheets/active_administration/grid.less +91 -0
- data/app/assets/stylesheets/active_administration/hint.less +120 -0
- data/app/assets/stylesheets/active_administration/iconFont-content.less +1353 -0
- data/app/assets/stylesheets/active_administration/iconFont.less +47 -0
- data/app/assets/stylesheets/active_administration/icons.less +10 -0
- data/app/assets/stylesheets/active_administration/images.less +75 -0
- data/app/assets/stylesheets/active_administration/layout.less +137 -0
- data/app/assets/stylesheets/active_administration/lists.less +258 -0
- data/app/assets/stylesheets/active_administration/menus.less +469 -0
- data/app/assets/stylesheets/active_administration/metro-bootstrap-responsive.less +300 -0
- data/app/assets/stylesheets/active_administration/metro-bootstrap.less +68 -0
- data/app/assets/stylesheets/active_administration/misc.less +72 -0
- data/app/assets/stylesheets/active_administration/navigation-bar.less +317 -0
- data/app/assets/stylesheets/active_administration/notice.less +52 -0
- data/app/assets/stylesheets/active_administration/notify.less +43 -0
- data/app/assets/stylesheets/active_administration/pagination.less +83 -0
- data/app/assets/stylesheets/active_administration/panels.less +38 -0
- data/app/assets/stylesheets/active_administration/progress-bar.less +25 -0
- data/app/assets/stylesheets/active_administration/rating.less +103 -0
- data/app/assets/stylesheets/active_administration/reset.less +219 -0
- data/app/assets/stylesheets/active_administration/scroll.less +141 -0
- data/app/assets/stylesheets/active_administration/sidebar.less +158 -0
- data/app/assets/stylesheets/active_administration/slider.less +106 -0
- data/app/assets/stylesheets/active_administration/stepper.less +80 -0
- data/app/assets/stylesheets/active_administration/streamer.less +250 -0
- data/app/assets/stylesheets/active_administration/tab-control.less +79 -0
- data/app/assets/stylesheets/active_administration/tables.less +170 -0
- data/app/assets/stylesheets/active_administration/tiles.less +599 -0
- data/app/assets/stylesheets/active_administration/transform.less +23 -0
- data/app/assets/stylesheets/active_administration/treeview.less +96 -0
- data/app/assets/stylesheets/active_administration/typography.less +382 -0
- data/app/assets/stylesheets/active_administration/utils.less +180 -0
- data/app/assets/stylesheets/active_administration/variables.less +250 -0
- data/app/assets/stylesheets/active_administration/window.less +225 -0
- data/app/assets/stylesheets/active_administration/wizard.less +53 -0
- data/lib/active_admin/version.rb +1 -1
- metadata +103 -10
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Date Format 1.2.3
|
|
3
|
+
* (c) 2007-2009 Steven Levithan <stevenlevithan.com>
|
|
4
|
+
* MIT license
|
|
5
|
+
*
|
|
6
|
+
* Includes enhancements by Scott Trenda <scott.trenda.net>
|
|
7
|
+
* and Kris Kowal <cixar.com/~kris.kowal/>
|
|
8
|
+
*
|
|
9
|
+
* Accepts a date, a mask, or a date and a mask.
|
|
10
|
+
* Returns a formatted version of the given date.
|
|
11
|
+
* The date defaults to the current date/time.
|
|
12
|
+
* The mask defaults to dateFormat.masks.default.
|
|
13
|
+
*/
|
|
14
|
+
// this is a temporary solution
|
|
15
|
+
|
|
16
|
+
var dateFormat = function () {
|
|
17
|
+
var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
|
|
18
|
+
timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
|
|
19
|
+
timezoneClip = /[^-+\dA-Z]/g,
|
|
20
|
+
pad = function (val, len) {
|
|
21
|
+
val = String(val);
|
|
22
|
+
len = len || 2;
|
|
23
|
+
while (val.length < len) val = "0" + val;
|
|
24
|
+
return val;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// Regexes and supporting functions are cached through closure
|
|
28
|
+
return function (date, mask, utc) {
|
|
29
|
+
var dF = dateFormat;
|
|
30
|
+
|
|
31
|
+
// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
|
|
32
|
+
if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
|
|
33
|
+
mask = date;
|
|
34
|
+
date = undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//console.log(arguments);
|
|
38
|
+
|
|
39
|
+
// Passing date through Date applies Date.parse, if necessary
|
|
40
|
+
date = date ? new Date(date) : new Date;
|
|
41
|
+
//if (isNaN(date)) throw SyntaxError("invalid date");
|
|
42
|
+
|
|
43
|
+
mask = String(dF.masks[mask] || mask || dF.masks["default"]);
|
|
44
|
+
|
|
45
|
+
// Allow setting the utc argument via the mask
|
|
46
|
+
if (mask.slice(0, 4) == "UTC:") {
|
|
47
|
+
mask = mask.slice(4);
|
|
48
|
+
utc = true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//console.log(locale);
|
|
52
|
+
|
|
53
|
+
locale = $.Metro.currentLocale;
|
|
54
|
+
|
|
55
|
+
var _ = utc ? "getUTC" : "get",
|
|
56
|
+
d = date[_ + "Date"](),
|
|
57
|
+
D = date[_ + "Day"](),
|
|
58
|
+
m = date[_ + "Month"](),
|
|
59
|
+
y = date[_ + "FullYear"](),
|
|
60
|
+
H = date[_ + "Hours"](),
|
|
61
|
+
M = date[_ + "Minutes"](),
|
|
62
|
+
s = date[_ + "Seconds"](),
|
|
63
|
+
L = date[_ + "Milliseconds"](),
|
|
64
|
+
o = utc ? 0 : date.getTimezoneOffset(),
|
|
65
|
+
flags = {
|
|
66
|
+
d: d,
|
|
67
|
+
dd: pad(d),
|
|
68
|
+
ddd: $.Metro.Locale[locale].days[D],
|
|
69
|
+
dddd: $.Metro.Locale[locale].days[D + 7],
|
|
70
|
+
m: m + 1,
|
|
71
|
+
mm: pad(m + 1),
|
|
72
|
+
mmm: $.Metro.Locale[locale].months[m],
|
|
73
|
+
mmmm: $.Metro.Locale[locale].months[m + 12],
|
|
74
|
+
yy: String(y).slice(2),
|
|
75
|
+
yyyy: y,
|
|
76
|
+
h: H % 12 || 12,
|
|
77
|
+
hh: pad(H % 12 || 12),
|
|
78
|
+
H: H,
|
|
79
|
+
HH: pad(H),
|
|
80
|
+
M: M,
|
|
81
|
+
MM: pad(M),
|
|
82
|
+
s: s,
|
|
83
|
+
ss: pad(s),
|
|
84
|
+
l: pad(L, 3),
|
|
85
|
+
L: pad(L > 99 ? Math.round(L / 10) : L),
|
|
86
|
+
t: H < 12 ? "a" : "p",
|
|
87
|
+
tt: H < 12 ? "am" : "pm",
|
|
88
|
+
T: H < 12 ? "A" : "P",
|
|
89
|
+
TT: H < 12 ? "AM" : "PM",
|
|
90
|
+
Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
|
|
91
|
+
o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
|
|
92
|
+
S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
return mask.replace(token, function ($0) {
|
|
96
|
+
return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
}();
|
|
100
|
+
|
|
101
|
+
// Some common format strings
|
|
102
|
+
dateFormat.masks = {
|
|
103
|
+
"default": "ddd mmm dd yyyy HH:MM:ss",
|
|
104
|
+
shortDate: "m/d/yy",
|
|
105
|
+
mediumDate: "mmm d, yyyy",
|
|
106
|
+
longDate: "mmmm d, yyyy",
|
|
107
|
+
fullDate: "dddd, mmmm d, yyyy",
|
|
108
|
+
shortTime: "h:MM TT",
|
|
109
|
+
mediumTime: "h:MM:ss TT",
|
|
110
|
+
longTime: "h:MM:ss TT Z",
|
|
111
|
+
isoDate: "yyyy-mm-dd",
|
|
112
|
+
isoTime: "HH:MM:ss",
|
|
113
|
+
isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
|
|
114
|
+
isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// Internationalization strings
|
|
118
|
+
dateFormat.i18n = {
|
|
119
|
+
dayNames: [
|
|
120
|
+
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
|
|
121
|
+
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
|
|
122
|
+
],
|
|
123
|
+
monthNames: [
|
|
124
|
+
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
|
125
|
+
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
|
|
126
|
+
]
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// For convenience...
|
|
130
|
+
Date.prototype.format = function (mask, utc) {
|
|
131
|
+
return dateFormat(this, mask, utc);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/*
|
|
135
|
+
* End date format
|
|
136
|
+
*/
|
|
137
|
+
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// DatePicker
|
|
2
|
+
|
|
3
|
+
(function( $ ) {
|
|
4
|
+
$.widget("metro.datepicker", {
|
|
5
|
+
|
|
6
|
+
version: "1.0.0",
|
|
7
|
+
|
|
8
|
+
options: {
|
|
9
|
+
format: "dd.mm.yyyy",
|
|
10
|
+
date: undefined,
|
|
11
|
+
effect: 'none',
|
|
12
|
+
position: 'bottom',
|
|
13
|
+
locale: $.Metro.currentLocale,
|
|
14
|
+
weekStart: (METRO_WEEK_START != undefined ? METRO_WEEK_START : 0), // 0 - Sunday, 1 - Monday
|
|
15
|
+
otherDays: false,
|
|
16
|
+
selected: function(d, d0){},
|
|
17
|
+
_calendar: undefined
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
_create: function(){
|
|
22
|
+
var that = this,
|
|
23
|
+
element = this.element,
|
|
24
|
+
input = element.children("input"),
|
|
25
|
+
button = element.children("button.btn-date");
|
|
26
|
+
|
|
27
|
+
if (element.data('date') != undefined) this.options.date = element.data('date');
|
|
28
|
+
if (element.data('format') != undefined) this.options.format = element.data('format');
|
|
29
|
+
if (element.data('effect') != undefined) this.options.effect = element.data('effect');
|
|
30
|
+
if (element.data('position') != undefined) this.options.position = element.data('position');
|
|
31
|
+
if (element.data('locale') != undefined) this.options.locale = element.data('locale');
|
|
32
|
+
if (element.data('weekStart') != undefined) this.options.weekStart = element.data('weekStart');
|
|
33
|
+
if (element.data('otherDays') != undefined) this.options.otherDays = element.data('otherDays');
|
|
34
|
+
|
|
35
|
+
this._createCalendar(element, this.options.date);
|
|
36
|
+
|
|
37
|
+
input.attr('readonly', true);
|
|
38
|
+
|
|
39
|
+
button.on('click', function(e){
|
|
40
|
+
e.stopPropagation();
|
|
41
|
+
if (that.options._calendar.css('display') == 'none') {
|
|
42
|
+
that._show();
|
|
43
|
+
} else {
|
|
44
|
+
that._hide();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
element.on('click', function(e){
|
|
49
|
+
e.stopPropagation();
|
|
50
|
+
if (that.options._calendar.css('display') == 'none') {
|
|
51
|
+
that._show();
|
|
52
|
+
} else {
|
|
53
|
+
that._hide();
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
$('html').on('click', function(e){
|
|
58
|
+
$(".calendar-dropdown").hide();
|
|
59
|
+
})
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
_createCalendar: function(to, curDate){
|
|
63
|
+
var _calendar, that = this;
|
|
64
|
+
|
|
65
|
+
_calendar = $("<div/>").css({
|
|
66
|
+
position: 'absolute'
|
|
67
|
+
, display: 'none'
|
|
68
|
+
, 'max-width': 260
|
|
69
|
+
, 'z-index': 1000
|
|
70
|
+
|
|
71
|
+
}).addClass('calendar calendar-dropdown').appendTo(to);
|
|
72
|
+
|
|
73
|
+
if (that.options.date != undefined) {
|
|
74
|
+
_calendar.data('date', that.options.date);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
_calendar.calendar({
|
|
78
|
+
multiSelect: false,
|
|
79
|
+
format: that.options.format,
|
|
80
|
+
buttons: false,
|
|
81
|
+
locale: that.options.locale,
|
|
82
|
+
otherDays: that.options.otherDays,
|
|
83
|
+
weekStart: that.options.weekStart,
|
|
84
|
+
click: function(d, d0){
|
|
85
|
+
//console.log(d, d0);
|
|
86
|
+
_calendar.calendar('setDate', d0);
|
|
87
|
+
to.children("input[type=text]").val(d);
|
|
88
|
+
that.options.selected(d, d0);
|
|
89
|
+
that._hide();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (curDate != undefined) {
|
|
94
|
+
_calendar.calendar('setDate', curDate);
|
|
95
|
+
to.children("input[type=text]").val(_calendar.calendar('getDate'));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Set position
|
|
99
|
+
switch (this.options.position) {
|
|
100
|
+
case 'top': _calendar.css({top: (0-_calendar.height()), left: 0}); break;
|
|
101
|
+
default: _calendar.css({top: '100%', left: 0});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this.options._calendar = _calendar;
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
_show: function(){
|
|
108
|
+
if (this.options.effect == 'slide') {
|
|
109
|
+
$(".calendar-dropdown").slideUp('fast');
|
|
110
|
+
this.options._calendar.slideDown('fast');
|
|
111
|
+
} else if (this.options.effect == 'fade') {
|
|
112
|
+
$(".calendar-dropdown").fadeOut('fast');
|
|
113
|
+
this.options._calendar.fadeIn('fast');
|
|
114
|
+
} else {
|
|
115
|
+
$(".calendar-dropdown").hide();
|
|
116
|
+
this.options._calendar.show();
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
_hide: function(){
|
|
120
|
+
if (this.options.effect == 'slide') {
|
|
121
|
+
this.options._calendar.slideUp('fast');
|
|
122
|
+
} else if (this.options.effect == 'fade') {
|
|
123
|
+
this.options._calendar.fadeOut('fast');
|
|
124
|
+
} else {
|
|
125
|
+
this.options._calendar.hide();
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
_destroy: function(){
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
_setOption: function(key, value){
|
|
133
|
+
this._super('_setOption', key, value);
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
})( jQuery );
|
|
137
|
+
|
|
138
|
+
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
(function($) {
|
|
2
|
+
if (METRO_DIALOG == undefined) {
|
|
3
|
+
//var METRO_DIALOG = false;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
$.Dialog = function(params) {
|
|
7
|
+
if(!$.Dialog.opened) {
|
|
8
|
+
$.Dialog.opened = true;
|
|
9
|
+
} else {
|
|
10
|
+
return METRO_DIALOG;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
$.Dialog.settings = params;
|
|
14
|
+
|
|
15
|
+
params = $.extend({
|
|
16
|
+
icon: false,
|
|
17
|
+
title: '',
|
|
18
|
+
content: '',
|
|
19
|
+
flat: false,
|
|
20
|
+
shadow: false,
|
|
21
|
+
overlay: false,
|
|
22
|
+
width: 'auto',
|
|
23
|
+
height: 'auto',
|
|
24
|
+
position: 'default',
|
|
25
|
+
padding: false,
|
|
26
|
+
overlayClickClose: true,
|
|
27
|
+
sysButtons: {
|
|
28
|
+
btnClose: true
|
|
29
|
+
},
|
|
30
|
+
onShow: function(_dialog){},
|
|
31
|
+
sysBtnCloseClick: function(event){},
|
|
32
|
+
sysBtnMinClick: function(event){},
|
|
33
|
+
sysBtnMaxClick: function(event){}
|
|
34
|
+
}, params);
|
|
35
|
+
|
|
36
|
+
var _overlay, _window, _caption, _content;
|
|
37
|
+
|
|
38
|
+
_overlay = $("<div/>").addClass("metro window-overlay");
|
|
39
|
+
|
|
40
|
+
if (params.overlay) {
|
|
41
|
+
_overlay.css({
|
|
42
|
+
backgroundColor: 'rgba(0,0,0,.7)'
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_window = $("<div/>").addClass("window");
|
|
47
|
+
if (params.flat) _window.addClass("flat");
|
|
48
|
+
if (params.shadow) _window.addClass("shadow").css('overflow', 'hidden');
|
|
49
|
+
_caption = $("<div/>").addClass("caption");
|
|
50
|
+
_content = $("<div/>").addClass("content");
|
|
51
|
+
_content.css({
|
|
52
|
+
paddingTop: 32 + params.padding,
|
|
53
|
+
paddingLeft: params.padding,
|
|
54
|
+
paddingRight: params.padding,
|
|
55
|
+
paddingBottom: params.padding
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
if (params.sysButtons) {
|
|
59
|
+
if (params.sysButtons.btnClose) {
|
|
60
|
+
$("<button/>").addClass("btn-close").on('click', function(e){
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
e.stopPropagation();
|
|
63
|
+
$.Dialog.close();
|
|
64
|
+
params.sysBtnCloseClick(e);
|
|
65
|
+
}).appendTo(_caption);
|
|
66
|
+
}
|
|
67
|
+
if (params.sysButtons.btnMax) {
|
|
68
|
+
$("<button/>").addClass("btn-max").on('click', function(e){
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
params.sysBtnMaxClick(e);
|
|
72
|
+
}).appendTo(_caption);
|
|
73
|
+
}
|
|
74
|
+
if (params.sysButtons.btnMin) {
|
|
75
|
+
$("<button/>").addClass("btn-min").on('click', function(e){
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
e.stopPropagation();
|
|
78
|
+
params.sysBtnMinClick(e);
|
|
79
|
+
}).appendTo(_caption);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (params.icon) $(params.icon).addClass("icon").appendTo(_caption);
|
|
84
|
+
$("<div/>").addClass("title").html(params.title).appendTo(_caption);
|
|
85
|
+
|
|
86
|
+
_content.html(params.content);
|
|
87
|
+
|
|
88
|
+
_caption.appendTo(_window);
|
|
89
|
+
_content.appendTo(_window);
|
|
90
|
+
_window.appendTo(_overlay);
|
|
91
|
+
|
|
92
|
+
if (params.width != 'auto') _window.css('min-width', params.width);
|
|
93
|
+
if (params.height != 'auto') _window.css('min-height', params.height);
|
|
94
|
+
|
|
95
|
+
_overlay.hide().appendTo('body').fadeIn('fast');
|
|
96
|
+
|
|
97
|
+
METRO_DIALOG = _window;
|
|
98
|
+
|
|
99
|
+
_window
|
|
100
|
+
.css("position", "fixed")
|
|
101
|
+
.css("z-index", parseInt(_overlay.css('z-index'))+1)
|
|
102
|
+
.css("top", ($(window).height() - METRO_DIALOG.outerHeight()) / 2 )
|
|
103
|
+
.css("left", ($(window).width() - _window.outerWidth()) / 2)
|
|
104
|
+
;
|
|
105
|
+
|
|
106
|
+
addTouchEvents(_window[0]);
|
|
107
|
+
|
|
108
|
+
if(params.draggable) {
|
|
109
|
+
_caption.on("mousedown", function(e) {
|
|
110
|
+
$.Dialog.drag = true;
|
|
111
|
+
_caption.css('cursor', 'move');
|
|
112
|
+
|
|
113
|
+
var z_idx = _window.css('z-index'),
|
|
114
|
+
drg_h = _window.outerHeight(),
|
|
115
|
+
drg_w = _window.outerWidth(),
|
|
116
|
+
pos_y = _window.offset().top + drg_h - e.pageY,
|
|
117
|
+
pos_x = _window.offset().left + drg_w - e.pageX;
|
|
118
|
+
|
|
119
|
+
_window.css('z-index', 99999).parents().on("mousemove", function(e) {
|
|
120
|
+
var t = (e.pageY > 0)?(e.pageY + pos_y - drg_h):(0);
|
|
121
|
+
var l = (e.pageX > 0)?(e.pageX + pos_x - drg_w):(0);
|
|
122
|
+
|
|
123
|
+
if ($.Dialog.drag) {
|
|
124
|
+
if(t >= 0 && t <= window.innerHeight - _window.outerHeight()) {
|
|
125
|
+
_window.offset({top: t});
|
|
126
|
+
}
|
|
127
|
+
if(l >= 0 && l <= window.innerWidth - _window.outerWidth()) {
|
|
128
|
+
_window.offset({left: l});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
}).on("mouseup", function() {
|
|
134
|
+
_window.removeClass('draggable');
|
|
135
|
+
$.Dialog.drag = false;
|
|
136
|
+
_caption.css('cursor', 'default');
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
_window.on('click', function(e){
|
|
141
|
+
e.stopPropagation();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
if (params.overlayClickClose) {
|
|
145
|
+
_overlay.on('click', function(e){
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
$.Dialog.close();
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
params.onShow(METRO_DIALOG);
|
|
152
|
+
|
|
153
|
+
$.Dialog.autoResize();
|
|
154
|
+
|
|
155
|
+
return METRO_DIALOG;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
$.Dialog.content = function(newContent) {
|
|
159
|
+
if(!$.Dialog.opened || METRO_DIALOG == undefined) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if(newContent) {
|
|
164
|
+
METRO_DIALOG.children(".content").html(newContent);
|
|
165
|
+
$.Dialog.autoResize();
|
|
166
|
+
return true;
|
|
167
|
+
} else {
|
|
168
|
+
return METRO_DIALOG.children(".content").html();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
$.Dialog.title = function(newTitle) {
|
|
173
|
+
if(!$.Dialog.opened || METRO_DIALOG == undefined) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
var _title = METRO_DIALOG.children('.caption').children('.title');
|
|
178
|
+
|
|
179
|
+
if(newTitle) {
|
|
180
|
+
_title.html(newTitle);
|
|
181
|
+
} else {
|
|
182
|
+
_title.html();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
$.Dialog.autoResize = function(){
|
|
189
|
+
if(!$.Dialog.opened || METRO_DIALOG == undefined) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
var _content = METRO_DIALOG.children(".content");
|
|
194
|
+
|
|
195
|
+
var top = ($(window).height() - METRO_DIALOG.outerHeight()) / 2;
|
|
196
|
+
var left = ($(window).width() - METRO_DIALOG.outerWidth()) / 2;
|
|
197
|
+
|
|
198
|
+
METRO_DIALOG.css({
|
|
199
|
+
width: _content.outerWidth(),
|
|
200
|
+
height: _content.outerHeight(),
|
|
201
|
+
top: top,
|
|
202
|
+
left: left
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
$.Dialog.close = function() {
|
|
209
|
+
if(!$.Dialog.opened || METRO_DIALOG == undefined) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
$.Dialog.opened = false;
|
|
214
|
+
var _overlay = METRO_DIALOG.parent(".window-overlay");
|
|
215
|
+
_overlay.fadeOut(function(){
|
|
216
|
+
$(this).remove();
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
})(jQuery);
|