diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2015-10-06 09:09:56 +0200 |
---|---|---|
committer | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2015-10-06 09:09:56 +0200 |
commit | 794dc4ee8adeabb6cf4fa19604b709a53733400e (patch) | |
tree | 38924d3df3d01b864c1e5de7697517613cc70e96 /src/Wallabag/CoreBundle/Resources/views/themes/material/public/js/materialize.js | |
parent | 8a60bc4cc2b6b1cfb5d8beb7ddcafc51d89a64c9 (diff) | |
parent | 68e9dcf6151adf60fc25ea921ebf541c6f97435f (diff) | |
download | wallabag-794dc4ee8adeabb6cf4fa19604b709a53733400e.tar.gz wallabag-794dc4ee8adeabb6cf4fa19604b709a53733400e.tar.zst wallabag-794dc4ee8adeabb6cf4fa19604b709a53733400e.zip |
Merge pull request #1459 from wallabag/v2-tags-chips
fix #1457 & update materialize
Diffstat (limited to 'src/Wallabag/CoreBundle/Resources/views/themes/material/public/js/materialize.js')
-rw-r--r-- | src/Wallabag/CoreBundle/Resources/views/themes/material/public/js/materialize.js | 424 |
1 files changed, 242 insertions, 182 deletions
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/public/js/materialize.js b/src/Wallabag/CoreBundle/Resources/views/themes/material/public/js/materialize.js index f19998ac..f36f94e6 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/public/js/materialize.js +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/public/js/materialize.js | |||
@@ -1,5 +1,5 @@ | |||
1 | /*! | 1 | /*! |
2 | * Materialize v0.97.0 (http://materializecss.com) | 2 | * Materialize v0.97.1 (http://materializecss.com) |
3 | * Copyright 2014-2015 Materialize | 3 | * Copyright 2014-2015 Materialize |
4 | * MIT License (https://raw.githubusercontent.com/Dogfalo/materialize/master/LICENSE) | 4 | * MIT License (https://raw.githubusercontent.com/Dogfalo/materialize/master/LICENSE) |
5 | */ | 5 | */ |
@@ -252,7 +252,7 @@ jQuery.extend( jQuery.easing, | |||
252 | }; | 252 | }; |
253 | })(Hammer.Manager.prototype.emit); | 253 | })(Hammer.Manager.prototype.emit); |
254 | })); | 254 | })); |
255 | ;Materialize = {}; | 255 | ;window.Materialize = {}; |
256 | 256 | ||
257 | // Unique ID | 257 | // Unique ID |
258 | Materialize.guid = (function() { | 258 | Materialize.guid = (function() { |
@@ -442,7 +442,8 @@ else { | |||
442 | constrain_width: true, // Constrains width of dropdown to the activator | 442 | constrain_width: true, // Constrains width of dropdown to the activator |
443 | hover: false, | 443 | hover: false, |
444 | gutter: 0, // Spacing from edge | 444 | gutter: 0, // Spacing from edge |
445 | belowOrigin: false | 445 | belowOrigin: false, |
446 | alignment: 'left' | ||
446 | }; | 447 | }; |
447 | 448 | ||
448 | this.each(function(){ | 449 | this.each(function(){ |
@@ -465,6 +466,8 @@ else { | |||
465 | options.gutter = origin.data('gutter'); | 466 | options.gutter = origin.data('gutter'); |
466 | if (origin.data('beloworigin') !== undefined) | 467 | if (origin.data('beloworigin') !== undefined) |
467 | options.belowOrigin = origin.data('beloworigin'); | 468 | options.belowOrigin = origin.data('beloworigin'); |
469 | if (origin.data('alignment') !== undefined) | ||
470 | options.alignment = origin.data('alignment'); | ||
468 | } | 471 | } |
469 | 472 | ||
470 | updateOptions(); | 473 | updateOptions(); |
@@ -487,27 +490,46 @@ else { | |||
487 | if (options.constrain_width === true) { | 490 | if (options.constrain_width === true) { |
488 | activates.css('width', origin.outerWidth()); | 491 | activates.css('width', origin.outerWidth()); |
489 | } | 492 | } |
493 | else { | ||
494 | activates.css('white-space', 'nowrap'); | ||
495 | } | ||
490 | var offset = 0; | 496 | var offset = 0; |
491 | if (options.belowOrigin === true) { | 497 | if (options.belowOrigin === true) { |
492 | offset = origin.height(); | 498 | offset = origin.height(); |
493 | } | 499 | } |
494 | 500 | ||
495 | // Handle edge alignment | 501 | // Offscreen detection |
496 | var offsetLeft = origin.offset().left; | 502 | var offsetLeft = origin.offset().left; |
497 | var width_difference = 0; | 503 | var activatesLeft, width_difference, gutter_spacing; |
498 | var gutter_spacing = options.gutter; | ||
499 | |||
500 | |||
501 | if (offsetLeft + activates.innerWidth() > $(window).width()) { | 504 | if (offsetLeft + activates.innerWidth() > $(window).width()) { |
502 | width_difference = origin.innerWidth() - activates.innerWidth(); | 505 | options.alignment = 'right'; |
503 | gutter_spacing = gutter_spacing * -1; | ||
504 | } | 506 | } |
507 | else if (offsetLeft - activates.innerWidth() + origin.innerWidth() < 0) { | ||
508 | options.alignment = 'left'; | ||
509 | } | ||
510 | |||
511 | // Handle edge alignment | ||
512 | if (options.alignment === 'left') { | ||
513 | width_difference = 0; | ||
514 | gutter_spacing = options.gutter; | ||
515 | activatesLeft = origin.position().left + width_difference + gutter_spacing; | ||
505 | 516 | ||
517 | // Position dropdown | ||
518 | activates.css({ left: activatesLeft }); | ||
519 | } | ||
520 | else if (options.alignment === 'right') { | ||
521 | var offsetRight = $(window).width() - offsetLeft - origin.innerWidth(); | ||
522 | width_difference = 0; | ||
523 | gutter_spacing = options.gutter; | ||
524 | activatesLeft = ( $(window).width() - origin.position().left - origin.innerWidth() ) + gutter_spacing; | ||
525 | |||
526 | // Position dropdown | ||
527 | activates.css({ right: activatesLeft }); | ||
528 | } | ||
506 | // Position dropdown | 529 | // Position dropdown |
507 | activates.css({ | 530 | activates.css({ |
508 | position: 'absolute', | 531 | position: 'absolute', |
509 | top: origin.position().top + offset, | 532 | top: origin.position().top + offset, |
510 | left: origin.position().left + width_difference + gutter_spacing | ||
511 | }); | 533 | }); |
512 | 534 | ||
513 | 535 | ||
@@ -1100,11 +1122,6 @@ $(document).ready(function(){ | |||
1100 | window_width = $(window).width(); | 1122 | window_width = $(window).width(); |
1101 | 1123 | ||
1102 | $this.width('100%'); | 1124 | $this.width('100%'); |
1103 | // Set Tab Width for each tab | ||
1104 | var $num_tabs = $(this).children('li').length; | ||
1105 | $this.children('li').each(function() { | ||
1106 | $(this).width((100/$num_tabs)+'%'); | ||
1107 | }); | ||
1108 | var $active, $content, $links = $this.find('li.tab a'), | 1125 | var $active, $content, $links = $this.find('li.tab a'), |
1109 | $tabs_width = $this.width(), | 1126 | $tabs_width = $this.width(), |
1110 | $tab_width = $this.find('li').first().outerWidth(), | 1127 | $tab_width = $this.find('li').first().outerWidth(), |
@@ -1234,153 +1251,164 @@ $(document).ready(function(){ | |||
1234 | var defaults = { | 1251 | var defaults = { |
1235 | delay: 350 | 1252 | delay: 350 |
1236 | }; | 1253 | }; |
1254 | |||
1255 | // Remove tooltip from the activator | ||
1256 | if (options === "remove") { | ||
1257 | this.each(function(){ | ||
1258 | $('#' + $(this).attr('data-tooltip-id')).remove(); | ||
1259 | }); | ||
1260 | return false; | ||
1261 | } | ||
1262 | |||
1237 | options = $.extend(defaults, options); | 1263 | options = $.extend(defaults, options); |
1238 | 1264 | ||
1239 | //Remove previously created html | ||
1240 | $('.material-tooltip').remove(); | ||
1241 | 1265 | ||
1242 | return this.each(function(){ | 1266 | return this.each(function(){ |
1267 | var tooltipId = Materialize.guid(); | ||
1243 | var origin = $(this); | 1268 | var origin = $(this); |
1244 | 1269 | origin.attr('data-tooltip-id', tooltipId); | |
1245 | // Create Text span | 1270 | |
1246 | var tooltip_text = $('<span></span>').text(origin.attr('data-tooltip')); | 1271 | // Create Text span |
1247 | 1272 | var tooltip_text = $('<span></span>').text(origin.attr('data-tooltip')); | |
1248 | // Create tooltip | 1273 | |
1249 | var newTooltip = $('<div></div>'); | 1274 | // Create tooltip |
1250 | newTooltip.addClass('material-tooltip').append(tooltip_text); | 1275 | var newTooltip = $('<div></div>'); |
1251 | newTooltip.appendTo($('body')); | 1276 | newTooltip.addClass('material-tooltip').append(tooltip_text) |
1252 | 1277 | .appendTo($('body')) | |
1253 | var backdrop = $('<div></div>').addClass('backdrop'); | 1278 | .attr('id', tooltipId); |
1254 | backdrop.appendTo(newTooltip); | 1279 | |
1255 | backdrop.css({ top: 0, left:0 }); | 1280 | var backdrop = $('<div></div>').addClass('backdrop'); |
1256 | 1281 | backdrop.appendTo(newTooltip); | |
1257 | 1282 | backdrop.css({ top: 0, left:0 }); | |
1258 | //Destroy previously binded events | 1283 | |
1259 | $(this).off('mouseenter mouseleave'); | 1284 | |
1260 | // Mouse In | 1285 | //Destroy previously binded events |
1261 | $(this).on({ | 1286 | origin.off('mouseenter.tooltip mouseleave.tooltip'); |
1262 | mouseenter: function(e) { | 1287 | // Mouse In |
1263 | var tooltip_delay = origin.data("delay"); | 1288 | origin.on({ |
1264 | tooltip_delay = (tooltip_delay === undefined || tooltip_delay === '') ? options.delay : tooltip_delay; | 1289 | 'mouseenter.tooltip': function(e) { |
1265 | counter = 0; | 1290 | var tooltip_delay = origin.data("delay"); |
1266 | counterInterval = setInterval(function(){ | 1291 | tooltip_delay = (tooltip_delay === undefined || tooltip_delay === '') ? options.delay : tooltip_delay; |
1267 | counter += 10; | 1292 | counter = 0; |
1268 | if (counter >= tooltip_delay && started === false) { | 1293 | counterInterval = setInterval(function(){ |
1269 | started = true; | 1294 | counter += 10; |
1270 | newTooltip.css({ display: 'block', left: '0px', top: '0px' }); | 1295 | if (counter >= tooltip_delay && started === false) { |
1271 | 1296 | started = true; | |
1272 | // Set Tooltip text | 1297 | newTooltip.css({ display: 'block', left: '0px', top: '0px' }); |
1273 | newTooltip.children('span').text(origin.attr('data-tooltip')); | 1298 | |
1274 | 1299 | // Set Tooltip text | |
1275 | // Tooltip positioning | 1300 | newTooltip.children('span').text(origin.attr('data-tooltip')); |
1276 | var originWidth = origin.outerWidth(); | 1301 | |
1277 | var originHeight = origin.outerHeight(); | 1302 | // Tooltip positioning |
1278 | var tooltipPosition = origin.attr('data-position'); | 1303 | var originWidth = origin.outerWidth(); |
1279 | var tooltipHeight = newTooltip.outerHeight(); | 1304 | var originHeight = origin.outerHeight(); |
1280 | var tooltipWidth = newTooltip.outerWidth(); | 1305 | var tooltipPosition = origin.attr('data-position'); |
1281 | var tooltipVerticalMovement = '0px'; | 1306 | var tooltipHeight = newTooltip.outerHeight(); |
1282 | var tooltipHorizontalMovement = '0px'; | 1307 | var tooltipWidth = newTooltip.outerWidth(); |
1283 | var scale_factor = 8; | 1308 | var tooltipVerticalMovement = '0px'; |
1284 | 1309 | var tooltipHorizontalMovement = '0px'; | |
1285 | if (tooltipPosition === "top") { | 1310 | var scale_factor = 8; |
1286 | // Top Position | 1311 | |
1287 | newTooltip.css({ | 1312 | if (tooltipPosition === "top") { |
1288 | top: origin.offset().top - tooltipHeight - margin, | 1313 | // Top Position |
1289 | left: origin.offset().left + originWidth/2 - tooltipWidth/2 | ||
1290 | }); | ||
1291 | tooltipVerticalMovement = '-10px'; | ||
1292 | backdrop.css({ | ||
1293 | borderRadius: '14px 14px 0 0', | ||
1294 | transformOrigin: '50% 90%', | ||
1295 | marginTop: tooltipHeight, | ||
1296 | marginLeft: (tooltipWidth/2) - (backdrop.width()/2) | ||
1297 | |||
1298 | }); | ||
1299 | } | ||
1300 | // Left Position | ||
1301 | else if (tooltipPosition === "left") { | ||
1302 | newTooltip.css({ | 1314 | newTooltip.css({ |
1303 | top: origin.offset().top + originHeight/2 - tooltipHeight/2, | 1315 | top: origin.offset().top - tooltipHeight - margin, |
1304 | left: origin.offset().left - tooltipWidth - margin | ||
1305 | }); | ||
1306 | tooltipHorizontalMovement = '-10px'; | ||
1307 | backdrop.css({ | ||
1308 | width: '14px', | ||
1309 | height: '14px', | ||
1310 | borderRadius: '14px 0 0 14px', | ||
1311 | transformOrigin: '95% 50%', | ||
1312 | marginTop: tooltipHeight/2, | ||
1313 | marginLeft: tooltipWidth | ||
1314 | }); | ||
1315 | } | ||
1316 | // Right Position | ||
1317 | else if (tooltipPosition === "right") { | ||
1318 | newTooltip.css({ | ||
1319 | top: origin.offset().top + originHeight/2 - tooltipHeight/2, | ||
1320 | left: origin.offset().left + originWidth + margin | ||
1321 | }); | ||
1322 | tooltipHorizontalMovement = '+10px'; | ||
1323 | backdrop.css({ | ||
1324 | width: '14px', | ||
1325 | height: '14px', | ||
1326 | borderRadius: '0 14px 14px 0', | ||
1327 | transformOrigin: '5% 50%', | ||
1328 | marginTop: tooltipHeight/2, | ||
1329 | marginLeft: '0px' | ||
1330 | }); | ||
1331 | } | ||
1332 | else { | ||
1333 | // Bottom Position | ||
1334 | newTooltip.css({ | ||
1335 | top: origin.offset().top + origin.outerHeight() + margin, | ||
1336 | left: origin.offset().left + originWidth/2 - tooltipWidth/2 | 1316 | left: origin.offset().left + originWidth/2 - tooltipWidth/2 |
1337 | }); | 1317 | }); |
1338 | tooltipVerticalMovement = '+10px'; | 1318 | tooltipVerticalMovement = '-10px'; |
1339 | backdrop.css({ | 1319 | backdrop.css({ |
1320 | borderRadius: '14px 14px 0 0', | ||
1321 | transformOrigin: '50% 90%', | ||
1322 | marginTop: tooltipHeight, | ||
1340 | marginLeft: (tooltipWidth/2) - (backdrop.width()/2) | 1323 | marginLeft: (tooltipWidth/2) - (backdrop.width()/2) |
1324 | |||
1341 | }); | 1325 | }); |
1342 | } | 1326 | } |
1327 | // Left Position | ||
1328 | else if (tooltipPosition === "left") { | ||
1329 | newTooltip.css({ | ||
1330 | top: origin.offset().top + originHeight/2 - tooltipHeight/2, | ||
1331 | left: origin.offset().left - tooltipWidth - margin | ||
1332 | }); | ||
1333 | tooltipHorizontalMovement = '-10px'; | ||
1334 | backdrop.css({ | ||
1335 | width: '14px', | ||
1336 | height: '14px', | ||
1337 | borderRadius: '14px 0 0 14px', | ||
1338 | transformOrigin: '95% 50%', | ||
1339 | marginTop: tooltipHeight/2, | ||
1340 | marginLeft: tooltipWidth | ||
1341 | }); | ||
1342 | } | ||
1343 | // Right Position | ||
1344 | else if (tooltipPosition === "right") { | ||
1345 | newTooltip.css({ | ||
1346 | top: origin.offset().top + originHeight/2 - tooltipHeight/2, | ||
1347 | left: origin.offset().left + originWidth + margin | ||
1348 | }); | ||
1349 | tooltipHorizontalMovement = '+10px'; | ||
1350 | backdrop.css({ | ||
1351 | width: '14px', | ||
1352 | height: '14px', | ||
1353 | borderRadius: '0 14px 14px 0', | ||
1354 | transformOrigin: '5% 50%', | ||
1355 | marginTop: tooltipHeight/2, | ||
1356 | marginLeft: '0px' | ||
1357 | }); | ||
1358 | } | ||
1359 | else { | ||
1360 | // Bottom Position | ||
1361 | newTooltip.css({ | ||
1362 | top: origin.offset().top + origin.outerHeight() + margin, | ||
1363 | left: origin.offset().left + originWidth/2 - tooltipWidth/2 | ||
1364 | }); | ||
1365 | tooltipVerticalMovement = '+10px'; | ||
1366 | backdrop.css({ | ||
1367 | marginLeft: (tooltipWidth/2) - (backdrop.width()/2) | ||
1368 | }); | ||
1369 | } | ||
1343 | 1370 | ||
1344 | // Calculate Scale to fill | 1371 | // Calculate Scale to fill |
1345 | scale_factor = tooltipWidth / 8; | 1372 | scale_factor = tooltipWidth / 8; |
1346 | if (scale_factor < 8) { | 1373 | if (scale_factor < 8) { |
1347 | scale_factor = 8; | 1374 | scale_factor = 8; |
1348 | } | 1375 | } |
1349 | if (tooltipPosition === "right" || tooltipPosition === "left") { | 1376 | if (tooltipPosition === "right" || tooltipPosition === "left") { |
1350 | scale_factor = tooltipWidth / 10; | 1377 | scale_factor = tooltipWidth / 10; |
1351 | if (scale_factor < 6) | 1378 | if (scale_factor < 6) |
1352 | scale_factor = 6; | 1379 | scale_factor = 6; |
1353 | } | 1380 | } |
1354 | 1381 | ||
1355 | newTooltip.velocity({ opacity: 1, marginTop: tooltipVerticalMovement, marginLeft: tooltipHorizontalMovement}, { duration: 350, queue: false }); | 1382 | newTooltip.velocity({ marginTop: tooltipVerticalMovement, marginLeft: tooltipHorizontalMovement}, { duration: 350, queue: false }) |
1356 | backdrop.css({ display: 'block' }) | 1383 | .velocity({opacity: 1}, {duration: 300, delay: 50, queue: false}); |
1357 | .velocity({opacity:1},{duration: 55, delay: 0, queue: false}) | 1384 | backdrop.css({ display: 'block' }) |
1358 | .velocity({scale: scale_factor}, {duration: 300, delay: 0, queue: false, easing: 'easeInOutQuad'}); | 1385 | .velocity({opacity:1},{duration: 55, delay: 0, queue: false}) |
1386 | .velocity({scale: scale_factor}, {duration: 300, delay: 0, queue: false, easing: 'easeInOutQuad'}); | ||
1359 | 1387 | ||
1360 | } | 1388 | } |
1361 | }, 10); // End Interval | 1389 | }, 10); // End Interval |
1362 | 1390 | ||
1363 | // Mouse Out | 1391 | // Mouse Out |
1364 | }, | 1392 | }, |
1365 | mouseleave: function(){ | 1393 | 'mouseleave.tooltip': function(){ |
1366 | // Reset State | 1394 | // Reset State |
1367 | clearInterval(counterInterval); | 1395 | clearInterval(counterInterval); |
1368 | counter = 0; | 1396 | counter = 0; |
1369 | 1397 | ||
1370 | // Animate back | 1398 | // Animate back |
1371 | newTooltip.velocity({ | 1399 | newTooltip.velocity({ |
1372 | opacity: 0, marginTop: 0, marginLeft: 0}, { duration: 225, queue: false, delay: 275 } | 1400 | opacity: 0, marginTop: 0, marginLeft: 0}, { duration: 225, queue: false, delay: 225 } |
1373 | ); | 1401 | ); |
1374 | backdrop.velocity({opacity: 0, scale: 1}, { | 1402 | backdrop.velocity({opacity: 0, scale: 1}, { |
1375 | duration:225, | 1403 | duration:225, |
1376 | delay: 275, queue: false, | 1404 | delay: 275, queue: false, |
1377 | complete: function(){ | 1405 | complete: function(){ |
1378 | backdrop.css('display', 'none'); | 1406 | backdrop.css('display', 'none'); |
1379 | newTooltip.css('display', 'none'); | 1407 | newTooltip.css('display', 'none'); |
1380 | started = false;} | 1408 | started = false;} |
1409 | }); | ||
1410 | } | ||
1381 | }); | 1411 | }); |
1382 | } | ||
1383 | }); | ||
1384 | }); | 1412 | }); |
1385 | }; | 1413 | }; |
1386 | 1414 | ||
@@ -1799,8 +1827,19 @@ $(document).ready(function(){ | |||
1799 | toast.classList.add(classes[i]); | 1827 | toast.classList.add(classes[i]); |
1800 | } | 1828 | } |
1801 | } | 1829 | } |
1802 | toast.innerHTML = html; | 1830 | // If type of parameter is HTML Element |
1803 | 1831 | if ( typeof HTMLElement === "object" ? html instanceof HTMLElement : html && typeof html === "object" && html !== null && html.nodeType === 1 && typeof html.nodeName==="string" | |
1832 | ) { | ||
1833 | toast.appendChild(html); | ||
1834 | } | ||
1835 | else if (html instanceof jQuery) { | ||
1836 | // Check if it is jQuery object | ||
1837 | toast.appendChild(html[0]); | ||
1838 | } | ||
1839 | else { | ||
1840 | // Insert as text; | ||
1841 | toast.innerHTML = html; | ||
1842 | } | ||
1804 | // Bind hammer | 1843 | // Bind hammer |
1805 | var hammerHandler = new Hammer(toast, {prevent_default: false}); | 1844 | var hammerHandler = new Hammer(toast, {prevent_default: false}); |
1806 | hammerHandler.on('pan', function(e) { | 1845 | hammerHandler.on('pan', function(e) { |
@@ -1872,17 +1911,18 @@ $(document).ready(function(){ | |||
1872 | } | 1911 | } |
1873 | 1912 | ||
1874 | // Add Touch Area | 1913 | // Add Touch Area |
1875 | $('body').append($('<div class="drag-target"></div>')); | 1914 | var dragTarget = $('<div class="drag-target"></div>'); |
1915 | $('body').append(dragTarget); | ||
1876 | 1916 | ||
1877 | if (options.edge == 'left') { | 1917 | if (options.edge == 'left') { |
1878 | menu_id.css('left', -1 * (options.menuWidth + 10)); | 1918 | menu_id.css('left', -1 * (options.menuWidth + 10)); |
1879 | $('.drag-target').css({'left': 0}); // Add Touch Area | 1919 | dragTarget.css({'left': 0}); // Add Touch Area |
1880 | } | 1920 | } |
1881 | else { | 1921 | else { |
1882 | menu_id.addClass('right-aligned') // Change text-alignment to right | 1922 | menu_id.addClass('right-aligned') // Change text-alignment to right |
1883 | .css('right', -1 * (options.menuWidth + 10)) | 1923 | .css('right', -1 * (options.menuWidth + 10)) |
1884 | .css('left', ''); | 1924 | .css('left', ''); |
1885 | $('.drag-target').css({'right': 0}); // Add Touch Area | 1925 | dragTarget.css({'right': 0}); // Add Touch Area |
1886 | } | 1926 | } |
1887 | 1927 | ||
1888 | // If fixed sidenav, bring menu out | 1928 | // If fixed sidenav, bring menu out |
@@ -1935,7 +1975,7 @@ $(document).ready(function(){ | |||
1935 | } }); | 1975 | } }); |
1936 | if (options.edge === 'left') { | 1976 | if (options.edge === 'left') { |
1937 | // Reset phantom div | 1977 | // Reset phantom div |
1938 | $('.drag-target').css({width: '', right: '', left: '0'}); | 1978 | dragTarget.css({width: '', right: '', left: '0'}); |
1939 | menu_id.velocity( | 1979 | menu_id.velocity( |
1940 | {left: -1 * (options.menuWidth + 10)}, | 1980 | {left: -1 * (options.menuWidth + 10)}, |
1941 | { duration: 200, | 1981 | { duration: 200, |
@@ -1953,7 +1993,7 @@ $(document).ready(function(){ | |||
1953 | } | 1993 | } |
1954 | else { | 1994 | else { |
1955 | // Reset phantom div | 1995 | // Reset phantom div |
1956 | $('.drag-target').css({width: '', right: '0', left: ''}); | 1996 | dragTarget.css({width: '', right: '0', left: ''}); |
1957 | menu_id.velocity( | 1997 | menu_id.velocity( |
1958 | {right: -1 * (options.menuWidth + 10)}, | 1998 | {right: -1 * (options.menuWidth + 10)}, |
1959 | { duration: 200, | 1999 | { duration: 200, |
@@ -1976,11 +2016,11 @@ $(document).ready(function(){ | |||
1976 | var panning = false; | 2016 | var panning = false; |
1977 | var menuOut = false; | 2017 | var menuOut = false; |
1978 | 2018 | ||
1979 | $('.drag-target').on('click', function(){ | 2019 | dragTarget.on('click', function(){ |
1980 | removeMenu(); | 2020 | removeMenu(); |
1981 | }); | 2021 | }); |
1982 | 2022 | ||
1983 | $('.drag-target').hammer({ | 2023 | dragTarget.hammer({ |
1984 | prevent_default: false | 2024 | prevent_default: false |
1985 | }).bind('pan', function(e) { | 2025 | }).bind('pan', function(e) { |
1986 | 2026 | ||
@@ -2059,7 +2099,7 @@ $(document).ready(function(){ | |||
2059 | if ((menuOut && velocityX <= 0.3) || velocityX < -0.5) { | 2099 | if ((menuOut && velocityX <= 0.3) || velocityX < -0.5) { |
2060 | menu_id.velocity({left: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'}); | 2100 | menu_id.velocity({left: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'}); |
2061 | $('#sidenav-overlay').velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'}); | 2101 | $('#sidenav-overlay').velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'}); |
2062 | $('.drag-target').css({width: '50%', right: 0, left: ''}); | 2102 | dragTarget.css({width: '50%', right: 0, left: ''}); |
2063 | } | 2103 | } |
2064 | else if (!menuOut || velocityX > 0.3) { | 2104 | else if (!menuOut || velocityX > 0.3) { |
2065 | // Enable Scrolling | 2105 | // Enable Scrolling |
@@ -2070,14 +2110,14 @@ $(document).ready(function(){ | |||
2070 | complete: function () { | 2110 | complete: function () { |
2071 | $(this).remove(); | 2111 | $(this).remove(); |
2072 | }}); | 2112 | }}); |
2073 | $('.drag-target').css({width: '10px', right: '', left: 0}); | 2113 | dragTarget.css({width: '10px', right: '', left: 0}); |
2074 | } | 2114 | } |
2075 | } | 2115 | } |
2076 | else { | 2116 | else { |
2077 | if ((menuOut && velocityX >= -0.3) || velocityX > 0.5) { | 2117 | if ((menuOut && velocityX >= -0.3) || velocityX > 0.5) { |
2078 | menu_id.velocity({right: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'}); | 2118 | menu_id.velocity({right: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'}); |
2079 | $('#sidenav-overlay').velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'}); | 2119 | $('#sidenav-overlay').velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'}); |
2080 | $('.drag-target').css({width: '50%', right: '', left: 0}); | 2120 | dragTarget.css({width: '50%', right: '', left: 0}); |
2081 | } | 2121 | } |
2082 | else if (!menuOut || velocityX < -0.3) { | 2122 | else if (!menuOut || velocityX < -0.3) { |
2083 | // Enable Scrolling | 2123 | // Enable Scrolling |
@@ -2088,7 +2128,7 @@ $(document).ready(function(){ | |||
2088 | complete: function () { | 2128 | complete: function () { |
2089 | $(this).remove(); | 2129 | $(this).remove(); |
2090 | }}); | 2130 | }}); |
2091 | $('.drag-target').css({width: '10px', right: 0, left: ''}); | 2131 | dragTarget.css({width: '10px', right: 0, left: ''}); |
2092 | } | 2132 | } |
2093 | } | 2133 | } |
2094 | 2134 | ||
@@ -2105,13 +2145,15 @@ $(document).ready(function(){ | |||
2105 | 2145 | ||
2106 | // Disable Scrolling | 2146 | // Disable Scrolling |
2107 | $('body').css('overflow', 'hidden'); | 2147 | $('body').css('overflow', 'hidden'); |
2108 | 2148 | // Push current drag target on top of DOM tree | |
2149 | $('body').append(dragTarget); | ||
2150 | |||
2109 | if (options.edge === 'left') { | 2151 | if (options.edge === 'left') { |
2110 | $('.drag-target').css({width: '50%', right: 0, left: ''}); | 2152 | dragTarget.css({width: '50%', right: 0, left: ''}); |
2111 | menu_id.velocity({left: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'}); | 2153 | menu_id.velocity({left: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'}); |
2112 | } | 2154 | } |
2113 | else { | 2155 | else { |
2114 | $('.drag-target').css({width: '50%', right: '', left: 0}); | 2156 | dragTarget.css({width: '50%', right: '', left: 0}); |
2115 | menu_id.velocity({right: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'}); | 2157 | menu_id.velocity({right: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'}); |
2116 | menu_id.css('left',''); | 2158 | menu_id.css('left',''); |
2117 | } | 2159 | } |
@@ -2454,7 +2496,7 @@ $(document).ready(function(){ | |||
2454 | var input_selector = 'input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], textarea'; | 2496 | var input_selector = 'input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], textarea'; |
2455 | $(input_selector).each(function(index, element) { | 2497 | $(input_selector).each(function(index, element) { |
2456 | if ($(element).val().length > 0 || $(this).attr('placeholder') !== undefined || $(element)[0].validity.badInput === true) { | 2498 | if ($(element).val().length > 0 || $(this).attr('placeholder') !== undefined || $(element)[0].validity.badInput === true) { |
2457 | $(this).siblings('label, i').addClass('active'); | 2499 | $(this).siblings('label').addClass('active'); |
2458 | } | 2500 | } |
2459 | else { | 2501 | else { |
2460 | $(this).siblings('label, i').removeClass('active'); | 2502 | $(this).siblings('label, i').removeClass('active'); |
@@ -2471,7 +2513,7 @@ $(document).ready(function(){ | |||
2471 | // Add active if form auto complete | 2513 | // Add active if form auto complete |
2472 | $(document).on('change', input_selector, function () { | 2514 | $(document).on('change', input_selector, function () { |
2473 | if($(this).val().length !== 0 || $(this).attr('placeholder') !== undefined) { | 2515 | if($(this).val().length !== 0 || $(this).attr('placeholder') !== undefined) { |
2474 | $(this).siblings('label, i').addClass('active'); | 2516 | $(this).siblings('label').addClass('active'); |
2475 | } | 2517 | } |
2476 | validate_field($(this)); | 2518 | validate_field($(this)); |
2477 | }); | 2519 | }); |
@@ -2510,10 +2552,14 @@ $(document).ready(function(){ | |||
2510 | if ($inputElement.val().length === 0 && $inputElement[0].validity.badInput !== true && $inputElement.attr('placeholder') === undefined) { | 2552 | if ($inputElement.val().length === 0 && $inputElement[0].validity.badInput !== true && $inputElement.attr('placeholder') === undefined) { |
2511 | $inputElement.siblings('label, i').removeClass('active'); | 2553 | $inputElement.siblings('label, i').removeClass('active'); |
2512 | } | 2554 | } |
2555 | |||
2556 | if ($inputElement.val().length === 0 && $inputElement[0].validity.badInput !== true && $inputElement.attr('placeholder') !== undefined) { | ||
2557 | $inputElement.siblings('i').removeClass('active'); | ||
2558 | } | ||
2513 | validate_field($inputElement); | 2559 | validate_field($inputElement); |
2514 | }); | 2560 | }); |
2515 | 2561 | ||
2516 | validate_field = function(object) { | 2562 | window.validate_field = function(object) { |
2517 | var hasLength = object.attr('length') !== undefined; | 2563 | var hasLength = object.attr('length') !== undefined; |
2518 | var lenAttr = parseInt(object.attr('length')); | 2564 | var lenAttr = parseInt(object.attr('length')); |
2519 | var len = object.val().length; | 2565 | var len = object.val().length; |
@@ -2527,7 +2573,7 @@ $(document).ready(function(){ | |||
2527 | else { | 2573 | else { |
2528 | if (object.hasClass('validate')) { | 2574 | if (object.hasClass('validate')) { |
2529 | // Check for character counter attributes | 2575 | // Check for character counter attributes |
2530 | if ((object.is(':valid') && hasLength && (len < lenAttr)) || (object.is(':valid') && !hasLength)) { | 2576 | if ((object.is(':valid') && hasLength && (len <= lenAttr)) || (object.is(':valid') && !hasLength)) { |
2531 | object.removeClass('invalid'); | 2577 | object.removeClass('invalid'); |
2532 | object.addClass('valid'); | 2578 | object.addClass('valid'); |
2533 | } | 2579 | } |
@@ -2590,20 +2636,24 @@ $(document).ready(function(){ | |||
2590 | } | 2636 | } |
2591 | }); | 2637 | }); |
2592 | 2638 | ||
2593 | $('body').on('keyup keydown', text_area_selector, function () { | 2639 | $('body').on('keyup keydown autoresize', text_area_selector, function () { |
2594 | textareaAutoResize($(this)); | 2640 | textareaAutoResize($(this)); |
2595 | }); | 2641 | }); |
2596 | 2642 | ||
2597 | 2643 | ||
2598 | // File Input Path | 2644 | // File Input Path |
2599 | $('.file-field').each(function() { | ||
2600 | var path_input = $(this).find('input.file-path'); | ||
2601 | $(this).find('input[type="file"]').change(function () { | ||
2602 | path_input.val($(this)[0].files[0].name); | ||
2603 | path_input.trigger('change'); | ||
2604 | }); | ||
2605 | }); | ||
2606 | 2645 | ||
2646 | $(document).on('change', '.file-field input[type="file"]', function () { | ||
2647 | var file_field = $(this).closest('.file-field'); | ||
2648 | var path_input = file_field.find('input.file-path'); | ||
2649 | var files = $(this)[0].files; | ||
2650 | var file_names = []; | ||
2651 | for (var i = 0; i < files.length; i++) { | ||
2652 | file_names.push(files[i].name); | ||
2653 | } | ||
2654 | path_input.val(file_names.join(", ")); | ||
2655 | path_input.trigger('change'); | ||
2656 | }); | ||
2607 | 2657 | ||
2608 | 2658 | ||
2609 | /**************** | 2659 | /**************** |
@@ -2625,7 +2675,7 @@ $(document).ready(function(){ | |||
2625 | thumb.find('.value').html($(this).val()); | 2675 | thumb.find('.value').html($(this).val()); |
2626 | }); | 2676 | }); |
2627 | 2677 | ||
2628 | $(document).on('mousedown touchstart', range_type, function(e) { | 2678 | $(document).on('input mousedown touchstart', range_type, function(e) { |
2629 | var thumb = $(this).siblings('.thumb'); | 2679 | var thumb = $(this).siblings('.thumb'); |
2630 | 2680 | ||
2631 | // If thumb indicator does not exist yet, create it | 2681 | // If thumb indicator does not exist yet, create it |
@@ -2691,9 +2741,8 @@ $(document).ready(function(){ | |||
2691 | left = width; | 2741 | left = width; |
2692 | } | 2742 | } |
2693 | thumb.addClass('active').css('left', left); | 2743 | thumb.addClass('active').css('left', left); |
2694 | 2744 | thumb.find('.value').html(thumb.siblings(range_type).val()); | |
2695 | } | 2745 | } |
2696 | |||
2697 | }); | 2746 | }); |
2698 | 2747 | ||
2699 | $(document).on('mouseout touchleave', range_wrapper, function() { | 2748 | $(document).on('mouseout touchleave', range_wrapper, function() { |
@@ -2725,7 +2774,7 @@ $(document).ready(function(){ | |||
2725 | // Tear down structure if Select needs to be rebuilt | 2774 | // Tear down structure if Select needs to be rebuilt |
2726 | var lastID = $select.data('select-id'); | 2775 | var lastID = $select.data('select-id'); |
2727 | if (lastID) { | 2776 | if (lastID) { |
2728 | $select.parent().find('i').remove(); | 2777 | $select.parent().find('span.caret').remove(); |
2729 | $select.parent().find('input').remove(); | 2778 | $select.parent().find('input').remove(); |
2730 | 2779 | ||
2731 | $select.unwrap(); | 2780 | $select.unwrap(); |
@@ -2783,7 +2832,10 @@ $(document).ready(function(){ | |||
2783 | if ( $select.is(':disabled') ) | 2832 | if ( $select.is(':disabled') ) |
2784 | dropdownIcon.addClass('disabled'); | 2833 | dropdownIcon.addClass('disabled'); |
2785 | 2834 | ||
2786 | var $newSelect = $('<input type="text" class="select-dropdown" readonly="true" ' + (($select.is(':disabled')) ? 'disabled' : '') + ' data-activates="select-options-' + uniqueID +'" value="'+ label.html() +'"/>'); | 2835 | // escape double quotes |
2836 | var sanitizedLabelHtml = label.html().replace(/"/g, '"'); | ||
2837 | |||
2838 | var $newSelect = $('<input type="text" class="select-dropdown" readonly="true" ' + (($select.is(':disabled')) ? 'disabled' : '') + ' data-activates="select-options-' + uniqueID +'" value="'+ sanitizedLabelHtml +'"/>'); | ||
2787 | $select.before($newSelect); | 2839 | $select.before($newSelect); |
2788 | $newSelect.before(dropdownIcon); | 2840 | $newSelect.before(dropdownIcon); |
2789 | 2841 | ||
@@ -3204,7 +3256,7 @@ $(document).ready(function(){ | |||
3204 | $(document).ready(function() { | 3256 | $(document).ready(function() { |
3205 | 3257 | ||
3206 | $(document).on('click.card', '.card', function (e) { | 3258 | $(document).on('click.card', '.card', function (e) { |
3207 | if ($(this).find('.card-reveal').length) { | 3259 | if ($(this).find('> .card-reveal').length) { |
3208 | if ($(e.target).is($('.card-reveal .card-title')) || $(e.target).is($('.card-reveal .card-title i'))) { | 3260 | if ($(e.target).is($('.card-reveal .card-title')) || $(e.target).is($('.card-reveal .card-title i'))) { |
3209 | // Make Reveal animate down and display none | 3261 | // Make Reveal animate down and display none |
3210 | $(this).find('.card-reveal').velocity( | 3262 | $(this).find('.card-reveal').velocity( |
@@ -3229,6 +3281,14 @@ $(document).ready(function(){ | |||
3229 | }( jQuery ));;(function ($) { | 3281 | }( jQuery ));;(function ($) { |
3230 | $(document).ready(function() { | 3282 | $(document).ready(function() { |
3231 | 3283 | ||
3284 | $(document).on('click.chip', '.chip .material-icons', function (e) { | ||
3285 | $(this).parent().remove(); | ||
3286 | }); | ||
3287 | |||
3288 | }); | ||
3289 | }( jQuery ));;(function ($) { | ||
3290 | $(document).ready(function() { | ||
3291 | |||
3232 | $.fn.pushpin = function (options) { | 3292 | $.fn.pushpin = function (options) { |
3233 | 3293 | ||
3234 | var defaults = { | 3294 | var defaults = { |
@@ -3530,7 +3590,7 @@ $(document).ready(function(){ | |||
3530 | 3590 | ||
3531 | var currentElement = document.querySelector(selector); | 3591 | var currentElement = document.querySelector(selector); |
3532 | if ( currentElement !== null) { | 3592 | if ( currentElement !== null) { |
3533 | var elementOffset = currentElement.getBoundingClientRect().top + document.body.scrollTop; | 3593 | var elementOffset = currentElement.getBoundingClientRect().top + window.pageYOffset; |
3534 | 3594 | ||
3535 | if (windowScroll > (elementOffset + offset)) { | 3595 | if (windowScroll > (elementOffset + offset)) { |
3536 | if (value.done !== true) { | 3596 | if (value.done !== true) { |