PageSourceSearch

https://konyvmolykepzo.hu/Scripts/rb-controls-1.8.6.js

js konyvmolykepzo.hu collected 2026-09-24 19:39:55 UTC 84,234 bytes, 2,421 lines download raw bytes

1/*!
2* RB Controls JavaScript Library
3*
4* Copyright 2016,
5*/
6
7function RBRowSelect(item) {
8    $(item).addClass("rb-grid-row-item-selected");
9}
10
11function RBGridYearMonthsFilterItemChange(div, valuefield, yearfield) {
12    var value = RBGetValue("." + div + " #" + valuefield);
13    $("." + div + " .rb-gridfilter-yearmonth").removeClass("rb-gridfilter-yearmonth-selected");
14    $("." + div + " .rb-gridfilter-yearmonth-" + value).addClass("rb-gridfilter-yearmonth-selected");
15    if (parseInt(value) > 0) {
16        var yearvalue = RBGetValue(yearfield);
17        if ((!yearvalue) || (yearvalue != parseInt(yearvalue))) {
18            RBSetValueChange(yearfield, new Date().getFullYear());
19        }
20    }
21}
22
23function RBGridIntFilterChange(div, valuefield, minInt, maxInt, isPrev, initField) {
24    var value = RBGetValue("." + div + " #" + valuefield);
25    if ((!value) || (value != parseInt(value))) {
26        value = maxInt;
27    }
28    else {
29        if (isPrev == 1) {
30            if (value <= minInt)
31                return;
32            value--;
33        }
34        else {
35            if (value >= maxInt)
36                return;
37            value++;
38        }
39    }
40    if (initField)
41        $("." + div + " ." + initField).removeClass("disableitem");
42    RBSetValueChange("." + div + " #" + valuefield, value);
43}
44
45function RBGraphIntFilterChange(div, valuefield, minInt, maxInt, isPrev) {
46    var value = parseInt($("#" + div + " ." + valuefield).html());
47    if (isPrev == 1) {
48        if (value <= minInt)
49            return;
50        value--;
51    }
52    else {
53        if (value >= maxInt)
54            return;
55        value++;
56    }
57    $("#" + div + " ." + valuefield).html(value);
58    $("#" + div).find(".rb-graph-line-year").addClass("disableitem");
59    $("#" + div).find(".rb-graph-line-year-" + value).removeClass("disableitem");
60}
61
62function RBCheckBoxButton(item, selectclass, field) {
63    if ($(item).hasClass(selectclass)) {
64        $(item).removeClass(selectclass);
65        RBSetValueChange("#" + field, "0");
66    }
67    else {
68        $(item).addClass(selectclass);
69        RBSetValueChange("#" + field, "1");
70    }
71}
72
73function RBRowMultiSelect(item, gridid, anothergrid, field, id, title, deleteTitle) {
74    if ($(item).find(".rb-grid-row-item-rowselect").hasClass("rb-grid-row-item-selected")) {
75        $(item).find(".rb-grid-row-item-rowselect").removeClass("rb-grid-row-item-selected");
76        RBMultiSelectDeleteItem(gridid, anothergrid, field, id, 0);
77    }
78    else {
79        $(item).find(".rb-grid-row-item-rowselect").addClass("rb-grid-row-item-selected");
80        RBMultiSelectAddItem(gridid, anothergrid, field, id, title, deleteTitle);
81    }
82}
83
84function RBMultiSelectAddItem(gridid, anothergrid, field, id, title, deleteTitle) {
85    var gridvaluefield = "grid_" + anothergrid + "_" + field + "_list_idvalues";
86    var gridvalue = RBGetValue("#" + gridvaluefield);
87    gridvalue += id + ";";
88    RBSetValueChange("#" + gridvaluefield, gridvalue);
89
90    $(".inputpage_field_" + field + " .rbmultiselect_list-body").append("<div class='rbmultiselect_list-item rbmultiselect_list-item-" + id + "' " +
91          "onclick='RBMultiSelectDeleteItem(\""+gridid+"\",\"" + anothergrid + "\",\"" + field + "\",\"" + id + "\",1)'>" + title +
92          "<div class='rbmultiselect_list-item-hover' title='" + deleteTitle + "'></div>" +
93          "</div>");
94}
95
96function RBMultiSelectDeleteItem(gridid, anothergrid, field, id, fromlist) {
97    var gridvaluefield = "grid_" + anothergrid + "_" + field + "_list_idvalues";
98    var gridvalue = RBGetValue("#" + gridvaluefield);
99    gridvalue = gridvalue.replace(";" + id + ";", ";");
100    RBSetValueChange("#" + gridvaluefield, gridvalue);
101
102    $(".inputpage_field_" + field + " .rbmultiselect_list-body .rbmultiselect_list-item-" + id).remove();
103    if (fromlist == 1) {
104        $("#" + gridid).find(".rb-grid-row-item-rowselect-" + id).removeClass("rb-grid-row-item-selected");
105    }
106}
107
108function RBMultiSelectGridInitRows($grid, anothergrid, field) {
109    var gridvaluefield = "grid_" + anothergrid + "_" + field + "_list_idvalues";
110    var gridvalue = RBGetValue("#" + gridvaluefield);
111
112    var rows = $grid.find(".rb-grid-row-data");
113    if (rows.length > 0)
114        for (var i = 0; i < rows.length; i++) {
115            var row = $(rows[i]);
116            var rowid = row.data("entityid");
117            if (gridvalue.indexOf(";" + rowid + ";") != -1)
118                $grid.find(".rb-grid-row-item-rowselect-" + rowid).addClass("rb-grid-row-item-selected");
119        }
120}
121
122function RBEntityListEditInsert(rbEditIdFieldName, mainid, fieldname, grid) {
123    var entityid = RBGetValue("#" + rbEditIdFieldName);
124    if (entityid<1)
125      return;
126    var entityListid = RBGetValue("#" + fieldname);
127    
128    var $ajaxloading = $('#' + rbEditIdFieldName);
129    RBAjax_AjaxLoadingItemStart($ajaxloading, true);
130    var url = "/" + grid + "/AddEntityListEditData";
131    $.post(url, {
132        entityListid: entityListid, entityid: entityid
133    }, function (response) {
134        RBAjax_AjaxLoadingEnd($ajaxloading, true);
135        if (response) {
136            if (response.error)
137                RBMessage(response.error);
138            else {
139                if (response.entitylistid > 0)
140                {
141                    RBSetValue("#" + fieldname, response.entitylistid);
142                    RBSetValue("#" + rbEditIdFieldName, "0");
143                    RBSetValue("#" + rbEditIdFieldName+"_Label", "");
144                    FireRefreshEventHandler(mainid, response.entitylistid, "");
145                }
146            }
147        }
148    }).fail(function (response) {
149        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
150        RBAjaxPostError();
151    });
152}
153
154function RBLinkListEditInsert(rbEditIdFieldName, mainid, table, masterfield, masterid, searchtable, searchfield, linktype, rbsliderid) {
155    var entityid = RBGetValue("#" + rbEditIdFieldName);
156    if (entityid < 1)
157        return;
158    var $ajaxloading = $('#' + rbEditIdFieldName);
159    RBAjax_AjaxLoadingItemStart($ajaxloading, true);
160    var url = "/Home/AddLinkListEditData";
161    $.post(url, {
162        table: table, masterfield: masterfield, masterid: masterid, searchtable: searchtable, searchfield: searchfield, entityid: entityid, linktype: linktype
163    }, function (response) {
164        RBAjax_AjaxLoadingEnd($ajaxloading, true);
165        if (response) {
166            if (response.error)
167                RBMessage(response.error);
168            else {
169                RBSetValue("#" + rbEditIdFieldName, "0");
170                RBSetValue("#" + rbEditIdFieldName + "_Label", "");
171                if (rbsliderid)
172                    FireRefreshEventHandler(rbsliderid, "-1", "Reload");
173                else
174                    FireRefreshEventHandler(mainid, "", "");
175            }
176        }
177    }).fail(function (response) {
178        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
179        RBAjaxPostError();
180    });
181}
182
183function RBCreateVote(divid, url, fieldid, isitem) {
184    var $ajaxloading = $('#' + divid);
185    RBAjax_AjaxLoadingItemStart($ajaxloading, true);
186    var fieldidvalue = RBGetValue("#" + fieldid);
187    $.post(url, {
188        divid: divid, fieldid: fieldid, fieldidvalue: fieldidvalue, isitem: isitem
189    }, function (response) {
190        RBAjax_AjaxLoadingEnd($ajaxloading, true);
191        if (response) {
192            if (response.error)
193                RBMessage(response.error);
194            else {
195                if (response.votetypeid > 0) {
196                    RBSetValue("#" + fieldid, response.votetypeid);
197                    $('#' + divid).html(response.result);
198                }
199            }
200        }
201    }).fail(function (response) {
202        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
203        RBAjaxPostError();
204    });
205}
206
207function RBEditVoteChange(divid, url, fieldid, field, itemid) {
208    var $ajaxloading = $('#' + divid);
209    RBAjax_AjaxLoadingItemStart($ajaxloading, false);
210    var fieldidvalue = RBGetValue("#" + fieldid);
211    var fieldvalue = RBGetValue("#" + field);
212    $.post(url, {
213        divid: divid, fieldid: fieldid, fieldidvalue: fieldidvalue, field: field, fieldvalue: fieldvalue, itemid: itemid
214    }, function (response) {
215        RBAjax_AjaxLoadingEnd($ajaxloading, false);
216        if (response) {
217            if (response.error)
218                RBMessage(response.error);
219            else {
220                if (response.result)
221                    if (response.result != "") {
222                        $('#' + divid).html(response.result);
223                    }
224            }
225        }
226    }).fail(function (response) {
227        RBAjax_AjaxLoadingItemEnd($ajaxloading, false);
228        RBAjaxPostError();
229    });
230}
231
232function RBAudioGoto(id, inputid) {
233    try {
234        var input = RBGetValue(inputid);
235        var inputitems = input.split(':');
236        var startSec = 0;
237        if (inputitems.length == 3)
238            startSec = ((parseInt(inputitems[0]) * 60) + parseInt(inputitems[1])) * 60 + parseInt(inputitems[2]);
239        if (inputitems.length == 2)
240            startSec = ((parseInt(inputitems[0]) * 60) + parseInt(inputitems[1])) * 60;
241        if (inputitems.length == 1)
242            startSec = (parseInt(inputitems[1])) * 60;
243        if (startSec < 1)
244            startSec = 0;
245        var aud = document.getElementById(id);
246        aud.currentTime = startSec;
247    } catch (e) {
248    }
249}
250
251$.fn.RBGrid = function (controller, entity, ismultiselect, isselected, backpage, pageindex, pagesize, masterfield, masterid, masterParam, multiselectfield,
252        multiselectazon, multiselectfilter, summaline, enablecookie) {
253
254    var base = this;
255    var $root = $(this);
256    var $body = $(this).find(".rb-grid-body");
257    var sortfield = "";
258    var sorttype = "";
259    var timer;
260    var working = false;
261    var actfilter = "";
262    var nextfilter = "";
263    var init = true;
264
265    this.initialize = function () {
266        InitGridFilterAndSort();
267        $root.find(".rb-grid-header-item").click(function () {
268            if ($(this).find('.rb-grid-header-item-sort').length > 0) {
269                var field = $(this).data("field");
270                if (field) {
271                    var newsortfield = sortfield;
272                    var newsorttype = sorttype;
273                    if (sortfield != field) {
274                        newsortfield = field;
275                        newsorttype = "";
276                    }
277                    else {
278                        if ($(this).hasClass("rb-grid-header-sortdesc"))
279                            newsorttype = "";
280                        else
281                            newsorttype = "Desc";
282                    }
283                    var newfilter = GetFilterValue(false);
284                    GetGridData(pageindex, newsortfield, newsorttype, newfilter, true);
285                }
286            }
287        });
288        $root.find(".rb-grid-export-button").click(function () {
289            var filter = GetFilterValue(false);
290            var exportazon = $(this).data("exportazon");
291            var ajaxurl = "/" + controller + "/RBExportData";
292            var url = ajaxurl + "?masterfield=" + masterfield + "&masterid=" + masterid + "&masterParam=" + masterParam + "&exportazon=" + exportazon + "&filter=" + filter +
293                        "&sortfield=" + sortfield + "&sorttype=" + sorttype;
294            RBLoadPage(url, "_blank");
295        });
296        $root.find(".rb-gridfilter").click(function () {
297            FilterChange();
298        });
299        $root.find(".rb-gridfilter").keyup(function () {
300            FilterChange();
301        });
302        $root.find(".rb-gridfilter").change(function () {
303            FilterChange();
304        });
305
306        var newfilter = GetFilterValue(false);
307        GetGridData(pageindex, sortfield, sorttype, newfilter, true);
308    }
309
310    function InitGridFilterAndSort() {
311        if (!ismultiselect)
312            if (enablecookie) {
313                var items = $root.find(".rb-gridfilter");
314                if (items.length > 0) {
315                    for (var i = 1; i <= items.length; i++) {
316                        var item = $(items[i - 1]);
317                        var field = item.data("field");
318                        var cookiename = GetCookieName(field);
319                        var cookievalue = RBGetCookie(cookiename);
320                        if (cookievalue) {
321                            if (cookievalue != item.val()) {
322                                item.val(cookievalue);
323                                if (item.hasClass("rb-gridfilter-initchange")) {
324                                    item.removeClass("rb-gridfilter-initchange");
325                                    item.change();
326                                }
327                            }
328                            if (item.data("filtertype") == "checkbox") {
329                                item.removeClass("rbcheckbox-null");
330                                item.removeClass("rbcheckbox-0");
331                                item.removeClass("rbcheckbox-1");
332                                item.addClass("rbcheckbox-" + cookievalue);
333                            }
334                        }
335                    }
336                }
337                var sortfieldcookiename = GetCookieName("SortField");
338                var sortfieldcookievalue = RBGetCookie(sortfieldcookiename);
339                if (sortfieldcookievalue)
340                    sortfield = sortfieldcookievalue;
341                var sorttypecookiename = GetCookieName("SortType");
342                var sorttypecookievalue = RBGetCookie(sorttypecookiename);
343                if (sorttypecookievalue)
344                    sorttype = sorttypecookievalue;
345                var pageindexcookiename = GetCookieName("PageIndex");
346                var pageindexcookievalue = RBGetCookie(pageindexcookiename);
347                if (pageindexcookievalue)
348                    pageindex = pageindexcookievalue;
349            }
350    }
351
352    function GetCookieName(field) {
353        var result = "RBGrid-" + entity + "-" + field;
354        if (masterParam)
355            result += "-" + masterParam;
356        return result;
357    }
358
359    function GetGridData(newpageindex, newsortfield, newsorttype, newfilter, goNow) {
360        nextfilter = newfilter;
361        clearTimeout(timer);
362        var waittime = 1000;
363        if (goNow)
364            waittime = 0;
365        timer = setTimeout(function () { GetGridDataRun(newpageindex, newsortfield, newsorttype, newfilter); }, waittime);
366    }
367
368    function GetGridDataRun(newpageindex, newsortfield, newsorttype, newfilter) {
369        if (working) {
370            GetGridData(newpageindex, newsortfield, newsorttype, newfilter, false);
371            return;
372        }
373        if (!init) {
374            if (actfilter == newfilter)
375                if (sortfield == newsortfield)
376                    if (sorttype == newsorttype)
377                        if (pageindex == newpageindex)
378                            return;
379            if (GetFilterValue(true) != newfilter)
380                return;
381
382            if (!ismultiselect)
383                if (enablecookie) {
384                    var sortfieldcookiename = GetCookieName("SortField");
385                    var sortfieldcookievalue = RBGetCookie(sortfieldcookiename);
386                    if (sortfieldcookievalue != newsortfield)
387                        RBSetCookie(sortfieldcookiename, newsortfield, 1);
388                    var sorttypecookiename = GetCookieName("SortType");
389                    var sorttypecookievalue = RBGetCookie(sorttypecookiename);
390                    if (sorttypecookievalue != newsorttype)
391                        RBSetCookie(sorttypecookiename, newsorttype, 1);
392                    var pageindexcookiename = GetCookieName("PageIndex");
393                    var pageindexcookievalue = RBGetCookie(pageindexcookiename);
394                    if (pageindexcookievalue != newpageindex)
395                        RBSetCookie(pageindexcookiename, newpageindex, 1);
396                }
397        }
398        init = false;
399        working = true;
400        if (!controller)
401            controller = "Admin" + entity + "InfoGrid";
402        var ajaxurl = "/" + controller + "/RBGridGetData";
403        $root.data("sortfield", newsortfield);
404        $root.data("sorttype", newsorttype);
405        $root.data("filter", newfilter);
406        RBAjax_AjaxLoadingItemStart($body, true);
407        $.post(ajaxurl, {
408            ismultiselect: ismultiselect, isselected: isselected, backpage: backpage, pageindex: newpageindex, pagesize: pagesize,
409            masterfield: masterfield, multiselectazon: multiselectazon, multiselectfilter: multiselectfilter, masterid: masterid, masterParam: masterParam,
410            gridid: $root.attr('id'), sortfield: newsortfield, sorttype: newsorttype, filter: newfilter, multiselectfield: multiselectfield, summaline: summaline
411        }, function (response) {
412            RBAjax_AjaxLoadingItemEnd($body, true);
413            if (response.error) {
414                RBMessage(response.error);
415                working = false;
416                return;
417            }
418            pageindex = newpageindex;
419            $root.find(".rb-grid-body").html(response.body);
420            $root.find(".rb-grid-pager").html(response.pager);
421            if (response.summaline)
422                $root.find(".rb-grid-summaline").html(response.summaline);
423
424            sortfield = response.sortfield;
425            sorttype = response.sorttype;
426
427            $root.find(".rb-grid-pager-page").click(function () {
428                var gotoPage = $(this).data("page");
429                if (gotoPage > 0)
430                    GetGridData(gotoPage - 1, sortfield, sorttype, newfilter, true);
431            });
432            $root.find(".rb-grid-header-item").removeClass("rb-grid-header-sort");
433            $root.find(".rb-grid-header-item").removeClass("rb-grid-header-sortdesc");
434            if (sortfield) {
435                $root.find(".rb-grid-header-item-" + sortfield).addClass("rb-grid-header-sort");
436                if (sorttype == "Desc")
437                    $root.find(".rb-grid-header-item-" + sortfield).addClass("rb-grid-header-sortdesc");
438            }
439            if (response.enableCreate) {
440                $root.find(".rb-grid-insert").css('display', 'inline-block');
441                if (response.createHtml != $root.find(".rb-grid-insert").html())
442                    $root.find(".rb-grid-insert").html(response.createHtml);
443            }
444            else {
445                $root.find(".rb-grid-insert").html();
446            }
447
448            if (multiselectfield)
449                RBMultiSelectGridInitRows($root, controller, multiselectfield);
450
451            actfilter = newfilter;
452            working = false;
453            if (response.totalItemCount > 0)
454                if (response.isempty == 1)
455                    GetGridDataRun(0, newsortfield, newsorttype, newfilter);
456        }).fail(function (response) {
457            RBAjax_AjaxLoadingItemEnd($body, true);
458            working = false;
459            RBAjaxPostError();
460        });
461    }
462
463    function GetFilterValue(setcookie) {
464        var result = "";
465        var items = $root.find(".rb-gridfilter");
466        if (items.length > 0) {
467            for (var i = 1; i <= items.length; i++) {
468                var item = $(items[i - 1]);
469                var field = item.data("field");
470                var itemvalue = item.val();
471                if (itemvalue) {
472                    if (result)
473                        result += ";";
474                    itemvalue = itemvalue.replace(";", ",");
475                    result += field + "=" + itemvalue;
476                }
477                if (!ismultiselect)
478                    if (enablecookie)
479                        if (setcookie) {
480                            var cookiename = GetCookieName(field);
481                            var cookievalue = RBGetCookie(cookiename);
482                            if (cookievalue != itemvalue)
483                                RBSetCookie(cookiename, itemvalue, 1);
484                        }
485            }
486        }
487        return result;
488    }
489
490    function FilterChange() {
491        var newfilter = GetFilterValue(false);
492        if (newfilter == actfilter)
493            return;
494        if (newfilter == nextfilter)
495            return;
496        GetGridData(0, sortfield, sorttype, newfilter, false);
497    }
498
499    /*
500    Start
501    */
502    this.each(function () {
503        base.initialize();
504    });
505
506    return this;
507}
508
509$.fn.RBDateEdit = function (fieldname, currentText, deleteText, monthNames, monthNamesShort, dayNamesMin, dateFormat, firstDay, popupButtonClass, marker, minDate, maxDate, onlyday, autopopup, availableDate) {
510
511    var base = this;
512    var $root = $(this);
513    var inputdate;
514    var actdate;
515    var mindate;
516    var maxdate;
517    var availabledate;
518    var today = new Date();
519
520    this.initialize = function () {
521        PopupClose();
522        if (minDate)
523            mindate = DateFromStr(minDate);
524        if (maxDate)
525            maxdate = DateFromStr(maxDate);
526        availabledate = availableDate;
527        if (autopopup)
528            PopupInit();
529        $root.find("." + popupButtonClass).click(function () {
530            if (PopupVisibled()) {
531                PopupClose();
532            }
533            else {
534                PopupInit();
535            }
536        });
537        $root[0].onchange = function (e) {
538            FireEvent(e.id, e.azon);
539        }
540    }
541
542    function PopupInit() {
543        if (marker)
544            RBScrollToId(marker);
545        if (!autopopup)
546            $(".rb-datedit-popup-enableclose").html("");
547        InitRBEdit();
548        var oldDate = RBGetValue("#" + fieldname);
549        inputdate = DateFromStr(oldDate);
550        actdate = new Date(inputdate.getFullYear(), inputdate.getMonth(), inputdate.getDate());
551        UpdateDays();
552    }
553
554    function PopupVisibled() {
555        return $root.find(".rb-datedit-popup").html();
556    }
557
558    function DateFromStr(oldDate) {
559        var result = new Date();
560        if (mindate)
561            if (mindate > result)
562                result = mindate;
563        try {
564            if (oldDate) {
565                var oldyear = parseInt(oldDate.substr(0, 4));
566                var oldmonth = parseInt(oldDate.substr(5, 2));
567                var oldday = parseInt(oldDate.substr(8, 2));
568                if ((oldyear > 1900) && (oldyear < 2100) && (oldmonth > 0) && (oldmonth < 13) && (oldday > 0) && (oldday < 32))
569                    result = new Date(oldyear, oldmonth - 1, oldday);
570            }
571        } catch (e) {
572        }
573        return result;
574    }
575
576    function CheckNewDate(newdate) {
577        if (mindate)
578            if (newdate < mindate)
579                return false;
580        if (maxdate)
581            if (newdate > maxdate)
582                return false;
583        return true;
584    }
585
586    function ModifyActDate(year, month) {
587        var newdate = new Date(actdate.getFullYear(), actdate.getMonth(), actdate.getDate());
588        if (year != 0) {
589            if (maxdate) {
590                if (year > 0)
591                    if (newdate.getFullYear() >= maxdate.getFullYear())
592                        return;
593                if (year < 0)
594                    if (newdate.getFullYear() <= maxdate.getFullYear())
595                        return;
596            }
597            newdate.setFullYear(newdate.getFullYear() + year);
598        }
599        if (month != 0) {
600            newdate.setMonth(newdate.getMonth() + month);
601        }
602
603        if (maxdate)
604            if (newdate > maxdate)
605                newdate = maxdate;
606        if (mindate)
607            if (newdate < mindate)
608                newdate = mindate;
609        actdate = new Date(newdate.getFullYear(), newdate.getMonth(), newdate.getDate()); ;
610        UpdateDays();
611    }
612
613    function FireEvent(id, azon) {
614        if (id == "mindate") {
615            mindate = DateFromStr(azon);
616        }
617        if (id == "availabledate") {
618            if (availabledate != azon) {
619                availabledate = azon;
620                UpdateDays();
621            }
622        }
623    }
624
625    function InitRBEdit() {
626        $root.find(".rb-datedit-popup").append("<div class='rb-datedit-popup-main'></div>");
627        if (!autopopup)
628            $root.find(".rb-datedit-popup").addClass("rb-datedit-popup-enableclose");
629        $root.find('.rb-datedit-popup-main').append("<div class='rb-datedit-popup-main-header'></div>");
630        $root.find('.rb-datedit-popup-main').append("<div class='rb-datedit-popup-main-body'></div>");
631        $root.find('.rb-datedit-popup-main').append("<div class='rb-datedit-popup-main-footer'></div>");
632
633        var enableYearButtons = true;
634        if (maxdate && mindate)
635            if (maxdate.getFullYear() >= mindate.getFullYear())
636                enableYearButtons = false;
637        if (enableYearButtons)
638            $root.find('.rb-datedit-popup-main-header').append("<div class='rb-datedit-popup-main-header-prevyear'></div>");
639        $root.find('.rb-datedit-popup-main-header').append("<div class='rb-datedit-popup-main-header-prevmonth'></div>");
640        $root.find('.rb-datedit-popup-main-header').append("<div class='rb-datedit-popup-main-header-actmonth'></div>");
641        $root.find('.rb-datedit-popup-main-header').append("<div class='rb-datedit-popup-main-header-nextmonth'></div>");
642        if (enableYearButtons)
643            $root.find('.rb-datedit-popup-main-header').append("<div class='rb-datedit-popup-main-header-nextyear'></div>");
644        $root.find('.rb-datedit-popup-main-header-prevyear').click(function () {
645            ModifyActDate(-1, 0);
646        });
647        $root.find('.rb-datedit-popup-main-header-prevmonth').click(function () {
648            ModifyActDate(0, -1);
649        });
650        $root.find('.rb-datedit-popup-main-header-nextmonth').click(function () {
651            ModifyActDate(0, 1);
652        });
653        $root.find('.rb-datedit-popup-main-header-nextyear').click(function () {
654            ModifyActDate(1, 0);
655        });
656
657        $root.find('.rb-datedit-popup-main-body').append("<div class='rb-datedit-popup-main-body-dayheaders'></div>");
658        for (var i = 0; i <= 6; i++) {
659            var j = i + firstDay;
660            if (j > 6)
661                j = j - 7;
662            var day = dayNamesMin[j];
663            $root.find('.rb-datedit-popup-main-body-dayheaders').append("<div class='rb-datedit-popup-main-body-dayheaders-day'>" + day + "</div>");
664        }
665        $root.find('.rb-datedit-popup-main-body').append("<div class='rb-datedit-popup-main-body-days'></div>");
666        for (var k = 1; k <= 6 * 7; k++) {
667            var dayclass = "rb-datedit-popup-main-body-day rb-datedit-popup-main-body-day-" + k;
668            $root.find('.rb-datedit-popup-main-body-days').append("<div class='" + dayclass + "'></div>");
669        }
670        $root.find('.rb-datedit-popup-main-body-day').click(function () {
671            var date = $(this).data("newdate");
672            if (mindate)
673                if ($(this).hasClass("rb-datedit-day-disabled"))
674                    return;
675            $root.find(".rb-datedit-popup-main-body-day").removeClass("rb-datedit-popup-main-body-day-inputdate");
676            $(this).addClass("rb-datedit-popup-main-body-day-inputdate");
677            DatePost(date);
678        });
679
680        if (CheckNewDate(today))
681            $root.find('.rb-datedit-popup-main-footer').append("<div class='rb-datedit-popup-main-footer-today'>" + currentText + "</div>");
682        $root.find('.rb-datedit-popup-main-footer').append("<div class='rb-datedit-popup-main-footer-delete'>" + deleteText + "</div>");
683        $root.find('.rb-datedit-popup-main-footer').append("<div class='rb-datedit-popup-close'></div>");
684        $root.find('.rb-datedit-popup-main-footer-today').click(function () {
685            if (CheckNewDate(today))
686                DatePost(GetNewDateStrFromDate(today));
687        });
688        $root.find('.rb-datedit-popup-main-footer-delete').click(function () {
689            $root.find(".rb-datedit-popup-main-body-day").removeClass("rb-datedit-popup-main-body-day-inputdate");
690            DatePost("");
691        });
692        $root.find('.inputpage_item').click(function () {
693            if (PopupVisibled())
694                PopupClose();
695        });
696        $root.find('.rb-datedit-popup-close').click(function () {
697            if (PopupVisibled())
698                PopupClose();
699        });
700    }
701
702    function GetNewDateStrFromDate(date) {
703        return GetNewDateStr(date.getFullYear(), date.getMonth(), date.getDate())
704    }
705
706    function GetNewDateStr(year, month, day) {
707        var result = year + ".";
708        if (month < 9)
709            result += "0";
710        result += (month + 1) + ".";
711        if (day < 10)
712            result += "0";
713        result += day + ".";
714        return result;
715    }
716
717    function DatePost(newdate) {
718        var result = "";
719        if (newdate) {
720            result = RBGetValue("#" + fieldname);
721            if (result.length > 10)
722                result = result.substring(11);
723            result = newdate + result;
724        }
725
726        RBSetValueChange("#" + fieldname, result);
727        inputdate = DateFromStr(result);
728        PopupClose();
729    }
730
731    function PopupClose() {
732        if (!autopopup)
733            $root.find(".rb-datedit-popup").html("");
734    }
735
736    function UpdateDays() {
737        var actdatestr = actdate.getFullYear() + ". " + monthNames[actdate.getMonth()];
738        $root.find(".rb-datedit-popup-main-header-actmonth").html(actdatestr);
739        var startDate = new Date();
740        startDate.setHours(0, 0, 0, 0);
741        startDate.setFullYear(actdate.getFullYear(), actdate.getMonth(), 1);
742        do {
743            var j = startDate.getDay();
744            if (j == firstDay)
745                break;
746            startDate.setDate(startDate.getDate() - 1);
747        } while (true);
748        $root.find(".rb-datedit-popup-main-body-day").removeClass("rb-datedit-popup-main-body-day-actmonth");
749        $root.find(".rb-datedit-popup-main-body-day").removeClass("rb-datedit-popup-main-body-day-today");
750        $root.find(".rb-datedit-popup-main-body-day").removeClass("rb-datedit-popup-main-body-day-inputdate");
751        if (mindate || maxdate || onlyday || availabledate)
752            $root.find(".rb-datedit-popup-main-body-day").removeClass("rb-datedit-day-disabled");
753        for (var i = 1; i <= 6 * 7; i++) {
754            var day = startDate.getDate();
755            var dayclass = "rb-datedit-popup-main-body-day-" + i;
756            $root.find("." + dayclass).html(day);
757            if (mindate)
758                if (startDate < mindate)
759                    $root.find("." + dayclass).addClass("rb-datedit-day-disabled");
760            if (maxdate)
761                if (startDate > maxdate)
762                    $root.find("." + dayclass).addClass("rb-datedit-day-disabled");
763            if (onlyday)
764                if (startDate.getDay() != onlyday)
765                    if (!mindate || (startDate != mindate))
766                        $root.find("." + dayclass).addClass("rb-datedit-day-disabled");
767            if (availabledate) {
768                var startDateStr = ";" + (startDate.getYear() + 1900) + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate() + ";";
769                if (availabledate.indexOf(startDateStr) == -1)
770                    $root.find("." + dayclass).addClass("rb-datedit-day-disabled");
771            }
772            if (startDate.getMonth() == actdate.getMonth())
773                $root.find("." + dayclass).addClass("rb-datedit-popup-main-body-day-actmonth");
774            if (day == today.getDate())
775                if (startDate.getMonth() == today.getMonth())
776                    if (startDate.getYear() == today.getYear())
777                        $root.find("." + dayclass).addClass("rb-datedit-popup-main-body-day-today");
778            if (day == inputdate.getDate())
779                if (startDate.getMonth() == inputdate.getMonth())
780                    if (startDate.getYear() == inputdate.getYear())
781                        $root.find("." + dayclass).addClass("rb-datedit-popup-main-body-day-inputdate");
782            $root.find("." + dayclass).data("newdate", GetNewDateStrFromDate(startDate));
783
784            startDate.setDate(startDate.getDate() + 1);
785        }
786    }
787    /*
788    Start
789    */
790    this.each(function () {
791        base.initialize();
792    });
793
794    return this;
795}
796
797$.fn.RBListSelect = function (fieldname, current) {
798
799    var base = this;
800    var $root = $(this);
801
802    this.initialize = function () {
803        UpdateItems();
804        $root[0].onchange = function (e) {
805            FireEvent(e.id, e.azon);
806        }
807        $("#" + fieldname).change(function () {
808            RefreshItems();
809            return false;
810        });
811    }
812
813    function FireEvent(id, azon) {
814        if (id == "items") {
815            $root.find(".rb-listselect").html(azon);
816            UpdateItems();
817        }
818    }
819
820    function InitRBListSelect() {
821        $root.find('.rb-listselect-item-enabled').click(function () {
822            var selectvalue = $(this).data("selectvalue");
823            RBSetValueChange("#" + fieldname, selectvalue);
824        });
825    }
826
827    function RefreshItems() {
828        var selectvalue = RBGetValue("#" + fieldname);
829        $root.find(".rb-listselect-item").removeClass("rb-listselect-item-selected");
830        $root.find(".rb-listselect-item-" + selectvalue).addClass("rb-listselect-item-selected");
831    }
832
833    function UpdateItems() {
834        InitRBListSelect();
835        RefreshItems();
836    }
837    /*
838    Start
839    */
840    this.each(function () {
841        base.initialize();
842    });
843
844    return this;
845}
846
847$.fn.RBEditId = function (field, linkanothergrid, linkanothertable, display, enableonlineedit, listorigfield, linkcombofilter, linkanothersort, minchangelength, timeoutsearch,
848         comboDisplayField, extParamField, notfoundmessage) {
849
850    var base = this;
851    var $root = $(this);
852    var $preview = $('#' + field + '-editidsearch-main');
853    var onlineeditbuttons = "inputpage_rbeditid-onlinebuttons-" + field;
854
855    var actvalue = "";
856    var ajaxurl = "/editidsearch";
857    var ajaxurllist = "/editidlist";
858    var timer;
859
860    this.initialize = function () {
861        $root.addClass("editidpanel-off");
862        $root.attr("autocomplete", "off");
863        $root.keyup(function () {
864            KeyUpFunc();
865            return false;
866        });
867        $root.change(function () {
868            KeyUpFunc();
869            return false;
870        });
871        $root.blur(function () {
872            setTimeout(
873            function () {
874                PreviewOff();
875            }, 1000);
876        });
877        $root[0].onchange = function (e) {
878            FireEvent(e.id, e.azon);
879        }
880        $("#" + field + "_Status").change(function () {
881            StatusChanged();
882            return false;
883        });
884        $("#" + field).change(function () {
885            // alert("RBEditId-FieldValueChanged");
886            SetStatusVisible();
887            if (listorigfield)
888                GetEditIdListData();
889            return false;
890        });
891
892        StatusChanged();
893    }
894
895    function StatusChanged() {
896        var status = RBGetValue("#" + field + "_Status");
897        var editIdValue = "-2";
898        if ((status == "Insert") || (status == "Edit")) {
899            if (status == "Insert") {
900                editIdValue = "-1";
901            }
902            else {
903                editIdValue = RBGetValue("#" + field);
904                // alert("RBEditId-GetValue: " + field + ": " + editIdValue);
905            }
906        }
907        SetStatusVisible();
908        // alert("RBEditId-SetEditIdEditField: " + field + "Edit -> " + editIdValue);
909        RBSetValueChange("#" + field + "Edit", editIdValue);
910    }
911
912    function SetStatusVisible() {
913        var status = RBGetValue("#" + field + "_Status");
914        if ((status == "Insert") || (status == "Edit")) {
915            SetDisable("." + onlineeditbuttons + " .inputpage_rbeditid-onlinebutton-insert");
916            SetDisable("." + onlineeditbuttons + " .inputpage_rbeditid-onlinebutton-edit");
917        }
918        else {
919            SetVisibleValue("." + onlineeditbuttons + " .inputpage_rbeditid-onlinebutton-insert", "inline-block");
920            var fieldValue = RBGetValue("#" + field);
921            // alert("RBEditId-SetStatusVisible-Edit: " + field + "-> " + fieldValue);
922            if (fieldValue > 0) {
923                SetVisibleValue("." + onlineeditbuttons + " .inputpage_rbeditid-onlinebutton-edit", "inline-block");
924            }
925            else {
926                SetDisable("." + onlineeditbuttons + " .inputpage_rbeditid-onlinebutton-edit");
927            }
928        }
929    }
930
931    function FireEvent(id, azon) {
932        if ($root[0].value == "") {
933            var oldvalue = RBGetValue("#" + field);
934            if (oldvalue > 0)
935                RBSetValueChange("#" + field, "0");
936        }
937        if (id == "blur") {
938            PreviewOff();
939        }
940    }
941
942    function KeyUpFunc() {
943        if (actvalue != $root[0].value) {
944            clearTimeout(timer);
945            PreviewOff();
946            actvalue = $root[0].value;
947            timer = setTimeout(function () { KeyUpRun(actvalue) }, timeoutsearch);
948        }
949    }
950
951    function KeyUpRun(act) {
952        if (act != actvalue)
953            return;
954        if (actvalue == "")
955            return;
956        if (actvalue.length < minchangelength)
957            return;
958
959        var extParamValue = "";
960        if (extParamField) {
961            extParamValue = $('input[name=' + extParamField + ']:checked').val();
962            if (!extParamValue)
963                extParamValue = RBGetValue("#" + extParamField);
964        }
965
966        $.post(ajaxurl, {
967            actvalue: actvalue, field: field, linkanothergrid: linkanothergrid, linkanothertable: linkanothertable, display: display, linkcombofilter: linkcombofilter,
968            linkanothersort: linkanothersort, textcombo: 0, comboDisplayField: comboDisplayField, extParamValue: extParamValue, notfoundmessage: notfoundmessage
969        },
970                function (response) {
971                    if (response.actvalue == actvalue) {
972                        if (response.message != '') {
973                            PreviewOn(response.message);
974                        }
975                    }
976                });
977    }
978
979    function GetEditIdListData() {
980        var listvalue = RBGetValue("#" + listorigfield);
981        var newvalue = RBGetValue("#" + field);
982        RBSetValue("#" + field + "_Label", "");
983
984        $.post(ajaxurllist, {
985            listvalue: listvalue, newvalue: newvalue, field: listorigfield, linkanothergrid: linkanothergrid, linkanothertable: linkanothertable, display: display, comboDisplayField: comboDisplayField
986        },
987                function (response) {
988                    if (response.listvalue != listvalue) {
989                        RBSetValue("#" + listorigfield, response.listvalue);
990                    }
991                    $("#" + listorigfield + "-data").html(response.data);
992                    if (response.message != '') {
993                        RBMessage(response.message);
994                    }
995                });
996    }
997
998    function PreviewOff() {
999        $preview.removeClass("editidsearch-active");
1000        $preview.addClass("editidsearch-disabled");
1001        $root.removeClass("editidpanel-on");
1002        $root.addClass("editidpanel-off");
1003        $preview.html("");
1004    }
1005
1006    function PreviewOn(message) {
1007        RBEditIdSearchOff();  // A többit eltüntetjük        
1008        if (message == "") {
1009            PreviewOff();
1010        }
1011        else {
1012            $preview.html(message);
1013            $preview.removeClass("editidsearch-disabled");
1014            $preview.addClass("editidsearch-active");
1015            $root.removeClass("editidpanel-off");
1016            $root.addClass("editidpanel-on");
1017        }
1018    }
1019
1020    /*
1021    Start
1022    */
1023    this.each(function () {
1024        base.initialize();
1025    });
1026
1027    return this;
1028}
1029
1030$.fn.RBTextCombo = function (field, linkanothergrid, linkanothertable, display, listorigfield, linkcombofilter, linkanothersort, minchangelength, timeoutsearch, textcombocookieazon,
1031notfoundmessage) {
1032
1033    var base = this;
1034    var $root = $(this);
1035
1036    var actvalue = "";
1037    var ajaxurl = "/editidsearch";
1038    var timer;
1039
1040    this.initialize = function () {
1041        $root.addClass("editidpanel-off");
1042        $root.attr("autocomplete", "off");
1043        $root.keyup(function () {
1044            KeyUpFunc();
1045            return false;
1046        });
1047        $root.change(function () {
1048            KeyUpFunc();
1049            return false;
1050        });
1051        $root.blur(function () {
1052            setTimeout(
1053            function () {
1054                PreviewOff();
1055            }, 1000);
1056        });
1057        $root[0].onchange = function (e) {
1058            FireEvent(e.id, e.azon);
1059        }
1060    }
1061
1062    function FireEvent(id, azon) {
1063        if (id == "blur") {
1064            PreviewOff();
1065        }
1066    }
1067
1068    function KeyUpFunc() {
1069        if (actvalue != $root[0].value) {
1070            clearTimeout(timer);
1071            PreviewOff();
1072            actvalue = $root[0].value;
1073            timer = setTimeout(function () { KeyUpRun(actvalue) }, timeoutsearch);
1074        }
1075    }
1076
1077    function KeyUpRun(act) {
1078        if (act != actvalue)
1079            return;
1080        if (actvalue == "")
1081            return;
1082        if (actvalue.length < minchangelength)
1083            return;
1084
1085        $.post(ajaxurl, {
1086            actvalue: actvalue, field: field, linkanothergrid: linkanothergrid, linkanothertable: linkanothertable, display: display, linkcombofilter: linkcombofilter,
1087            linkanothersort: linkanothersort, textcombo: 1, textcombocookieazon: textcombocookieazon, notfoundmessage: notfoundmessage
1088        },
1089                function (response) {
1090                    if (response.actvalue == actvalue) {
1091                        if (response.message != '') {
1092                            PreviewOn(response.message);
1093                        }
1094                    }
1095                });
1096    }
1097
1098    function GetPreviewMain(create) {
1099        var form = $root[0].parentNode;
1100        var $preview = $(form).find(".editidsearch-main");
1101        if (!$preview[0]) {
1102            if (create) {
1103                preview = document.createElement('div');
1104                RBInsertNodeAfter($root[0], preview);
1105                $preview = $(preview);
1106                $preview.addClass("editidsearch-main");
1107            }
1108        }
1109        return $preview;
1110    }
1111
1112    function PreviewOff() {
1113        try {
1114            var $preview = GetPreviewMain(false);
1115            if ($preview[0]) {
1116                $preview.removeClass("editidsearch-active");
1117                $preview.addClass("editidsearch-disabled");
1118                $root.removeClass("editidpanel-on");
1119                $root.addClass("editidpanel-off");
1120            }
1121        } catch (e) {
1122        }
1123    }
1124
1125    function PreviewOn(message) {
1126        RBEditIdSearchOff();  // A többit eltüntetjük
1127        var $preview = GetPreviewMain(true);
1128        if ($preview[0]) {
1129            if (message == "") {
1130                PreviewOff();
1131            }
1132            else {
1133                $preview.html(message);
1134                $preview.removeClass("editidsearch-disabled");
1135                $preview.addClass("editidsearch-active");
1136                $root.removeClass("editidpanel-off");
1137                $root.addClass("editidpanel-on");
1138            }
1139        }
1140    }
1141
1142    /*
1143    Start
1144    */
1145    this.each(function () {
1146        base.initialize();
1147    });
1148
1149    return this;
1150}
1151
1152function SetTextItemPlaceHolder(item, addplaceholdertovalinstart) {
1153    var placeholder = item.attr("placeholder");
1154    if (placeholder) {
1155        item.addClass("haveplaceholder");
1156        if (!item.is(":focus")) {
1157            if (item.val() == "") {
1158                if (addplaceholdertovalinstart == 1)
1159                    item.val(placeholder);
1160                item.addClass("showplaceholder");
1161            }
1162        }
1163
1164        item.bind('focus', function () {
1165            item.addClass("placeholder-focused");
1166            item.removeClass("showplaceholder");
1167            if (item.val() == placeholder) {
1168                item.val("");
1169                item.addClass("showplaceholder-hidden");
1170            }
1171        });
1172
1173        item.bind('blur', function () {
1174            item.removeClass("placeholder-focused");
1175            item.removeClass("showplaceholder-hidden");
1176            if (item.val() == "") {
1177                item.val(placeholder);
1178                item.addClass("showplaceholder");
1179            }
1180        });
1181    }
1182}
1183
1184function RBZoomerImage(boxid, image, div) {
1185    var imagesrc = $('#' + boxid + " ." + image).attr('src');
1186    var imagedata = "url('" + imagesrc + "')";
1187    $("#" + boxid + " ." + div).css('background-image', imagedata);
1188    $('#' + boxid).bind('mousemove', function (e) {
1189        var box = $("#" + boxid);
1190        var original = $("#" + boxid + " ." + image);
1191        var magnified = $("#" + boxid + " ." + div);
1192
1193        var boxoffset = box.offset();
1194        var x = e.pageX - boxoffset.left;
1195        var y = e.pageY - boxoffset.top;
1196        var imgWidth = original.width();
1197        var imgHeight = original.height();
1198        var xperc = ((x / imgWidth) * 100);
1199        var yperc = ((y / imgHeight) * 100);
1200
1201        if (x > (.01 * imgWidth)) {
1202            xperc += (.15 * xperc);
1203        };
1204
1205        if (y >= (.01 * imgHeight)) {
1206            yperc += (.15 * yperc);
1207        };
1208        magnified.css('background-position', (xperc - 9) + '% ' + (yperc - 9) + '%');
1209
1210        magnified.css("left", (x - 180) + 'px');
1211        magnified.css("top", (y - 180) + 'px');
1212
1213    }
1214	);
1215}
1216
1217
1218jQuery.fn.placeholder = function () {
1219    $('textarea').each(function () {
1220        /* SetTextItemPlaceHolder($(this), 1);*/
1221    }
1222	);
1223
1224    /*var counter = 0;*/
1225
1226    $('input').each(function () {
1227        var placeholder = $(this).attr("placeholder");
1228        if (placeholder) {
1229            var id = $(this).attr("id");
1230
1231            if ($(this).attr("type") == "password") {
1232                /*SetTextItemPlaceHolder($(this), 1);*/
1233            }
1234
1235            if ($(this).attr("type") == "text") {
1236                /*SetTextItemPlaceHolder($(this), 1);*/
1237            }
1238
1239        }
1240    }
1241	);
1242};
1243
1244$.fn.RBPreviewSearch = function (searchazon, field) {
1245
1246    var base = this;
1247    var $root = $(this);
1248    var stopserver = false;
1249
1250    var actvalue = "";
1251    var ajaxurl = "/previewsearch";
1252
1253    var timer;
1254
1255    this.initialize = function () {
1256        $root.addClass("previewpanel-off");
1257        $root.attr("autocomplete", "off");
1258        $root.keyup(function () {
1259            KeyUpFunc();
1260            return false;
1261        });
1262        $root.change(function () {
1263            KeyUpFunc();
1264            return false;
1265        });
1266        $root[0].onchange = function (e) {
1267            FireEvent(e.id, e.azon);
1268        }
1269        $root.focusin(function () {
1270            var $preview = GetPreviewMain(false);
1271            if ($preview[0])
1272                if ($preview.hasClass("previewsearch-active"))
1273                    if ($root[0].value)
1274                        if (actvalue == $root[0].value)
1275                            return;
1276            PreviewOff();
1277            if ($root[0].value)
1278                if (actvalue == $root[0].value)
1279                    KeyUpRun(actvalue);
1280
1281            return false;
1282        });
1283    }
1284
1285    function FireEvent(id, azon) {
1286        if (id == "blur") {
1287            PreviewOff();
1288            stopserver = true;
1289        }
1290    }
1291
1292    function KeyUpFunc() {
1293        if (actvalue != $root[0].value) {
1294            clearTimeout(timer);
1295            PreviewOff();
1296            actvalue = $root[0].value;
1297            timer = setTimeout(function () { KeyUpRun(actvalue) }, 500);
1298        }
1299    }
1300
1301    function KeyUpRun(act) {
1302        if (act != actvalue)
1303            return;
1304        if (actvalue == "")
1305            return;
1306        if (actvalue.length < 3)
1307            return;
1308
1309        stopserver = false;
1310
1311        $.post(ajaxurl, {
1312            actvalue: actvalue, searchazon: searchazon, field: field
1313        },
1314                function (response) {
1315                    if (response.actvalue == actvalue) {
1316                        if (response.message != '') {
1317                            if (rbenablesubmit)
1318                                if (!stopserver)
1319                                    PreviewOn(response.message);
1320                        }
1321                    }
1322                });
1323    }
1324
1325    function GetPreviewMain(create) {
1326        var form = $root[0].parentNode;
1327        var $preview = $(form).find(".previewsearch-main");
1328        if (!$preview[0]) {
1329            if (create) {
1330                preview = document.createElement('div');
1331                RBInsertNodeAfter($root[0], preview);
1332                $preview = $(preview);
1333                $preview.addClass("previewsearch-main");
1334            }
1335        }
1336        return $preview;
1337    }
1338
1339    function PreviewOff() {
1340        try {
1341            var $preview = GetPreviewMain(false);
1342            if ($preview[0]) {
1343                $preview.removeClass("previewsearch-active");
1344                $preview.addClass("previewsearch-disabled");
1345                $root.removeClass("previewpanel-on");
1346                $root.addClass("previewpanel-off");
1347            }
1348        } catch (e) {
1349        }
1350    }
1351
1352    function PreviewOn(message) {
1353        RBPreviewSearchOff();  // A többit eltüntetjük
1354        var $preview = GetPreviewMain(true);
1355        if ($preview[0]) {
1356            if (message == "") {
1357                PreviewOff();
1358            }
1359            else {
1360                $preview.html(message);
1361                $preview.removeClass("previewsearch-disabled");
1362                $preview.addClass("previewsearch-active");
1363                $root.removeClass("previewpanel-off");
1364                $root.addClass("previewpanel-on");
1365            }
1366        }
1367    }
1368
1369    /*
1370    Start
1371    */
1372    this.each(function () {
1373        base.initialize();
1374    });
1375
1376    return this;
1377}
1378
1379$.fn.RBOnChangeSearch = function (listboxid, ajaxurl, displayazon, pagesize, rbslider2id, filterParamAzon, filterParam, focus, minchangelength, timeoutsearch) {
1380
1381    var base = this;
1382    var $root = $(this);
1383
1384    var actvalue = "";
1385
1386    var timer;
1387
1388    this.initialize = function () {
1389        actvalue = $root[0].value;
1390        if (focus == 1)
1391            SetFocus(this);
1392        /*$(this).focus();*/
1393
1394        $root.keyup(function () {
1395            KeyUpFunc();
1396            return false;
1397        });
1398    }
1399
1400    function KeyUpFunc() {
1401        if (actvalue != $root[0].value) {
1402            actvalue = $root[0].value;
1403            clearTimeout(timer);
1404            timer = setTimeout(KeyUpRun, timeoutsearch);
1405        }
1406    }
1407
1408    function KeyUpRun() {
1409        if (actvalue.length < minchangelength)
1410            if (actvalue != "")
1411                return;
1412
1413        if (actvalue == $root[0].value) {
1414            if (ajaxurl)
1415                RBAjax_ListBoxRefresh(ajaxurl, listboxid, 'search', displayazon, '', '1', '', '0', 'Mosaic', '', actvalue, pagesize);
1416            if (filterParamAzon) {
1417                RBSetSliderFilterParam(rbslider2id, filterParamAzon, filterParam, actvalue, "", rbslider2id);
1418            }
1419            else {
1420                if (rbslider2id) {
1421                    FireRefreshEventHandler(rbslider2id, "Parameters", actvalue);
1422                }
1423            }
1424        }
1425    }
1426
1427    /*
1428    Start
1429    */
1430    this.each(function () {
1431        base.initialize();
1432    });
1433
1434    return this;
1435}
1436
1437$.fn.RBCommentHelper = function (imagefield, videofield) {
1438
1439    var base = this;
1440    var $root = $(this);
1441    var timer;
1442    var actvalue = "";
1443    var ajaxurl = "/Comment/CommentAnalyse";
1444
1445    this.initialize = function () {
1446        $root.keyup(function () {
1447            KeyUpFunc();
1448            return false;
1449        });
1450        $root.change(function () {
1451            KeyUpFunc();
1452            return false;
1453        });
1454    }
1455
1456    function KeyUpFunc() {
1457        if (actvalue != $root[0].value) {
1458            clearTimeout(timer);
1459            actvalue = $root[0].value;
1460            timer = setTimeout(function () { KeyUpRun(actvalue) }, 500);
1461        }
1462    }
1463
1464    function KeyUpRun(act) {
1465        if (act != actvalue)
1466            return;
1467        if (act == "")
1468            return;
1469        if (act.length < 3)
1470            return;
1471        if (act.indexOf("http://") == -1)
1472            if (act.indexOf("https://") == -1)
1473                return;
1474        var imageFieldValue = $('#' + imagefield).val();
1475        if (imageFieldValue)
1476            return;
1477        var videoFieldValue = $('#' + videofield).val();
1478        if (videoFieldValue)
1479            return;
1480
1481        $.post(ajaxurl, {
1482            actvalue: act
1483        }, function (response) {
1484            if (response) {
1485                if (act == actvalue) {
1486                    if (response.fromvalue) {
1487                        actvalue = actvalue.replace(response.fromvalue, "");
1488                        $root.val(actvalue);
1489                    }
1490                    if (response.video) {
1491                        SetVisible(".comment_inputpage_field_video");
1492                        $('#' + videofield).val(response.video).change();
1493                        $(".rb-comment-video-body").html(response.videodiv);
1494                        $(".rb-comment-video-description").html(response.videodesc);
1495                    }
1496                    if (response.image) {
1497                        RBOnClick(".comment_newlinkbutton_image");
1498                        $('#' + imagefield + "_img").attr("src", response.image);
1499                        $('#' + imagefield).val(response.image).change();
1500                    }
1501                }
1502            }
1503        });
1504    }
1505
1506    /*
1507    Start
1508    */
1509    this.each(function () {
1510        base.initialize();
1511    });
1512
1513    return this;
1514}
1515
1516$.fn.RBTabbedPage = function (activpage) {
1517
1518    var base = this;
1519    var $root = $(this);
1520    var $pages = null;
1521
1522    this.initialize = function () {
1523        var id = base[0].id;
1524        $pages = $(document).find(".rb-tabbed-" + id + "-items");
1525        if ($pages.lenght == 0)
1526            return;
1527        if (!activpage)
1528            activpage = 0;
1529        for (var i = 0; i < $pages.length; i++) {
1530            setTabbadPage(i, $pages[i]);
1531        };
1532        setActivePage(activpage);
1533        $root.find('.rb-tabbed-master-item').click(function () {
1534            var index = $root.children().index(this);
1535            setActivePage(index);
1536            return false;
1537        });
1538
1539    }
1540    function setTabbadPage(i, page) {
1541        // $field.append('<div class="mf-field-player-' + i + ' mf-field-player ' + classTeam + '"><div class="mf-player-name"><p></p></div><div class="mf-player-prop"></div></div>');
1542        var $page = $(page);
1543        var $pageTitle = $page.find(".rb-tabbed-pageitem-data");
1544        if ($pageTitle[0]) {
1545            var text = $pageTitle[0].innerHTML;
1546            if (text) {
1547                var classname = "rb-tabbed-master-item rb-tabbed-master-item-" + i;
1548                if (activpage == i)
1549                    classname = classname + " rb-tabbed-master-item-activ";
1550                $root.append('<div class="' + classname + '"><div class="rb-tabbed-master-item-name"><p>' + text + '</p></div></div>');
1551            }
1552        }
1553    }
1554
1555    function setActivePage(newactivpage) {
1556        $root.find(".rb-tabbed-master-item").removeClass("rb-tabbed-master-item-activ");
1557        $(document).find(".rb-tabbed-" + base[0].id + "-items").addClass("rb-tabbed-pageitem-disabled");
1558        activepage = newactivpage;
1559        var masteritem = $root.find(".rb-tabbed-master-item").eq(activepage);
1560        if (masteritem)
1561            masteritem.addClass("rb-tabbed-master-item-activ");
1562        var pageitem = $(document).find(".rb-tabbed-" + base[0].id + "-items").eq(activepage);
1563        if (pageitem)
1564            pageitem.removeClass("rb-tabbed-pageitem-disabled");
1565    }
1566
1567    /*
1568    Start
1569    */
1570    this.each(function () {
1571        base.initialize();
1572    });
1573
1574    return this;
1575}
1576
1577$.fn.RBImageGroupEdit = function (imagegroupid, azon, azonid, needverify, fieldName, mainid, imagePath, pageSize, deletecaption, showempty, showpager, imagewidth, imageheight, enabled,
1578         watermarkimage, refreshurl, deleteurl, watermarkurl, watermarkcaption, autowatermarkimage) {
1579
1580    var base = this;
1581    var $root = $(this);
1582
1583    var pageCount = 1;
1584
1585    this.initialize = function () {
1586        Refresh(pageCount);
1587
1588        RefreshEventHandler();
1589    }
1590
1591    function RefreshEventHandler() {
1592        $root[0].onchange = function (e) {
1593            if (imagegroupid == "")
1594                imagegroupid = e.id;
1595            Refresh(pageCount);
1596        }
1597    }
1598
1599    function Refresh(newPageCount) {
1600        $.post(refreshurl, {
1601            imagegroupid: imagegroupid, azon: azon, azonid: azonid, needverify: needverify, fieldName: fieldName, mainid: mainid, imagePath: imagePath, pageCount: newPageCount,
1602            pageSize: pageSize, showempty: showempty, showpager: showpager, imagewidth: imagewidth, imageheight: imageheight, enabled: enabled, watermarkimage: watermarkimage,
1603            autowatermarkimage: autowatermarkimage
1604        },
1605                function (response) {
1606                    if (response.result) {
1607                        $root.html(response.result);
1608                        pageCount = newPageCount;
1609                        if (enabled == 1)
1610                            SetParams();
1611                    }
1612                });
1613    }
1614
1615    function SetParams() {
1616        $root.find(".imagegroupedit_item_enabledelete").hover(function () {
1617            $(this).append('<div class="imagegroupedit_item_delete" title="' + deletecaption + '"></div>');
1618            var imageid = this.id;
1619
1620            $(this).find(".imagegroupedit_item_delete").click(function () {
1621                $.post(deleteurl, {
1622                    imagegroupid: imagegroupid, azon: azon, azonid: azonid, needverify: needverify, fieldName: fieldName, mainid: mainid, imagePath: imagePath, pageCount: pageCount, pageSize: pageSize, showempty: showempty, showpager: showpager,
1623                    imageId: imageid, imagewidth: imagewidth, imageheight: imageheight, enabled: enabled, watermarkimage: watermarkimage
1624                },
1625                        function (response) {
1626                            if (response.result) {
1627                                $root.html(response.result);
1628                                SetParams();
1629                            }
1630                        });
1631            });
1632        }, function () {
1633            $(this).find(".imagegroupedit_item_delete").remove();
1634        });
1635
1636        $root.find(".imagegroupedit_item_enablewatermark").hover(function () {
1637            $(this).append('<div class="imagegroupedit_item_watermark" title="' + watermarkcaption + '"></div>');
1638            var imageid = this.id;
1639
1640            $(this).find(".imagegroupedit_item_watermark").click(function () {
1641                $.post(watermarkurl, {
1642                    imagegroupid: imagegroupid, azon: azon, azonid: azonid, needverify: needverify, fieldName: fieldName, mainid: mainid, imagePath: imagePath, pageCount: pageCount, pageSize: pageSize, showempty: showempty, showpager: showpager,
1643                    imageId: imageid, imagewidth: imagewidth, imageheight: imageheight, enabled: enabled, watermarkimage: watermarkimage, autowatermarkimage: autowatermarkimage
1644                },
1645                        function (response) {
1646                            if (response.result) {
1647                                $root.html(response.result);
1648                                SetParams();
1649                            }
1650                        });
1651            });
1652        }, function () {
1653            $(this).find(".imagegroupedit_item_watermark").remove();
1654        });
1655
1656        $root.find(".imagegroupedit_prev_enable").click(function () {
1657            Refresh(pageCount - 1);
1658        });
1659        $root.find(".imagegroupedit_next_enable").click(function () {
1660            Refresh(pageCount + 1);
1661        });
1662
1663    }
1664
1665    /*
1666    Start
1667    */
1668    this.each(function () {
1669        base.initialize();
1670    });
1671
1672    return this;
1673}
1674
1675$.fn.RBEntityListEdit = function (entitylistid, fieldName, mainid, grid, deletecaption, enabled) {
1676
1677    var base = this;
1678    var $root = $(this);
1679
1680    var refreshurl = "/" + grid + "/GetEntityListEditData";
1681    var deleteurl = "/" + grid + "/DeleteEntityListEditData";
1682
1683    this.initialize = function () {
1684        Refresh();
1685
1686        RefreshEventHandler();
1687    }
1688
1689    function RefreshEventHandler() {
1690        $root[0].onchange = function (e) {
1691            if (entitylistid == "")
1692                entitylistid = e.id;
1693            Refresh();
1694        }
1695    }
1696
1697    function Refresh() {
1698        $.post(refreshurl, {
1699            entitylistid: entitylistid, fieldName: fieldName, mainid: mainid, enabled: enabled
1700        },
1701                function (response) {
1702                    if (response.result) {
1703                        $root.find(".entitylistedit-main").html(response.result);
1704                        if (enabled == 1)
1705                            SetParams();
1706                    }
1707                });
1708    }
1709
1710    function SetParams() {
1711        $root.find(".entitylistedit_item_enabledelete").hover(function () {
1712            $(this).append('<div class="entitylistedit_item_delete" title="' + deletecaption + '"></div>');
1713            var entityid = this.id;
1714
1715            $(this).find(".entitylistedit_item_delete").click(function () {
1716                $.post(deleteurl, {
1717                    entitylistid: entitylistid, fieldName: fieldName, mainid: mainid, entityId: entityid, enabled: enabled
1718                },
1719                        function (response) {
1720                            if (response.result) {
1721                                $root.find(".entitylistedit-main").html(response.result);
1722                                SetParams();
1723                            }
1724                        });
1725                RBStopEvent(event);
1726                return false;
1727            });
1728        }, function () {
1729            $(this).find(".entitylistedit_item_delete").remove();
1730        });
1731    }
1732
1733    /*
1734    Start
1735    */
1736    this.each(function () {
1737        base.initialize();
1738    });
1739
1740    return this;
1741}
1742
1743$.fn.RBLinkListEdit = function (mainid, table, masterfield, masterid, detailfield, linktype, deletecaption, enabled, displayazon) {
1744
1745    var base = this;
1746    var $root = $(this);
1747
1748    var refreshurl = "/Home/GetLinkListEditData";
1749    var deleteurl = "/Home/DeleteLinkListEditData";
1750
1751    this.initialize = function () {
1752        Refresh();
1753
1754        RefreshEventHandler();
1755    }
1756
1757    function RefreshEventHandler() {
1758        $root[0].onchange = function (e) {
1759            Refresh();
1760        }
1761    }
1762
1763    function Refresh() {
1764        $.post(refreshurl, {
1765            mainid: mainid, table: table, masterfield: masterfield, masterid: masterid, linktype: linktype, enabled: enabled, displayazon: displayazon
1766        },
1767                function (response) {
1768                    if (response.result) {
1769                        $root.find(".entitylistedit-main").html(response.result);
1770                        if (enabled == 1)
1771                            SetParams();
1772                    }
1773                });
1774    }
1775
1776    function SetParams() {
1777        $root.find(".entitylistedit_item_enabledelete").hover(function () {
1778            $(this).append('<div class="entitylistedit_item_delete" title="' + deletecaption + '"></div>');
1779            var entityid = this.id;
1780
1781            $(this).find(".entitylistedit_item_delete").click(function () {
1782                $.post(deleteurl, {
1783                    mainid: mainid, entityId: entityid, table: table, masterfield: masterfield, masterid: masterid, detailfield: detailfield, linktype: linktype, enabled: enabled, displayazon: displayazon
1784                },
1785                        function (response) {
1786                            if (response.result) {
1787                                $root.find(".entitylistedit-main").html(response.result);
1788                                SetParams();
1789                            }
1790                        });
1791                RBStopEvent(event);
1792                return false;
1793            });
1794        }, function () {
1795            $(this).find(".entitylistedit_item_delete").remove();
1796        });
1797    }
1798
1799    /*
1800    Start
1801    */
1802    this.each(function () {
1803        base.initialize();
1804    });
1805
1806    return this;
1807}
1808
1809$.fn.RBSidebar = function (panelfield, effect, loadurl) {
1810
1811    var base = this;
1812    var $root = $(this);
1813    var animateSpeed = 300;
1814
1815    function DisablePanelStart() {
1816        $root.removeClass("rbsidebar_button_disabled");
1817        $root.addClass("rbsidebar_button_visibled");
1818    }
1819
1820    function DisablePanelFinis(init) {
1821        $(document).find('#' + panelfield).removeClass("rbsidebar_panel_visibled");
1822        $(document).find('#' + panelfield).addClass("rbsidebar_panel_disabled");
1823
1824        if (!init)
1825            RBBodyOverlayOff(); // Az overlay-t is bezárjuk
1826    }
1827
1828    function ShowPanelStart() {
1829        RBBodyOverlayClick();  // mindent bezárunk, ha kell
1830
1831        /* RBBodyOverlayOn("rb-noblackoverlay-on");*/
1832        RBBodyOverlayOn();
1833
1834        $(document).find('#' + panelfield).removeClass("rbsidebar_panel_disabled");
1835        $(document).find('#' + panelfield).addClass("rbsidebar_panel_visibled");
1836    }
1837
1838    function ShowPanelFinis() {
1839        $root.removeClass("rbsidebar_button_visibled");
1840        $root.addClass("rbsidebar_button_disabled");
1841    }
1842
1843    function DisablePanelEffect() {
1844        if (effect == "push") {
1845            $(document).find('#' + panelfield).animate({ width: "0%" }, animateSpeed, function () {
1846                // Animation complete.
1847                DisablePanelFinis(false);
1848            });
1849        }
1850        if (effect == "slide") {
1851            $(document).find('#' + panelfield).animate({ width: "0%" }, animateSpeed, function () {
1852                // Animation complete.
1853                DisablePanelFinis(false);
1854            });
1855        }
1856    }
1857
1858    function ShowPanelEffect() {
1859        if (effect == "push") {
1860            $(document).find('#' + panelfield).animate({ width: "100%" }, animateSpeed, function () {
1861                // Animation complete.
1862                ShowPanelFinis();
1863            });
1864        }
1865        if (effect == "slide") {
1866            $(document).find('#' + panelfield).animate({ width: "100%" }, animateSpeed, function () {
1867                // Animation complete.
1868                ShowPanelFinis();
1869            });
1870        }
1871    }
1872
1873    this.initialize = function () {
1874        DisablePanelStart();
1875        DisablePanelFinis(true);
1876
1877        if (loadurl)
1878            $('#' + panelfield).html("");
1879
1880        $root.click(function () {
1881            visibled = RBHasClass($(document).find('#' + panelfield)[0], "rbsidebar_panel_visibled");
1882            if (visibled) {
1883                DisablePanelStart();
1884                DisablePanelEffect();
1885            }
1886            else {
1887                if (loadurl) {
1888                    var data = $('#' + panelfield).html();
1889                    if (!data) {
1890                        LoadPanelData();
1891                        return;
1892                    }
1893                }
1894                ShowPanelStart();
1895                ShowPanelEffect();
1896            }
1897
1898            return false;
1899        });
1900    }
1901
1902    function LoadPanelData() {
1903        $.post(loadurl, function (response) {
1904            if (response) {
1905                if (response.data) {
1906                    var ajaxdiv = $('#' + panelfield);
1907                    ajaxdiv.html(response.data);
1908
1909                    ShowPanelStart();
1910                    ShowPanelEffect();
1911                }
1912            }
1913        });
1914    }
1915
1916    /*
1917    Start
1918    */
1919    this.each(function () {
1920        base.initialize();
1921    });
1922
1923    return this;
1924}
1925
1926$.confirm = function (params) {
1927    if ($('#rbconfirmOverlay').length) {
1928        return false;
1929    }
1930    var buttonHTML = '';
1931    $.each(params.buttons, function (name, obj) {
1932        buttonHTML += '<a href="#" class="rbconfirmBoxButton ' + obj['class'] + '">' + obj['name'] + '<span></span></a>';
1933        if (!obj.action) {
1934            obj.action = function () { };
1935        }
1936    });
1937
1938    var markup = [
1939            '<div id="rbconfirmOverlay">',
1940            '<div id="rbconfirmBox">',
1941            '<h2 class="rbh1">', params.title, '</h2>',
1942            '<p>', params.message, '</p>',
1943            '<div id="rbconfirmButtons">',
1944            buttonHTML,
1945            '</div></div></div>'
1946        ].join('');
1947
1948    $(markup).hide().appendTo('body').fadeIn();
1949
1950    var buttons = $('#rbconfirmBox .rbconfirmBoxButton'),
1951           i = 0;
1952
1953    $.each(params.buttons, function (name, obj) {
1954        buttons.eq(i++).click(function () {
1955            if (obj.action)
1956                eval(obj.action);
1957            $.confirm.hide();
1958            return false;
1959        });
1960    });
1961}
1962
1963$.confirm.hide = function () {
1964    $('#rbconfirmOverlay').fadeOut(function () {
1965        $(this).remove();
1966    });
1967}
1968
1969$.fn.RBUploadImages = function (fieldname, dirname, enableext, isimage, maxUpload, inputs, imageWidth, imageHeight, uploadazon, imageFlood, url, inputPrefixId, autoWaterMarkImage) {
1970
1971    var base = this;
1972    var $root = $(this);
1973
1974    this.initialize = function () {
1975        $('#' + inputPrefixId + ' #' + fieldname + '-close').click(function () {
1976            if (inputs > 0)
1977                for (var i = 0; i < inputs; i++) {
1978                    var rootfield = fieldname + '-' + i;
1979                    if (i == 0)
1980                        rootfield = fieldname + (i + 1);
1981                    $root.find('.inputpage_textimage-item-' + rootfield).remove();
1982                }
1983            inputs = 0;
1984        });
1985
1986        InitInput(fieldname, 0);
1987        if (inputs > 0)
1988            for (var i = 0; i < inputs; i++) {
1989                InitInput(fieldname + '-' + (i + 1), i + 1);
1990            }
1991        var multiplevalue = RBGetMultipleValue('#' + inputPrefixId + ' #' + fieldname);
1992        RBSetValue('#' + inputPrefixId + " #" + fieldname + "_More", multiplevalue);
1993        if (imageFlood)
1994            InitFlood(true);
1995    }
1996
1997    function AddNewInput(startvalue) {
1998        if (inputs >= maxUpload)
1999            return;
2000        inputs++;
2001        var newField = fieldname + '-' + inputs;
2002        $.post(url, {
2003            rootField: fieldname, fieldName: newField, dirName: dirname, enableext: enableext, isImage: isimage, imageWidth: imageWidth, imageHeight: imageHeight, startvalue: startvalue,
2004            uploadazon: uploadazon, inputPrefixId: inputPrefixId, autoWaterMarkImage: autoWaterMarkImage
2005        }, function (response) {
2006            if (response.result) {
2007                $root.append(response.result);
2008                InitInput(newField, inputs);
2009                if (imageFlood) {
2010                    $root.find('.inputpage_textimage-item-' + newField + ' img').load(function () {
2011                        CheckFlood();
2012                    });
2013                    InitFlood(false);
2014                }
2015            }
2016        });
2017    }
2018
2019    function InitInput(field, inputDik) {
2020        // $('#file_upload_input_' + field).change(function () {
2021        $('#' + inputPrefixId + ' #' + field).change(function () {
2022            var multiplevalue = RBGetMultipleValue('#' + inputPrefixId + ' #' + fieldname);
2023            RBSetValue('#' + inputPrefixId + " #" + fieldname + "_More", multiplevalue);
2024            if (imageFlood)
2025                InitFlood(true);
2026            if (inputDik == inputs)
2027                AddNewInput("");
2028        });
2029    }
2030
2031    function InitFlood(init) {
2032        /*
2033        for (var i = 0; i < (inputs + 1); i++) {
2034        var rootfield = fieldname + '-' + i;
2035        if (i == 0)
2036        rootfield = fieldname + (i + 1);
2037        $root.find('.inputpage_textimage-item-' + rootfield).addClass('rbuploadimages-init');
2038        $root.find('.inputpage_textimage-item-' + rootfield).css('width', (100 / imageFlood) + '%');
2039        }
2040        CheckFlood();
2041        */
2042    }
2043
2044    function CheckFloodPage(actPage) {
2045        var page = 0;
2046        var actheight = 0;
2047        var marginHeight = 20;
2048        for (var i = 0; i < (inputs + 1); i++) {
2049            page++;
2050            if (page > imageFlood)
2051                page = imageFlood;
2052            if (page != actPage)
2053                continue;
2054            var rootfield = fieldname + '-' + i;
2055            if (i == 0)
2056                rootfield = fieldname + (i + 1);
2057            var item = $root.find('.inputpage_textimage-item-' + rootfield);
2058            if ($(item).hasClass("rbuploadimages-init")) {
2059                var imgItems = item.find('img');
2060                if (imgItems.length > 0) {
2061                    for (var j = 0; j < imgItems.length; j++) {
2062                        var imgItem = imgItems[j];
2063                        if (!imgItem.complete)
2064                            return false;
2065                    }
2066                }
2067                $(item).css('top', actheight + 'px');
2068                item.top = actheight;
2069                $(item).removeClass("rbuploadimages-init");
2070            }
2071            actheight += item.height() + marginHeight;
2072        }
2073    }
2074
2075    function CheckFlood() {
2076        /*
2077        for (var actPage = 0; actPage < imageFlood; actPage++) {
2078        CheckFloodPage(actPage + 1);
2079        }
2080        */
2081    }
2082    /*
2083    Start
2084    */
2085    this.each(function () {
2086        base.initialize();
2087    });
2088
2089    return this;
2090}
2091
2092$.fn.RBListSlider = function () {
2093
2094    var base = this;
2095    var $root = $(this);
2096    var items = $root.find(".rb-listslideritems .rb-listslideritem");
2097    var act = 0;
2098
2099    this.initialize = function () {
2100        $root[0].onchange = function (e) {
2101            FireEvent(e.id, e.azon);
2102        }
2103        $root.find('.rb-listslider-prevnext-next').click(function () {
2104            GotoNext();
2105        });
2106        $root.find('.rb-listslider-prevnext-prev').click(function () {
2107            GotoPrev();
2108        });
2109    }
2110
2111    function FireEvent(id, azon) {
2112        if (!id && !azon)
2113            return;
2114        if (id == "Select") {
2115            SelectItem(azon);
2116            return;
2117        }
2118    }
2119
2120    function GotoNext() {
2121        if (act < items.length - 1)
2122            SetSelected(act + 1);
2123    }
2124
2125    function GotoPrev() {
2126        if (act > 0)
2127            SetSelected(act - 1);
2128    }
2129
2130    function SetSelected(newact) {
2131        if (newact < 0)
2132            return;
2133        items.removeClass("rb-listslideritem-selected");
2134        var top = 0;
2135        for (var i = 1; i <= items.length; i++) {
2136            if ((i - 1) >= newact) {
2137                $(items[i - 1]).addClass("rb-listslideritem-selected");
2138                break;
2139            }
2140            top += $(items[i - 1]).outerHeight();
2141        }
2142        act = newact;
2143        $root.find(".rb-listslider-container").css('top', '-' + top + 'px');
2144    }
2145
2146    function SelectItem(azon) {
2147        if (!azon)
2148            return;
2149        for (var i = 1; i <= items.length; i++) {
2150            if ($(items[i - 1]).hasClass("rb-listslideritem-" + azon)) {
2151                SetSelected(i - 1);
2152                return;
2153            }
2154        }
2155    }
2156
2157    /*
2158    Start
2159    */
2160    this.each(function () {
2161        base.initialize();
2162    });
2163
2164    return this;
2165}
2166
2167$.fn.RBDashBoardSlider = function (azon, param, extracode, morestr, showurl, startenablenext) {
2168
2169    var base = this;
2170    var $root = $(this);
2171    var act = 0;
2172    var enablenext;
2173    var actshowurl = showurl;
2174
2175    this.initialize = function () {
2176        SetAct(0, startenablenext);
2177        $root.find('.rb-dashboard-controlitem-next').click(function () {
2178            GotoNext();
2179        });
2180        $root.find('.rb-dashboard-controlitem-prev').click(function () {
2181            GotoPrev();
2182        });
2183        $root.find('.rb-dashboard-controlitem-show').click(function () {
2184            RBLoadPage(actshowurl);
2185        });
2186    }
2187
2188    function GotoNext() {
2189        if (!enablenext)
2190            return;
2191        GetData(act + 1);
2192    }
2193
2194    function GotoPrev() {
2195        if (act > 0)
2196            GetData(act - 1);
2197    }
2198
2199    function SetAct(newact, newenablenext) {
2200        act = newact;
2201        enablenext = newenablenext;
2202        if (act == 0)
2203            $root.find('.rb-dashboard-controlitem-prev').addClass("rb-dashboard-nextprev-disabled");
2204        else
2205            $root.find('.rb-dashboard-controlitem-prev').removeClass("rb-dashboard-nextprev-disabled");
2206        if (enablenext)
2207            $root.find('.rb-dashboard-controlitem-next').removeClass("rb-dashboard-nextprev-disabled");
2208        else
2209            $root.find('.rb-dashboard-controlitem-next').addClass("rb-dashboard-nextprev-disabled");
2210    }
2211
2212    function GetData(newact) {
2213        $.post("/Home/DashBoardSliderGetData", {
2214            azon: azon, param: param, extracode: extracode, morestr: morestr, act: newact
2215        }, function (response) {
2216            if (response.error) {
2217                RBMessage(response.error);
2218                return;
2219            }
2220            SetAct(newact, response.enablenext);
2221            actshowurl = response.showurl;
2222            if (response.data) {
2223                $root.find('.rb-section-dashboard-data').html(response.data);
2224            }
2225        });
2226    }
2227
2228    /*
2229    Start
2230    */
2231    this.each(function () {
2232        base.initialize();
2233    });
2234
2235    return this;
2236}
2237
2238$.fn.RBPlayTimeLog = function (azon, url, autoPlay, personId, nextSendSec) {
2239
2240    var base = this;
2241    var id = this[0].id;
2242    var $root = $(this);
2243    var aud = this[0];
2244    var logSec = 0;
2245    var startPayTime = 0;
2246    var validEndPayTime = 0;
2247    var playing = 0;
2248
2249    this.initialize = function () {
2250        $('#' + id).bind('play', function () {
2251            startPayTime = aud.currentTime;
2252            validEndPayTime = 0;
2253            playing = 1;
2254        });
2255        $('#' + id).bind('timeupdate', function () {
2256            if (!aud.seeking)
2257                validEndPayTime = aud.currentTime;
2258        });
2259        $('#' + id).bind('seeking', function () {
2260            EndPlay(true);
2261        });
2262        $('#' + id).bind('pause', function () {
2263            EndPlay(aud.seeking);
2264        });
2265        $('#' + id).bind('ended', function () {
2266            EndPlay(false);
2267        });
2268        if (autoPlay == 1)
2269            playing = 1;
2270        SetCheckNextData();
2271    }
2272
2273    function EndPlay(seek) {
2274        if (playing == 1) {
2275            playing = 0;
2276            var endPayTime = aud.currentTime;
2277            if (seek) {
2278                endPayTime = validEndPayTime;
2279            }
2280            if (endPayTime > 0)
2281                if (endPayTime > startPayTime) {
2282                    logSec += endPayTime - startPayTime;
2283                }
2284            startPayTime = 0;
2285            validEndPayTime = 0;
2286            if (seek) {
2287                startPayTime = aud.currentTime;
2288                playing = 1;
2289            }
2290        }
2291    }
2292
2293    function UpdateLogSec() {
2294        var result = 0;
2295        if (logSec > 0) {
2296            result += logSec;
2297            logSec = 0;
2298        }
2299        if (playing == 1) {
2300            var endPayTime = aud.currentTime;
2301            if (endPayTime > startPayTime) {
2302                result += endPayTime - startPayTime;
2303                startPayTime = endPayTime;
2304            }
2305        }
2306        if (result > 0) {
2307            var resultInt = Math.floor(result);
2308            logSec += result - resultInt;
2309            result = resultInt;
2310        }
2311        return result;
2312    }
2313
2314    function SetCheckNextData() {
2315        setTimeout(function () {
2316            SendData();
2317        }, nextSendSec);
2318    }
2319
2320    function SendData() {
2321        var actLogSec = UpdateLogSec();
2322        if (actLogSec == 0) {
2323            SetCheckNextData();
2324            return;
2325        }
2326        $.post(url, {
2327            azon: azon, actLogSec: actLogSec, personId: personId
2328        }, function (response) {
2329            SetCheckNextData();
2330        }).fail(function (response) {
2331            logSec += actLogSec;
2332            SetCheckNextData();
2333        });
2334    }
2335
2336    /*
2337    Start
2338    */
2339    this.each(function () {
2340        base.initialize();
2341    });
2342
2343    return this;
2344}
2345
2346$.fn.RBShowAudioTrack = function (fullid) {
2347
2348    var base = this;
2349    var id = this[0].id;
2350    var $root = $(this);
2351    var aud = this[0];
2352    var $full = $("#" + fullid);
2353    var $selectfield = $full.find(".rbaudio-controls-select");
2354
2355    this.initialize = function () {
2356        $('#' + id).bind('timeupdate', function () {
2357            ShowTrack();
2358        });
2359        $full.find(".rbaudio-controls-prev").click(function () {
2360            GoTrack(0);
2361        });
2362        $full.find(".rbaudio-controls-next").click(function () {
2363            GoTrack(1);
2364        });
2365        $full.find(".rbaudio-controls-select").change(function () {
2366            var value = $selectfield.val();
2367            SetActTrack(value);
2368        });
2369    }
2370
2371    function ShowTrack() {
2372        var value = GetActTrack();
2373        if ($selectfield.val() != value)
2374            $selectfield.val(value);
2375    }
2376
2377    function GetActTrack() {
2378        var value = 0;
2379        var actStartSec = -1;
2380        var actSec = aud.currentTime;
2381        $full.find("option").each(function () {
2382            var startSec = parseInt($(this).data("time"));
2383            if (actSec >= startSec)
2384                if (startSec > actStartSec) {
2385                    actStartSec = startSec;
2386                    value = $(this).val();
2387                }
2388        });
2389        return parseInt(value);
2390    }
2391
2392    function GoTrack(tonext) {
2393        var value = GetActTrack();
2394        if (tonext==1)
2395            value += 1;
2396        else {
2397            if (value == 0)
2398                return;
2399            value -= 1;
2400        }
2401        SetActTrack(value);
2402    }
2403
2404    function SetActTrack(value) {
2405        $full.find("option").each(function () {
2406            if ($(this).val() == value) {
2407                var startSec = parseInt($(this).data("time"));
2408                aud.currentTime = startSec;
2409            }
2410        });
2411    }
2412
2413    /*
2414    Start
2415    */
2416    this.each(function () {
2417        base.initialize();
2418    });
2419
2420    return this;
2421}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.