drg_cms 0.7.0.2 → 0.7.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/drg_cms/drg_cms.js +110 -35
- data/app/assets/javascripts/drg_cms/jquery.bpopup.js +372 -0
- data/app/assets/javascripts/drg_cms_application.js +1 -1
- data/app/assets/javascripts/drg_cms_cms.js +1 -1
- data/app/assets/stylesheets/drg_cms/drg_cms.css +126 -36
- data/app/assets/stylesheets/drg_cms/select-multiple.css +6 -7
- data/app/controllers/cmsedit_controller.rb +78 -47
- data/app/controllers/dc_application_controller.rb +22 -25
- data/app/controllers/dc_common_controller.rb +9 -6
- data/app/controllers/dc_main_controller.rb +0 -1
- data/app/controls/{dc_category_control.rb → dc_gallery_control.rb} +15 -30
- data/app/controls/dc_image_control.rb +180 -0
- data/app/controls/dc_page_control.rb +3 -3
- data/app/controls/dc_poll_result_control.rb +38 -39
- data/app/controls/dc_report.rb +9 -4
- data/app/controls/dc_setup_control.rb +53 -0
- data/app/controls/design_element_settings_control.rb +88 -37
- data/app/forms/all_options.yml +20 -9
- data/app/forms/cms_menu.yml +14 -2
- data/app/forms/dc_gallery.yml +1 -1
- data/app/forms/dc_image.yml +122 -0
- data/app/forms/dc_image_search.yml +72 -0
- data/app/forms/dc_page.yml +11 -8
- data/app/forms/dc_poll.yml +2 -1
- data/app/forms/dc_poll_result.yml +10 -7
- data/app/forms/dc_setup.yml +45 -0
- data/app/forms/dc_steps_template.yml +6 -2
- data/app/helpers/cms_common_helper.rb +36 -24
- data/app/helpers/cms_edit_helper.rb +26 -33
- data/app/helpers/cms_helper.rb +29 -12
- data/app/helpers/cms_index_helper.rb +109 -80
- data/app/helpers/dc_application_helper.rb +108 -86
- data/app/helpers/dc_image_helper.rb +127 -0
- data/app/models/concerns/dc_policy_rule_concern.rb +1 -1
- data/app/models/concerns/dc_user_concern.rb +13 -5
- data/app/models/dc_big_table.rb +1 -1
- data/app/models/dc_category.rb +12 -0
- data/app/models/dc_design.rb +5 -4
- data/app/models/dc_filter.rb +24 -27
- data/app/models/dc_image.rb +237 -0
- data/app/models/dc_internals.rb +5 -9
- data/app/models/dc_memory.rb +2 -2
- data/app/models/dc_policy_role.rb +8 -8
- data/app/models/dc_setup.rb +111 -0
- data/app/models/drgcms_form_fields/datetime_picker.rb +1 -1
- data/app/models/drgcms_form_fields/drgcms_field.rb +9 -26
- data/app/models/drgcms_form_fields/embedded.rb +28 -17
- data/app/models/drgcms_form_fields/journal_diff.rb +2 -2
- data/app/models/drgcms_form_fields/multitext_autocomplete.rb +88 -76
- data/app/models/drgcms_form_fields/select.rb +41 -19
- data/app/models/drgcms_form_fields/text_with_select.rb +5 -9
- data/app/renderers/dc_big_menu_renderer.rb +18 -20
- data/app/renderers/dc_gallery_renderer.rb +10 -4
- data/app/renderers/dc_menu_renderer.rb +21 -58
- data/app/renderers/dc_page_renderer.rb +7 -7
- data/app/renderers/dc_poll_renderer.rb +13 -12
- data/app/renderers/dc_simple_menu_renderer.rb +1 -1
- data/app/views/cmsedit/_edit_stuff.html.erb +4 -1
- data/app/views/cmsedit/edit.html.erb +1 -1
- data/app/views/cmsedit/index.html.erb +1 -1
- data/app/views/cmsedit/new.html.erb +1 -0
- data/config/locales/drgcms_en.yml +22 -2
- data/config/locales/drgcms_sl.yml +25 -6
- data/config/locales/models_en.yml +50 -1
- data/config/locales/models_sl.yml +60 -1
- data/drg_cms.gemspec +1 -1
- data/lib/drg_cms/version.rb +1 -1
- data/lib/drg_cms.rb +40 -27
- data/lib/generators/convert_to_ar/USAGE +8 -0
- data/lib/generators/convert_to_ar/convert_to_ar_generator.rb +158 -0
- data/lib/generators/new_drg_form/new_drg_form_generator.rb +32 -14
- metadata +19 -10
- data/app/assets/javascripts/drg_cms/jquery.bpopup.min.js +0 -7
- data/app/views/layouts/__cmsedit.html.erb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 836e52abeb4f9f04c54c21d66c4c053b5bc9cb8906904ce6c608b0c03edc57d7
|
4
|
+
data.tar.gz: 86469fb38b082d39f20ce81ee903354e11d693db34060a224cf031facd554b45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af0af1882f81f7240438b80a4138c415ada71850395ce149f3a9b4d30b5e8858081aad9a438e9a7a9749a8e75cc0b16775aec187785a765870d4d726aa4f66e1
|
7
|
+
data.tar.gz: d8c3c2d0184e4e97451962203a64d7d4a2e59dd08e5e48320d05f0203a12f8e50cbd0263958d2af189c7ef84f0627f95067558321fb0d44f4ce88b7683897b5d
|
@@ -87,19 +87,41 @@ confirmation_is_cancled = function(object) {
|
|
87
87
|
*******************************************************************/
|
88
88
|
update_select_depend = function(select_name, depend_name, method) {
|
89
89
|
let select_field = $('#' + select_name);
|
90
|
-
let
|
91
|
-
|
90
|
+
let depend_value= ''
|
91
|
+
let depend_field= null;
|
92
|
+
let field_value= null;
|
93
|
+
|
94
|
+
depend_name.split(",").forEach( function(depend) {
|
95
|
+
if ( $('#record_' + depend.trim()).length ) {
|
96
|
+
depend_field = $('#record_' + depend.trim());
|
97
|
+
} else {
|
98
|
+
depend_field = $('#_record_' + depend.trim()); // virtual field
|
99
|
+
}
|
100
|
+
|
101
|
+
// checkbox
|
102
|
+
if (depend_field.is(':checkbox')) {
|
103
|
+
field_value = depend_field.is(":checked");
|
104
|
+
} else {
|
105
|
+
field_value = depend_field.val();
|
106
|
+
}
|
107
|
+
|
108
|
+
if (depend_value.length > 0) depend_value = depend_value + ',';
|
109
|
+
depend_value = depend_value + field_value;
|
110
|
+
});
|
111
|
+
|
92
112
|
$.ajax({
|
93
113
|
url: "/dc_common/autocomplete",
|
94
114
|
type: "POST",
|
95
115
|
dataType: "json",
|
96
|
-
data: { input:
|
116
|
+
data: { input: depend_value, search: method},
|
97
117
|
success: function(data) {
|
98
118
|
|
99
119
|
select_field.empty();
|
100
120
|
$.each(data, function(index, element) {
|
101
121
|
select_field.append( new Option(element['label'], element['id']) );
|
102
122
|
});
|
123
|
+
// refresh multiple select field
|
124
|
+
if (select_field.hasClass('select-multiple')) { select_field.selectMultiple('refresh') }
|
103
125
|
}
|
104
126
|
});
|
105
127
|
};
|
@@ -272,10 +294,12 @@ process_json_result = function(json) {
|
|
272
294
|
closeClass: 'dc-link' });
|
273
295
|
}
|
274
296
|
else {
|
275
|
-
|
297
|
+
if (selector == '') { selector = 'info' }
|
298
|
+
let popup_html = '<div class="popup-' + selector + '">' + value + '<br><button class="dc-link">OK</button></div>';
|
299
|
+
$('#popup').html(popup_html);
|
276
300
|
$('#popup').bPopup( {
|
277
301
|
transition: 'slideDown', transitionClose: 'slideDown', speed: 300,
|
278
|
-
opacity: 0, position: ['auto',
|
302
|
+
opacity: 0, position: ['auto', 'auto'],
|
279
303
|
closeClass: 'dc-link' });
|
280
304
|
}
|
281
305
|
// resize parent iframe if smaller then 500px to ensure popup some space
|
@@ -478,14 +502,66 @@ function dc_url_add_params(form, url) {
|
|
478
502
|
*******************************************************************/
|
479
503
|
function dc_copy_to_clipboard(div) {
|
480
504
|
let copyText = document.getElementById(div).innerText;
|
481
|
-
console.log(copyText);
|
505
|
+
//console.log(copyText);
|
482
506
|
/* Copy the text inside the text field */
|
483
507
|
navigator.clipboard.writeText(copyText);
|
484
508
|
}
|
485
509
|
|
486
510
|
/*******************************************************************
|
487
|
-
*
|
511
|
+
* Image preview called in images manager. Preview image in bPopup window.
|
512
|
+
*******************************************************************/
|
513
|
+
dc_image_preview = function(img) {
|
514
|
+
$('#dc-image-preview').bPopup({
|
515
|
+
content: 'image',
|
516
|
+
contentContainer: '#dc-image-preview',
|
517
|
+
loadUrl: img,
|
518
|
+
opacity: 0
|
519
|
+
});
|
520
|
+
};
|
521
|
+
|
522
|
+
/*******************************************************************
|
523
|
+
* Image selected in images manager. Return selected image file name to caller.
|
524
|
+
*******************************************************************/
|
525
|
+
dc_image_select = function(img) {
|
526
|
+
let ck_func_name = $.getUrlParam('CKEditorFuncNum');
|
527
|
+
let field_name = $.getUrlParam('field_name');
|
528
|
+
if (ck_func_name) {
|
529
|
+
window.opener.CKEDITOR.tools.callFunction(ck_func_name, img);
|
530
|
+
} else {
|
531
|
+
window.opener.document.getElementById(field_name).value = img;
|
532
|
+
|
533
|
+
// update image preview
|
534
|
+
//let img_src = window.opener.$(`#td_${field_name} .dc-image-preview img`);
|
535
|
+
//img_src.attr("src", img);
|
536
|
+
|
537
|
+
// even better. Click save button.
|
538
|
+
window.opener.$(`.mi.mi-save`).first().click();
|
539
|
+
}
|
540
|
+
window.close();
|
541
|
+
};
|
542
|
+
|
543
|
+
/*******************************************************************
|
544
|
+
* Resize iframe_embedded to the size of form.
|
488
545
|
*******************************************************************/
|
546
|
+
function resize_iframe_embedded(that) {
|
547
|
+
let embedded_height = that.contentWindow.document.body.offsetHeight;
|
548
|
+
// workaround. It gets tricky when embedded field is on tab
|
549
|
+
if (embedded_height == 0) embedded_height = 50;
|
550
|
+
that.style.height = (embedded_height + 30) + 'px';
|
551
|
+
// resize parent element too
|
552
|
+
let parentWindow= that.contentWindow.parent;
|
553
|
+
let parent_height= (parentWindow.document.body.offsetHeight + 30) + 'px';
|
554
|
+
parentWindow.frameElement.style.height = parent_height;
|
555
|
+
};
|
556
|
+
|
557
|
+
|
558
|
+
/*******************************************************************
|
559
|
+
*
|
560
|
+
*
|
561
|
+
* EVENTS START HERE
|
562
|
+
*
|
563
|
+
*
|
564
|
+
********************************************************************/
|
489
565
|
$(document).ready( function() {
|
490
566
|
/* This could be the way to focus on first input field on document open
|
491
567
|
if ( $('.dc-form')[0] ) {
|
@@ -533,6 +609,7 @@ $(document).ready( function() {
|
|
533
609
|
$('.cms-toggle').bind('click', function(e) {
|
534
610
|
var url = '/dc_common/toggle_edit_mode?return_to=' + window.location.href;
|
535
611
|
if (e.pageX < 30) url = url + '&return_to_ypos=' + e.pageY ;
|
612
|
+
console.log(url);
|
536
613
|
window.location.href = url;
|
537
614
|
});
|
538
615
|
|
@@ -546,11 +623,12 @@ $(document).ready( function() {
|
|
546
623
|
/*******************************************************************
|
547
624
|
* Popup CMS edit menu option clicked
|
548
625
|
*******************************************************************/
|
549
|
-
$('.drgcms_popmenu_item').on('click',function(e) {
|
626
|
+
$('.drgcms_popmenu_item').on('click', function(e) {
|
550
627
|
let url = e.target.getAttribute("data-url");
|
628
|
+
if (url === null) { url = e.target.parentNode.getAttribute("data-url") };
|
629
|
+
|
551
630
|
$('#iframe_cms').attr('src', url);
|
552
|
-
//
|
553
|
-
// scroll to top of page and hide menu
|
631
|
+
// scroll to top of page and hide menu
|
554
632
|
window.scrollTo(0,0);
|
555
633
|
$(e.target).parents('dl:first').find('ul').toggleClass('div-hidden');
|
556
634
|
});
|
@@ -563,7 +641,6 @@ $(document).ready( function() {
|
|
563
641
|
let form = e.target.getAttribute("data-form");
|
564
642
|
if (form === null) form = table;
|
565
643
|
let sort = e.target.value;
|
566
|
-
// e.target.value = null;
|
567
644
|
let url = "/cmsedit/run?control=cmsedit.sort&sort=" + sort + "&table=" + table + "&form_name=" + form;
|
568
645
|
simple_ajax_call(url);
|
569
646
|
});
|
@@ -644,7 +721,7 @@ $(document).ready( function() {
|
|
644
721
|
});
|
645
722
|
|
646
723
|
/*******************************************************************
|
647
|
-
* Resize iframe_cms to the size of its contents. Make at least 500 px high
|
724
|
+
* Resize iframe_cms on load to the size of its contents. Make at least 500 px high
|
648
725
|
* unless on initial display.
|
649
726
|
*******************************************************************/
|
650
727
|
$('#iframe_cms').on('load', function() {
|
@@ -656,7 +733,7 @@ $(document).ready( function() {
|
|
656
733
|
});
|
657
734
|
|
658
735
|
/*******************************************************************
|
659
|
-
*
|
736
|
+
* Resize iframe_edit on load to the size of its contents. Resize it + 30px
|
660
737
|
* unless on initial display with no data
|
661
738
|
*******************************************************************/
|
662
739
|
$('#iframe_edit').on('load', function() {
|
@@ -668,18 +745,16 @@ $(document).ready( function() {
|
|
668
745
|
});
|
669
746
|
|
670
747
|
/*******************************************************************
|
671
|
-
*
|
748
|
+
* Resize iframe_embedded on load to the size of its contents.
|
749
|
+
* It doesn't work well with firefox, when CK editor object is on the form.
|
750
|
+
* Adding some delay is resolving the problem.
|
672
751
|
*******************************************************************/
|
673
752
|
$('.iframe_embedded').on('load', function() {
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
let parentWindow = this.contentWindow.parent;
|
680
|
-
let parent_height = (parentWindow.document.body.offsetHeight + 30) + 'px';
|
681
|
-
//parentWindow.frameElement.setAttribute('style', 'height:' + parent_height);
|
682
|
-
parentWindow.frameElement.style.height = parent_height;
|
753
|
+
if (/Firefox/.test(navigator.userAgent)) {
|
754
|
+
setTimeout(resize_iframe_embedded, 100, this);
|
755
|
+
} else {
|
756
|
+
resize_iframe_embedded(this);
|
757
|
+
}
|
683
758
|
});
|
684
759
|
|
685
760
|
/*******************************************************************
|
@@ -809,11 +884,13 @@ $(document).ready( function() {
|
|
809
884
|
let title = this.getAttribute("title");
|
810
885
|
let w = this.getAttribute("data-x") || 1000;
|
811
886
|
let h = this.getAttribute("data-y") || 800;
|
887
|
+
let offset = parent.window.scrollY || window.scrollY;
|
812
888
|
|
813
889
|
url = dc_url_add_params(this, url)
|
814
890
|
$('#popup').bPopup({ loadUrl: url,
|
815
|
-
transition: 'slideDown', transitionClose: 'slideDown',
|
816
|
-
|
891
|
+
transition: 'slideDown', transitionClose: 'slideDown',
|
892
|
+
speed: 300, opacity: 0,
|
893
|
+
position: ['auto', offset + 20],
|
817
894
|
closeClass: 'dc-link'
|
818
895
|
});
|
819
896
|
});
|
@@ -1019,9 +1096,7 @@ $(document).ready( function() {
|
|
1019
1096
|
*******************************************************************/
|
1020
1097
|
$('#_record__filter_field').keydown( function(e) {
|
1021
1098
|
if (e.which == '13' || e.which == '9') {
|
1022
|
-
|
1023
|
-
// url = url + "&filter_value=" + this.value;
|
1024
|
-
// simple_ajax_call(url);
|
1099
|
+
e.preventDefault();
|
1025
1100
|
$('.record_filter_field_icon').trigger("click")
|
1026
1101
|
};
|
1027
1102
|
});
|
@@ -1045,7 +1120,7 @@ $(document).ready( function() {
|
|
1045
1120
|
});
|
1046
1121
|
|
1047
1122
|
/*******************************************************************
|
1048
|
-
*
|
1123
|
+
* on click => show filter form
|
1049
1124
|
*******************************************************************/
|
1050
1125
|
$('#open_drgcms_filter').on('click', function(e) {
|
1051
1126
|
$('#drgcms_filter').bPopup({
|
@@ -1056,9 +1131,9 @@ $(document).ready( function() {
|
|
1056
1131
|
position: ['auto', 20],
|
1057
1132
|
closeClass: 'dc-link' });
|
1058
1133
|
});
|
1059
|
-
|
1134
|
+
|
1060
1135
|
/*******************************************************************
|
1061
|
-
*
|
1136
|
+
* on click => Preview image in popup window
|
1062
1137
|
*******************************************************************/
|
1063
1138
|
$('.dc-image-preview').on('click', function(e) {
|
1064
1139
|
let img = $(this).children(":first").attr('src');
|
@@ -1069,9 +1144,9 @@ $(document).ready( function() {
|
|
1069
1144
|
opacity: 0
|
1070
1145
|
});
|
1071
1146
|
});
|
1072
|
-
|
1147
|
+
|
1073
1148
|
/*******************************************************************
|
1074
|
-
*
|
1149
|
+
* on click => set new filter
|
1075
1150
|
*******************************************************************/
|
1076
1151
|
$('.dc-filter-set').on('click', function(e) {
|
1077
1152
|
let url = $(this).attr( 'data-url' );
|
@@ -1082,7 +1157,7 @@ $(document).ready( function() {
|
|
1082
1157
|
});
|
1083
1158
|
|
1084
1159
|
/*******************************************************************
|
1085
|
-
*
|
1160
|
+
* on click => toggle one cmsedit menu level
|
1086
1161
|
*******************************************************************/
|
1087
1162
|
$('.cmsedit-top-level-menu div').on('click', function(e) {
|
1088
1163
|
$(e.target).siblings('ul').toggle('fast');
|
@@ -1090,7 +1165,7 @@ $(document).ready( function() {
|
|
1090
1165
|
});
|
1091
1166
|
|
1092
1167
|
/*******************************************************************
|
1093
|
-
*
|
1168
|
+
* on click => toggle result set record menu
|
1094
1169
|
*
|
1095
1170
|
* This and additional two event hadlers provide expected behavior of submenus popup and close.
|
1096
1171
|
*******************************************************************/
|
@@ -0,0 +1,372 @@
|
|
1
|
+
/*===================================================================================================================
|
2
|
+
* @name: bPopupy
|
3
|
+
* @type: jQuery
|
4
|
+
* @author: (c) Bjoern Klinggaard - @bklinggaard
|
5
|
+
* @demo: http://dinbror.dk/bpopup
|
6
|
+
* @version: 0.11.0
|
7
|
+
* @requires jQuery 1.4.3
|
8
|
+
*==================================================================================================================*/
|
9
|
+
;(function($) {
|
10
|
+
'use strict';
|
11
|
+
|
12
|
+
$.fn.bPopup = function(options, callback) {
|
13
|
+
|
14
|
+
if ($.isFunction(options)) {
|
15
|
+
callback = options;
|
16
|
+
options = null;
|
17
|
+
}
|
18
|
+
|
19
|
+
// OPTIONS
|
20
|
+
var o = $.extend({}, $.fn.bPopup.defaults, options);
|
21
|
+
|
22
|
+
// HIDE SCROLLBAR?
|
23
|
+
if (!o.scrollBar)
|
24
|
+
$('html').css('overflow', 'hidden');
|
25
|
+
|
26
|
+
// VARIABLES
|
27
|
+
var $popup = this
|
28
|
+
, d = $(document)
|
29
|
+
, w = window
|
30
|
+
, $w = $(w)
|
31
|
+
, wH = windowHeight()
|
32
|
+
, wW = windowWidth()
|
33
|
+
, prefix = '__b-popup'
|
34
|
+
, isIOS6X = (/OS 6(_\d)+/i).test(navigator.userAgent) // Used for a temporary fix for ios6 timer bug when using zoom/scroll
|
35
|
+
, buffer = 200
|
36
|
+
, popups = 0
|
37
|
+
, id
|
38
|
+
, inside
|
39
|
+
, fixedVPos
|
40
|
+
, fixedHPos
|
41
|
+
, fixedPosStyle
|
42
|
+
, vPos
|
43
|
+
, hPos
|
44
|
+
, height
|
45
|
+
, width
|
46
|
+
, debounce
|
47
|
+
, autoCloseTO
|
48
|
+
;
|
49
|
+
|
50
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
51
|
+
// PUBLIC FUNCTION - call it: $(element).bPopup().close();
|
52
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
53
|
+
$popup.close = function() {
|
54
|
+
close();
|
55
|
+
};
|
56
|
+
|
57
|
+
$popup.reposition = function(animateSpeed) {
|
58
|
+
reposition(animateSpeed);
|
59
|
+
};
|
60
|
+
|
61
|
+
return $popup.each(function() {
|
62
|
+
if ($(this).data('bPopup')) return; //POPUP already exists?
|
63
|
+
init();
|
64
|
+
});
|
65
|
+
|
66
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
67
|
+
// HELPER FUNCTIONS - PRIVATE
|
68
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
69
|
+
function init() {
|
70
|
+
triggerCall(o.onOpen);
|
71
|
+
popups = ($w.data('bPopup') || 0) + 1, id = prefix + popups + '__',fixedVPos = o.position[1] !== 'auto', fixedHPos = o.position[0] !== 'auto', fixedPosStyle = o.positionStyle === 'fixed', height = $popup.outerHeight(true), width = $popup.outerWidth(true);
|
72
|
+
o.loadUrl ? createContent() : open();
|
73
|
+
};
|
74
|
+
|
75
|
+
function createContent() {
|
76
|
+
o.contentContainer = $(o.contentContainer || $popup);
|
77
|
+
switch (o.content) {
|
78
|
+
case ('iframe'):
|
79
|
+
var iframe = $('<iframe class="b-iframe" ' + o.iframeAttr +'></iframe>');
|
80
|
+
iframe.appendTo(o.contentContainer);
|
81
|
+
height = $popup.outerHeight(true);
|
82
|
+
width = $popup.outerWidth(true);
|
83
|
+
open();
|
84
|
+
iframe.attr('src', o.loadUrl); // setting iframe src after open due IE9 bug
|
85
|
+
triggerCall(o.loadCallback);
|
86
|
+
break;
|
87
|
+
case ('image'):
|
88
|
+
open();
|
89
|
+
$('<img />')
|
90
|
+
.on('load',function() {
|
91
|
+
triggerCall(o.loadCallback);
|
92
|
+
recenter($(this));
|
93
|
+
}).attr('src', o.loadUrl).hide().appendTo(o.contentContainer);
|
94
|
+
break;
|
95
|
+
default:
|
96
|
+
open();
|
97
|
+
$('<div class="b-ajax-wrapper"></div>')
|
98
|
+
.load(o.loadUrl, o.loadData, function(response, status, xhr) {
|
99
|
+
triggerCall(o.loadCallback, status);
|
100
|
+
recenter($(this));
|
101
|
+
}).hide().appendTo(o.contentContainer);
|
102
|
+
break;
|
103
|
+
}
|
104
|
+
};
|
105
|
+
|
106
|
+
function open(){
|
107
|
+
// MODAL OVERLAY
|
108
|
+
if (o.modal) {
|
109
|
+
$('<div class="b-modal '+id+'"></div>')
|
110
|
+
.css({backgroundColor: o.modalColor, position: 'fixed', top: 0, right:0, bottom:0, left: 0, opacity: 0, zIndex: o.zIndex + popups})
|
111
|
+
.appendTo(o.appendTo)
|
112
|
+
.fadeTo(o.speed, o.opacity);
|
113
|
+
}
|
114
|
+
|
115
|
+
// POPUP
|
116
|
+
calcPosition();
|
117
|
+
$popup
|
118
|
+
.data('bPopup', o).data('id',id)
|
119
|
+
.css({
|
120
|
+
'left': o.transition == 'slideIn' || o.transition == 'slideBack' ? (o.transition == 'slideBack' ? d.scrollLeft() + wW : (hPos + width) *-1) : getLeftPos(!(!o.follow[0] && fixedHPos || fixedPosStyle))
|
121
|
+
, 'position': o.positionStyle || 'absolute'
|
122
|
+
, 'top': o.transition == 'slideDown' || o.transition == 'slideUp' ? (o.transition == 'slideUp' ? d.scrollTop() + wH : vPos + height * -1) : getTopPos(!(!o.follow[1] && fixedVPos || fixedPosStyle))
|
123
|
+
, 'z-index': o.zIndex + popups + 1
|
124
|
+
}).each(function() {
|
125
|
+
if(o.appending) {
|
126
|
+
$(this).appendTo(o.appendTo);
|
127
|
+
}
|
128
|
+
});
|
129
|
+
doTransition(true);
|
130
|
+
};
|
131
|
+
|
132
|
+
function close() {
|
133
|
+
if (o.modal) {
|
134
|
+
$('.b-modal.'+$popup.data('id'))
|
135
|
+
.fadeTo(o.speed, 0, function() {
|
136
|
+
$(this).remove();
|
137
|
+
});
|
138
|
+
}
|
139
|
+
// Clean up
|
140
|
+
unbindEvents();
|
141
|
+
clearTimeout(autoCloseTO);
|
142
|
+
// Close trasition
|
143
|
+
doTransition();
|
144
|
+
|
145
|
+
return false; // Prevent default
|
146
|
+
};
|
147
|
+
|
148
|
+
function reposition(animateSpeed){
|
149
|
+
wH = windowHeight();
|
150
|
+
wW = windowWidth();
|
151
|
+
inside = insideWindow();
|
152
|
+
if(inside.x || inside.y){
|
153
|
+
clearTimeout(debounce);
|
154
|
+
debounce = setTimeout(function(){
|
155
|
+
calcPosition();
|
156
|
+
animateSpeed = animateSpeed || o.followSpeed;
|
157
|
+
var css = {};
|
158
|
+
if(inside.x)
|
159
|
+
css.left = o.follow[0] ? getLeftPos(true) : 'auto';
|
160
|
+
if(inside.y)
|
161
|
+
css.top = o.follow[1] ? getTopPos(true) : 'auto';
|
162
|
+
$popup
|
163
|
+
.dequeue()
|
164
|
+
.each(function() {
|
165
|
+
if(fixedPosStyle) {
|
166
|
+
$(this).css({ 'left': hPos, 'top': vPos });
|
167
|
+
}
|
168
|
+
else {
|
169
|
+
$(this).animate(css, animateSpeed, o.followEasing);
|
170
|
+
}
|
171
|
+
});
|
172
|
+
}, 50);
|
173
|
+
}
|
174
|
+
};
|
175
|
+
|
176
|
+
//Eksperimental
|
177
|
+
function recenter(content){
|
178
|
+
var _width = content.width(), _height = content.height(), css = {};
|
179
|
+
o.contentContainer.css({height:_height,width:_width});
|
180
|
+
|
181
|
+
if (_height >= $popup.height()){
|
182
|
+
css.height = $popup.height();
|
183
|
+
}
|
184
|
+
if(_width >= $popup.width()){
|
185
|
+
css.width = $popup.width();
|
186
|
+
}
|
187
|
+
height = $popup.outerHeight(true)
|
188
|
+
, width = $popup.outerWidth(true);
|
189
|
+
|
190
|
+
calcPosition();
|
191
|
+
o.contentContainer.css({height:'auto',width:'auto'});
|
192
|
+
|
193
|
+
css.left = getLeftPos(!(!o.follow[0] && fixedHPos || fixedPosStyle)),
|
194
|
+
css.top = getTopPos(!(!o.follow[1] && fixedVPos || fixedPosStyle));
|
195
|
+
|
196
|
+
$popup
|
197
|
+
.animate(
|
198
|
+
css
|
199
|
+
, 250
|
200
|
+
, function() {
|
201
|
+
content.show();
|
202
|
+
inside = insideWindow();
|
203
|
+
}
|
204
|
+
);
|
205
|
+
};
|
206
|
+
|
207
|
+
function bindEvents() {
|
208
|
+
$w.data('bPopup', popups);
|
209
|
+
$popup.delegate('.bClose, .' + o.closeClass, 'click.'+id, close); // legacy, still supporting the close class bClose
|
210
|
+
|
211
|
+
if (o.modalClose) {
|
212
|
+
$('.b-modal.'+id).css('cursor', 'pointer').bind('click', close);
|
213
|
+
}
|
214
|
+
|
215
|
+
// Temporary disabling scroll/resize events on devices with IOS6+
|
216
|
+
// due to a bug where events are dropped after pinch to zoom
|
217
|
+
if (!isIOS6X && (o.follow[0] || o.follow[1])) {
|
218
|
+
$w.bind('scroll.'+id, function() {
|
219
|
+
if(inside.x || inside.y){
|
220
|
+
var css = {};
|
221
|
+
if(inside.x)
|
222
|
+
css.left = o.follow[0] ? getLeftPos(!fixedPosStyle) : 'auto';
|
223
|
+
if(inside.y)
|
224
|
+
css.top = o.follow[1] ? getTopPos(!fixedPosStyle) : 'auto';
|
225
|
+
$popup
|
226
|
+
.dequeue()
|
227
|
+
.animate(css, o.followSpeed, o.followEasing);
|
228
|
+
}
|
229
|
+
}).bind('resize.'+id, function() {
|
230
|
+
reposition();
|
231
|
+
});
|
232
|
+
}
|
233
|
+
if (o.escClose) {
|
234
|
+
d.bind('keydown.'+id, function(e) {
|
235
|
+
if (e.which == 27) { //escape
|
236
|
+
close();
|
237
|
+
}
|
238
|
+
});
|
239
|
+
}
|
240
|
+
};
|
241
|
+
|
242
|
+
function unbindEvents() {
|
243
|
+
if (!o.scrollBar) {
|
244
|
+
$('html').css('overflow', 'auto');
|
245
|
+
}
|
246
|
+
$('.b-modal.'+id).unbind('click');
|
247
|
+
d.unbind('keydown.'+id);
|
248
|
+
$w.unbind('.'+id).data('bPopup', ($w.data('bPopup')-1 > 0) ? $w.data('bPopup')-1 : null);
|
249
|
+
$popup.undelegate('.bClose, .' + o.closeClass, 'click.'+id, close).data('bPopup', null);
|
250
|
+
};
|
251
|
+
|
252
|
+
function doTransition(open) {
|
253
|
+
switch (open ? o.transition : o.transitionClose || o.transition) {
|
254
|
+
case "slideIn":
|
255
|
+
animate({
|
256
|
+
left: open ? getLeftPos(!(!o.follow[0] && fixedHPos || fixedPosStyle)) : d.scrollLeft() - (width || $popup.outerWidth(true)) - buffer
|
257
|
+
});
|
258
|
+
break;
|
259
|
+
case "slideBack":
|
260
|
+
animate({
|
261
|
+
left: open ? getLeftPos(!(!o.follow[0] && fixedHPos || fixedPosStyle)) : d.scrollLeft() + wW + buffer
|
262
|
+
});
|
263
|
+
break;
|
264
|
+
case "slideDown":
|
265
|
+
animate({
|
266
|
+
top: open ? getTopPos(!(!o.follow[1] && fixedVPos || fixedPosStyle)) : d.scrollTop() - (height || $popup.outerHeight(true)) - buffer
|
267
|
+
});
|
268
|
+
break;
|
269
|
+
case "slideUp":
|
270
|
+
animate({
|
271
|
+
top: open ? getTopPos(!(!o.follow[1] && fixedVPos || fixedPosStyle)) : d.scrollTop() + wH + buffer
|
272
|
+
});
|
273
|
+
break;
|
274
|
+
default:
|
275
|
+
//Hardtyping 1 and 0 to ensure opacity 1 and not 0.9999998
|
276
|
+
$popup.stop().fadeTo(o.speed, open ? 1 : 0, function(){onCompleteCallback(open);});
|
277
|
+
}
|
278
|
+
|
279
|
+
function animate(css){
|
280
|
+
$popup
|
281
|
+
.css({display: 'block',opacity: 1})
|
282
|
+
.animate(css, o.speed, o.easing, function(){ onCompleteCallback(open); });
|
283
|
+
};
|
284
|
+
};
|
285
|
+
|
286
|
+
|
287
|
+
function onCompleteCallback(open){
|
288
|
+
if(open){
|
289
|
+
bindEvents();
|
290
|
+
triggerCall(callback);
|
291
|
+
if(o.autoClose){
|
292
|
+
autoCloseTO = setTimeout(close, o.autoClose);
|
293
|
+
}
|
294
|
+
} else {
|
295
|
+
$popup.hide();
|
296
|
+
triggerCall(o.onClose);
|
297
|
+
if (o.loadUrl) {
|
298
|
+
o.contentContainer.empty();
|
299
|
+
$popup.css({height: 'auto', width: 'auto'});
|
300
|
+
}
|
301
|
+
}
|
302
|
+
};
|
303
|
+
|
304
|
+
function getLeftPos(includeScroll){
|
305
|
+
return includeScroll ? hPos + d.scrollLeft() : hPos;
|
306
|
+
};
|
307
|
+
|
308
|
+
function getTopPos(includeScroll){
|
309
|
+
return includeScroll ? vPos + d.scrollTop() : vPos;
|
310
|
+
};
|
311
|
+
|
312
|
+
function triggerCall(func, arg) {
|
313
|
+
$.isFunction(func) && func.call($popup, arg);
|
314
|
+
};
|
315
|
+
|
316
|
+
function calcPosition(){
|
317
|
+
vPos = fixedVPos ? o.position[1] : Math.max(0, ((wH- $popup.outerHeight(true)) / 2) - o.amsl)
|
318
|
+
, hPos = fixedHPos ? o.position[0] : (wW - $popup.outerWidth(true)) / 2
|
319
|
+
, inside = insideWindow();
|
320
|
+
};
|
321
|
+
|
322
|
+
function insideWindow(){
|
323
|
+
return {
|
324
|
+
x: wW > $popup.outerWidth(true),
|
325
|
+
y: wH > $popup.outerHeight(true)
|
326
|
+
}
|
327
|
+
};
|
328
|
+
|
329
|
+
function windowHeight(){
|
330
|
+
return $w.height();
|
331
|
+
};
|
332
|
+
|
333
|
+
function windowWidth(){
|
334
|
+
return $w.width();
|
335
|
+
};
|
336
|
+
};
|
337
|
+
|
338
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
339
|
+
// DEFAULT VALUES
|
340
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
341
|
+
$.fn.bPopup.defaults = {
|
342
|
+
amsl: 50
|
343
|
+
, appending: true
|
344
|
+
, appendTo: 'body'
|
345
|
+
, autoClose: false
|
346
|
+
, closeClass: 'b-close'
|
347
|
+
, content: 'ajax' // ajax, iframe or image
|
348
|
+
, contentContainer: false
|
349
|
+
, easing: 'swing'
|
350
|
+
, escClose: true
|
351
|
+
, follow: [true, true] // x, y
|
352
|
+
, followEasing: 'swing'
|
353
|
+
, followSpeed: 500
|
354
|
+
, iframeAttr: 'scrolling="no" frameborder="0"'
|
355
|
+
, loadCallback: false
|
356
|
+
, loadData: false
|
357
|
+
, loadUrl: false
|
358
|
+
, modal: true
|
359
|
+
, modalClose: true
|
360
|
+
, modalColor: '#000'
|
361
|
+
, onClose: false
|
362
|
+
, onOpen: false
|
363
|
+
, opacity: 0.7
|
364
|
+
, position: ['auto', 'auto'] // x, y,
|
365
|
+
, positionStyle: 'absolute'// absolute or fixed
|
366
|
+
, scrollBar: true
|
367
|
+
, speed: 250 // open & close speed
|
368
|
+
, transition: 'fadeIn' //transitions: fadeIn, slideDown, slideIn, slideBack
|
369
|
+
, transitionClose: false
|
370
|
+
, zIndex: 9997 // popup gets z-index 9999, modal overlay 9998
|
371
|
+
};
|
372
|
+
})(jQuery);
|