adminlte.js 28.2 KB
Newer Older
A
Abdullah Almsaeed 已提交
1 2 3 4 5 6
/*! AdminLTE app.js
* ================
* Main JS application file for AdminLTE v2. This file
* should be included in all pages. It controls some layout
* options and implements exclusive AdminLTE plugins.
*
R
REJack 已提交
7 8
* @author Colorlib
* @support <https://github.com/ColorlibHQ/AdminLTE/issues>
R
REJack 已提交
9
* @version 2.4.11
R
REJack 已提交
10
* @repository git://github.com/ColorlibHQ/AdminLTE.git
A
Abdullah Almsaeed 已提交
11 12 13 14 15 16 17 18
* @license MIT <http://opensource.org/licenses/MIT>
*/

// Make sure jQuery has been loaded
if (typeof jQuery === 'undefined') {
throw new Error('AdminLTE requires jQuery')
}

A
Abdullah Almsaeed 已提交
19 20 21
/* BoxRefresh()
 * =========
 * Adds AJAX content control to a box.
A
Abdullah Almsaeed 已提交
22
 *
A
Abdullah Almsaeed 已提交
23 24 25
 * @Usage: $('#my-box').boxRefresh(options)
 *         or add [data-widget="box-refresh"] to the box element
 *         Pass any option as data-option="value"
A
Abdullah Almsaeed 已提交
26 27
 */
+function ($) {
28
  'use strict';
A
Abdullah Almsaeed 已提交
29

30
  var DataKey = 'lte.boxrefresh';
A
Abdullah Almsaeed 已提交
31 32

  var Default = {
A
Abdullah Almsaeed 已提交
33 34 35 36 37 38 39 40 41 42
    source         : '',
    params         : {},
    trigger        : '.refresh-btn',
    content        : '.box-body',
    loadInContent  : true,
    responseType   : '',
    overlayTemplate: '<div class="overlay"><div class="fa fa-refresh fa-spin"></div></div>',
    onLoadStart    : function () {
    },
    onLoadDone     : function (response) {
43
      return response;
A
Abdullah Almsaeed 已提交
44
    }
45
  };
A
Abdullah Almsaeed 已提交
46 47

  var Selector = {
A
Abdullah Almsaeed 已提交
48
    data: '[data-widget="box-refresh"]'
49
  };
A
Abdullah Almsaeed 已提交
50

A
Abdullah Almsaeed 已提交
51 52 53
  // BoxRefresh Class Definition
  // =========================
  var BoxRefresh = function (element, options) {
54 55
    this.element  = element;
    this.options  = options;
O
Olda Horák 已提交
56
    this.$overlay = $(options.overlayTemplate);
A
Abdullah Almsaeed 已提交
57

A
Abdullah Almsaeed 已提交
58
    if (options.source === '') {
59
      throw new Error('Source url was not defined. Please specify a url in your BoxRefresh source option.');
A
Abdullah Almsaeed 已提交
60 61
    }

62 63 64
    this._setUpListeners();
    this.load();
  };
A
Abdullah Almsaeed 已提交
65

A
Abdullah Almsaeed 已提交
66
  BoxRefresh.prototype.load = function () {
67 68
    this._addOverlay();
    this.options.onLoadStart.call($(this));
A
Abdullah Almsaeed 已提交
69

A
Abdullah Almsaeed 已提交
70 71
    $.get(this.options.source, this.options.params, function (response) {
      if (this.options.loadInContent) {
O
Olda Horák 已提交
72
        $(this.element).find(this.options.content).html(response);
A
Abdullah Almsaeed 已提交
73
      }
74 75 76 77
      this.options.onLoadDone.call($(this), response);
      this._removeOverlay();
    }.bind(this), this.options.responseType !== '' && this.options.responseType);
  };
A
Abdullah Almsaeed 已提交
78

A
Abdullah Almsaeed 已提交
79
  // Private
A
Abdullah Almsaeed 已提交
80

A
Abdullah Almsaeed 已提交
81
  BoxRefresh.prototype._setUpListeners = function () {
O
Olda Horák 已提交
82
    $(this.element).on('click', this.options.trigger, function (event) {
83 84 85 86
      if (event) event.preventDefault();
      this.load();
    }.bind(this));
  };
A
Abdullah Almsaeed 已提交
87

A
Abdullah Almsaeed 已提交
88
  BoxRefresh.prototype._addOverlay = function () {
89 90
    $(this.element).append(this.$overlay);
  };
A
Abdullah Almsaeed 已提交
91

A
Abdullah Almsaeed 已提交
92
  BoxRefresh.prototype._removeOverlay = function () {
O
Olda Horák 已提交
93
    $(this.$overlay).remove();
94
  };
A
Abdullah Almsaeed 已提交
95 96 97 98 99

  // Plugin Definition
  // =================
  function Plugin(option) {
    return this.each(function () {
100 101
      var $this = $(this);
      var data  = $this.data(DataKey);
A
Abdullah Almsaeed 已提交
102 103

      if (!data) {
104 105
        var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
        $this.data(DataKey, (data = new BoxRefresh($this, options)));
A
Abdullah Almsaeed 已提交
106 107
      }

A
Abdullah Almsaeed 已提交
108 109
      if (typeof data == 'string') {
        if (typeof data[option] == 'undefined') {
110
          throw new Error('No method named ' + option);
A
Abdullah Almsaeed 已提交
111
        }
112
        data[option]();
A
Abdullah Almsaeed 已提交
113
      }
114
    });
A
Abdullah Almsaeed 已提交
115 116
  }

117
  var old = $.fn.boxRefresh;
A
Abdullah Almsaeed 已提交
118

119 120
  $.fn.boxRefresh             = Plugin;
  $.fn.boxRefresh.Constructor = BoxRefresh;
A
Abdullah Almsaeed 已提交
121

A
Abdullah Almsaeed 已提交
122
  // No Conflict Mode
A
Abdullah Almsaeed 已提交
123
  // ================
A
Abdullah Almsaeed 已提交
124
  $.fn.boxRefresh.noConflict = function () {
125 126 127
    $.fn.boxRefresh = old;
    return this;
  };
A
Abdullah Almsaeed 已提交
128

A
Abdullah Almsaeed 已提交
129 130
  // BoxRefresh Data API
  // =================
A
Abdullah Almsaeed 已提交
131
  $(window).on('load', function () {
A
Abdullah Almsaeed 已提交
132
    $(Selector.data).each(function () {
133 134 135
      Plugin.call($(this));
    });
  });
A
Abdullah Almsaeed 已提交
136

137
}(jQuery);
A
Abdullah Almsaeed 已提交
138 139


A
Abdullah Almsaeed 已提交
140 141 142
/* BoxWidget()
 * ======
 * Adds box widget functions to boxes.
A
Abdullah Almsaeed 已提交
143
 *
A
Abdullah Almsaeed 已提交
144 145 146
 * @Usage: $('.my-box').boxWidget(options)
 *         This plugin auto activates on any element using the `.box` class
 *         Pass any option as data-option="value"
A
Abdullah Almsaeed 已提交
147 148
 */
+function ($) {
149
  'use strict';
A
Abdullah Almsaeed 已提交
150

151
  var DataKey = 'lte.boxwidget';
A
Abdullah Almsaeed 已提交
152 153

  var Default = {
A
Abdullah Almsaeed 已提交
154 155 156 157 158 159
    animationSpeed : 500,
    collapseTrigger: '[data-widget="collapse"]',
    removeTrigger  : '[data-widget="remove"]',
    collapseIcon   : 'fa-minus',
    expandIcon     : 'fa-plus',
    removeIcon     : 'fa-times'
160
  };
A
Abdullah Almsaeed 已提交
161 162

  var Selector = {
A
Abdullah Almsaeed 已提交
163 164
    data     : '.box',
    collapsed: '.collapsed-box',
165
    header   : '.box-header',
A
Abdullah Almsaeed 已提交
166 167 168
    body     : '.box-body',
    footer   : '.box-footer',
    tools    : '.box-tools'
169
  };
A
Abdullah Almsaeed 已提交
170 171

  var ClassName = {
A
Abdullah Almsaeed 已提交
172
    collapsed: 'collapsed-box'
173
  };
A
Abdullah Almsaeed 已提交
174 175

  var Event = {
A
Abdullah Almsaeed 已提交
176 177 178 179 180 181 182
        collapsing: 'collapsing.boxwidget',
        collapsed: 'collapsed.boxwidget',
        expanding: 'expanding.boxwidget',
        expanded: 'expanded.boxwidget',
        removing: 'removing.boxwidget',
        removed: 'removed.boxwidget'        
    };
A
Abdullah Almsaeed 已提交
183

A
Abdullah Almsaeed 已提交
184 185 186
  // BoxWidget Class Definition
  // =====================
  var BoxWidget = function (element, options) {
187 188
    this.element = element;
    this.options = options;
A
Abdullah Almsaeed 已提交
189

190 191
    this._setUpListeners();
  };
A
Abdullah Almsaeed 已提交
192

A
Abdullah Almsaeed 已提交
193
  BoxWidget.prototype.toggle = function () {
194
    var isOpen = !$(this.element).is(Selector.collapsed);
A
Abdullah Almsaeed 已提交
195

A
Abdullah Almsaeed 已提交
196
    if (isOpen) {
197
      this.collapse();
A
Abdullah Almsaeed 已提交
198
    } else {
199
      this.expand();
A
Abdullah Almsaeed 已提交
200
    }
201
  };
A
Abdullah Almsaeed 已提交
202

A
Abdullah Almsaeed 已提交
203
  BoxWidget.prototype.expand = function () {
204
    var expandedEvent = $.Event(Event.expanded);
A
Abdullah Almsaeed 已提交
205
    var expandingEvent = $.Event(Event.expanding);
206 207
    var collapseIcon  = this.options.collapseIcon;
    var expandIcon    = this.options.expandIcon;
A
Abdullah Almsaeed 已提交
208

209
    $(this.element).removeClass(ClassName.collapsed);
A
Abdullah Almsaeed 已提交
210

A
Abdullah Almsaeed 已提交
211
    $(this.element)
212 213
      .children(Selector.header + ', ' + Selector.body + ', ' + Selector.footer)
      .children(Selector.tools)
A
Abdullah Almsaeed 已提交
214 215
      .find('.' + expandIcon)
      .removeClass(expandIcon)
216
      .addClass(collapseIcon);
A
Abdullah Almsaeed 已提交
217

218
    $(this.element).children(Selector.body + ', ' + Selector.footer)
A
Abdullah Almsaeed 已提交
219
      .slideDown(this.options.animationSpeed, function () {
220
        $(this.element).trigger(expandedEvent);
A
Abdullah Almsaeed 已提交
221 222
      }.bind(this))
      .trigger(expandingEvent);
223
  };
A
Abdullah Almsaeed 已提交
224

A
Abdullah Almsaeed 已提交
225
  BoxWidget.prototype.collapse = function () {
226
    var collapsedEvent = $.Event(Event.collapsed);
A
Abdullah Almsaeed 已提交
227
    var collapsingEvent = $.Event(Event.collapsing);
228 229
    var collapseIcon   = this.options.collapseIcon;
    var expandIcon     = this.options.expandIcon;
A
Abdullah Almsaeed 已提交
230

A
Abdullah Almsaeed 已提交
231
    $(this.element)
232 233
      .children(Selector.header + ', ' + Selector.body + ', ' + Selector.footer)
      .children(Selector.tools)
A
Abdullah Almsaeed 已提交
234 235
      .find('.' + collapseIcon)
      .removeClass(collapseIcon)
236
      .addClass(expandIcon);
A
Abdullah Almsaeed 已提交
237

238
    $(this.element).children(Selector.body + ', ' + Selector.footer)
A
Abdullah Almsaeed 已提交
239
      .slideUp(this.options.animationSpeed, function () {
240 241
        $(this.element).addClass(ClassName.collapsed);
        $(this.element).trigger(collapsedEvent);
A
Abdullah Almsaeed 已提交
242
      }.bind(this))
N
Nicolas Bourasseau 已提交
243
      .trigger(collapsingEvent);
244
  };
A
Abdullah Almsaeed 已提交
245

A
Abdullah Almsaeed 已提交
246
  BoxWidget.prototype.remove = function () {
247
    var removedEvent = $.Event(Event.removed);
A
Abdullah Almsaeed 已提交
248
    var removingEvent = $.Event(Event.removing);
A
Abdullah Almsaeed 已提交
249

A
Abdullah Almsaeed 已提交
250
    $(this.element).slideUp(this.options.animationSpeed, function () {
251 252
      $(this.element).trigger(removedEvent);
      $(this.element).remove();
A
Abdullah Almsaeed 已提交
253 254
    }.bind(this))
    .trigger(removingEvent);
255
  };
A
Abdullah Almsaeed 已提交
256 257 258

  // Private

A
Abdullah Almsaeed 已提交
259
  BoxWidget.prototype._setUpListeners = function () {
260
    var that = this;
A
Abdullah Almsaeed 已提交
261

A
Abdullah Almsaeed 已提交
262
    $(this.element).on('click', this.options.collapseTrigger, function (event) {
263 264 265 266
      if (event) event.preventDefault();
      that.toggle($(this));
      return false;
    });
A
Abdullah Almsaeed 已提交
267 268

    $(this.element).on('click', this.options.removeTrigger, function (event) {
269 270 271 272 273
      if (event) event.preventDefault();
      that.remove($(this));
      return false;
    });
  };
A
Abdullah Almsaeed 已提交
274 275 276 277 278

  // Plugin Definition
  // =================
  function Plugin(option) {
    return this.each(function () {
279 280
      var $this = $(this);
      var data  = $this.data(DataKey);
A
Abdullah Almsaeed 已提交
281 282

      if (!data) {
283 284
        var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
        $this.data(DataKey, (data = new BoxWidget($this, options)));
A
Abdullah Almsaeed 已提交
285 286 287 288
      }

      if (typeof option == 'string') {
        if (typeof data[option] == 'undefined') {
289
          throw new Error('No method named ' + option);
A
Abdullah Almsaeed 已提交
290
        }
291
        data[option]();
A
Abdullah Almsaeed 已提交
292
      }
293
    });
A
Abdullah Almsaeed 已提交
294 295
  }

296
  var old = $.fn.boxWidget;
A
Abdullah Almsaeed 已提交
297

298 299
  $.fn.boxWidget             = Plugin;
  $.fn.boxWidget.Constructor = BoxWidget;
A
Abdullah Almsaeed 已提交
300 301 302

  // No Conflict Mode
  // ================
A
Abdullah Almsaeed 已提交
303
  $.fn.boxWidget.noConflict = function () {
304 305 306
    $.fn.boxWidget = old;
    return this;
  };
A
Abdullah Almsaeed 已提交
307

A
Abdullah Almsaeed 已提交
308 309
  // BoxWidget Data API
  // ==================
A
Abdullah Almsaeed 已提交
310 311
  $(window).on('load', function () {
    $(Selector.data).each(function () {
312 313 314 315
      Plugin.call($(this));
    });
  });
}(jQuery);
A
Abdullah Almsaeed 已提交
316 317 318 319 320 321 322 323 324 325 326


/* ControlSidebar()
 * ===============
 * Toggles the state of the control sidebar
 *
 * @Usage: $('#control-sidebar-trigger').controlSidebar(options)
 *         or add [data-toggle="control-sidebar"] to the trigger
 *         Pass any option as data-option="value"
 */
+function ($) {
327
  'use strict';
A
Abdullah Almsaeed 已提交
328

329
  var DataKey = 'lte.controlsidebar';
A
Abdullah Almsaeed 已提交
330 331 332

  var Default = {
    slide: true
333
  };
A
Abdullah Almsaeed 已提交
334 335 336 337 338 339 340 341 342

  var Selector = {
    sidebar: '.control-sidebar',
    data   : '[data-toggle="control-sidebar"]',
    open   : '.control-sidebar-open',
    bg     : '.control-sidebar-bg',
    wrapper: '.wrapper',
    content: '.content-wrapper',
    boxed  : '.layout-boxed'
343
  };
A
Abdullah Almsaeed 已提交
344 345 346 347

  var ClassName = {
    open : 'control-sidebar-open',
    fixed: 'fixed'
348
  };
A
Abdullah Almsaeed 已提交
349 350 351 352

  var Event = {
    collapsed: 'collapsed.controlsidebar',
    expanded : 'expanded.controlsidebar'
353
  };
A
Abdullah Almsaeed 已提交
354 355 356 357

  // ControlSidebar Class Definition
  // ===============================
  var ControlSidebar = function (element, options) {
358 359 360
    this.element         = element;
    this.options         = options;
    this.hasBindedResize = false;
A
Abdullah Almsaeed 已提交
361

362 363
    this.init();
  };
A
Abdullah Almsaeed 已提交
364 365 366 367 368

  ControlSidebar.prototype.init = function () {
    // Add click listener if the element hasn't been
    // initialized using the data API
    if (!$(this.element).is(Selector.data)) {
369
      $(this).on('click', this.toggle);
A
Abdullah Almsaeed 已提交
370 371
    }

372
    this.fix();
A
Abdullah Almsaeed 已提交
373
    $(window).resize(function () {
374 375 376
      this.fix();
    }.bind(this));
  };
A
Abdullah Almsaeed 已提交
377 378

  ControlSidebar.prototype.toggle = function (event) {
379
    if (event) event.preventDefault();
A
Abdullah Almsaeed 已提交
380

381
    this.fix();
A
Abdullah Almsaeed 已提交
382 383

    if (!$(Selector.sidebar).is(Selector.open) && !$('body').is(Selector.open)) {
384
      this.expand();
A
Abdullah Almsaeed 已提交
385
    } else {
386
      this.collapse();
A
Abdullah Almsaeed 已提交
387
    }
388
  };
A
Abdullah Almsaeed 已提交
389 390

  ControlSidebar.prototype.expand = function () {
391
    $(Selector.sidebar).show();
A
Abdullah Almsaeed 已提交
392
    if (!this.options.slide) {
393
      $('body').addClass(ClassName.open);
A
Abdullah Almsaeed 已提交
394
    } else {
395
      $(Selector.sidebar).addClass(ClassName.open);
A
Abdullah Almsaeed 已提交
396 397
    }

398

399 400
    $(this.element).trigger($.Event(Event.expanded));
  };
A
Abdullah Almsaeed 已提交
401 402

  ControlSidebar.prototype.collapse = function () {
403
    $('body, ' + Selector.sidebar).removeClass(ClassName.open);
404
    $(Selector.sidebar).fadeOut();
405 406
    $(this.element).trigger($.Event(Event.collapsed));
  };
A
Abdullah Almsaeed 已提交
407 408 409

  ControlSidebar.prototype.fix = function () {
    if ($('body').is(Selector.boxed)) {
410
      this._fixForBoxed($(Selector.bg));
A
Abdullah Almsaeed 已提交
411
    }
412
  };
A
Abdullah Almsaeed 已提交
413 414 415 416 417 418 419

  // Private

  ControlSidebar.prototype._fixForBoxed = function (bg) {
    bg.css({
      position: 'absolute',
      height  : $(Selector.wrapper).height()
420 421
    });
  };
A
Abdullah Almsaeed 已提交
422 423 424 425 426

  // Plugin Definition
  // =================
  function Plugin(option) {
    return this.each(function () {
427 428
      var $this = $(this);
      var data  = $this.data(DataKey);
A
Abdullah Almsaeed 已提交
429 430

      if (!data) {
431 432
        var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
        $this.data(DataKey, (data = new ControlSidebar($this, options)));
A
Abdullah Almsaeed 已提交
433 434
      }

435 436
      if (typeof option == 'string') data.toggle();
    });
A
Abdullah Almsaeed 已提交
437 438
  }

439
  var old = $.fn.controlSidebar;
A
Abdullah Almsaeed 已提交
440

441 442
  $.fn.controlSidebar             = Plugin;
  $.fn.controlSidebar.Constructor = ControlSidebar;
A
Abdullah Almsaeed 已提交
443 444 445 446

  // No Conflict Mode
  // ================
  $.fn.controlSidebar.noConflict = function () {
447 448 449
    $.fn.controlSidebar = old;
    return this;
  };
A
Abdullah Almsaeed 已提交
450 451 452 453

  // ControlSidebar Data API
  // =======================
  $(document).on('click', Selector.data, function (event) {
454 455 456
    if (event) event.preventDefault();
    Plugin.call($(this), 'toggle');
  });
A
Abdullah Almsaeed 已提交
457

458
}(jQuery);
A
Abdullah Almsaeed 已提交
459 460


A
Abdullah Almsaeed 已提交
461 462 463
/* DirectChat()
 * ===============
 * Toggles the state of the control sidebar
A
Abdullah Almsaeed 已提交
464
 *
A
Abdullah Almsaeed 已提交
465 466
 * @Usage: $('#my-chat-box').directChat()
 *         or add [data-widget="direct-chat"] to the trigger
A
Abdullah Almsaeed 已提交
467 468
 */
+function ($) {
469
  'use strict';
A
Abdullah Almsaeed 已提交
470

471
  var DataKey = 'lte.directchat';
A
Abdullah Almsaeed 已提交
472

A
Abdullah Almsaeed 已提交
473 474 475
  var Selector = {
    data: '[data-widget="chat-pane-toggle"]',
    box : '.direct-chat'
476
  };
A
Abdullah Almsaeed 已提交
477

A
Abdullah Almsaeed 已提交
478 479
  var ClassName = {
    open: 'direct-chat-contacts-open'
480
  };
A
Abdullah Almsaeed 已提交
481 482 483 484

  // DirectChat Class Definition
  // ===========================
  var DirectChat = function (element) {
485 486
    this.element = element;
  };
A
Abdullah Almsaeed 已提交
487 488

  DirectChat.prototype.toggle = function ($trigger) {
489 490
    $trigger.parents(Selector.box).first().toggleClass(ClassName.open);
  };
A
Abdullah Almsaeed 已提交
491 492 493 494 495

  // Plugin Definition
  // =================
  function Plugin(option) {
    return this.each(function () {
496 497
      var $this = $(this);
      var data  = $this.data(DataKey);
A
Abdullah Almsaeed 已提交
498 499

      if (!data) {
500
        $this.data(DataKey, (data = new DirectChat($this)));
A
Abdullah Almsaeed 已提交
501 502
      }

503 504
      if (typeof option == 'string') data.toggle($this);
    });
A
Abdullah Almsaeed 已提交
505 506
  }

507
  var old = $.fn.directChat;
A
Abdullah Almsaeed 已提交
508

509 510
  $.fn.directChat             = Plugin;
  $.fn.directChat.Constructor = DirectChat;
A
Abdullah Almsaeed 已提交
511 512 513 514

  // No Conflict Mode
  // ================
  $.fn.directChat.noConflict = function () {
515 516 517
    $.fn.directChat = old;
    return this;
  };
A
Abdullah Almsaeed 已提交
518 519 520 521

  // DirectChat Data API
  // ===================
  $(document).on('click', Selector.data, function (event) {
522 523 524
    if (event) event.preventDefault();
    Plugin.call($(this), 'toggle');
  });
A
Abdullah Almsaeed 已提交
525

526
}(jQuery);
A
Abdullah Almsaeed 已提交
527 528 529 530 531 532 533 534 535 536 537 538


/* Layout()
 * ========
 * Implements AdminLTE layout.
 * Fixes the layout height in case min-height fails.
 *
 * @usage activated automatically upon window load.
 *        Configure any options by passing data-option="value"
 *        to the body tag.
 */
+function ($) {
539
  'use strict';
A
Abdullah Almsaeed 已提交
540

541
  var DataKey = 'lte.layout';
A
Abdullah Almsaeed 已提交
542 543 544 545

  var Default = {
    slimscroll : true,
    resetHeight: true
546
  };
A
Abdullah Almsaeed 已提交
547 548 549 550 551 552 553 554 555 556 557 558

  var Selector = {
    wrapper       : '.wrapper',
    contentWrapper: '.content-wrapper',
    layoutBoxed   : '.layout-boxed',
    mainFooter    : '.main-footer',
    mainHeader    : '.main-header',
    sidebar       : '.sidebar',
    controlSidebar: '.control-sidebar',
    fixed         : '.fixed',
    sidebarMenu   : '.sidebar-menu',
    logo          : '.main-header .logo'
559
  };
A
Abdullah Almsaeed 已提交
560 561

  var ClassName = {
A
Abdullah Almsaeed 已提交
562 563
    fixed         : 'fixed',
    holdTransition: 'hold-transition'
564
  };
A
Abdullah Almsaeed 已提交
565

A
Abdullah Almsaeed 已提交
566
  var Layout = function (options) {
567 568 569 570
    this.options      = options;
    this.bindedResize = false;
    this.activate();
  };
A
Abdullah Almsaeed 已提交
571

A
Abdullah Almsaeed 已提交
572
  Layout.prototype.activate = function () {
573 574
    this.fix();
    this.fixSidebar();
A
Abdullah Almsaeed 已提交
575

576
    $('body').removeClass(ClassName.holdTransition);
A
Abdullah Almsaeed 已提交
577 578 579 580 581

    if (this.options.resetHeight) {
      $('body, html, ' + Selector.wrapper).css({
        'height'    : 'auto',
        'min-height': '100%'
582
      });
A
Abdullah Almsaeed 已提交
583 584 585 586
    }

    if (!this.bindedResize) {
      $(window).resize(function () {
587 588
        this.fix();
        this.fixSidebar();
A
Abdullah Almsaeed 已提交
589 590

        $(Selector.logo + ', ' + Selector.sidebar).one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function () {
591 592 593 594
          this.fix();
          this.fixSidebar();
        }.bind(this));
      }.bind(this));
A
Abdullah Almsaeed 已提交
595

596
      this.bindedResize = true;
A
Abdullah Almsaeed 已提交
597 598 599
    }

    $(Selector.sidebarMenu).on('expanded.tree', function () {
600 601 602
      this.fix();
      this.fixSidebar();
    }.bind(this));
A
Abdullah Almsaeed 已提交
603 604

    $(Selector.sidebarMenu).on('collapsed.tree', function () {
605 606 607 608
      this.fix();
      this.fixSidebar();
    }.bind(this));
  };
A
Abdullah Almsaeed 已提交
609

A
Abdullah Almsaeed 已提交
610 611
  Layout.prototype.fix = function () {
    // Remove overflow from .wrapper if layout-boxed exists
612
    $(Selector.layoutBoxed + ' > ' + Selector.wrapper).css('overflow', 'hidden');
A
Abdullah Almsaeed 已提交
613

A
Abdullah Almsaeed 已提交
614
    // Get window height and the wrapper height
A
Abdullah Almsaeed 已提交
615 616 617
    var footerHeight = $(Selector.mainFooter).outerHeight() || 0;
    var headerHeight  = $(Selector.mainHeader).outerHeight() || 0;
    var neg           = headerHeight + footerHeight;
618 619
    var windowHeight  = $(window).height();
    var sidebarHeight = $(Selector.sidebar).height() || 0;
A
Abdullah Almsaeed 已提交
620 621 622 623

    // Set the min-height of the content and sidebar based on
    // the height of the document.
    if ($('body').hasClass(ClassName.fixed)) {
624
      $(Selector.contentWrapper).css('min-height', windowHeight - footerHeight);
A
Abdullah Almsaeed 已提交
625
    } else {
626
      var postSetHeight;
A
Abdullah Almsaeed 已提交
627

628
      if (windowHeight >= sidebarHeight + headerHeight) {
629 630
        $(Selector.contentWrapper).css('min-height', windowHeight - neg);
        postSetHeight = windowHeight - neg;
A
Abdullah Almsaeed 已提交
631
      } else {
632 633
        $(Selector.contentWrapper).css('min-height', sidebarHeight);
        postSetHeight = sidebarHeight;
A
Abdullah Almsaeed 已提交
634 635 636
      }

      // Fix for the control sidebar height
637
      var $controlSidebar = $(Selector.controlSidebar);
A
Abdullah Almsaeed 已提交
638 639
      if (typeof $controlSidebar !== 'undefined') {
        if ($controlSidebar.height() > postSetHeight)
640
          $(Selector.contentWrapper).css('min-height', $controlSidebar.height());
A
Abdullah Almsaeed 已提交
641
      }
A
Abdullah Almsaeed 已提交
642
    }
643
  };
A
Abdullah Almsaeed 已提交
644

A
Abdullah Almsaeed 已提交
645 646 647 648
  Layout.prototype.fixSidebar = function () {
    // Make sure the body tag has the .fixed class
    if (!$('body').hasClass(ClassName.fixed)) {
      if (typeof $.fn.slimScroll !== 'undefined') {
649
        $(Selector.sidebar).slimScroll({ destroy: true }).height('auto');
A
Abdullah Almsaeed 已提交
650
      }
651
      return;
A
Abdullah Almsaeed 已提交
652
    }
A
Abdullah Almsaeed 已提交
653

A
Abdullah Almsaeed 已提交
654 655 656 657
    // Enable slimscroll for fixed layout
    if (this.options.slimscroll) {
      if (typeof $.fn.slimScroll !== 'undefined') {
        // Destroy if it exists
658
        // $(Selector.sidebar).slimScroll({ destroy: true }).height('auto')
A
Abdullah Almsaeed 已提交
659

A
Abdullah Almsaeed 已提交
660 661
        // Add slimscroll
        $(Selector.sidebar).slimScroll({
662 663
          height: ($(window).height() - $(Selector.mainHeader).height()) + 'px'
        });
A
Abdullah Almsaeed 已提交
664 665
      }
    }
666
  };
A
Abdullah Almsaeed 已提交
667

A
Abdullah Almsaeed 已提交
668 669 670 671
  // Plugin Definition
  // =================
  function Plugin(option) {
    return this.each(function () {
672 673
      var $this = $(this);
      var data  = $this.data(DataKey);
A
Abdullah Almsaeed 已提交
674 675

      if (!data) {
676 677
        var options = $.extend({}, Default, $this.data(), typeof option === 'object' && option);
        $this.data(DataKey, (data = new Layout(options)));
A
Abdullah Almsaeed 已提交
678 679 680 681
      }

      if (typeof option === 'string') {
        if (typeof data[option] === 'undefined') {
682
          throw new Error('No method named ' + option);
A
Abdullah Almsaeed 已提交
683
        }
684
        data[option]();
A
Abdullah Almsaeed 已提交
685
      }
686
    });
A
Abdullah Almsaeed 已提交
687 688
  }

689
  var old = $.fn.layout;
A
Abdullah Almsaeed 已提交
690

691 692
  $.fn.layout            = Plugin;
  $.fn.layout.Constuctor = Layout;
A
Abdullah Almsaeed 已提交
693 694 695 696

  // No conflict mode
  // ================
  $.fn.layout.noConflict = function () {
697 698 699
    $.fn.layout = old;
    return this;
  };
A
Abdullah Almsaeed 已提交
700 701 702 703

  // Layout DATA-API
  // ===============
  $(window).on('load', function () {
704 705 706
    Plugin.call($('body'));
  });
}(jQuery);
A
Abdullah Almsaeed 已提交
707 708 709 710 711 712 713 714 715 716 717


/* PushMenu()
 * ==========
 * Adds the push menu functionality to the sidebar.
 *
 * @usage: $('.btn').pushMenu(options)
 *          or add [data-toggle="push-menu"] to any button
 *          Pass any option as data-option="value"
 */
+function ($) {
718
  'use strict';
A
Abdullah Almsaeed 已提交
719

720
  var DataKey = 'lte.pushmenu';
A
Abdullah Almsaeed 已提交
721 722 723 724 725

  var Default = {
    collapseScreenSize   : 767,
    expandOnHover        : false,
    expandTransitionDelay: 200
726
  };
A
Abdullah Almsaeed 已提交
727 728 729 730 731 732 733 734 735 736 737

  var Selector = {
    collapsed     : '.sidebar-collapse',
    open          : '.sidebar-open',
    mainSidebar   : '.main-sidebar',
    contentWrapper: '.content-wrapper',
    searchInput   : '.sidebar-form .form-control',
    button        : '[data-toggle="push-menu"]',
    mini          : '.sidebar-mini',
    expanded      : '.sidebar-expanded-on-hover',
    layoutFixed   : '.fixed'
738
  };
A
Abdullah Almsaeed 已提交
739 740 741 742 743 744 745 746

  var ClassName = {
    collapsed    : 'sidebar-collapse',
    open         : 'sidebar-open',
    mini         : 'sidebar-mini',
    expanded     : 'sidebar-expanded-on-hover',
    expandFeature: 'sidebar-mini-expand-feature',
    layoutFixed  : 'fixed'
747
  };
A
Abdullah Almsaeed 已提交
748 749 750 751

  var Event = {
    expanded : 'expanded.pushMenu',
    collapsed: 'collapsed.pushMenu'
752
  };
A
Abdullah Almsaeed 已提交
753 754 755 756

  // PushMenu Class Definition
  // =========================
  var PushMenu = function (options) {
757 758 759
    this.options = options;
    this.init();
  };
A
Abdullah Almsaeed 已提交
760 761 762 763

  PushMenu.prototype.init = function () {
    if (this.options.expandOnHover
      || ($('body').is(Selector.mini + Selector.layoutFixed))) {
764 765
      this.expandOnHover();
      $('body').addClass(ClassName.expandFeature);
A
Abdullah Almsaeed 已提交
766 767 768 769 770
    }

    $(Selector.contentWrapper).click(function () {
      // Enable hide menu when clicking on the content-wrapper on small screens
      if ($(window).width() <= this.options.collapseScreenSize && $('body').hasClass(ClassName.open)) {
771
        this.close();
A
Abdullah Almsaeed 已提交
772
      }
773
    }.bind(this));
A
Abdullah Almsaeed 已提交
774 775 776

    // __Fix for android devices
    $(Selector.searchInput).click(function (e) {
777 778 779
      e.stopPropagation();
    });
  };
A
Abdullah Almsaeed 已提交
780

A
Abdullah Almsaeed 已提交
781
  PushMenu.prototype.toggle = function () {
782 783
    var windowWidth = $(window).width();
    var isOpen      = !$('body').hasClass(ClassName.collapsed);
A
Abdullah Almsaeed 已提交
784

A
Abdullah Almsaeed 已提交
785
    if (windowWidth <= this.options.collapseScreenSize) {
786
      isOpen = $('body').hasClass(ClassName.open);
A
Abdullah Almsaeed 已提交
787
    }
A
Abdullah Almsaeed 已提交
788

A
Abdullah Almsaeed 已提交
789
    if (!isOpen) {
790
      this.open();
A
Abdullah Almsaeed 已提交
791
    } else {
792
      this.close();
A
Abdullah Almsaeed 已提交
793
    }
794
  };
A
Abdullah Almsaeed 已提交
795

A
Abdullah Almsaeed 已提交
796
  PushMenu.prototype.open = function () {
797
    var windowWidth = $(window).width();
A
Abdullah Almsaeed 已提交
798

A
Abdullah Almsaeed 已提交
799 800
    if (windowWidth > this.options.collapseScreenSize) {
      $('body').removeClass(ClassName.collapsed)
801
        .trigger($.Event(Event.expanded));
A
Abdullah Almsaeed 已提交
802 803 804
    }
    else {
      $('body').addClass(ClassName.open)
805
        .trigger($.Event(Event.expanded));
A
Abdullah Almsaeed 已提交
806
    }
807
  };
A
Abdullah Almsaeed 已提交
808

A
Abdullah Almsaeed 已提交
809
  PushMenu.prototype.close = function () {
810
    var windowWidth = $(window).width();
A
Abdullah Almsaeed 已提交
811 812
    if (windowWidth > this.options.collapseScreenSize) {
      $('body').addClass(ClassName.collapsed)
813
        .trigger($.Event(Event.collapsed));
A
Abdullah Almsaeed 已提交
814 815
    } else {
      $('body').removeClass(ClassName.open + ' ' + ClassName.collapsed)
816
        .trigger($.Event(Event.collapsed));
A
Abdullah Almsaeed 已提交
817
    }
818
  };
A
Abdullah Almsaeed 已提交
819

A
Abdullah Almsaeed 已提交
820 821 822 823
  PushMenu.prototype.expandOnHover = function () {
    $(Selector.mainSidebar).hover(function () {
      if ($('body').is(Selector.mini + Selector.collapsed)
        && $(window).width() > this.options.collapseScreenSize) {
824
        this.expand();
A
Abdullah Almsaeed 已提交
825 826 827
      }
    }.bind(this), function () {
      if ($('body').is(Selector.expanded)) {
828
        this.collapse();
A
Abdullah Almsaeed 已提交
829
      }
830 831
    }.bind(this));
  };
A
Abdullah Almsaeed 已提交
832

A
Abdullah Almsaeed 已提交
833 834 835
  PushMenu.prototype.expand = function () {
    setTimeout(function () {
      $('body').removeClass(ClassName.collapsed)
836 837 838
        .addClass(ClassName.expanded);
    }, this.options.expandTransitionDelay);
  };
A
Abdullah Almsaeed 已提交
839

A
Abdullah Almsaeed 已提交
840 841 842
  PushMenu.prototype.collapse = function () {
    setTimeout(function () {
      $('body').removeClass(ClassName.expanded)
843 844 845
        .addClass(ClassName.collapsed);
    }, this.options.expandTransitionDelay);
  };
A
Abdullah Almsaeed 已提交
846

A
Abdullah Almsaeed 已提交
847 848
  // PushMenu Plugin Definition
  // ==========================
A
Abdullah Almsaeed 已提交
849 850
  function Plugin(option) {
    return this.each(function () {
851 852
      var $this = $(this);
      var data  = $this.data(DataKey);
A
Abdullah Almsaeed 已提交
853 854

      if (!data) {
855 856
        var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
        $this.data(DataKey, (data = new PushMenu(options)));
A
Abdullah Almsaeed 已提交
857 858
      }

859 860
      if (option === 'toggle') data.toggle();
    });
A
Abdullah Almsaeed 已提交
861 862
  }

863
  var old = $.fn.pushMenu;
A
Abdullah Almsaeed 已提交
864

865 866
  $.fn.pushMenu             = Plugin;
  $.fn.pushMenu.Constructor = PushMenu;
A
Abdullah Almsaeed 已提交
867 868 869

  // No Conflict Mode
  // ================
A
Abdullah Almsaeed 已提交
870
  $.fn.pushMenu.noConflict = function () {
871 872 873
    $.fn.pushMenu = old;
    return this;
  };
A
Abdullah Almsaeed 已提交
874

A
Abdullah Almsaeed 已提交
875 876 877
  // Data API
  // ========
  $(document).on('click', Selector.button, function (e) {
878 879 880
    e.preventDefault();
    Plugin.call($(this), 'toggle');
  });
A
Abdullah Almsaeed 已提交
881
  $(window).on('load', function () {
882 883 884
    Plugin.call($(Selector.button));
  });
}(jQuery);
A
Abdullah Almsaeed 已提交
885 886 887 888 889 890 891 892 893 894 895


/* TodoList()
 * =========
 * Converts a list into a todoList.
 *
 * @Usage: $('.my-list').todoList(options)
 *         or add [data-widget="todo-list"] to the ul element
 *         Pass any option as data-option="value"
 */
+function ($) {
896
  'use strict';
A
Abdullah Almsaeed 已提交
897

898
  var DataKey = 'lte.todolist';
A
Abdullah Almsaeed 已提交
899 900

  var Default = {
A
Abdullah Almsaeed 已提交
901
    onCheck  : function (item) {
902
      return item;
A
Abdullah Almsaeed 已提交
903
    },
A
Abdullah Almsaeed 已提交
904
    onUnCheck: function (item) {
905
      return item;
A
Abdullah Almsaeed 已提交
906
    }
907
  };
A
Abdullah Almsaeed 已提交
908 909 910

  var Selector = {
    data: '[data-widget="todo-list"]'
911
  };
A
Abdullah Almsaeed 已提交
912 913 914

  var ClassName = {
    done: 'done'
915
  };
A
Abdullah Almsaeed 已提交
916 917 918 919

  // TodoList Class Definition
  // =========================
  var TodoList = function (element, options) {
920 921
    this.element = element;
    this.options = options;
A
Abdullah Almsaeed 已提交
922

923 924
    this._setUpListeners();
  };
A
Abdullah Almsaeed 已提交
925 926

  TodoList.prototype.toggle = function (item) {
927
    item.parents(Selector.li).first().toggleClass(ClassName.done);
A
Abdullah Almsaeed 已提交
928
    if (!item.prop('checked')) {
929 930
      this.unCheck(item);
      return;
A
Abdullah Almsaeed 已提交
931 932
    }

933 934
    this.check(item);
  };
A
Abdullah Almsaeed 已提交
935 936

  TodoList.prototype.check = function (item) {
937 938
    this.options.onCheck.call(item);
  };
A
Abdullah Almsaeed 已提交
939 940

  TodoList.prototype.unCheck = function (item) {
941 942
    this.options.onUnCheck.call(item);
  };
A
Abdullah Almsaeed 已提交
943 944 945 946

  // Private

  TodoList.prototype._setUpListeners = function () {
947
    var that = this;
A
Abdullah Almsaeed 已提交
948
    $(this.element).on('change ifChanged', 'input:checkbox', function () {
949 950 951
      that.toggle($(this));
    });
  };
A
Abdullah Almsaeed 已提交
952 953 954 955 956

  // Plugin Definition
  // =================
  function Plugin(option) {
    return this.each(function () {
957 958
      var $this = $(this);
      var data  = $this.data(DataKey);
A
Abdullah Almsaeed 已提交
959 960

      if (!data) {
961 962
        var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
        $this.data(DataKey, (data = new TodoList($this, options)));
A
Abdullah Almsaeed 已提交
963 964 965 966
      }

      if (typeof data == 'string') {
        if (typeof data[option] == 'undefined') {
967
          throw new Error('No method named ' + option);
A
Abdullah Almsaeed 已提交
968
        }
969
        data[option]();
A
Abdullah Almsaeed 已提交
970
      }
971
    });
A
Abdullah Almsaeed 已提交
972 973
  }

974
  var old = $.fn.todoList;
A
Abdullah Almsaeed 已提交
975

976 977
  $.fn.todoList             = Plugin;
  $.fn.todoList.Constructor = TodoList;
A
Abdullah Almsaeed 已提交
978 979 980 981

  // No Conflict Mode
  // ================
  $.fn.todoList.noConflict = function () {
982 983 984
    $.fn.todoList = old;
    return this;
  };
A
Abdullah Almsaeed 已提交
985 986 987 988 989

  // TodoList Data API
  // =================
  $(window).on('load', function () {
    $(Selector.data).each(function () {
990 991 992
      Plugin.call($(this));
    });
  });
A
Abdullah Almsaeed 已提交
993

994
}(jQuery);
A
Abdullah Almsaeed 已提交
995 996


A
Abdullah Almsaeed 已提交
997 998 999 1000
/* Tree()
 * ======
 * Converts a nested list into a multilevel
 * tree view menu.
A
Abdullah Almsaeed 已提交
1001
 *
A
Abdullah Almsaeed 已提交
1002 1003 1004
 * @Usage: $('.my-menu').tree(options)
 *         or add [data-widget="tree"] to the ul element
 *         Pass any option as data-option="value"
A
Abdullah Almsaeed 已提交
1005 1006
 */
+function ($) {
1007
  'use strict';
A
Abdullah Almsaeed 已提交
1008

1009
  var DataKey = 'lte.tree';
A
Abdullah Almsaeed 已提交
1010 1011 1012 1013 1014 1015

  var Default = {
    animationSpeed: 500,
    accordion     : true,
    followLink    : false,
    trigger       : '.treeview a'
1016
  };
A
Abdullah Almsaeed 已提交
1017 1018

  var Selector = {
A
Abdullah Almsaeed 已提交
1019 1020 1021 1022 1023 1024 1025
    tree        : '.tree',
    treeview    : '.treeview',
    treeviewMenu: '.treeview-menu',
    open        : '.menu-open, .active',
    li          : 'li',
    data        : '[data-widget="tree"]',
    active      : '.active'
1026
  };
A
Abdullah Almsaeed 已提交
1027 1028

  var ClassName = {
A
Abdullah Almsaeed 已提交
1029 1030
    open: 'menu-open',
    tree: 'tree'
1031
  };
A
Abdullah Almsaeed 已提交
1032

A
Abdullah Almsaeed 已提交
1033 1034 1035
  var Event = {
    collapsed: 'collapsed.tree',
    expanded : 'expanded.tree'
1036
  };
A
Abdullah Almsaeed 已提交
1037 1038 1039 1040

  // Tree Class Definition
  // =====================
  var Tree = function (element, options) {
1041 1042
    this.element = element;
    this.options = options;
A
Abdullah Almsaeed 已提交
1043

1044
    $(this.element).addClass(ClassName.tree);
A
Abdullah Almsaeed 已提交
1045

1046
    $(Selector.treeview + Selector.active, this.element).addClass(ClassName.open);
A
Abdullah Almsaeed 已提交
1047

1048 1049
    this._setUpListeners();
  };
A
Abdullah Almsaeed 已提交
1050

A
Abdullah Almsaeed 已提交
1051
  Tree.prototype.toggle = function (link, event) {
1052 1053 1054
    var treeviewMenu = link.next(Selector.treeviewMenu);
    var parentLi     = link.parent();
    var isOpen       = parentLi.hasClass(ClassName.open);
A
Abdullah Almsaeed 已提交
1055 1056

    if (!parentLi.is(Selector.treeview)) {
1057
      return;
A
Abdullah Almsaeed 已提交
1058 1059
    }

1060
    if (!this.options.followLink || link.attr('href') === '#') {
1061
      event.preventDefault();
A
Abdullah Almsaeed 已提交
1062 1063 1064
    }

    if (isOpen) {
1065
      this.collapse(treeviewMenu, parentLi);
A
Abdullah Almsaeed 已提交
1066
    } else {
1067
      this.expand(treeviewMenu, parentLi);
A
Abdullah Almsaeed 已提交
1068
    }
1069
  };
A
Abdullah Almsaeed 已提交
1070 1071

  Tree.prototype.expand = function (tree, parent) {
1072
    var expandedEvent = $.Event(Event.expanded);
A
Abdullah Almsaeed 已提交
1073 1074

    if (this.options.accordion) {
1075 1076 1077
      var openMenuLi = parent.siblings(Selector.open);
      var openTree   = openMenuLi.children(Selector.treeviewMenu);
      this.collapse(openTree, openMenuLi);
A
Abdullah Almsaeed 已提交
1078 1079
    }

1080
    parent.addClass(ClassName.open);
A
Abdullah Almsaeed 已提交
1081
    tree.slideDown(this.options.animationSpeed, function () {
R
REJack 已提交
1082
      $(this.element).trigger(expandedEvent);
1083 1084
    }.bind(this));
  };
A
Abdullah Almsaeed 已提交
1085 1086

  Tree.prototype.collapse = function (tree, parentLi) {
1087
    var collapsedEvent = $.Event(Event.collapsed);
A
Abdullah Almsaeed 已提交
1088

1089
    //tree.find(Selector.open).removeClass(ClassName.open);
1090
    parentLi.removeClass(ClassName.open);
D
Daniel Vilanova Yamuza 已提交
1091
    tree.slideUp(this.options.animationSpeed, function () {
1092
      //tree.find(Selector.open + ' > ' + Selector.treeview).slideUp();
R
REJack 已提交
1093
      $(this.element).trigger(collapsedEvent);
1094 1095
    }.bind(this));
  };
A
Abdullah Almsaeed 已提交
1096 1097

  // Private
1098

A
Abdullah Almsaeed 已提交
1099
  Tree.prototype._setUpListeners = function () {
1100
    var that = this;
A
Abdullah Almsaeed 已提交
1101 1102

    $(this.element).on('click', this.options.trigger, function (event) {
1103 1104 1105
      that.toggle($(this), event);
    });
  };
A
Abdullah Almsaeed 已提交
1106 1107 1108 1109 1110

  // Plugin Definition
  // =================
  function Plugin(option) {
    return this.each(function () {
1111 1112
      var $this = $(this);
      var data  = $this.data(DataKey);
A
Abdullah Almsaeed 已提交
1113 1114

      if (!data) {
1115 1116
        var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
        $this.data(DataKey, new Tree($this, options));
A
Abdullah Almsaeed 已提交
1117
      }
1118
    });
A
Abdullah Almsaeed 已提交
1119 1120
  }

1121
  var old = $.fn.tree;
A
Abdullah Almsaeed 已提交
1122

1123 1124
  $.fn.tree             = Plugin;
  $.fn.tree.Constructor = Tree;
A
Abdullah Almsaeed 已提交
1125 1126 1127

  // No Conflict Mode
  // ================
A
Abdullah Almsaeed 已提交
1128
  $.fn.tree.noConflict = function () {
1129 1130 1131
    $.fn.tree = old;
    return this;
  };
A
Abdullah Almsaeed 已提交
1132

A
Abdullah Almsaeed 已提交
1133 1134 1135 1136
  // Tree Data API
  // =============
  $(window).on('load', function () {
    $(Selector.data).each(function () {
1137 1138 1139
      Plugin.call($(this));
    });
  });
A
Abdullah Almsaeed 已提交
1140

1141
}(jQuery);