- _get_options: function() {
- var self = this;
- var o = _.extend({}, this.dialog_options);
- var sizes = {
- width: $(window.top).width(),
- height: $(window.top).height(),
- };
- _.each(sizes, function(available_size, unit) {
- o[unit] = self._get_size(o[unit], available_size);
- o['min_' + unit] = self._get_size(o['min_' + unit] || 0, available_size);
- o['max_' + unit] = self._get_size(o['max_' + unit] || 0, available_size);
- if (o[unit] !== 'auto' && o['min_' + unit] && o[unit] < o['min_' + unit]) {
- o[unit] = o['min_' + unit];
- }
- if (o[unit] !== 'auto' && o['max_' + unit] && o[unit] > o['max_' + unit]) {
- o[unit] = o['max_' + unit];
- }
- });
- var layout_inner = {};
- var layout_outer = {};
- _.each(o, function(value,key){
- if (_.contains(self.css_layout_inner, ''+key+'')){
- layout_inner[key] = value;
- delete o[key];
- }
- if (_.contains(self.css_layout_outer, ''+key+'')){
- layout_outer[key] = value;
- delete o[key];
- }
- });
- o.layout_inner = layout_inner;
- o.layout_outer = layout_outer;
- o.title = o.title || this.dialog_title;
- return o;
- },
- _get_size: function(val, available_size) {
- val = val.toString();
- if (val === 'auto') {
- return val;
- } else if (val.slice(-1) === "%") {
- return Math.round(available_size / 100 * parseInt(val.slice(0, -1), 10));
- } else {
- return parseInt(val, 10);
- }
- },