PageSourceSearch

https://www.ocftacademy.com/wp-content/themes/ocft/framework/scripts/framework.js?ver=7.0.6

js ocftacademy.com collected 2026-10-04 13:30:25 UTC 17,933 bytes, 591 lines download raw bytes

1/*==============================================================================
2 * old file upload control JS - needs refarctored
3 =============================================================================*/
4
5function getMediaIdFromWordPressMediaInsert(mediaClasses) {
6  var splitMediaId = mediaClasses.split("wp-image-");
7  return splitMediaId[splitMediaId.length - 1];
8}
9
10var thunderAdmin;
11thunderAdmin = {};
12
13jQuery(document).ready( function( _readyEvent ) {
14
15  thunderAdmin.fileInputFields = jQuery ( '.file-upload-text' );
16  window.isToUseSendToFileControls = false;
17
18  function _switchBackToDefaultEditor ( ) {
19    window.isToUseSendToFileControls = false;
20  }
21
22  jQuery ('.file-upload-button').click(function( _event ) {
23    var _textElement;
24    _textElement = jQuery ( _event.currentTarget).prev( '.file-upload-text' );
25    thunderAdmin.fileInputFields.not ( _textElement ).removeClass ( 'file-upload-text-selected' );
26    _textElement.addClass ( 'file-upload-text-selected' );
27    tb_show( '', 'media-upload.php?type=image&TB_iframe=true' );
28    window.isToUseSendToFileControls = true;
29    jQuery ( '#TB_overlay, #TB_closeWindowButton' ).click ( function ( _event ) {
30      setTimeout ( _switchBackToDefaultEditor, 200 );
31    } );
32    return false;
33  });
34
35  window.defaultWPSendToEditor = window.send_to_editor;
36
37  window.send_to_editor = function ( html ) {
38    if ( window.isToUseSendToFileControls ) {
39      window.sendToFileControls ( html );
40    } else {
41      window.defaultWPSendToEditor ( html );
42    }
43  }
44
45  window.sendToFileControls = function(html) {
46    var mediaId = getMediaIdFromWordPressMediaInsert(jQuery('img', html).attr('class'));
47    thunderAdmin.fileInputFields.filter ( '.file-upload-text-selected').val(mediaId);
48    thunderAdmin.fileInputFields.removeClass ( 'file-upload-text-selected' );
49    tb_remove();
50    window.isToUseSendToFileControls = false;
51  }
52
53});
54
55/*==============================================================================
56 * http://stackoverflow.com/questions/5306680/move-an-array-element-from-one-array-position-to-another
57 =============================================================================*/
58
59Array.prototype.move = function (old_index, new_index) {
60  if (new_index >= this.length) {
61    var k = new_index - this.length;
62    while ((k--) + 1) {
63      this.push(undefined);
64    }
65  }
66  this.splice(new_index, 0, this.splice(old_index, 1)[0]);
67  return this; // for testing purposes
68};
69
70
71/*==============================================================================
72 * Global angular object
73 =============================================================================*/
74
75var GlobalAngular = {
76
77  GetSlug: function (e) {
78    return jQuery(e).attr("slug");
79  },
80
81  GetLimit: function (e) {
82    return jQuery(e.find('[limit]')).first().val();
83  },
84
85  GetData: function (e) {
86    var values = [];
87    var dataJson = jQuery(e).val();
88    if (dataJson != "" && dataJson != undefined) {
89      values = JSON.parse(dataJson);
90    }
91    return values;
92  },
93
94  Save: function (e, values) {
95    jQuery(e).val(JSON.stringify(values));
96  },
97
98  Add: function (index, values, obj) {
99    values.splice(index, 0, obj);
100    return values;
101  },
102
103  Delete: function (values, index, text) {
104    if(text == undefined || text == '') {
105      text = "this";
106    }
107    if (confirm('Are you sure you want to delete ' + text + '?')) {
108      values.splice(index, 1)
109    }
110    return values;
111  },
112
113  DeleteAll: function (text, values) {
114    if (confirm('Are you sure you want to delete all the ' + text + '?')) {
115      return [];
116    }
117    return values;
118  },
119
120  Up: function (values, index, amount) {
121    values.move(index, index - amount)
122    return values;
123  },
124
125  Down: function (values, index, amount) {
126    values.move(index, index + amount)
127    return values;
128  }
129
130}
131
132
133/*==============================================================================
134 * TextList
135 =============================================================================*/
136
137var TextList = angular.module('TextList', []);
138TextList.controller('TextListController', function ($scope, $timeout, $rootElement) {
139
140  var dataElement = jQuery($rootElement.find('[data]')).first();
141  $scope.values = GlobalAngular.GetData(dataElement);
142  $scope.slug = GlobalAngular.GetSlug($rootElement);
143  $scope.limit = GlobalAngular.GetLimit($rootElement);
144
145  /* main object */
146  function Obj() {
147    this.value = '';
148  }
149
150  /** copy values to text input when form is posted for to Save with php */
151  jQuery("#post").submit(function (event) {
152    $scope.Save();
153  });
154
155  $scope.Save = function () {
156    GlobalAngular.Save(dataElement, $scope.values);
157  };
158
159  $scope.Add = function ($index) {
160    $scope.values = GlobalAngular.Add($index, $scope.values, new Obj());
161    $scope.Save();
162  };
163
164  $scope.DeleteAll = function () {
165    $scope.values = GlobalAngular.DeleteAll('text boxes', $scope.values);
166    $scope.Save();
167  };
168
169  $scope.Delete = function ($index) {
170    $scope.values = GlobalAngular.Delete($scope.values, $index, $scope.values[$index].value);
171    $scope.Save();
172  };
173
174  $scope.Up = function ($index, $amount) {
175    $scope.values = GlobalAngular.Up($scope.values, $index, $amount);
176    $scope.Save();
177  };
178
179  $scope.Down = function ($index, $amount) {
180    $scope.values = GlobalAngular.Down($scope.values, $index, $amount);
181    $scope.Save();
182  }
183
184});
185
186
187/*==============================================================================
188 * LinkList
189 =============================================================================*/
190
191var LinkList = angular.module('LinkList', []);
192LinkList.controller('LinkListController', function ($scope, $timeout, $rootElement) {
193
194  var dataElement = jQuery($rootElement.find('[data]')).first();
195  $scope.values = GlobalAngular.GetData(dataElement);
196  $scope.slug = GlobalAngular.GetSlug($rootElement);
197  $scope.limit = GlobalAngular.GetLimit($rootElement);
198  $scope.types = ['onsite', 'offsite'];
199
200  $scope.posts = [];
201  var postsElement = jQuery($rootElement.find('[source]')).first();
202  var postsJson = jQuery(postsElement).val();
203  if (postsJson != "" && postsJson != undefined) {
204    $scope.posts = JSON.parse(postsJson);
205  }
206
207  /* main object */
208  function Obj() {
209    this.type = 'onsite';
210    this.id = '';
211    this.external = '';
212    this.newTab = '';
213    this.text = '';
214  }
215
216  /** copy values to text input when form is posted for to Save with php */
217  jQuery("#post").submit(function (event) {
218    $scope.Save();
219  });
220
221  $scope.Save = function () {
222    GlobalAngular.Save(dataElement, $scope.values);
223  };
224
225  $scope.Add = function ($index) {
226    $scope.values = GlobalAngular.Add($index, $scope.values, new Obj());
227    $scope.Save();
228  };
229
230  $scope.DeleteAll = function () {
231    $scope.values = GlobalAngular.DeleteAll('links', $scope.values);
232    $scope.Save();
233  };
234
235  $scope.Delete = function ($index) {
236    $scope.values = GlobalAngular.Delete($scope.values, $index, $scope.values[$index].text);
237    $scope.Save();
238  };
239
240  $scope.Up = function ($index, $amount) {
241    $scope.values = GlobalAngular.Up($scope.values, $index, $amount);
242    $scope.Save();
243  };
244
245  $scope.Down = function ($index, $amount) {
246    $scope.values = GlobalAngular.Down($scope.values, $index, $amount);
247    $scope.Save();
248  }
249
250});
251
252
253/*==============================================================================
254 * Content list
255 =============================================================================*/
256
257var ContentList = angular.module('ContentList', []);
258ContentList.controller('ContentListController', function ($scope, $timeout, $rootElement) {
259
260  $scope.content = [];
261  var contentElement = jQuery($rootElement.find('[content]')).first();
262  var contentJson = jQuery(contentElement).val();
263  if (contentJson != "" && contentJson != undefined) {
264    $scope.content = JSON.parse(contentJson);
265  }
266
267  var dataElement = jQuery($rootElement.find('[data]')).first();
268  $scope.values = GlobalAngular.GetData(dataElement);
269  $scope.slug = GlobalAngular.GetSlug($rootElement);
270  $scope.limit = GlobalAngular.GetLimit($rootElement);
271
272  /* main object */
273  function Obj() {
274    this.id = '';
275  }
276
277  /** copy values to text input when form is posted for to Save with php */
278  jQuery("#post").submit(function (event) {
279    $scope.Save();
280  });
281
282  $scope.Save = function () {
283    GlobalAngular.Save(dataElement, $scope.values);
284  };
285
286  $scope.Add = function ($index) {
287    $scope.values = GlobalAngular.Add($index, $scope.values, new Obj());
288    $scope.Save();
289  };
290
291  $scope.DeleteAll = function () {
292    $scope.values = GlobalAngular.DeleteAll('all items', $scope.values);
293    $scope.Save();
294  };
295
296  $scope.Delete = function ($index) {
297    $scope.values = GlobalAngular.Delete($scope.values, $index, 'item');
298    $scope.Save();
299  };
300
301  $scope.Up = function ($index, $amount) {
302    $scope.values = GlobalAngular.Up($scope.values, $index, $amount);
303    $scope.Save();
304  };
305
306  $scope.Down = function ($index, $amount) {
307    $scope.values = GlobalAngular.Down($scope.values, $index, $amount);
308    $scope.Save();
309  }
310
311});
312
313
314/*==============================================================================
315 * Calendar
316 =============================================================================*/
317
318var Calendar = angular.module('Calendar', []);
319Calendar.controller('CalendarController', function ($scope, $timeout, $rootElement) {
320
321  $scope.CurrentDate = new Date();
322  $scope.slug = jQuery($rootElement).attr("slug");
323  $scope.monthYearText = '';
324  $scope.month = [];
325  $scope.hour = 8;
326  $scope.minute = 0;
327  $scope.meridiem = 'am';
328  $scope.tableHeads = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];
329  $scope.hourValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
330  $scope.meridiemValues = ['am', 'pm'];
331  $scope.minuteValues = [];
332  for (var i = 0; i < 60; i++) {
333    $scope.minuteValues.push(i);
334  }
335
336  $scope.values = [];
337  var data = jQuery($rootElement.find('[data]')).first();
338  var dataJson = jQuery(data).val();
339  if (dataJson != "" && dataJson != undefined) {
340    $scope.values = JSON.parse(dataJson);
341    $scope.CurrentDate = new Date($scope.values);
342    var h = $scope.CurrentDate.getHours();
343    if (h > 12) {
344      h = h - 12;
345      $scope.meridiem = 'pm';
346    } else {
347      $scope.meridiem = 'am';
348    }
349    $scope.hour = h;
350    $scope.minute = $scope.CurrentDate.getMinutes();
351  }
352
353  $scope.Update = function () {
354    $scope.month = $scope.CreateCalendarMonthArray();
355    //Update calendar title with correct month and year
356    $scope.monthYearText = $scope.GetCurrentDateLabel();
357  }
358
359  /** copy values to text input when form is posted for to Save with php */
360  jQuery("#post").submit(function (event) {
361    $scope.Save();
362  });
363
364  $scope.Save = function () {
365    //Add hour and minute values to $scope.CurrentDate
366    $scope.SetTime();
367    //Save milliseconds (unix epoch) as value to database
368    var UtcUnixEpoch = $scope.CurrentDate.getTime();
369    $scope.values = UtcUnixEpoch;
370    GlobalAngular.Save(data, $scope.values);
371  };
372
373  $scope.GetCurrentMonth = function () {
374    //zero based so we Add one
375    return $scope.CurrentDate.getMonth() + 1;
376  }
377
378  $scope.GetLastDayInCurrentMonth = function() {
379    var LastDayInCurrentMonth = new Date($scope.GetCurrentYear(), $scope.GetCurrentMonth(), 0);
380    return LastDayInCurrentMonth.getDate();
381  }
382
383  $scope.GetCurrentYear = function() {
384    return $scope.CurrentDate.getFullYear();
385  }
386
387  $scope.GetCurrentDay = function() {
388    return $scope.CurrentDate.getDate();
389  }
390
391  $scope.GetCurrentDateLabel = function() {
392    var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
393    //used for header of calendar to display month name and year
394    return months[$scope.GetCurrentMonth() - 1] + ' ' + $scope.GetCurrentYear();
395  }
396
397  $scope.GoToNextMonth = function () {
398    $scope.CurrentDate.addMonths(1);
399    $scope.CurrentDate.setDate(1);
400    $scope.Update();
401  }
402
403  $scope.GoToPreviousMonth = function () {
404    $scope.CurrentDate.addMonths(-1)
405    $scope.CurrentDate.setDate(1);
406    $scope.Update();
407  }
408
409  $scope.SetTime = function () {
410    if ($scope.hour != undefined && $scope.hour > 0 && $scope.minute != undefined && $scope.minute > -1 && $scope.meridiem != undefined && $scope.meridiem != '') {
411      var h = parseInt($scope.hour);
412      if ($scope.meridiem == "pm") {
413        h = h + 12;
414      }
415      $scope.CurrentDate.setMinutes(parseInt($scope.minute));
416      $scope.CurrentDate.setHours(parseInt(h));
417      $scope.CurrentDate.setSeconds(0); //we aren't keeping track of seconds crazy
418    }
419  }
420
421  $scope.SelectDate = function (day) {
422    $scope.CurrentDate.setDate(day);
423    $scope.Update();
424  }
425
426  $scope.SelectToday = function (Day, Month, Year) {
427    $scope.CurrentDate = new Date();
428    $scope.Update();
429  }
430
431  // Returns an array of arrays representing the current month
432  $scope.CreateCalendarMonthArray = function () {
433    var Month = new Array();
434    for (WeekCounter = 0; WeekCounter < 6; WeekCounter++) {
435      Month[WeekCounter] = new Array(7);
436    }
437    var FirstDayOfCurrentMonth = new Date($scope.GetCurrentYear(), $scope.GetCurrentMonth() - 1, 1).getDay();
438    var TotalDaysInMonth = $scope.GetLastDayInCurrentMonth();
439    var DateCounter = 1;
440    var Day, Week;
441    //first week doesn't necessarily start on sunday so we loop through the first week separately.
442    for (Day = FirstDayOfCurrentMonth; Day < 7; Day++) {
443      Month[0][Day] = DateCounter;
444      DateCounter++;
445    }
446    //after the first week, start looping through each Additional week.
447    for (Week = 1; Week < 6; Week++) {
448      for (Day = 0; Day < 7; Day++) {
449        if (DateCounter <= TotalDaysInMonth) {
450          Month[Week][Day] = DateCounter;
451          DateCounter++;
452        }
453      }
454    }
455    return Month;
456  }
457
458  //draw initial calendar
459  $scope.Update();
460
461});
462
463/** format the minutes in the minute drop Down */
464Calendar.filter("minuteFormatter", function () {
465  return function (minute) {
466    if (parseInt(minute) < 10) {
467      return "0" + minute;
468    } else {
469      return minute;
470    }
471  }
472});
473
474
475/*==============================================================================
476 * Widget list
477 =============================================================================*/
478
479var Widget = angular.module('WidgetList', ['ui.sortable']);
480Widget.controller('WidgetListController', function ($scope, $timeout, $rootElement) {
481
482  $scope.selectedWidgetIndex = 0;
483  $scope.selectedTabIndex = 0;
484  $scope.selectedPostType = '';
485
486  $scope.content = [];
487  var contentElement = jQuery($rootElement.find('[content]')).first();
488  var contentJson = jQuery(contentElement).val();
489  if (contentJson != "" && contentJson != undefined) {
490    $scope.content = JSON.parse(contentJson);
491  }
492
493  $scope.postTypes = [];
494  var postTypesElement = jQuery($rootElement.find('[postTypes]')).first();
495  var postTypesJson = jQuery(postTypesElement).val();
496  if (postTypesJson != "" && postTypesJson != undefined) {
497    $scope.postTypes = JSON.parse(postTypesJson);
498    if($scope.postTypes.length > 0 && $scope.postTypes[0] != undefined) {
499      $scope.selectedPostType = $scope.postTypes[0].systemName;      
500    }
501  }
502
503  var dataElement = jQuery($rootElement.find('[data]')).first();
504  $scope.values = GlobalAngular.GetData(dataElement);
505  $scope.slug = GlobalAngular.GetSlug($rootElement);
506  $scope.limit = GlobalAngular.GetLimit($rootElement);
507
508  /* main object */
509  function Obj() {
510    this.id = -1;
511  }
512
513  /** copy values to text input when form is posted for to Save with php */
514  jQuery("#post").submit(function (event) {
515    $scope.Save();
516  });
517
518  $scope.Save = function () {
519    GlobalAngular.Save(dataElement, $scope.values);
520  };
521
522  $scope.Add = function ($index) {
523    $scope.values = GlobalAngular.Add($index, $scope.values, new Obj());
524    $scope.DisplayWidgetSelector(0);
525    $scope.Save();
526  };
527
528  $scope.DeleteAll = function () {
529    $scope.values = GlobalAngular.DeleteAll('all widgets from this section', $scope.values);
530    $scope.Save();
531  };
532
533  $scope.Delete = function ($index) {
534    $scope.values = GlobalAngular.Delete($scope.values, $index, 'widget');
535    $scope.Save();
536  };
537
538  $scope.Up = function ($index, $amount) {
539    $scope.values = GlobalAngular.Up($scope.values, $index, $amount);
540    $scope.Save();
541  };
542
543  $scope.Down = function ($index, $amount) {
544    $scope.values = GlobalAngular.Down($scope.values, $index, $amount);
545    $scope.Save();
546  }
547
548  $scope.DisplayWidgetSelector = function ($index) {
549    $scope.selectedWidgetIndex = $index;
550    jQuery('body').css('overflow', 'hidden');
551    var widgetSelector = jQuery('#' + $scope.slug + '-widget-selector');
552    widgetSelector.removeClass('wordpressnes-hidden');
553    var widgetSelectorBackground = jQuery('#' + $scope.slug + '-widget-selector-background');
554    widgetSelectorBackground.removeClass('wordpressnes-hidden');
555  }
556
557  $scope.HideWidgetSelector = function () {
558    jQuery('body').css('overflow', 'auto');
559    var widgetSelector = jQuery('#' + $scope.slug + '-widget-selector');
560    widgetSelector.addClass('wordpressnes-hidden');
561    var widgetSelectorBackground = jQuery('#' + $scope.slug + '-widget-selector-background');
562    widgetSelectorBackground.addClass('wordpressnes-hidden');
563  }
564
565  $scope.ChangeWidgetCategory = function ($index) {
566    $scope.selectedTabIndex = $index;
567    $scope.selectedPostType = $scope.postTypes[$index].systemName;
568  }
569
570  $scope.GetActiveClass = function ($index) {
571    if ($index == $scope.selectedTabIndex) {
572      return "active";
573    }
574  }
575
576  $scope.SelectWidget = function ($selectedContentPostId) {
577    $scope.HideWidgetSelector();
578    for(var i = 0; i < $scope.values.length; ++i){
579      if(i == $scope.selectedWidgetIndex) {
580        $scope.values[i].id = $selectedContentPostId;
581      }
582    }
583    $scope.Save();
584  }
585
586});
587Widget.filter('unsafe', function($sce) {
588  return function(val) {
589      return $sce.trustAsHtml(val);
590  };
591});

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.