OpenSencillo  2015.009
Long live the simplicity of PHP
 All Data Structures Namespaces Files Functions Pages
custom.js
1 /*
2  * To change this license header, choose License Headers in Project Properties.
3  * To change this template file, choose Tools | Templates
4  * and open the template in the editor.
5  */
6 
8 $(function () {
9  $('#sidebar-menu li ul').slideUp();
10  $('#sidebar-menu li').removeClass('active');
11 
12  $('#sidebar-menu li').on('click touchstart', function() {
13  var link = $('a', this).attr('href');
14 
15  if(link) {
16  window.location.href = link;
17  } else {
18  if ($(this).is('.active')) {
19  $(this).removeClass('active');
20  $('ul', this).slideUp();
21  } else {
22  $('#sidebar-menu li').removeClass('active');
23  $('#sidebar-menu li ul').slideUp();
24 
25  $(this).addClass('active');
26  $('ul', this).slideDown();
27  }
28  }
29  });
30 
31  $('#menu_toggle').click(function () {
32  if ($('body').hasClass('nav-md')) {
33  $('body').removeClass('nav-md').addClass('nav-sm');
34  $('.left_col').removeClass('scroll-view').removeAttr('style');
35  $('.sidebar-footer').hide();
36 
37  if ($('#sidebar-menu li').hasClass('active')) {
38  $('#sidebar-menu li.active').addClass('active-sm').removeClass('active');
39  }
40  } else {
41  $('body').removeClass('nav-sm').addClass('nav-md');
42  $('.sidebar-footer').show();
43 
44  if ($('#sidebar-menu li').hasClass('active-sm')) {
45  $('#sidebar-menu li.active-sm').addClass('active').removeClass('active-sm');
46  }
47  }
48  });
49 });
50 
51 /* Sidebar Menu active class */
52 $(function () {
53  var url = window.location;
54  $('#sidebar-menu a[href="' + url + '"]').parent('li').addClass('current-page');
55  $('#sidebar-menu a').filter(function () {
56  return this.href == url;
57  }).parent('li').addClass('current-page').parent('ul').slideDown().parent().addClass('active');
58 });
59 
62 $(".right_col").css("min-height", $(window).height());
63 $(window).resize(function () {
64  $(".right_col").css("min-height", $(window).height());
65 });
71 $(function () {
72  $('[data-toggle="tooltip"]').tooltip()
73 })
76 if ($(".progress .progress-bar")[0]) {
77  $('.progress .progress-bar').progressbar(); // bootstrap 3
78 }
81 if ($(".js-switch")[0]) {
82  var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));
83  elems.forEach(function (html) {
84  var switchery = new Switchery(html, {
85  color: '#26B99A'
86  });
87  });
88 }
91 // Close ibox function
92 $('.close-link').click(function () {
93  var content = $(this).closest('div.x_panel');
94  content.remove();
95 });
96 
97 // Collapse ibox function
98 $('.collapse-link').click(function () {
99  var x_panel = $(this).closest('div.x_panel');
100  var button = $(this).find('i');
101  var content = x_panel.find('div.x_content');
102  content.slideToggle(200);
103  (x_panel.hasClass('fixed_height_390') ? x_panel.toggleClass('').toggleClass('fixed_height_390') : '');
104  (x_panel.hasClass('fixed_height_320') ? x_panel.toggleClass('').toggleClass('fixed_height_320') : '');
105  button.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down');
106  setTimeout(function () {
107  x_panel.resize();
108  }, 50);
109 });
112 if ($("input.flat")[0]) {
113  $(document).ready(function () {
114  $('input.flat').iCheck({
115  checkboxClass: 'icheckbox_flat-green',
116  radioClass: 'iradio_flat-green'
117  });
118  });
119 }
122 // Starrr plugin (https://github.com/dobtco/starrr)
123 var __slice = [].slice;
124 
125 (function ($, window) {
126  var Starrr;
127 
128  Starrr = (function () {
129  Starrr.prototype.defaults = {
130  rating: void 0,
131  numStars: 5,
132  change: function (e, value) {
133  }
134  };
135 
136  function Starrr($el, options) {
137  var i, _, _ref,
138  _this = this;
139 
140  this.options = $.extend({}, this.defaults, options);
141  this.$el = $el;
142  _ref = this.defaults;
143  for (i in _ref) {
144  _ = _ref[i];
145  if (this.$el.data(i) != null) {
146  this.options[i] = this.$el.data(i);
147  }
148  }
149  this.createStars();
150  this.syncRating();
151  this.$el.on('mouseover.starrr', 'span', function (e) {
152  return _this.syncRating(_this.$el.find('span').index(e.currentTarget) + 1);
153  });
154  this.$el.on('mouseout.starrr', function () {
155  return _this.syncRating();
156  });
157  this.$el.on('click.starrr', 'span', function (e) {
158  return _this.setRating(_this.$el.find('span').index(e.currentTarget) + 1);
159  });
160  this.$el.on('starrr:change', this.options.change);
161  }
162 
163  Starrr.prototype.createStars = function () {
164  var _i, _ref, _results;
165 
166  _results = [];
167  for (_i = 1, _ref = this.options.numStars; 1 <= _ref ? _i <= _ref : _i >= _ref; 1 <= _ref ? _i++ : _i--) {
168  _results.push(this.$el.append("<span class='glyphicon .glyphicon-star-empty'></span>"));
169  }
170  return _results;
171  };
172 
173  Starrr.prototype.setRating = function (rating) {
174  if (this.options.rating === rating) {
175  rating = void 0;
176  }
177  this.options.rating = rating;
178  this.syncRating();
179  return this.$el.trigger('starrr:change', rating);
180  };
181 
182  Starrr.prototype.syncRating = function (rating) {
183  var i, _i, _j, _ref;
184 
185  rating || (rating = this.options.rating);
186  if (rating) {
187  for (i = _i = 0, _ref = rating - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
188  this.$el.find('span').eq(i).removeClass('glyphicon-star-empty').addClass('glyphicon-star');
189  }
190  }
191  if (rating && rating < 5) {
192  for (i = _j = rating; rating <= 4 ? _j <= 4 : _j >= 4; i = rating <= 4 ? ++_j : --_j) {
193  this.$el.find('span').eq(i).removeClass('glyphicon-star').addClass('glyphicon-star-empty');
194  }
195  }
196  if (!rating) {
197  return this.$el.find('span').removeClass('glyphicon-star').addClass('glyphicon-star-empty');
198  }
199  };
200 
201  return Starrr;
202 
203  })();
204  return $.fn.extend({
205  starrr: function () {
206  var args, option;
207 
208  option = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
209  return this.each(function () {
210  var data;
211 
212  data = $(this).data('star-rating');
213  if (!data) {
214  $(this).data('star-rating', (data = new Starrr($(this), option)));
215  }
216  if (typeof option === 'string') {
217  return data[option].apply(data, args);
218  }
219  });
220  }
221  });
222 })(window.jQuery, window);
223 
224 $(function () {
225  return $(".starrr").starrr();
226 });
227 
228 $(document).ready(function () {
229 
230  $('#stars').on('starrr:change', function (e, value) {
231  $('#count').html(value);
232  });
233 
234 
235  $('#stars-existing').on('starrr:change', function (e, value) {
236  $('#count-existing').html(value);
237  });
238 
239 });
242 $('table input').on('ifChecked', function () {
243  check_state = '';
244  $(this).parent().parent().parent().addClass('selected');
245  countChecked();
246 });
247 $('table input').on('ifUnchecked', function () {
248  check_state = '';
249  $(this).parent().parent().parent().removeClass('selected');
250  countChecked();
251 });
252 
253 var check_state = '';
254 $('.bulk_action input').on('ifChecked', function () {
255  check_state = '';
256  $(this).parent().parent().parent().addClass('selected');
257  countChecked();
258 });
259 $('.bulk_action input').on('ifUnchecked', function () {
260  check_state = '';
261  $(this).parent().parent().parent().removeClass('selected');
262  countChecked();
263 });
264 $('.bulk_action input#check-all').on('ifChecked', function () {
265  check_state = 'check_all';
266  countChecked();
267 });
268 $('.bulk_action input#check-all').on('ifUnchecked', function () {
269  check_state = 'uncheck_all';
270  countChecked();
271 });
272 
273 function countChecked() {
274  if (check_state == 'check_all') {
275  $(".bulk_action input[name='table_records']").iCheck('check');
276  }
277  if (check_state == 'uncheck_all') {
278  $(".bulk_action input[name='table_records']").iCheck('uncheck');
279  }
280  var n = $(".bulk_action input[name='table_records']:checked").length;
281  if (n > 0) {
282  $('.column-title').hide();
283  $('.bulk-actions').show();
284  $('.action-cnt').html(n + ' Records Selected');
285  } else {
286  $('.column-title').show();
287  $('.bulk-actions').hide();
288  }
289 }
299 $(function () {
300  $(".expand").on("click", function () {
301  $(this).next().slideToggle(200);
302  $expand = $(this).find(">:first-child");
303 
304  if ($expand.text() == "+") {
305  $expand.text("-");
306  } else {
307  $expand.text("+");
308  }
309  });
310 });
311 
315 $(document).ready(function () {
316 
317  $(".scroll-view").niceScroll({
318  touchbehavior: true,
319  cursorcolor: "rgba(42, 63, 84, 0.35)"
320  });
321 
322 });
326 if (typeof NProgress != 'undefined') {
327  $(document).ready(function () {
328  NProgress.start();
329  });
330 
331  $(window).load(function () {
332  NProgress.done();
333  });
334 }