PageSourceSearch

https://www.asia-p.co.jp/wp-content/plugins/wp-cleanfix/wpdk/assets/js/wpdk.js?ver=1.1.0

js asia-p.co.jp collected 2026-10-06 13:18:06 UTC 74,732 bytes, 2,688 lines download raw bytes

1/**
2 * Like PHP empty()
3 *
4 * @brief Check emmpty
5 * @since 1.0.0.b3
6 *
7 * @param mixed_var
8 * @return {Boolean}
9 */
10function empty( mixed_var ) {
11  // Checks if the argument variable is empty
12  // undefined, null, false, number 0, empty string,
13  // string "0", objects without properties and empty arrays
14  // are considered empty
15  //
16  // http://kevin.vanzonneveld.net
17  // +   original by: Philippe Baumann
18  // +      input by: Onno Marsman
19  // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
20  // +      input by: LH
21  // +   improved by: Onno Marsman
22  // +   improved by: Francesco
23  // +   improved by: Marc Jansen
24  // +      input by: Stoyan Kyosev (http://www.svest.org/)
25  // +   improved by: Rafal Kukawski
26  // *     example 1: empty(null);
27  // *     returns 1: true
28  // *     example 2: empty(undefined);
29  // *     returns 2: true
30  // *     example 3: empty([]);
31  // *     returns 3: true
32  // *     example 4: empty({});
33  // *     returns 4: true
34  // *     example 5: empty({'aFunc' : function () { alert('humpty'); } });
35  // *     returns 5: false
36  var undef, key, i, len;
37  var emptyValues = [undef, null, false, 0, "", "0"];
38
39  for ( i = 0, len = emptyValues.length; i < len; i++ ) {
40    if ( mixed_var === emptyValues[i] ) {
41      return true;
42    }
43  }
44
45  if ( typeof mixed_var === "object" ) {
46    for ( key in mixed_var ) {
47      // TODO: should we check for own properties only?
48      //if (mixed_var.hasOwnProperty(key)) {
49      return false;
50      //}
51    }
52    return true;
53  }
54
55  return false;
56}
57
58/**
59 * Like PHP isset()
60 *
61 * @brief Check isset
62 * @since 1.0.0.b3
63 *
64 * @return {Boolean}
65 */
66function isset() {
67  // http://kevin.vanzonneveld.net
68  // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
69  // +   improved by: FremyCompany
70  // +   improved by: Onno Marsman
71  // +   improved by: Rafał Kukawski
72  // *     example 1: isset( undefined, true);
73  // *     returns 1: false
74  // *     example 2: isset( 'Kevin van Zonneveld' );
75  // *     returns 2: true
76  var a = arguments,
77    l = a.length,
78    i = 0,
79    undef;
80
81  if ( l === 0 ) {
82    throw new Error( 'Empty isset' );
83  }
84
85  while ( i !== l ) {
86    if ( a[i] === undef || a[i] === null ) {
87      return false;
88    }
89    i++;
90  }
91  return true;
92}
93
94/**
95 * Do a sprintf()
96 *
97 * @brief Replace sprintf()
98 *
99 * @since 1.0.0.b3
100 *
101 * @return {*|void}
102 */
103function sprintf() {
104  // http://kevin.vanzonneveld.net
105  // +   original by: Ash Searle (http://hexmen.com/blog/)
106  // + namespaced by: Michael White (http://getsprink.com)
107  // +    tweaked by: Jack
108  // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
109  // +      input by: Paulo Freitas
110  // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
111  // +      input by: Brett Zamir (http://brett-zamir.me)
112  // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
113  // +   improved by: Dj
114  // +   improved by: Allidylls
115  // *     example 1: sprintf("%01.2f", 123.1);
116  // *     returns 1: 123.10
117  // *     example 2: sprintf("[%10s]", 'monkey');
118  // *     returns 2: '[    monkey]'
119  // *     example 3: sprintf("[%'#10s]", 'monkey');
120  // *     returns 3: '[####monkey]'
121  // *     example 4: sprintf("%d", 123456789012345);
122  // *     returns 4: '123456789012345'
123  var regex = /%%|%(\d+\$)?([-+\'#0 ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([scboxXuideEfFgG])/g;
124  var a = arguments,
125    i = 0,
126    format = a[i++];
127
128  // pad()
129  var pad = function ( str, len, chr, leftJustify ) {
130    if ( !chr ) {
131      chr = ' ';
132    }
133    var padding = (str.length >= len) ? '' : Array( 1 + len - str.length >>> 0 ).join( chr );
134    return leftJustify ? str + padding : padding + str;
135  };
136
137  // justify()
138  var justify = function ( value, prefix, leftJustify, minWidth, zeroPad, customPadChar ) {
139    var diff = minWidth - value.length;
140    if ( diff > 0 ) {
141      if ( leftJustify || !zeroPad ) {
142        value = pad( value, minWidth, customPadChar, leftJustify );
143      }
144      else {
145        value = value.slice( 0, prefix.length ) + pad( '', diff, '0', true ) + value.slice( prefix.length );
146      }
147    }
148    return value;
149  };
150
151  // formatBaseX()
152  var formatBaseX = function ( value, base, prefix, leftJustify, minWidth, precision, zeroPad ) {
153    // Note: casts negative numbers to positive ones
154    var number = value >>> 0;
155    prefix = prefix && number && {
156      '2'  : '0b',
157      '8'  : '0',
158      '16' : '0x'
159    }[base] || '';
160    value = prefix + pad( number.toString( base ), precision || 0, '0', false );
161    return justify( value, prefix, leftJustify, minWidth, zeroPad );
162  };
163
164  // formatString()
165  var formatString = function ( value, leftJustify, minWidth, precision, zeroPad, customPadChar ) {
166    if ( precision != null ) {
167      value = value.slice( 0, precision );
168    }
169    return justify( value, '', leftJustify, minWidth, zeroPad, customPadChar );
170  };
171
172  // doFormat()
173  var doFormat = function ( substring, valueIndex, flags, minWidth, _, precision, type ) {
174    var number;
175    var prefix;
176    var method;
177    var textTransform;
178    var value;
179
180    if ( substring == '%%' ) {
181      return '%';
182    }
183
184    // parse flags
185    var leftJustify = false,
186      positivePrefix = '',
187      zeroPad = false,
188      prefixBaseX = false,
189      customPadChar = ' ';
190    var flagsl = flags.length;
191    for ( var j = 0; flags && j < flagsl; j++ ) {
192      switch ( flags.charAt( j ) ) {
193        case ' ':
194          positivePrefix = ' ';
195          break;
196        case '+':
197          positivePrefix = '+';
198          break;
199        case '-':
200          leftJustify = true;
201          break;
vendor: 4,460 bytes, lines 202-340
202        case "'":
203          customPadChar = flags.charAt( j + 1 );
204          break;
205        case '0':
206          zeroPad = true;
207          break;
208        case '#':
209          prefixBaseX = true;
210          break;
211      }
212    }
213
214    // parameters may be null, undefined, empty-string or real valued
215    // we want to ignore null, undefined and empty-string values
216    if ( !minWidth ) {
217      minWidth = 0;
218    }
219    else if ( minWidth == '*' ) {
220      minWidth = +a[i++];
221    }
222    else if ( minWidth.charAt( 0 ) == '*' ) {
223      minWidth = +a[minWidth.slice( 1, -1 )];
224    }
225    else {
226      minWidth = +minWidth;
227    }
228
229    // Note: undocumented perl feature:
230    if ( minWidth < 0 ) {
231      minWidth = -minWidth;
232      leftJustify = true;
233    }
234
235    if ( !isFinite( minWidth ) ) {
236      throw new Error( 'sprintf: (minimum-)width must be finite' );
237    }
238
239    if ( !precision ) {
240      precision = 'fFeE'.indexOf( type ) > -1 ? 6 : (type == 'd') ? 0 : undefined;
241    }
242    else if ( precision == '*' ) {
243      precision = +a[i++];
244    }
245    else if ( precision.charAt( 0 ) == '*' ) {
246      precision = +a[precision.slice( 1, -1 )];
247    }
248    else {
249      precision = +precision;
250    }
251
252    // grab value using valueIndex if required?
253    value = valueIndex ? a[valueIndex.slice( 0, -1 )] : a[i++];
254
255    switch ( type ) {
256      case 's':
257        return formatString( String( value ), leftJustify, minWidth, precision, zeroPad, customPadChar );
258      case 'c':
259        return formatString( String.fromCharCode( +value ), leftJustify, minWidth, precision, zeroPad );
260      case 'b':
261        return formatBaseX( value, 2, prefixBaseX, leftJustify, minWidth, precision, zeroPad );
262      case 'o':
263        return formatBaseX( value, 8, prefixBaseX, leftJustify, minWidth, precision, zeroPad );
264      case 'x':
265        return formatBaseX( value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad );
266      case 'X':
267        return formatBaseX( value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad ).toUpperCase();
268      case 'u':
269        return formatBaseX( value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad );
270      case 'i':
271      case 'd':
272        number = +value || 0;
273        number = Math.round( number - number % 1 ); // Plain Math.round doesn't just truncate
274        prefix = number < 0 ? '-' : positivePrefix;
275        value = prefix + pad( String( Math.abs( number ) ), precision, '0', false );
276        return justify( value, prefix, leftJustify, minWidth, zeroPad );
277      case 'e':
278      case 'E':
279      case 'f': // Should handle locales (as per setlocale)
280      case 'F':
281      case 'g':
282      case 'G':
283        number = +value;
284        prefix = number < 0 ? '-' : positivePrefix;
285        method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf( type.toLowerCase() )];
286        textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf( type ) % 2];
287        value = prefix + Math.abs( number )[method]( precision );
288        return justify( value, prefix, leftJustify, minWidth, zeroPad )[textTransform]();
289      default:
290        return substring;
291    }
292  };
293
294  return format.replace( regex, doFormat );
295}
296
297/**
298 * Porting of PHP join function
299 *
300 * @param glue
301 * @param pieces
302 * @return {*}
303 */
304function join( glue, pieces ) {
305  // http://kevin.vanzonneveld.net
306  // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
307  // -    depends on: implode
308  // *     example 1: join(' ', ['Kevin', 'van', 'Zonneveld']);
309  // *     returns 1: 'Kevin van Zonneveld'
310  return this.implode( glue, pieces );
311}
312
313/**
314 *
315 * @param glue
316 * @param pieces
317 * @return {*}
318 */
319function implode( glue, pieces ) {
320  // http://kevin.vanzonneveld.net
321  // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
322  // +   improved by: Waldo Malqui Silva
323  // +   improved by: Itsacon (http://www.itsacon.net/)
324  // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
325  // *     example 1: implode(' ', ['Kevin', 'van', 'Zonneveld']);
326  // *     returns 1: 'Kevin van Zonneveld'
327  // *     example 2: implode(' ', {first:'Kevin', last: 'van Zonneveld'});
328  // *     returns 2: 'Kevin van Zonneveld'
329  var i = '',
330    retVal = '',
331    tGlue = '';
332  if ( arguments.length === 1 ) {
333    pieces = glue;
334    glue = '';
335  }
336  if ( typeof(pieces) === 'object' ) {
337    if ( Object.prototype.toString.call( pieces ) === '[object Array]' ) {
338      return pieces.join( glue );
339    }
340    for ( i in pieces ) {
341      retVal += tGlue + pieces[i];
342      tGlue = glue;
343    }
344    return retVal;
345  }
346  return pieces;
347}
348
349/**
350 * Return TRUE if the string NOT contains '', 'false', '0', 'no', 'n', 'off', null.
351 *
352 * @brief Check if bool
353 * @since 1.0.0.b4
354 *
355 * @note This is a porting of homonymous php function to check if a param is TRUE.
356 *
357 * @param $mixed
358 *
359 * @return {Boolean}
360 */
361function wpdk_is_bool( $mixed ) {
362  var undef, key, i, len;
363  var emptyValues = [undef, null, false, 0, "", "0", 'n', 'no', 'off', 'false'];
364  for ( i = 0, len = emptyValues.length; i < len; i++ ) {
365    if ( $mixed === emptyValues[i] || $mixed.toLowerCase() == emptyValues[i] ) {
366      return false;
367    }
368  }
369  return true;
370}
371
372/**
373 * Initialize a jQuery plugin scroller
374 *
375 * @author          =undo= <[email protected]>
376 * @copyright       Copyright (C) 2012-2013 wpXtreme Inc. All Rights Reserved.
377 * @date            2012-11-28
378 * @version         0.8.1
379 *
380 */
381(function ( $ ) {
382  $.fn.extend( {
383
384    scroller : function () {
385
386      // Iterate over the current set of matched elements
387      return this.each( function () {
388
389        var $this = $( this );
390        var $scroller = $this.find( 'div' ).eq( 0 );
391
392        var scroller_height = parseInt( $scroller.height() );
393        var timing = (200 + scroller_height) * 50;
394
395        $this.css( { height : '200px', overflow : 'hidden', marginBottom : '32px' } );
396
397        $scroller.css( { marginTop : '200px' } );
398
399        var moveup = function () {
400          var posy = parseInt( $scroller.css( 'marginTop' ) );
401          posy -= 2;
402          $scroller.css( { marginTop : posy + 'px' } );
403          if ( posy < -scroller_height ) {
404            $scroller.css( { marginTop : '200px' } );
405          }
406        };
407
408        $scroller.animate( { marginTop : -scroller_height }, timing );
409
410      } );
411    }
412  } );
413})( jQuery );
414
415/**
416 * jQuery Cookie Plugin v1.3
417 * https://github.com/carhartl/jquery-cookie
418 *
419 * Copyright 2011, Klaus Hartl
420 * Dual licensed under the MIT or GPL Version 2 licenses.
421 * http://www.opensource.org/licenses/mit-license.php
422 * http://www.opensource.org/licenses/GPL-2.0
423 */
424(function ( $, document, undefined ) {
425
426  var pluses = /\+/g;
427
428  function raw( s ) {
429    return s;
430  }
431
432  function decoded( s ) {
433    return decodeURIComponent( s.replace( pluses, ' ' ) );
434  }
435
436  var config = $.cookie = function ( key, value, options ) {
437
438    // write
439    if ( value !== undefined ) {
440      options = $.extend( {}, config.defaults, options );
441
442      if ( value === null ) {
443        options.expires = -1;
444      }
445
446      if ( typeof options.expires === 'number' ) {
447        var days = options.expires, t = options.expires = new Date();
448        t.setDate( t.getDate() + days );
449      }
450
451      value = config.json ? JSON.stringify( value ) : String( value );
452
453      return (document.cookie = [
454        encodeURIComponent( key ), '=', config.raw ? value : encodeURIComponent( value ),
455        options.expires ? '; expires=' + options.expires.toUTCString() : '',
456        // use expires attribute, max-age is not supported by IE
457        options.path ? '; path=' + options.path : '',
458        options.domain ? '; domain=' + options.domain : '',
459        options.secure ? '; secure' : ''
460      ].join( '' ));
461    }
462
463    // read
464    var decode = config.raw ? raw : decoded;
465    var cookies = document.cookie.split( '; ' );
466    for ( var i = 0, l = cookies.length; i < l; i++ ) {
467      var parts = cookies[i].split( '=' );
468      if ( decode( parts.shift() ) === key ) {
469        var cookie = decode( parts.join( '=' ) );
470        return config.json ? JSON.parse( cookie ) : cookie;
471      }
472    }
473
474    return null;
475  };
476
477  config.defaults = {};
478
479  $.removeCookie = function ( key, options ) {
480    if ( $.cookie( key ) !== null ) {
481      $.cookie( key, null, options );
482      return true;
483    }
484    return false;
485  };
486
487})( jQuery, document );
488
489/**
490 * This class manage all forms controles and fields, attach new event and perform special actions.
491 *
492 * @class           WPDKControls
493 * @author          =undo= <[email protected]>
494 * @copyright       Copyright (C) 2012-2013 wpXtreme Inc. All Rights Reserved.
495 * @date            2013-01-21
496 * @version         0.9.5
497 *
498 */
499var WPDKControls = (function ( $ ) {
500
501  /**
502   * Internal class pointer
503   *
504   * @brief This object
505   */
506  var $this = {};
507
508  // -----------------------------------------------------------------------------------------------------------------
509  // Public properties
510  // -----------------------------------------------------------------------------------------------------------------
511
512  /**
513   * The WPDKControls version
514   *
515   * @brief Version
516   */
517  $this.version = "0.9.5";
518
519  /**
520   * Init this class
521   *
522   * @brief Init this class
523   */
524  $this.init = function () {
525    _initClearInput();
526    _initSwipeControl();
527    _initLockedControl();
528    _initAccordion();
529    _initBehavior();
530    _initGuide();
531  };
532
533  /**
534   * Return the standard form for a configuration view. See wpdk-ui.php for more detail.
535   *
536   * @brief Get the form
537   * @since 0.9.5
538   *
539   * @param {string} $id Configuration view ID
540   * @return {*|jQuery|HTMLElement}
541   */
542  $this.configurationForm = function ( $id ) {
543    return $( 'form#wpdk_configuration_view_form-' + $id );
544  };
545
546  /**
547   * Init the guide engine to open a modal twitter window with an iframe to developer center
548   *
549   * @brief Init the guide engine
550   * @since 1.0.0.b4
551   *
552   * @private
553   */
554  function _initGuide() {
555    $( 'a.wpdk-guide' ).click( function () {
556
557      // Set guide title
558      var $title = $( this ).data( 'title' );
559
560      // If guide content is directly into data-content attribute
561      if( typeof $( this ).data( 'content' ) != 'undefined' && $( this ).data( 'content' ).length > 0 ) {
562        var $content = $( this ).data( 'content' );
563      }
564      // If guide is in Developer Center
565      else {
566        var $url = sprintf( 'https://developer.wpxtre.me/api/v1/articles/%s', $( this ).attr( 'href' ) );
567        var $content = sprintf( '<iframe class="wpdk-iframe-guide" frameborder="0" height="520" width="530" src="%s"></iframe>', $url );
568      }
569
570      var $modal = new WPDKTwitterBootstrapModal( 'wpdk-guide', $title, $content );
571      $modal.height = 512;
572      $modal.display();
573
574      return false;
575    } );
576  }
577
578  /**
579   * When an input field has the clear right button, on click the previous left input is cleaned.
580   *
581   * @brief Clear input field
582   *
583   * @private
584   */
585  function _initClearInput() {
586    $( 'span.wpdk-form-clear-left' ).live( 'click', function () {
587      $( this ).prev().val( '' ).triggerHandler( 'change' );
588    } );
589  }
590
591  /**
592   * Initialize the WPDK custom Swipe Control.
593   * When a Swipe Control is clicked (or swipe) an event `swipe` is trigged:
594   *
595   *     $('.wpdk-form-swipe').on('swipe', function(a, swipeButton, status ) {});
596   *
597   * @brief Init Swipe
598   *
599   * @private
600   */
601  function _initSwipeControl() {
602    $( 'span.wpdk-form-swipe span' ).live( 'click', function () {
603      var $control = $( this ).parent();
604      var $status = wpdk_is_bool( $control.swipe() );
605      var $enabled = $status ? 'off' : 'on';
606      var $result = $control.triggerHandler( 'swipe', [ $control, $enabled] );
607      if( typeof $result == 'undefined' || $result ) {
608        $control.swipe( $enabled );
609      }
610    } );
611
612    /* Extends. */
613    $.fn.swipe = function ( v ) {
614      if ( $( this ).hasClass( 'wpdk-form-swipe' ) ) {
615        /* Get main control. */
616        var $control = $( this );
617
618        /* Get sub-elements. */
619        var $knob = $control.children( 'span' ).eq( 0 );
620        var $input = $control.children( 'input[type=hidden]' ).eq( 0 );
621
622        /* Set. */
623        if ( typeof( v ) != 'undefined' ) {
624
625          /* On. */
626          if ( 'on' === v ) {
627            $input.val( 'on' );
628            $control.triggerHandler( 'change', [ $control, 'on' ] );
629            $knob.animate( { marginLeft : '23px' }, 100, function () {
630              $control.addClass( 'wpdk-form-swipe-on' );
631            } );
632          }
633
634          /* Off. */
635          else {
636            $input.val( 'off' );
637            $control.triggerHandler( 'change', [ $control, 'off' ] );
638            $knob.animate( { marginLeft : '0' }, 100, function () {
639              $control.removeClass( 'wpdk-form-swipe-on' );
640            } );
641          }
642        }
643
644        /* Get. */
645        else {
646          return $input.val();
647        }
648      }
649    };
650  }
651
652  /**
653   * A Locked Control is a special input text when a lock to avoid change unwanted.
654   * When you try to edit this field a Javascript confirm is displayed. You have to confirm the edit to next.
655   *
656   * @brief Init Locked Control
657   *
658   * @private
659   */
660  function _initLockedControl() {
661    $( '.wpdk-form-locked' ).live( 'click', function () {
662      if ( confirm( wpdk_i18n.messageUnLockField ) ) {
663        $( this )
664          .attr( 'class', 'wpdk-form-unlocked' )
665          .prev( 'input' )
666          .removeAttr( 'readonly' );
667      }
668    } );
669  }
670
671  /**
672   * Initialize the wpdk accordion
673   *
674   * @brief Init accordion
675   *
676   * @private
677   */
678  function _initAccordion() {
679    if ( $( 'i.wpdk-openclose-accordion' ).length ) {
680      /* Memorizzo altezza */
681      $( 'i.wpdk-openclose-accordion' ).parent().next( 'div.wpdk-accordion' ).each( function ( i, e ) {
682        $( this ).addClass( 'wpdk-accordion-open' ).data( 'height', $( this ).height() );
683        if ( i > 0 ) {
684          $( this ).removeClass( 'wpdk-accordion-open' );
685        }
686        else {
687          $( e ).css( 'height', $( e ).data( 'height' ) + 'px' );
688        }
689      } );
690
691      $( 'i.wpdk-openclose-accordion' ).click( function () {
692        /* Chiudo tutti gli altri - solo i fieldsset del form parent */
693        var $form = $( this ).parents( 'form' );
694        $form.find( 'fieldset' ).removeClass( 'wpdk-accordion-open' );
695        $form.find( 'fieldset div.wpdk-accordion' ).css( 'height', '0' );
696
697        /* Me stesso lo apro */
698        $( this ).parents( 'fieldset' ).addClass( 'wpdk-accordion-open' );
699
700        /* Animation su container */
701        var $container = $( this ).parent().next( 'div.wpdk-accordion' );
702        $container.css( 'height', $container.data( 'height' ) + 'px' );
703
704      } );
705    }
706  }
707
708  /**
709   * Initialize special behaviors as auto disabled after click, and more.
710   *
711   * @brief Initialize special behaviors
712   *
713   * @private
714   */
715  function _initBehavior() {
716
717    /* Disabled after click for input. */
718    $( 'input.wpdk-disable-after-click' ).click( function () {
719      $( this ).addClass( 'disabled' );
720    } );
721  }
722
723  return $this;
724
725})( jQuery );
726
727/**
728 * This class manage all forms and fields, attach new event and perform special actions.
729 *
730 * @class           WPDKTwitterBootstrap
731 * @author          =undo= <[email protected]>
732 * @copyright       Copyright (C) 2012-2013 wpXtreme Inc. All Rights Reserved.
733 * @date            2012-11-28
734 * @version         0.8.1
735 *
736 */
737var WPDKTwitterBootstrap = (function ( $ ) {
738
739  /**
740   * Internal class pointer
741   *
742   * @brief This object
743   */
744  var $this = {};
745
746  // -----------------------------------------------------------------------------------------------------------------
747  // Public properties
748  // -----------------------------------------------------------------------------------------------------------------
749
750  /**
751   * The WPDKTwitterBootstrap version
752   *
753   * @brief Version
754   */
755  $this.version = "1.0";
756
757  /**
758   * Init this class
759   *
760   * @brief Init this class
761   */
762  $this.init = function () {
763    $( document ).ready( _init );
764  };
765
766  /**
767   * Init when the document is ready
768   *
769   * @brief Document ready
770   *
771   * @private
772   */
773  function _init() {
774    /* Init tooltip. */
775    $( '.wpdk-tooltip' ).tooltip();
776
777    /* Init alert. */
778    $().alert();
779  }
780
781  return $this;
782
783})( jQuery );
784
785/**
786 * This class manage all jQuery enhancer
787 *
788 * @class           WPDKjQuery
789 * @author          =undo= <[email protected]>
790 * @copyright       Copyright (C) 2012-2013 wpXtreme Inc. All Rights Reserved.
791 * @date            2012-11-28
792 * @version         1.0.0
793 */
794var WPDKjQuery = (function ( $ ) {
795
796  /**
797   * Internal class pointer
798   *
799   * @brief This object
800   */
801  var $this = {};
802
803  /**
804   * The WPDKTwitterBootstrap version
805   *
806   * @brief Version
807   */
808  $this.version = "1.0.0";
809
810  /**
811   * Called by default when an Ajax request is perform. Display the Ajax animation on the center of page.
812   *
813   * @brief Display Ajax waiting
814   */
815  $( document ).ajaxStart( function () {
816    $( '<div />' ).addClass( 'wpxm-loader' ).appendTo( 'body' ).fadeIn( 500 );
817  } );
818
819  /**
820   * Called by default when an Ajax request is over. Remove the Ajax animation on the center of page.
821   *
822   * @brief Remove Ajax waiting
823   */
824  $( document ).ajaxComplete( function () {
825    $( 'div.wpxm-loader' ).fadeOut( function () { $( this ).remove() } );
826  } );
827
828  /**
829   * Init this class
830   *
831   * @brief Init this class
832   */
833  $this.init = function () {
834    _initDatePicker();
835    _initTabs();
836    __initAutocomplete();
837    _initAutocomplete();
838    _initCopyPaste();
839
840    /* Wrap the date picker with my pwn class. */
841    $( '#ui-datepicker-div' ).wrap( '<div class="wpdk-jquery-ui"/>' );
842  };
843
844  /**
845   * Initialize the Date Picker
846   *
847   * @brief Init Date Picker
848   *
849   * @private
850   */
851  function _initDatePicker() {
852
853    /* Enable Date Picker on wpdk input class. */
854    $( 'input.wpdk-form-date' ).datepicker();
855
856    /* Locale */
857    if ( $().datetimepicker ) {
858      $( 'input.wpdk-form-datetime:visible' ).datetimepicker( {
859        timeOnlyTitle : wpdk_i18n.timeOnlyTitle,
860        timeText      : wpdk_i18n.timeText,
861        hourText      : wpdk_i18n.hourText,
862        minuteText    : wpdk_i18n.minuteText,
863        secondText    : wpdk_i18n.secondText,
864        currentText   : wpdk_i18n.currentText,
865        dayNamesMin   : (wpdk_i18n.dayNamesMin).split( ',' ),
866        monthNames    : (wpdk_i18n.monthNames).split( ',' ),
867        closeText     : wpdk_i18n.closeText,
868        timeFormat    : wpdk_i18n.timeFormat,
869        dateFormat    : wpdk_i18n.dateFormat
870      } );
871    }
872    else {
873      if ( typeof window.console !== 'undefined' ) {
874        console.log( 'Date Time Picker not loaded' );
875      }
876    }
877
878    /* Date Picker defaults */
879    $.datepicker.setDefaults( {
880      changeMonth     : true,
881      changeYear      : true,
882      dayNamesMin     : (wpdk_i18n.dayNamesMin).split( ',' ),
883      monthNames      : (wpdk_i18n.monthNames).split( ',' ),
884      monthNamesShort : (wpdk_i18n.monthNamesShort).split( ',' ),
885      dateFormat      : wpdk_i18n.dateFormat
886    } );
887  }
888
889  /**
890   * Initialize the jQuery Tabs with special cookie for remember the open tab.
891   *
892   * @brief Init jQuery Tabs
893   *
894   * @private
895   */
896  function _initTabs() {
897    if ( document.location.href.indexOf( '#' ) > 0 ) {
898      $( ".wpdk-tabs" ).tabs();
899    }
900    else {
901      $( ".wpdk-tabs" ).each( function () {
902        var id = $( this ).attr( "id" );
903        if ( typeof id === 'undefined' || id == null || id == "" ) {
904          $( this ).tabs( {
905            cookie : {
906              expires : 1
907            }
908          } );
909        }
910        else {
911          $( this ).tabs( {
912            cookie : {
913              expires : 1,
914              name    : id
915            }
916          } );
917        }
918      } );
919    }
920  }
921
922  /**
923   * Attach an autocomplete Ajax event when an input has the `data-autocomplete_action` attribute.
924   * Usually you will use an input text. When you digit smething an Ajax call is made with action get from
925   * `autocomplete_action` attribute.
926   *
927   * @brief Autocomplete
928   * @deprecated Since 1.0.0.b4
929   *
930   * @private
931   */
932  function __initAutocomplete() {
933    $( 'input[data-autocomplete_action]' ).each( function ( index, element ) {
934      $( element ).autocomplete(
935        {
936          source    : function ( request, response ) {
937            $.post( wpdk_i18n.ajaxURL,
938              {
939                action          : $( element ).data( 'autocomplete_action' ),
940                autocomplete_id : $( element ).data( 'autocomplete_id' ),
941                data            : $( element ).data( 'user_data' ),
942                term            : request.term
943              },
944              function ( data ) {
945                response( $.parseJSON( data ) );
946              } );
947          },
948          select    : function ( event, ui ) {
949            if ( typeof ui.item.href !== 'undefined' ) {
950              document.location = ui.item.href;
951            }
952            else {
953              var $name = $( element ).data( 'autocomplete_target' );
954              $( 'input[name=' + $name + ']' ).val( ui.item.id );
955            }
956          },
957          minLength : $( element ).data( 'autocomplete_min_length' ) | 0
958        }
959      );
960    } );
961  }
962
963  /**
964   * Select all input with data-autocomplete attribute and init the right autocomplete subset
965   *
966   * @brief Init the right autocomplete
967   *
968   * @private
969   */
970  function _initAutocomplete() {
971    $( 'input[data-autocomplete]' ).each( function ( index, element ) {
972      switch ( $( element ).data( 'autocomplete' ) ) {
973        case 'posts':
974          _initAutocompletePosts( element );
975          break;
976
977        case 'embed':
978        case 'inline':
979          _initAutocompleteEmbed( element );
980          break;
981
982        case 'custom':
983          _initAutocompleteCustom( element );
984          break;
985      }
986    } );
987  }
988
989  /**
990   * Attach an autocomplete Ajax event when an input has the `data-autocomplete_posts` attribute.
991   * Usually you will use an input text. When you digit something an Ajax call 'wpdk_action_autocomplete_posts' is made.
992   *
993   * @brief Autocomplete Posts
994   *
995   * @param element DOM element
996   *
997   * @private
998   */
999  function _initAutocompletePosts( element ) {
1000
1001    /* Init. */
1002    $( element ).autocomplete(
1003      {
1004        source    : function ( request, response ) {
1005          $.post( wpdk_i18n.ajaxURL,
1006            {
1007              action      : 'wpdk_action_autocomplete_posts',
1008              post_type   : function() {
1009                var $post_type = '';
1010                if ( $( $( element ).data( 'post_type' ) ).length ) {
1011                  $post_type = $( $( element ).data( 'post_type' ) ).val();
1012                }
1013                /* The data attribute post type contains the post type id. */
1014                else {
1015                  $post_type = $( element ).data( 'post_type' );
1016                }
1017                return $post_type;
1018              },
1019              post_status : $( element ).data( 'post_status' ),
1020              limit       : $( element ).data( 'limit' ),
1021              order       : $( element ).data( 'order' ),
1022              orderby     : $( element ).data( 'orderby' ),
1023              term        : request.term
1024            },
1025            function ( data ) {
1026              response( $.parseJSON( data ) );
1027            } );
1028        },
1029        select    : function ( event, ui ) {
1030          if ( typeof ui.item.href !== 'undefined' ) {
1031            document.location = ui.item.href;
1032          }
1033          else {
1034            var $name = $( element ).data( 'target' );
1035            if ( !empty( $name ) ) {
1036              $( 'input[name=' + $name + ']' ).val( ui.item.id );
1037            }
1038          }
1039        },
1040        minLength : $( element ).data( 'min_length' ) | 0
1041      }
1042    );
1043  }
1044
1045  /**
1046   * Init an autocomplete with a jSON array embed (inner) into the element
1047   *
1048   * @brief Init embed autocomplete
1049   *
1050   * @param element DOM element
1051   * @private
1052   */
1053  function _initAutocompleteEmbed( element ) {
1054    var $source = $( element ).data( 'source' );
1055
1056    if ( !empty( $source ) ) {
1057
1058      var $source = $.parseJSON( $( element ).data( 'source' ).replace( /'/g, "\"" ) );
1059      $( element ).autocomplete(
1060        {
1061          source    : $source,
1062          minLength : $( element ).data( 'min_length' ) | 0
1063        }
1064      );
1065    }
1066  }
1067
1068  /**
1069   * Init an autocomplete with a jSON array embed (inner) into the element
1070   *
1071   * @brief Init custom autocomplete
1072   *
1073   * @param element DOM element
1074   * @private
1075   */
1076  function _initAutocompleteCustom( element ) {
1077    var $source = $.parseJSON( $( element ).data( 'source' ).replace( /'/g, "\"" ) );
1078    var $function = $( element ).data( 'function' );
1079    var $select = $( element ).data( 'select' );
1080
1081    $( element ).autocomplete(
1082      {
1083        source    : $source,
1084        minLength : $( element ).data( 'min_length' ) | 0
1085      }
1086    ).data( "ui-autocomplete" )._renderItem = eval( $function );
1087  }
1088
1089  /**
1090   * The Copy and Paste engine allow to copy a value from a source input to a target input.
1091   *
1092   * @brief Init the Copy and Paste
1093   *
1094   * @private
1095   */
1096  function _initCopyPaste() {
1097
1098    /* This is a hack to send in POST/GET the new value in the multiple select tag. */
1099    $( 'form' ).submit( function () {
1100      $( '[data-paste]' ).each( function () {
1101        var paste = $( '#' + $( this ).attr( 'data-paste' ) );
1102        var element_paste_type = paste.get( 0 ).tagName;
1103        if ( element_paste_type.toLowerCase() == 'select' && paste.attr( 'multiple' ) !== 'undefined' ) {
1104          paste.find( 'option' ).attr( 'selected', 'selected' );
1105        }
1106      } );
1107    } );
1108
1109    /* Copy & Paste */
1110    $( '.wpdk-form-button-copy-paste' ).live( 'click', function () {
1111      /* Recupero options */
1112      var options = $( this ).attr( 'data-options' ) ? $( this ).attr( 'data-options' ).split( ' ' ) : [];
1113
1114      /* @todo Aggiungere evento/filtro */
1115
1116      var copy = $( '#' + $( this ).attr( 'data-copy' ) );
1117      var paste = $( '#' + $( this ).attr( 'data-paste' ) );
1118
1119      /* Determino da dove copio e dove incollo */
1120      var element_copy_type = copy.get( 0 ).tagName;
1121
1122      switch ( element_copy_type.toLowerCase() ) {
1123        case 'input':
1124          var value = copy.val();
1125          var text = value;
1126          if ( $.inArray( 'clear_after_copy', options ) !== false ) {
1127            copy.val( '' );
1128          }
1129          break;
1130        case 'select':
1131          var value = $( 'option:selected', copy ).val();
1132          var text = $( 'option:selected', copy ).text();
1133          break;
1134      }
1135
1136      if ( value != '' || value != '' ) {
1137
1138        /* Determino dove devo incollare */
1139        var element_paste_type = paste.get( 0 ).tagName;
1140
1141        switch ( element_paste_type.toLowerCase() ) {
1142          case 'select':
1143            paste.append( '<option class="wpdk-form-option" value="' + value + '">
1143' + text + '</option>' );
1144            break;
1145        }
1146      }
1147    } );
1148
1149    /* Remove. */
1150    $( '.wpdk-form-button-remove' ).live( 'click', function () {
1151      var remove_from = $( this ).attr( 'data-remove_from' );
1152      $( 'option:selected', '#' + remove_from ).remove();
1153    } );
1154  }
1155
1156  return $this;
1157
1158})( jQuery );
1159
1160/**
1161 * This class manage all WPDKTableView
1162 *
1163 * @class           WPDKTableView
1164 * @author          =undo= <[email protected]>
1165 * @copyright       Copyright (C) 2012-2013 wpXtreme Inc. All Rights Reserved.
1166 * @date            2012-11-28
1167 * @version         0.8.1
1168 *
1169 * @deprecated      To replace
1170 *
1171 */
1172var WPDKTableView = (function ( $ ) {
1173
1174  /**
1175   * Internal class pointer
1176   *
1177   * @brief This object
1178   */
1179  var $this = {};
1180
1181  /* @todo Questo non va bene, fare qui quello che è stato fatto per il Product Picker */
1182  var _paged = 1;
1183
1184  /**
1185   * Utility property
1186   *
1187   * @brief Image animation for Ajax
1188   *
1189   * @type {String}
1190   * @private
1191   */
1192  var _wait16x16 = '<img style="margin:6px 4px 0 8px;float:right;display:block;width:16px;height:16px;border:none" border="0" alt="Wait" src="data:image/gif;base64,R0lGODlhEgASAMQaAHl5d66urMXFw3l5dpSUk5WVlKOjoq+vrsbGw6Sko7u7uaWlpbm5t3h4doiIhtLSz4aGhJaWlsbGxNHRzrCwr5SUkqKiobq6uNHRz4eHhf///wAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFAAAaACwAAAAAEgASAAAFaaAmjmRplstyrkmbrCNFaUZtaFF0HvyhWRZNYVgwBY4BEmFJOB1NlYpJoYBpHI7RZXtZZb4ZEbd7AodFDIYVAjFJJCYA4ISoI0hyuUnAF2geDxoDgwMnfBoYiRgaDQ1WiIqPJBMTkpYaIQAh+QQFAAAaACwBAAEAEAAQAAAFY6AmjhpFkSh5rEc6KooWzIG2LOilX3Kd/AnSjjcyGA0oBiNlsZAkEtcoEtEgrghpYVsQeAVSgpig8UpFlQrp8Ug5HCiMHEPK2DOkOR0A0NzxJBMTGnx8GhAQZwOLA2ckDQ0uIQAh+QQFAAAaACwBAAEAEAAQAAAFZKAmjpqikCh5rVc6SpLGthSFIjiiMYx2/AeSYCggBY4B1DB1JD0ertFiocFYMdGENnHFugxgg2YyiYosFhIAkIpEUOs1qUAvkAb4gcbh0BD+BCgNDRoZhhkaFRVmh4hmIxAQLiEAIfkEBQAAGgAsAQABABAAEAAABWOgJo6aJJEoiaxIOj6PJsyCpigopmNyff0X0o43AgZJk0mKwSABAK4RhaJ5PqOH7GHAHUQD4ICm0YiKwCSHI7VYoDLwDClBT5Di8khEY+gbUBAQGgWEBRoWFmYEiwRmJBUVLiEAIfkEBQAAGgAsAQABABAAEAAABWSgJo7a85Aoia1YOgKAxraShMKwNk0a4iOkgXBAEhgFqEYjZSQ5HK6RQqHJWDPRi/Zyxbq2Fw0EEhUxGKRIJEWhoArwAulAP5AIeIJmsdAE/gEoFRUaCYYJfoFRBowGZSQWFi4hACH5BAUAABoALAEAAQAQABAAAAVloCaOGgCQKGma6eg42iAP2vOgWZ5pTaNhQAxJtxsFhSQIJDWZkCKR1kgi0RSuBSliiyB4CVKBWKCpVKQiMWmxSCkUqIQ8QbrYLySD3qChUDR3eCQWFhoHhwcaDAxoAY4BaCSOLSEAIfkEBQAAGgAsAQABABAAEAAABWOgJo6a45Aoma1ZOkaRxrYAgBZ4oUGQVtckgpBAGhgHqEol1WiQFgvX6PHQJK4JKWaLMXgNWq7GYpGKJhMShZKSSFCH+IGEqCNIgXxAo1BoBIACKHkaF4YXf4JSh4hmIwwMLiEAIfkEBQAAGgAsAQABABAAEAAABWSgJo5aFJEoWaxFOi6LRsyE5jhooidaVWmZYIZkKBpIwiHJYklBICQKxTUCADSH7IFqtQa+AepgPNB8qaJGg6RQpB4P1GV+IWHuGBK9LpFo8HkkDAwaCIYIGhMTaAKNAmgkjS4hADs=" />';
1193
1194  /**
1195   * The WPDKTableView version
1196   *
1197   * @brief Version
1198   */
1199  $this.version = "0.8.1";
1200
1201  /**
1202   * Init this class
1203   *
1204   * @brief Init this class
1205   */
1206  $this.init = function () {
1207    /* Se esiste... */
1208    if ( $( '.wpdk-tableview' ).length ) {
1209
1210      /* Display more rows */
1211      $( '.wpdk-tableview tbody tr' ).live( 'click', _tableViewDisplaydMoreRows );
1212    }
1213  };
1214
1215  /**
1216   * Attach event on the row and on the last row "more"
1217   *
1218   * @brief Attacj event
1219   *
1220   * @private
1221   */
1222  function _tableViewDisplaydMoreRows() {
1223    var id = $( this ).attr( 'id' );
1224    if ( id != '' ) {
1225      var pa = id.split( '_' );
1226      var kc = pa[1];
1227      $( this ).parents( '.wpdk-tableview' ).triggerHandler( 'wpdkTableViewRowDidSelected', [kc, $( this )] );
1228    }
1229    else if ( $( this ).hasClass( 'wpdk-tableview-moreitems' ) ) {
1230      $( this ).prepend( _wait16x16 );
1231      var ajaxHook = $( '.wpdk-tableview #wpdk-tableview-ajaxhook' ).val();
1232      _paged++;
1233      $.post( wpdk_i18n.ajaxURL, {
1234          action : ajaxHook,
1235          paged  : _paged
1236        }, function ( data ) {
1237          $( 'tr.wpdk-tableview-moreitems' ).remove();
1238          $( 'table.wpdk-tableview-table tbody' ).append( data );
1239        }
1240      );
1241    }
1242  }
1243
1244  return $this;
1245
1246})( jQuery );
1247
1248/**
1249 * This class manage a WPDKDynamicTable
1250 *
1251 * @class           WPDKDynamicTable
1252 * @author          =undo= <[email protected]>
1253 * @copyright       Copyright (C) 2012-2013 wpXtreme Inc. All Rights Reserved.
1254 * @date            2012-11-28
1255 * @version         0.8.1
1256 */
1257var WPDKDynamicTable = (function ( $ ) {
1258
1259  /**
1260   * Internal class pointer
1261   *
1262   * @brief This object
1263   */
1264  var $this = {};
1265
1266  /**
1267   * The WPDKDynamicTable version
1268   *
1269   * @brief Version
1270   */
1271  $this.version = "1.0";
1272
1273  /**
1274   * Return a singleton instance of WPDKDynamicTable class
1275   *
1276   * @brief Init this class
1277   *
1278   * @return WPDKDynamicTable
1279   */
1280  $this.init = function () {
1281    if ( typeof $this.instance == 'undefined' ) {
1282      $this.instance = __construct();
1283    }
1284    return $this.instance;
1285  };
1286
1287  /**
1288   * Create an instance of WPDKDynamicTable class
1289   *
1290   * @return {WPDKDynamicTable}
1291   * @private
1292   */
1293  function __construct() {
1294    $( 'input.wpdk-dt-add-row' ).live( 'click', _addRow );
1295    $( 'input.wpdk-dt-delete-row' ).live( 'click', _deleteRow );
1296
1297    $( 'input.wpdk-dt-delete-row' ).live( 'mouseenter', function () {
1298      $( this ).parents( 'tr' ).addClass( 'wpdk-dt-highlight-delete' );
1299    } );
1300
1301    $( 'input.wpdk-dt-delete-row' ).live( 'mouseleave', function () {
1302      $( this ).parents( 'tr' ).removeClass( 'wpdk-dt-highlight-delete' );
1303    } );
1304
1305    /* Sortable. */
1306    $( 'table.wpdk-dynamic-table-sortable tbody' ).sortable( {
1307      axis   : "y",
1308      cursor : "n-resize",
1309      start  : function ( e, ui ) {},
1310      stop   : function () {}
1311    } );
1312
1313    return $this;
1314  }
1315
1316  /**
1317   * Add a row to the dynamic table
1318   *
1319   * @brief Add row
1320   *
1321   * @private
1322   */
1323  function _addRow() {
1324    var table = $( this ).parents( 'table.wpdk-dynamic-table' );
1325    var clone = $( this ).parents( 'tr' ).prevAll( '.wpdk-dt-clone' ).clone();
1326    clone.removeClass( 'wpdk-dt-clone' ).appendTo( table );
1327    $( this ).hide().siblings( '.wpdk-dt-clone' ).removeClass( 'wpdk-dt-clone' ).show( function () {
1328      WPDK.init();
1329    } );
1330  }
1331
1332  /**
1333   * Delete a row from dynamic table
1334   *
1335   * @brief Delete item
1336   *
1337   * @private
1338   */
1339  function _deleteRow() {
1340    $( this ).tooltip( 'hide' );
1341    $( this ).parents( 'tr' ).fadeOut( 300, function () { $( this ).remove(); } );
1342  }
1343
1344  return $this.init();
1345
1346})( jQuery );
1347
1348/**
1349 * This is a little Javascript framework to improve the UI and checking control specially in the form management.
1350 *
1351 * @class           WPDK
1352 * @author          =undo= <[email protected]>
1353 * @copyright       Copyright (C) 2012-2013 wpXtreme Inc. All Rights Reserved.
1354 * @date            2013-04-03
1355 * @version         0.9.4
1356 *
1357 */
1358var WPDK = (function ( $ ) {
1359
1360  /**
1361   * Internal class pointer
1362   *
1363   * @brief This object
1364   */
1365  var $this = {};
1366
1367  /**
1368   * The WPDK Javascript version
1369   * @brief Version
1370   */
1371  $this.version = "0.9.4";
1372
1373  /**
1374   * Initialize all Javascript hook.
1375   * If you modify the DOM you can call this method to refresh hooks.
1376   *
1377   * @brief Init
1378   */
1379  $this.init = function () {
1380    _hackMenu();
1381    WPDKControls.init();
1382    WPDKjQuery.init();
1383    WPDKTwitterBootstrap.init();
1384    WPDKTableView.init();
1385  };
1386
1387  /**
1388   * See WPDK.init();
1389   *
1390   * @deprecated Use WPDK.init() instead
1391   */
1392  $this.refresh = function () {
1393    $this.init();
1394  };
1395
1396  /**
1397   * Enabled/Disabled loading on the screen top most
1398   *
1399   * @param status True to display loading on top most, False to remove
1400   *
1401   * @brief Display or remove the Ajax loader
1402   */
1403  $this.loading = function ( status ) {
1404    if ( status ) {
1405      $( '<div />' ).addClass( 'wpxm-loader' ).appendTo( 'body' ).fadeIn( 500 );
1406    }
1407    else {
1408      $( 'div.wpxm-loader' ).fadeOut( function () { $( this ).remove() } );
1409    }
1410  };
1411
1412  /**
1413   * Reload current document with clear and waiting effects
1414   *
1415   * @brief Reload document
1416   * @since 1.0.0.b3
1417   */
1418  $this.reloadDocument = function () {
1419    $( '<div id="wpxm-mask" />' ).appendTo( 'body' );
1420    document.location = document.location.href;
1421  };
1422
1423  // -----------------------------------------------------------------------------------------------------------------
1424  // wpXtreme Server
1425  // -----------------------------------------------------------------------------------------------------------------
1426
1427  /**
1428   * Send a message to the wpXtreme Server to do a signout from backend admin area.
1429   *
1430   * @brief Do signout
1431   *
1432   * @todo Move this method to the wpXtreme Server Javascript
1433   *
1434   */
1435  $( 'input[name=wpxserver_logout]' ).click( function () {
1436    $.post( wpdk_i18n.ajaxURL, {
1437        action   : 'wpxtreme_action_set_token',
1438        token    : '',
1439        referrer : document.location.href
1440      }, function ( data ) {
1441        /* I dati arrivano sempre in jSON, come sempre se message è undefined è tutto ok. */
1442        var result = $.parseJSON( data );
1443        if ( typeof result.message !== 'undefined' ) {
1444          alert( result.message );
1445        }
1446        else {
1447          /* Ricarico la pagina */
1448          document.location = result.referrer;
1449        }
1450      }
1451    );
1452  } );
1453
1454  /**
1455   * Call the init when the document is ready
1456   *
1457   * @brief Document Ready
1458   */
1459  $( document ).ready( function () {
1460    $this.init();
1461  } );
1462
1463  /**
1464   * Remove the A tag to create a separator item for wpXtreme menu.
1465   *
1466   * @brief Hack the WordPress menu
1467   *
1468   * @private
1469   */
1470  function _hackMenu() {
1471    $( 'ul#adminmenu .wp-submenu a[href*=wpdk_menu_divider]' ).each( function ( i, e ) {
1472      var $content = $( this ).html();
1473      $( this ).parent().replaceWith( '<li class="wpdk_menu_divider">' + $content + '</li>' );
1474    } );
1475  }
1476
1477  return $this;
1478
1479})( jQuery );
1480
1481/**
1482 * Utility for Twitter Bootstrap Modal dialog.
1483 *
1484 * @class           WPDK
1485 * @author          =undo= <[email protected]>
1486 * @copyright       Copyright (C) 2012-2013 wpXtreme Inc. All Rights Reserved.
1487 * @date            2013-01-17
1488 * @version         0.1.0
1489 *
1490 */
1491var WPDKTwitterBootstrapModal = function ( $id, $title, $content ) {
1492
1493  /**
1494   * Resolve conflict
1495   *
1496   * @brief jQuery
1497   *
1498   * @type {*}
1499   */
1500  var $ = window.jQuery;
1501
1502  /**
1503   * @brief Instance
1504   *
1505   * @type {WPDKTwitterBootstrapModal}
1506   */
1507  var $this = this;
1508
1509  $this.id = $id;
1510  $this.title = $title;
1511  $this.content = $content;
1512  $this.width = '';
1513  $this.height = '';
1514  $this.close_button = true;
1515  $this.buttons = [];
1516  $this.data = [];
1517
1518  // -----------------------------------------------------------------------------------------------------------------
1519  // Private methods
1520  // -----------------------------------------------------------------------------------------------------------------
1521
1522  /**
1523   * Return the HTML aria title format
1524   *
1525   * @brief Return the aria title
1526   *
1527   * @return string
1528   */
1529  function aria_title() {
1530    return $this.id + '-title';
1531  }
1532
1533  /**
1534   * Return the HTML markup for top right dismiss button [x]
1535   *
1536   * @brief Dismiss button
1537   *
1538   * @return {string}
1539   */
1540  function close_button() {
1541    var $result = '';
1542    if ( $this.close_button ) {
1543      $result = '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>';
1544    }
1545    return $result;
1546  }
1547
1548  /**
1549   * Build the inline CSS style for width and heght
1550   *
1551   * @brief Get the size
1552   *
1553   * @return string
1554   */
1555  function size() {
1556    var $result = '';
1557    var $styles = [];
1558
1559    if ( !empty( $this.width ) ) {
1560      $styles['width'] = $this.width + 'px';
1561    }
1562
1563    if ( !empty( $this.height ) ) {
1564      $styles['height'] = $this.height + 'px';
1565    }
1566
1567    var $inline_style = '';
1568    for ( $key in $styles ) {
1569      $inline_style += $key + ':' + $styles[$key] + ';';
1570    }
1571
1572    if ( !empty( $inline_style ) ) {
1573      $result = 'style="' + $inline_style + '"';
1574    }
1575
1576    return $result;
1577
1578  }
1579
1580  /**
1581   * Return the HTML markup for footer buttons
1582   *
1583   * @brief Footer buttons
1584   *
1585   * @return string
1586   */
1587  function buttons() {
1588    var $result = '';
1589    if ( !empty( $this.buttons ) ) {
1590      var $buttons = '';
1591      for ( $key in $this.buttons ) {
1592        var $value = $this.buttons[$key];
1593        var $class = isset( $value['classes'] ) ? $value['classes'] : '';
1594        var $label = isset( $value['label'] ) ? $value['label'] : '';
1595        var $data_dismiss = ( isset( $value['dismiss'] ) && true == $value['dismiss'] ) ? 'data-dismiss="modal"' : '';
1596        $buttons += sprintf( '<button id="%s" class="btn button %s" %s aria-hidden="true">%s</button>', $key, $class, $data_dismiss, $label );
1597      }
1598    }
1599
1600    if ( !empty( $buttons ) ) {
1601      $result = sprintf( '<div class="modal-footer">%s</div>', $buttons );
1602    }
1603
1604    return $result;
1605  }
1606
1607  /**
1608   * Return the HTML attribute markup for 'data-' attribute
1609   *
1610   * @brief Build data attribute
1611   *
1612   * @return string
1613   */
1614  function data() {
1615    var $result = '';
1616    var $stack = [];
1617    if ( !empty( $this.data ) ) {
1618      for ( var $key in $this.data ) {
1619        var $value = $this.data[$key];
1620        $stack.push( sprintf( 'data-%s="%s"', $key, $value ) );
1621      }
1622      $result = join( ' ', $stack );
1623    }
1624    return $result;
1625  }
1626
1627  /**
1628   * Return the HTML markup for Twitter boostrap modal
1629   *
1630   * @brief Get HTML
1631   *
1632   * @return string
1633   */
1634  $this.html = function () {
1635    var $content = '';
1636
1637    $content = '<div class="modal hide fade" ' + data() +
1638      'id="' + $this.id + '"' +
1639      'tabindex="-1"' +
1640      'role="dialog"' +
1641      'aria-labelledby="' + aria_title() + '"' +
1642      'aria-hidden="true">' +
1643      '<div class="modal-header">' +
1644      close_button() +
1645      '<h3 id="' + aria_title() + '">' + $this.title + '</h3>' +
1646      '</div>' +
1647      '<div class="modal-body" ' + size() + ' >' +
1648      $this.content +
1649      '</div>' +
1650      buttons() +
1651      '</div>';
1652
1653    return $content;
1654  };
1655
1656  /**
1657   * Display the Twitter boostrap modal
1658   *
1659   * @brief Display
1660   */
1661  $this.display = function () {
1662    $( 'body' ).append( $this.html() );
1663    $( '#' + $this.id ).modal( 'show' );
1664    $( '#' + $this.id ).on( 'hidden', function () {
1665      $( this ).remove();
1666    } );
1667  };
1668
1669  /**
1670   * Add a footer button
1671   *
1672   * @brief Add button
1673   *
1674   * @param string $id      Unique id for button
1675   * @param string $label   Text label
1676   * @param bool   $dismiss True for data-dismiss
1677   * @param string $class   Addition CSS class
1678   */
1679  $this.add_buttons = function ( $id, $label, $dismiss, $class ) {
1680    $this.buttons[$id] = {
1681      label   : $label,
1682      classes : $class || '',
1683      dismiss : $dismiss || true
1684    };
1685  };
1686
1687  /**
1688   * Add an attribute data
1689   *
1690   * @brief Add data
1691   */
1692  $this.add_data = function ( $key, $value ) {
1693    $this.data.push(
1694      {
1695        key   : $key,
1696        value : $value
1697      } );
1698  };
1699
1700  // -----------------------------------------------------------------------------------------------------------------
1701  // Public utility methods
1702  // -----------------------------------------------------------------------------------------------------------------
1703
1704  /**
1705   * Return the HTML markup for button tag to open this modal dialog
1706   *
1707   * @brief Return a button for open this dialog
1708   *
1709   * @param string $label Text button label
1710   * @param string $class Additional class
1711   *
1712   * @return string
1713   */
1714  $this.button_open_modal = function ( $label, $class ) {
1715    $id = '#' + $this.id;
1716    $result = sprintf( '<button class="button %s" type="button" data-toggle="modal" data-target="%s">%s</button>', ( $class || '' ), $id, $label );
1717    return $result;
1718  }
1719
1720};
1721
1722/**
1723 * Plugin ribbonize
1724 *
1725 * @todo To complete
1726 */
1727(function ( $, window, document, undefined ) {
1728
1729  // undefined is used here as the undefined global variable in ECMAScript 3 is
1730  // mutable (ie. it can be changed by someone else). undefined isn't really being
1731  // passed in so we can ensure the value of it is truly undefined. In ES5, undefined
1732  // can no longer be modified.
1733
1734  // window and document are passed through as local variable rather than global
1735  // as this (slightly) quickens the resolution process and can be more efficiently
1736  // minified (especially when both are regularly referenced in your plugin).
1737
1738  // Create the defaults once
1739  var pluginName = "ribbonize",
1740    defaults = {
1741      propertyName : "value"
1742    };
1743
1744  // The actual plugin constructor
1745  function Plugin( element, content, options ) {
1746    this.element = element;
1747    this.content = content;
1748
1749    // jQuery has an extend method which merges the contents of two or
1750    // more objects, storing the result in the first object. The first object
1751    // is generally empty as we don't want to alter the default options for
1752    // future instances of the plugin
1753    this.options = $.extend( {}, defaults, options );
1754
1755    this._defaults = defaults;
1756    this._name = pluginName;
1757
1758    this.init();
1759  }
1760
1761  Plugin.prototype = {
1762
1763    init : function () {
1764      // Place initialization logic here
1765      // You already have access to the DOM element and
1766      // the options via the instance, e.g. this.element
1767      // and this.options
1768      // you can add more functions like the one below and
1769      // call them like so: this.yourOtherFunction(this.element, this.options).
1770
1771      if ( !$( this.element ).next().hasClass( 'wpdk-ribbon' ) ) {
1772        var $html = '';
1773        $html += '<div class="wpdk-ribbon fade right">';
1774        $html += '<div class="wpdk-ribbon-arrow"></div>';
1775        $html += '<div class="wpdk-ribbon-inner">' + this.content + '</div>';
1776        $html += '</div>';
1777
1778        $( this.element ).after( $html );
1779
1780        if( '' !== this.content ) {
1781          $( this.element ).next().addClass( 'in' );
1782        }
1783      }
1784    },
1785
1786    yourOtherFunction : function ( el, options ) {
1787      // some logic
1788    }
1789
1790  };
1791
1792  // A really lightweight plugin wrapper around the constructor,
1793  // preventing against multiple instantiations
1794  $.fn[pluginName] = function ( content, options ) {
1795    return this.each( function () {
1796      if ( !$.data( this, "plugin_" + pluginName ) ) {
1797        $.data( this, "plugin_" + pluginName, new Plugin( this, content, options ) );
1798      }
1799      else if ( '' !== content ) {
1800        $( this ).next().find( '.wpdk-ribbon-inner' ).html( content );
1801        $( this ).next().addClass( 'in' );
1802      }
1803      else if ( '' == content ) {
1804        $( this ).next().removeClass( 'in' );
1805      }
1806    } );
1807  };
1808
1809})( jQuery, window, document );
1810
1811
1812if( typeof( jQuery.fn.transition ) === 'undefined' ) {
1813/* ===================================================
1814 * bootstrap-transition.js v2.3.1
1815 * http://twitter.github.com/bootstrap/javascript.html#transitions
1816 * ===================================================
1817 * Copyright 2012 Twitter, Inc.
1818 *
1819 * Licensed under the Apache License, Version 2.0 (the "License");
1820 * you may not use this file except in compliance with the License.
1821 * You may obtain a copy of the License at
1822 *
1823 * http://www.apache.org/licenses/LICENSE-2.0
1824 *
1825 * Unless required by applicable law or agreed to in writing, software
1826 * distributed under the License is distributed on an "AS IS" BASIS,
1827 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1828 * See the License for the specific language governing permissions and
1829 * limitations under the License.
1830 * ========================================================== */
1831!function ($) {
1832
1833  "use strict"; // jshint ;_;
1834
1835
1836  /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
1837   * ======================================================= */
1838
1839  $(function () {
1840
1841    $.support.transition = (function () {
1842
1843      var transitionEnd = (function () {
1844
1845        var el = document.createElement('bootstrap')
1846          , transEndEventNames = {
1847               'WebkitTransition' : 'webkitTransitionEnd'
1848            ,  'MozTransition'    : 'transitionend'
1849            ,  'OTransition'      : 'oTransitionEnd otransitionend'
1850            ,  'transition'       : 'transitionend'
1851            }
1852          , name
1853
1854        for (name in transEndEventNames){
1855          if (el.style[name] !== undefined) {
1856            return transEndEventNames[name]
1857          }
1858        }
1859
1860      }())
1861
1862      return transitionEnd && {
1863        end: transitionEnd
1864      }
1865
1866    })()
1867
1868  })
1869
1870}(window.jQuery);
1871}
1872
1873if( typeof( jQuery.fn.modal ) === 'undefined' ) {
1874/* =========================================================
1875 * bootstrap-modal.js v2.3.1
1876 * http://twitter.github.com/bootstrap/javascript.html#modals
1877 * =========================================================
1878 * Copyright 2012 Twitter, Inc.
1879 *
1880 * Licensed under the Apache License, Version 2.0 (the "License");
1881 * you may not use this file except in compliance with the License.
1882 * You may obtain a copy of the License at
1883 *
1884 * http://www.apache.org/licenses/LICENSE-2.0
1885 *
1886 * Unless required by applicable law or agreed to in writing, software
1887 * distributed under the License is distributed on an "AS IS" BASIS,
1888 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1889 * See the License for the specific language governing permissions and
1890 * limitations under the License.
1891 * ========================================================= */
1892
1893!function ($) {
1894
1895  "use strict"; // jshint ;_;
1896
1897
1898 /* MODAL CLASS DEFINITION
1899  * ====================== */
1900
1901  var Modal = function (element, options) {
1902    this.options = options
1903    this.$element = $(element)
1904      .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
1905    this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
1906  }
1907
1908  Modal.prototype = {
1909
1910      constructor: Modal
1911
1912    , toggle: function () {
1913        return this[!this.isShown ? 'show' : 'hide']()
1914      }
1915
1916    , show: function () {
1917        var that = this
1918          , e = $.Event('show')
1919
1920        this.$element.trigger(e)
1921
1922        if (this.isShown || e.isDefaultPrevented()) return
1923
1924        this.isShown = true
1925
1926        this.escape()
1927
1928        this.backdrop(function () {
1929          var transition = $.support.transition && that.$element.hasClass('fade')
1930
1931          if (!that.$element.parent().length) {
1932            that.$element.appendTo(document.body) //don't move modals dom position
1933          }
1934
1935          that.$element.show()
1936
1937          if (transition) {
1938            that.$element[0].offsetWidth // force reflow
1939          }
1940
1941          that.$element
1942            .addClass('in')
1943            .attr('aria-hidden', false)
1944
1945          that.enforceFocus()
1946
1947          transition ?
1948            that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) :
1949            that.$element.focus().trigger('shown')
1950
1951        })
1952      }
1953
1954    , hide: function (e) {
1955        e && e.preventDefault()
1956
1957        var that = this
1958
1959        e = $.Event('hide')
1960
1961        this.$element.trigger(e)
1962
1963        if (!this.isShown || e.isDefaultPrevented()) return
1964
1965        this.isShown = false
1966
1967        this.escape()
1968
1969        $(document).off('focusin.modal')
1970
1971        this.$element
1972          .removeClass('in')
1973          .attr('aria-hidden', true)
1974
1975        $.support.transition && this.$element.hasClass('fade') ?
1976          this.hideWithTransition() :
1977          this.hideModal()
1978      }
1979
1980    , enforceFocus: function () {
1981        var that = this
1982        $(document).on('focusin.modal', function (e) {
1983          if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
1984            that.$element.focus()
1985          }
1986        })
1987      }
1988
1989    , escape: function () {
1990        var that = this
1991        if (this.isShown && this.options.keyboard) {
1992          this.$element.on('keyup.dismiss.modal', function ( e ) {
1993            e.which == 27 && that.hide()
1994          })
1995        } else if (!this.isShown) {
1996          this.$element.off('keyup.dismiss.modal')
1997        }
1998      }
1999
2000    , hideWithTransition: function () {
2001        var that = this
2002          , timeout = setTimeout(function () {
2003              that.$element.off($.support.transition.end)
2004              that.hideModal()
2005            }, 500)
2006
2007        this.$element.one($.support.transition.end, function () {
2008          clearTimeout(timeout)
2009          that.hideModal()
2010        })
2011      }
2012
2013    , hideModal: function () {
2014        var that = this
2015        this.$element.hide()
2016        this.backdrop(function () {
2017          that.removeBackdrop()
2018          that.$element.trigger('hidden')
2019        })
2020      }
2021
2022    , removeBackdrop: function () {
2023        this.$backdrop && this.$backdrop.remove()
2024        this.$backdrop = null
2025      }
2026
2027    , backdrop: function (callback) {
2028        var that = this
2029          , animate = this.$element.hasClass('fade') ? 'fade' : ''
2030
2031        if (this.isShown && this.options.backdrop) {
2032          var doAnimate = $.support.transition && animate
2033
2034          this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
2035            .appendTo(document.body)
2036
2037          this.$backdrop.click(
2038            this.options.backdrop == 'static' ?
2039              $.proxy(this.$element[0].focus, this.$element[0])
2040            : $.proxy(this.hide, this)
2041          )
2042
2043          if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
2044
2045          this.$backdrop.addClass('in')
2046
2047          if (!callback) return
2048
2049          doAnimate ?
2050            this.$backdrop.one($.support.transition.end, callback) :
2051            callback()
2052
2053        } else if (!this.isShown && this.$backdrop) {
2054          this.$backdrop.removeClass('in')
2055
2056          $.support.transition && this.$element.hasClass('fade')?
2057            this.$backdrop.one($.support.transition.end, callback) :
2058            callback()
2059
2060        } else if (callback) {
2061          callback()
2062        }
2063      }
2064  }
2065
2066
2067 /* MODAL PLUGIN DEFINITION
2068  * ======================= */
2069
2070  var old = $.fn.modal
2071
2072  $.fn.modal = function (option) {
2073    return this.each(function () {
2074      var $this = $(this)
2075        , data = $this.data('modal')
2076        , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
2077      if (!data) $this.data('modal', (data = new Modal(this, options)))
2078      if (typeof option == 'string') data[option]()
2079      else if (options.show) data.show()
2080    })
2081  }
2082
2083  $.fn.modal.defaults = {
2084      backdrop: true
2085    , keyboard: true
2086    , show: true
2087  }
2088
2089  $.fn.modal.Constructor = Modal
2090
2091
2092 /* MODAL NO CONFLICT
2093  * ================= */
2094
2095  $.fn.modal.noConflict = function () {
2096    $.fn.modal = old
2097    return this
2098  }
2099
2100
2101 /* MODAL DATA-API
2102  * ============== */
2103
2104  $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
2105    var $this = $(this)
2106      , href = $this.attr('href')
2107      , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
2108      , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
2109
2110    e.preventDefault()
2111
2112    $target
2113      .modal(option)
2114      .one('hide', function () {
2115        $this.focus()
2116      })
2117  })
2118
2119}(window.jQuery);
2120}
2121
2122if( typeof( jQuery.fn.tooltip ) === 'undefined' ) {
2123/* ===========================================================
2124 * bootstrap-tooltip.js v2.3.1
2125 * http://twitter.github.com/bootstrap/javascript.html#tooltips
2126 * Inspired by the original jQuery.tipsy by Jason Frame
2127 * ===========================================================
2128 * Copyright 2012 Twitter, Inc.
2129 *
2130 * Licensed under the Apache License, Version 2.0 (the "License");
2131 * you may not use this file except in compliance with the License.
2132 * You may obtain a copy of the License at
2133 *
2134 * http://www.apache.org/licenses/LICENSE-2.0
2135 *
2136 * Unless required by applicable law or agreed to in writing, software
2137 * distributed under the License is distributed on an "AS IS" BASIS,
2138 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2139 * See the License for the specific language governing permissions and
2140 * limitations under the License.
2141 * ========================================================== */
2142!function ($) {
2143
2144  "use strict"; // jshint ;_;
2145
2146
2147 /* TOOLTIP PUBLIC CLASS DEFINITION
2148  * =============================== */
2149
2150  var Tooltip = function (element, options) {
2151    this.init('tooltip', element, options)
2152  }
2153
2154  Tooltip.prototype = {
2155
2156    constructor: Tooltip
2157
2158  , init: function (type, element, options) {
2159      var eventIn
2160        , eventOut
2161        , triggers
2162        , trigger
2163        , i
2164
2165      this.type = type
2166      this.$element = $(element)
2167      this.options = this.getOptions(options)
2168      this.enabled = true
2169
2170      triggers = this.options.trigger.split(' ')
2171
2172      for (i = triggers.length; i--;) {
2173        trigger = triggers[i]
2174        if (trigger == 'click') {
2175          this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
2176        } else if (trigger != 'manual') {
2177          eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
2178          eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
2179          this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
2180          this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
2181        }
2182      }
2183
2184      this.options.selector ?
2185        (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
2186        this.fixTitle()
2187    }
2188
2189  , getOptions: function (options) {
2190      options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options)
2191
2192      if (options.delay && typeof options.delay == 'number') {
2193        options.delay = {
2194          show: options.delay
2195        , hide: options.delay
2196        }
2197      }
2198
2199      return options
2200    }
2201
2202  , enter: function (e) {
2203      var defaults = $.fn[this.type].defaults
2204        , options = {}
2205        , self
2206
2207      this._options && $.each(this._options, function (key, value) {
2208        if (defaults[key] != value) options[key] = value
2209      }, this)
2210
2211      self = $(e.currentTarget)[this.type](options).data(this.type)
2212
2213      if (!self.options.delay || !self.options.delay.show) return self.show()
2214
2215      clearTimeout(this.timeout)
2216      self.hoverState = 'in'
2217      this.timeout = setTimeout(function() {
2218        if (self.hoverState == 'in') self.show()
2219      }, self.options.delay.show)
2220    }
2221
2222  , leave: function (e) {
2223      var self = $(e.currentTarget)[this.type](this._options).data(this.type)
2224
2225      if (this.timeout) clearTimeout(this.timeout)
2226      if (!self.options.delay || !self.options.delay.hide) return self.hide()
2227
2228      self.hoverState = 'out'
2229      this.timeout = setTimeout(function() {
2230        if (self.hoverState == 'out') self.hide()
2231      }, self.options.delay.hide)
2232    }
2233
2234  , show: function () {
2235      var $tip
2236        , pos
2237        , actualWidth
2238        , actualHeight
2239        , placement
2240        , tp
2241        , e = $.Event('show')
2242
2243      if (this.hasContent() && this.enabled) {
2244        this.$element.trigger(e)
2245        if (e.isDefaultPrevented()) return
2246        $tip = this.tip()
2247        this.setContent()
2248
2249        if (this.options.animation) {
2250          $tip.addClass('fade')
2251        }
2252
2253        placement = typeof this.options.placement == 'function' ?
2254          this.options.placement.call(this, $tip[0], this.$element[0]) :
2255          this.options.placement
2256
2257        $tip
2258          .detach()
2259          .css({ top: 0, left: 0, display: 'block' })
2260
2261        this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
2262
2263        pos = this.getPosition()
2264
2265        actualWidth = $tip[0].offsetWidth
2266        actualHeight = $tip[0].offsetHeight
2267
2268        switch (placement) {
2269          case 'bottom':
2270            tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
2271            break
2272          case 'top':
2273            tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
2274            break
2275          case 'left':
2276            tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
2277            break
2278          case 'right':
2279            tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
2280            break
2281        }
2282
2283        this.applyPlacement(tp, placement)
2284        this.$element.trigger('shown')
2285      }
2286    }
2287
2288  , applyPlacement: function(offset, placement){
2289      var $tip = this.tip()
2290        , width = $tip[0].offsetWidth
2291        , height = $tip[0].offsetHeight
2292        , actualWidth
2293        , actualHeight
2294        , delta
2295        , replace
2296
2297      $tip
2298        .offset(offset)
2299        .addClass(placement)
2300        .addClass('in')
2301
2302      actualWidth = $tip[0].offsetWidth
2303      actualHeight = $tip[0].offsetHeight
2304
2305      if (placement == 'top' && actualHeight != height) {
2306        offset.top = offset.top + height - actualHeight
2307        replace = true
2308      }
2309
2310      if (placement == 'bottom' || placement == 'top') {
2311        delta = 0
2312
2313        if (offset.left < 0){
2314          delta = offset.left * -2
2315          offset.left = 0
2316          $tip.offset(offset)
2317          actualWidth = $tip[0].offsetWidth
2318          actualHeight = $tip[0].offsetHeight
2319        }
2320
2321        this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
2322      } else {
2323        this.replaceArrow(actualHeight - height, actualHeight, 'top')
2324      }
2325
2326      if (replace) $tip.offset(offset)
2327    }
2328
2329  , replaceArrow: function(delta, dimension, position){
2330      this
2331        .arrow()
2332        .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
2333    }
2334
2335  , setContent: function () {
2336      var $tip = this.tip()
2337        , title = this.getTitle()
2338
2339      $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
2340      $tip.removeClass('fade in top bottom left right')
2341    }
2342
2343  , hide: function () {
2344      var that = this
2345        , $tip = this.tip()
2346        , e = $.Event('hide')
2347
2348      this.$element.trigger(e)
2349      if (e.isDefaultPrevented()) return
2350
2351      $tip.removeClass('in')
2352
2353      function removeWithAnimation() {
2354        var timeout = setTimeout(function () {
2355          $tip.off($.support.transition.end).detach()
2356        }, 500)
2357
2358        $tip.one($.support.transition.end, function () {
2359          clearTimeout(timeout)
2360          $tip.detach()
2361        })
2362      }
2363
2364      $.support.transition && this.$tip.hasClass('fade') ?
2365        removeWithAnimation() :
2366        $tip.detach()
2367
2368      this.$element.trigger('hidden')
2369
2370      return this
2371    }
2372
2373  , fixTitle: function () {
2374      var $e = this.$element
2375      if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
2376        $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
2377      }
2378    }
2379
2380  , hasContent: function () {
2381      return this.getTitle()
2382    }
2383
2384  , getPosition: function () {
2385      var el = this.$element[0]
2386      return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
2387        width: el.offsetWidth
2388      , height: el.offsetHeight
2389      }, this.$element.offset())
2390    }
2391
2392  , getTitle: function () {
2393      var title
2394        , $e = this.$element
2395        , o = this.options
2396
2397      title = $e.attr('data-original-title')
2398        || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)
2399
2400      return title
2401    }
2402
2403  , tip: function () {
2404      return this.$tip = this.$tip || $(this.options.template)
2405    }
2406
2407  , arrow: function(){
2408      return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
2409    }
2410
2411  , validate: function () {
2412      if (!this.$element[0].parentNode) {
2413        this.hide()
2414        this.$element = null
2415        this.options = null
2416      }
2417    }
2418
2419  , enable: function () {
2420      this.enabled = true
2421    }
2422
2423  , disable: function () {
2424      this.enabled = false
2425    }
2426
2427  , toggleEnabled: function () {
2428      this.enabled = !this.enabled
2429    }
2430
2431  , toggle: function (e) {
2432      var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
2433      self.tip().hasClass('in') ? self.hide() : self.show()
2434    }
2435
2436  , destroy: function () {
2437      this.hide().$element.off('.' + this.type).removeData(this.type)
2438    }
2439
2440  }
2441
2442
2443 /* TOOLTIP PLUGIN DEFINITION
2444  * ========================= */
2445
2446  var old = $.fn.tooltip
2447
2448  $.fn.tooltip = function ( option ) {
2449    return this.each(function () {
2450      var $this = $(this)
2451        , data = $this.data('tooltip')
2452        , options = typeof option == 'object' && option
2453      if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
2454      if (typeof option == 'string') data[option]()
2455    })
2456  }
2457
2458  $.fn.tooltip.Constructor = Tooltip
2459
2460  $.fn.tooltip.defaults = {
2461    animation: true
2462  , placement: 'top'
2463  , selector: false
2464  , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
2465  , trigger: 'hover focus'
2466  , title: ''
2467  , delay: 0
2468  , html: false
2469  , container: false
2470  }
2471
2472
2473 /* TOOLTIP NO CONFLICT
2474  * =================== */
2475
2476  $.fn.tooltip.noConflict = function () {
2477    $.fn.tooltip = old
2478    return this
2479  }
2480
2481}(window.jQuery);
2482}
2483
2484if( typeof( jQuery.fn.alert ) === 'undefined' ) {
2485/* ==========================================================
2486 * bootstrap-alert.js v2.3.1
2487 * http://twitter.github.com/bootstrap/javascript.html#alerts
2488 * ==========================================================
2489 * Copyright 2012 Twitter, Inc.
2490 *
2491 * Licensed under the Apache License, Version 2.0 (the "License");
2492 * you may not use this file except in compliance with the License.
2493 * You may obtain a copy of the License at
2494 *
2495 * http://www.apache.org/licenses/LICENSE-2.0
2496 *
2497 * Unless required by applicable law or agreed to in writing, software
2498 * distributed under the License is distributed on an "AS IS" BASIS,
2499 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2500 * See the License for the specific language governing permissions and
2501 * limitations under the License.
2502 * ========================================================== */
2503!function ($) {
2504
2505  "use strict"; // jshint ;_;
2506
2507
2508 /* ALERT CLASS DEFINITION
2509  * ====================== */
2510
2511  var dismiss = '[data-dismiss="alert"]'
2512    , Alert = function (el) {
2513        $(el).on('click', dismiss, this.close)
2514      }
2515
2516  Alert.prototype.close = function (e) {
2517    var $this = $(this)
2518      , selector = $this.attr('data-target')
2519      , $parent
2520
2521    if (!selector) {
2522      selector = $this.attr('href')
2523      selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
2524    }
2525
2526    $parent = $(selector)
2527
2528    e && e.preventDefault()
2529
2530    $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
2531
2532    $parent.trigger(e = $.Event('close'))
2533
2534    if (e.isDefaultPrevented()) return
2535
2536    $parent.removeClass('in')
2537
2538    function removeElement() {
2539      $parent
2540        .trigger('closed')
2541        .remove()
2542    }
2543
2544    $.support.transition && $parent.hasClass('fade') ?
2545      $parent.on($.support.transition.end, removeElement) :
2546      removeElement()
2547  }
2548
2549
2550 /* ALERT PLUGIN DEFINITION
2551  * ======================= */
2552
2553  var old = $.fn.alert
2554
2555  $.fn.alert = function (option) {
2556    return this.each(function () {
2557      var $this = $(this)
2558        , data = $this.data('alert')
2559      if (!data) $this.data('alert', (data = new Alert(this)))
2560      if (typeof option == 'string') data[option].call($this)
2561    })
2562  }
2563
2564  $.fn.alert.Constructor = Alert
2565
2566
2567 /* ALERT NO CONFLICT
2568  * ================= */
2569
2570  $.fn.alert.noConflict = function () {
2571    $.fn.alert = old
2572    return this
2573  }
2574
2575
2576 /* ALERT DATA-API
2577  * ============== */
2578
2579  $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
2580
2581}(window.jQuery);
2582}
2583
2584if( typeof( jQuery.fn.button ) === 'undefined' ) {
2585/* ============================================================
2586 * bootstrap-button.js v2.3.1
2587 * http://twitter.github.com/bootstrap/javascript.html#buttons
2588 * ============================================================
2589 * Copyright 2012 Twitter, Inc.
2590 *
2591 * Licensed under the Apache License, Version 2.0 (the "License");
2592 * you may not use this file except in compliance with the License.
2593 * You may obtain a copy of the License at
2594 *
2595 * http://www.apache.org/licenses/LICENSE-2.0
2596 *
2597 * Unless required by applicable law or agreed to in writing, software
2598 * distributed under the License is distributed on an "AS IS" BASIS,
2599 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2600 * See the License for the specific language governing permissions and
2601 * limitations under the License.
2602 * ============================================================ */
2603!function ($) {
2604
2605  "use strict"; // jshint ;_;
2606
2607
2608 /* BUTTON PUBLIC CLASS DEFINITION
2609  * ============================== */
2610
2611  var Button = function (element, options) {
2612    this.$element = $(element)
2613    this.options = $.extend({}, $.fn.button.defaults, options)
2614  }
2615
2616  Button.prototype.setState = function (state) {
2617    var d = 'disabled'
2618      , $el = this.$element
2619      , data = $el.data()
2620      , val = $el.is('input') ? 'val' : 'html'
2621
2622    state = state + 'Text'
2623    data.resetText || $el.data('resetText', $el[val]())
2624
2625    $el[val](data[state] || this.options[state])
2626
2627    // push to event loop to allow forms to submit
2628    setTimeout(function () {
2629      state == 'loadingText' ?
2630        $el.addClass(d).attr(d, d) :
2631        $el.removeClass(d).removeAttr(d)
2632    }, 0)
2633  }
2634
2635  Button.prototype.toggle = function () {
2636    var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
2637
2638    $parent && $parent
2639      .find('.active')
2640      .removeClass('active')
2641
2642    this.$element.toggleClass('active')
2643  }
2644
2645
2646 /* BUTTON PLUGIN DEFINITION
2647  * ======================== */
2648
2649  var old = $.fn.button
2650
2651  $.fn.button = function (option) {
2652    return this.each(function () {
2653      var $this = $(this)
2654        , data = $this.data('button')
2655        , options = typeof option == 'object' && option
2656      if (!data) $this.data('button', (data = new Button(this, options)))
2657      if (option == 'toggle') data.toggle()
2658      else if (option) data.setState(option)
2659    })
2660  }
2661
2662  $.fn.button.defaults = {
2663    loadingText: 'loading...'
2664  }
2665
2666  $.fn.button.Constructor = Button
2667
2668
2669 /* BUTTON NO CONFLICT
2670  * ================== */
2671
2672  $.fn.button.noConflict = function () {
2673    $.fn.button = old
2674    return this
2675  }
2676
2677
2678 /* BUTTON DATA-API
2679  * =============== */
2680
2681  $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
2682    var $btn = $(e.target)
2683    if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
2684    $btn.button('toggle')
2685  })
2686
2687}(window.jQuery);
2688}

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.