diff --git a/Bundle/BlogBundle/Entity/BlogCategory.php b/Bundle/BlogBundle/Entity/BlogCategory.php index 874d7548d..1ecced556 100644 --- a/Bundle/BlogBundle/Entity/BlogCategory.php +++ b/Bundle/BlogBundle/Entity/BlogCategory.php @@ -2,6 +2,7 @@ namespace Victoire\Bundle\BlogBundle\Entity; +use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use Victoire\Bundle\BusinessEntityBundle\Entity\Traits\BusinessEntityTrait; @@ -108,8 +109,8 @@ class BlogCategory */ public function __construct() { - $this->children = new \Doctrine\Common\Collections\ArrayCollection(); - $this->articles = new \Doctrine\Common\Collections\ArrayCollection(); + $this->children = new ArrayCollection(); + $this->articles = new ArrayCollection(); } /** @@ -187,7 +188,7 @@ public function getSlug() * * @param string $articles * - * @return PostPage + * @return BlogCategory */ public function setArticles($articles) { @@ -211,7 +212,7 @@ public function getArticles() * * @param int $lft * - * @return Menu + * @return BlogCategory */ public function setLft($lft) { @@ -235,7 +236,7 @@ public function getLft() * * @param int $lvl * - * @return Menu + * @return BlogCategory */ public function setLvl($lvl) { @@ -259,7 +260,7 @@ public function getLvl() * * @param int $rgt * - * @return Menu + * @return BlogCategory */ public function setRgt($rgt) { @@ -283,7 +284,7 @@ public function getRgt() * * @param int $root * - * @return Menu + * @return BlogCategory */ public function setRoot($root) { @@ -305,9 +306,9 @@ public function getRoot() /** * Set parent. * - * @param Menu $parent + * @param BlogCategory $parent * - * @return Menu + * @return BlogCategory */ public function setParent(self $parent = null) { @@ -319,7 +320,7 @@ public function setParent(self $parent = null) /** * Get parent. * - * @return Menu + * @return BlogCategory */ public function getParent() { @@ -329,9 +330,9 @@ public function getParent() /** * Add child. * - * @param Menu $child + * @param BlogCategory $child * - * @return Menu + * @return BlogCategory */ public function addChild(self $child) { @@ -344,7 +345,7 @@ public function addChild(self $child) /** * Remove children. * - * @param Menu $child + * @param BlogCategory $child */ public function removeChild(self $child) { @@ -354,7 +355,7 @@ public function removeChild(self $child) /** * Remove children. * - * @param Menu $child + * @param BlogCategory $child */ public function removeChildren(self $child) { @@ -366,7 +367,7 @@ public function removeChildren(self $child) * * @param array $children * - * @return \Victoire\Bundle\BlogBundle\Entity\BlogCategory + * @return BlogCategory */ public function setChildren($children) { @@ -376,7 +377,7 @@ public function setChildren($children) } /** - * @return \Doctrine\Common\Collections\ArrayCollection + * @return ArrayCollection */ public function getChildren() { @@ -416,7 +417,7 @@ public function getBlog() /** * @param Blog $blog * - * @return $this + * @return BlogCategory */ public function setBlog(Blog $blog) { diff --git a/Bundle/CoreBundle/Entity/Link.php b/Bundle/CoreBundle/Entity/Link.php index c3af64e3e..7dd652d51 100644 --- a/Bundle/CoreBundle/Entity/Link.php +++ b/Bundle/CoreBundle/Entity/Link.php @@ -3,6 +3,7 @@ namespace Victoire\Bundle\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; +use Gedmo\Timestampable\Traits\TimestampableEntity; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Mapping\ClassMetadata; @@ -25,7 +26,7 @@ class Link const TARGET_BLANK = '_blank'; const TARGET_MODAL = '_modal'; - use \Gedmo\Timestampable\Traits\TimestampableEntity; + use TimestampableEntity; /** * @var int @@ -40,6 +41,8 @@ class Link * @var string * * @ORM\Column(name="url", type="string", length=255, nullable=true) + * + * @Assert\Url() */ protected $url; @@ -338,16 +341,16 @@ public function checkLink(ExecutionContextInterface $context) // check if the name is actually a fake name switch ($this->getLinkType()) { case self::TYPE_VIEW_REFERENCE: - $violation = $this->getViewReference() == null; + $violation = $this->getViewReference() === null; break; case self::TYPE_ROUTE: - $violation = $this->getRoute() == null; + $violation = $this->getRoute() === null; break; case self::TYPE_URL: - $violation = $this->getUrl() == null; + $violation = $this->getUrl() === null; break; case self::TYPE_WIDGET: - $violation = $this->getAttachedWidget() == null; + $violation = $this->getAttachedWidget() === null; break; default: break; diff --git a/Bundle/CoreBundle/Entity/View.php b/Bundle/CoreBundle/Entity/View.php index 15edb3336..10f5947c4 100644 --- a/Bundle/CoreBundle/Entity/View.php +++ b/Bundle/CoreBundle/Entity/View.php @@ -5,13 +5,12 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; +use Gedmo\Timestampable\Traits\TimestampableEntity; use Knp\DoctrineBehaviors\Model\Translatable\Translatable; use Symfony\Component\PropertyAccess\PropertyAccess; use Victoire\Bundle\BusinessPageBundle\Entity\BusinessTemplate; use Victoire\Bundle\BusinessPageBundle\Entity\VirtualBusinessPage; -use Victoire\Bundle\TemplateBundle\Entity\Template; use Victoire\Bundle\ViewReferenceBundle\ViewReference\ViewReference; -use Victoire\Bundle\WidgetBundle\Entity\Widget; use Victoire\Bundle\WidgetMapBundle\Entity\WidgetMap; /** @@ -29,7 +28,7 @@ */ abstract class View { - use \Gedmo\Timestampable\Traits\TimestampableEntity; + use TimestampableEntity; use Translatable; /** @@ -126,8 +125,6 @@ abstract class View protected $references; /** - * @var string - * * @ORM\ManyToOne(targetEntity="\Victoire\Bundle\TemplateBundle\Entity\Template", inversedBy="inheritors", cascade={"persist"}) * @ORM\JoinColumn(name="template_id", referencedColumnName="id", onDelete="CASCADE") */ @@ -153,14 +150,16 @@ abstract class View * @ORM\OrderBy({"id" = "ASC"}) */ protected $widgets; + /** * @var bool * * @ORM\Column(name="cssUpToDate", type="boolean") */ protected $cssUpToDate = false; + /** - * @var bool + * @var string * * @ORM\Column(name="roles", type="text", nullable=true) */ @@ -300,7 +299,7 @@ public function hasChildren() /** * Get WebView children. * - * @return string + * @return array */ public function getWebViewChildren() { @@ -815,7 +814,7 @@ public function setSlug($slug, $locale = null) } /** - * @return array + * @return string */ public function getRoles() { diff --git a/Bundle/CoreBundle/Menu/MenuBuilder.php b/Bundle/CoreBundle/Menu/MenuBuilder.php index 32343d482..3bf8b31d4 100644 --- a/Bundle/CoreBundle/Menu/MenuBuilder.php +++ b/Bundle/CoreBundle/Menu/MenuBuilder.php @@ -76,7 +76,7 @@ public function initLeftNavbar() * @param ItemInterface $rootItem * @param string $title * @param array $attributes - * @param string $caret + * @param bool $caret * * @return \Knp\Menu\ItemInterface */ diff --git a/Bundle/CoreBundle/Repository/StateFullRepositoryTrait.php b/Bundle/CoreBundle/Repository/StateFullRepositoryTrait.php index 0598e62b4..dbcc502d8 100644 --- a/Bundle/CoreBundle/Repository/StateFullRepositoryTrait.php +++ b/Bundle/CoreBundle/Repository/StateFullRepositoryTrait.php @@ -12,6 +12,9 @@ */ trait StateFullRepositoryTrait { + /** + * @var QueryBuilder + */ protected $qb; /** @@ -65,7 +68,7 @@ public function clearInstance() * Run active query. * * @param string $method The method to run - * @param string $hydrationMode How the results will be (Object ? Array ) + * @param int $hydrationMode How the results will be (Object ? Array ) * @param bool $autoClear AutoClear means reset active instance * * @return array() diff --git a/Bundle/CoreBundle/Resources/config/assetic_injector.json b/Bundle/CoreBundle/Resources/config/assetic_injector.json index 00eae28ac..bc2fc1d39 100644 --- a/Bundle/CoreBundle/Resources/config/assetic_injector.json +++ b/Bundle/CoreBundle/Resources/config/assetic_injector.json @@ -28,7 +28,8 @@ "victoire-head": [ "@VictoireCoreBundle/Resources/public/vendor/jquery/1.10.2/jquery-1.10.2.js", - "@VictoireCoreBundle/Resources/public/js/jquery.noConflict.js" + "@VictoireCoreBundle/Resources/public/js/jquery.noConflict.js", + "@VictoireCoreBundle/Resources/public/js/vic-intercooler.js" ], "modernizr": [ diff --git a/Bundle/CoreBundle/Resources/config/services.yml b/Bundle/CoreBundle/Resources/config/services.yml index 2c3d5d402..89e985f52 100644 --- a/Bundle/CoreBundle/Resources/config/services.yml +++ b/Bundle/CoreBundle/Resources/config/services.yml @@ -1,5 +1,7 @@ services: + # ================== Widgets ================== # + victoire_core.entity_proxy.fields_builder: class: Victoire\Bundle\CoreBundle\Form\Builder\EntityProxyFieldsBuilder arguments: @@ -15,6 +17,7 @@ services: - { name: doctrine.event_subscriber, connection: default } # ================== MENU ================== # + victoire_core.admin_menu_builder: class: Victoire\Bundle\CoreBundle\Menu\MenuBuilder arguments: [ '@knp_menu.factory', '@security.authorization_checker' ] @@ -66,6 +69,7 @@ services: - { name: kernel.event_listener, event: kernel.controller, method: preExecuteAutorun } # ================== Twig ================== # + victoire_core.twig.cms_extension: class: Victoire\Bundle\CoreBundle\Twig\Extension\CmsExtension arguments: @@ -122,15 +126,15 @@ services: tags: - { name: kernel.event_subscriber } - # ================== Cache =================== # + victoire_core.cache_warmer.entity_proxy_warmer: class: Victoire\Bundle\CoreBundle\CacheWarmer\EntityProxyWarmer arguments: - "@victoire_core.helper.business_entity_helper" - "@file_locator" tags: - - { name: kernel.cache_warmer, priority: 100} #Must be lower than victoire_business_entity.warmer + - { name: kernel.cache_warmer, priority: 100} # Must be lower than victoire_business_entity.warmer victoire_core.entity_proxy.cache_driver: class: Victoire\Bundle\CoreBundle\CacheWarmer\EntityProxyCacheDriver @@ -161,7 +165,6 @@ services: # ================== View ================== # - victoire_core.view_helper: class: Victoire\Bundle\CoreBundle\Helper\ViewHelper arguments: @@ -188,7 +191,6 @@ services: victoire_core.current_view: class: Victoire\Bundle\CoreBundle\Helper\CurrentViewHelper - twig.extension.routing: class: 'Victoire\Bundle\CoreBundle\Twig\Extension\RoutingExtension' public: false @@ -217,6 +219,7 @@ services: - { name: data_collector, template: 'VictoireCoreBundle:Profiler:widget_cache', id: 'victoire_core.victoire_collector', priority: 200 } # ================== Repositories ================== # + victoire.repository.error_page: class: Doctrine\ORM\EntityRepository factory: ['@doctrine.orm.default_entity_manager', getRepository] diff --git a/Bundle/CoreBundle/Resources/public/js/edit/modal.js b/Bundle/CoreBundle/Resources/public/js/edit/modal.js index 89f55fd3b..32dff8ad9 100644 --- a/Bundle/CoreBundle/Resources/public/js/edit/modal.js +++ b/Bundle/CoreBundle/Resources/public/js/edit/modal.js @@ -14,15 +14,9 @@ function openModal(url) { if (false === response.success) { warn(response.message, 10000); } else { - //remove the previous instance of the modal - $vic('#vic-modal').remove(); //add the html of the modal - $vic('body').append(response.html); - //display the modal - $vic('#vic-modal').vicmodal({ - keyboard: true, - backdrop: false - }); + $vic('#vic-modal-container').html(response.html); + eval("VicIntercooler.processNodes($vic('#vic-modal-container'));"); } loading(false); $vic(document).trigger('victoire_modal_open_after'); diff --git a/Bundle/CoreBundle/Resources/public/js/vic-intercooler.js b/Bundle/CoreBundle/Resources/public/js/vic-intercooler.js new file mode 100644 index 000000000..19bb64877 --- /dev/null +++ b/Bundle/CoreBundle/Resources/public/js/vic-intercooler.js @@ -0,0 +1,1922 @@ +//////////////////////////////////// + +/** + * Intercooler.js - there is no need to be upset. + */ +var VicIntercooler = VicIntercooler || (function() { + 'use strict'; // inside function for better merging + + // work around zepto build issue TODO - fix me + if((typeof Zepto !== "undefined") && ($ == null)) { + $ = Zepto + } + + //-------------------------------------------------- + // Vars + //-------------------------------------------------- + var USE_DATA = false; + var USE_ACTUAL_HTTP_METHOD = false; + + var _MACROS = $vic.map(['v-ic-get-from', 'v-ic-post-to', 'v-ic-put-to', 'v-ic-patch-to', 'v-ic-delete-from', + 'v-ic-style-src', 'v-ic-attr-src', 'v-ic-prepend-from', 'v-ic-append-from', 'v-ic-action'], + function(elt){ return fixICAttributeName(elt) }); + + var _scrollHandler = null; + var _UUID = 1; + var _readyHandlers = []; + + var _isDependentFunction = function(src, dest) { + if (!src || !dest) { + return false; + } + + // For two urls to be considered dependant, either one must contain all + // of the path arguments the other has, like so: + // - chomp off everything after ? or #. This is a design decision, so this + // function will fail to determine dependencies for sites that store + // their model IDs in query/hash params. If your usecase is not covered + // by this you need to implement this function yourself by overriding + // Intercooler.setIsDependentFunction(function(src, dest) { return bool; }); + // - split by / to get the individual path elements, clear out empty values, + // then simply compare them + var asrc = src.split(/[\?#]/, 1)[0].split("/").filter(function(e) { + return e != ""; + }); + + var adest = dest.split(/[\?#]/, 1)[0].split("/").filter(function(e) { + return e != ""; + }); + + // ignore purely local tags (local transport) + if (asrc == "" || adest == "") { + return false; + } + return adest.slice(0, asrc.length).join("/") == asrc.join("/") || + asrc.slice(0, adest.length).join("/") == adest.join("/"); + }; + + //============================================================ + // Base Swap Definitions + //============================================================ + function remove(elt) { + elt.remove(); + } + + function showIndicator(elt) { + if (elt.closest('.v-ic-use-transition').length > 0) { + elt.data('v-ic-use-transition', true); + elt.removeClass('v-ic-use-transition'); + } else { + elt.show(); + } + } + + function hideIndicator(elt) { + if (elt.data('v-ic-use-transition')) { + elt.data('v-ic-use-transition', null); + elt.addClass('v-ic-use-transition'); + } else { + elt.hide(); + } + } + + function fixICAttributeName(s) { + if (USE_DATA) { + return 'data-' + s; + } else { + return s; + } + } + + function getICAttribute(element, attributeName) { + return element.attr(fixICAttributeName(attributeName)); + } + + function setICAttribute(element, attributeName, attributeValue) { + element.attr(fixICAttributeName(attributeName), attributeValue); + } + + function prepend(parent, responseContent) { + try { + parent.prepend(responseContent); + } catch (e) { + log(parent, formatError(e), "ERROR"); + } + if (getICAttribute(parent, 'v-ic-limit-children')) { + var limit = parseInt(getICAttribute(parent, 'v-ic-limit-children')); + if (parent.children().length > limit) { + parent.children().slice(limit, parent.children().length).remove(); + } + } + } + + function append(parent, responseContent) { + try { + parent.append(responseContent); + } catch (e) { + log(parent, formatError(e), "ERROR"); + } + if (getICAttribute(parent, 'v-ic-limit-children')) { + var limit = parseInt(getICAttribute(parent, 'v-ic-limit-children')); + if (parent.children().length > limit) { + parent.children().slice(0, parent.children().length - limit).remove(); + } + } + } + + //============================================================ + // Utility Methods + //============================================================ + function triggerEvent(elt, event, args){ + if($vic.zepto) { + event = event.split(".").reverse().join(":"); + } + elt.trigger(event, args); + } + + function log(elt, msg, level) { + if (elt == null) { + elt = $vic('body'); + } + triggerEvent(elt, "log.ic", [msg, level, elt]); + if (level == "ERROR") { + if (window.console) { + window.console.log("VicIntercooler Error : " + msg); + } + var errorUrl = closestAttrValue($vic('body'), 'v-ic-post-errors-to'); + if (errorUrl) { + $vic.post(errorUrl, {'error': msg}); + } + } + } + + function uuid() { + return _UUID++; + } + + function icSelectorFor(elt) { + return getICAttributeSelector("v-ic-id='" + getIntercoolerId(elt) + "'"); + } + + function parseInterval(str) { + log(null, "POLL: Parsing interval string " + str, 'DEBUG'); + if (str == "null" || str == "false" || str == "") { + return null; + } else if (str.lastIndexOf("ms") == str.length - 2) { + return parseFloat(str.substr(0, str.length - 2)); + } else if (str.lastIndexOf("s") == str.length - 1) { + return parseFloat(str.substr(0, str.length - 1)) * 1000; + } else { + return 1000; + } + } + + function getICAttributeSelector(attribute) { + return "[" + fixICAttributeName(attribute) + "]"; + } + + function initScrollHandler() { + if (_scrollHandler == null) { + _scrollHandler = function() { + $vic(getICAttributeSelector("v-ic-trigger-on='scrolled-into-view'")).each(function() { + var _this = $vic(this); + if (isScrolledIntoView(getTriggeredElement(_this)) && _this.data('v-ic-scrolled-into-view-loaded') != true) { + _this.data('v-ic-scrolled-into-view-loaded', true); + fireICRequest(_this); + } + }); + }; + $vic(window).scroll(_scrollHandler); + } + } + + function currentUrl() { + return window.location.pathname + window.location.search + window.location.hash; + } + + // taken from turbolinks.js + function createDocument(html) { + var doc = null; + if (/<(html|body)/i.test(html)) { + doc = document.documentElement.cloneNode(); + doc.innerHTML = html; + } else { + doc = document.documentElement.cloneNode(true); + doc.querySelector('body').innerHTML = html; + } + return $vic(doc); + } + + //============================================================ + // Request/Parameter/Include Processing + //============================================================ + function getTarget(elt) { + return getTargetImpl(elt, 'v-ic-target') + } + + function getTargetImpl(elt, attibuteName) { + var closest = $vic(elt).closest(getICAttributeSelector(attibuteName)); + var targetValue = getICAttribute(closest, attibuteName); + if (targetValue == 'this') { + return closest; + } else if (targetValue && targetValue.indexOf('this.') != 0) { + if (targetValue.indexOf('closest ') == 0) { + return elt.closest(targetValue.substr(8)); + } else if (targetValue.indexOf('find ') == 0) { + return elt.find(targetValue.substr(5)); + } else { + return $vic(targetValue); + } + } else { + return elt; + } + } + + function processHeaders(elt, xhr) { + elt = $vic(elt); + triggerEvent(elt, "beforeHeaders.ic", [elt, xhr]); + log(elt, "response headers: " + xhr.getAllResponseHeaders(), "DEBUG"); + var target = null; + + // set page title by header + if (xhr.getResponseHeader("X-VIC-Title")) { + document.title = xhr.getResponseHeader("X-VIC-Title"); + } + + if (xhr.getResponseHeader("X-VIC-Refresh")) { + var pathsToRefresh = xhr.getResponseHeader("X-VIC-Refresh").split(","); + log(elt, "X-VIC-Refresh: refreshing " + pathsToRefresh, "DEBUG"); + $vic.each(pathsToRefresh, function(i, str) { + refreshDependencies(str.replace(/ /g, ""), elt); + }); + } + + if (xhr.getResponseHeader("X-VIC-Script")) { + log(elt, "X-VIC-Script: evaling " + xhr.getResponseHeader("X-VIC-Script"), "DEBUG"); + globalEval(xhr.getResponseHeader("X-VIC-Script"), [["elt", elt]]); + } + + if (xhr.getResponseHeader("X-VIC-Redirect")) { + log(elt, "X-VIC-Redirect: redirecting to " + xhr.getResponseHeader("X-VIC-Redirect"), "DEBUG"); + window.location = xhr.getResponseHeader("X-VIC-Redirect"); + } + + if (xhr.getResponseHeader("X-VIC-CancelPolling") == "true") { + cancelPolling(elt.closest(getICAttributeSelector('v-ic-poll'))); + } + + if (xhr.getResponseHeader("X-VIC-ResumePolling") == "true") { + var pollingElt = elt.closest(getICAttributeSelector('v-ic-poll')); + setICAttribute(pollingElt, 'v-ic-pause-polling', null); + startPolling(pollingElt); + } + + if (xhr.getResponseHeader("X-VIC-SetPollInterval")) { + var pollingElt = elt.closest(getICAttributeSelector('v-ic-poll')); + cancelPolling(pollingElt); + setICAttribute(pollingElt, 'v-ic-poll', xhr.getResponseHeader("X-VIC-SetPollInterval")); + startPolling(pollingElt); + } + + if (xhr.getResponseHeader("X-VIC-Open")) { + log(elt, "X-VIC-Open: opening " + xhr.getResponseHeader("X-VIC-Open"), "DEBUG"); + window.open(xhr.getResponseHeader("X-VIC-Open")); + } + + var triggerValue = xhr.getResponseHeader("X-VIC-Trigger"); + if (triggerValue) { + log(elt, "X-VIC-Trigger: found trigger " + triggerValue, "DEBUG"); + target = getTarget(elt); + // Deprecated API + if (xhr.getResponseHeader("X-VIC-Trigger-Data")) { + var triggerArgs = $vic.parseJSON(xhr.getResponseHeader("X-VIC-Trigger-Data")); + triggerEvent(target, triggerValue, triggerArgs); + } else { + if (triggerValue.indexOf("{") >= 0) { + $vic.each($vic.parseJSON(triggerValue), function(event, args) { + triggerEvent(target, event, args); + }); + } else { + triggerEvent(target, triggerValue, []); + } + } + } + + var localVars = xhr.getResponseHeader("X-VIC-Set-Local-Vars"); + if (localVars) { + $vic.each($vic.parseJSON(localVars), function(key, val) { + localStorage.setItem(key, val); + }); + } + + if (xhr.getResponseHeader("X-VIC-Remove")) { + if (elt) { + var removeVal = xhr.getResponseHeader("X-VIC-Remove"); + removeVal += ''; // normalize as string for zapto + var removeValAsInterval = parseInterval(removeVal); + log(elt, "X-VIC-Remove header found.", "DEBUG"); + target = getTarget(elt); + if(removeVal == "true" || removeValAsInterval == null) { + remove(target); + } else { + target.addClass('v-ic-removing'); + setTimeout(function () { + remove(target); + }, removeValAsInterval); + } + } + } + + triggerEvent(elt, "afterHeaders.ic", [elt, xhr]); + + return true; + } + + + function beforeRequest(elt) { + elt.addClass('disabled'); + elt.data('v-ic-request-in-flight', true); + } + + function requestCleanup(indicator, elt) { + if (indicator.length > 0) { + hideIndicator(indicator); + } + elt.removeClass('disabled'); + elt.data('v-ic-request-in-flight', false); + if (elt.data('v-ic-next-request')) { + elt.data('v-ic-next-request')["req"](); + elt.data('v-ic-next-request', null); + } + } + + function replaceOrAddMethod(data, actualMethod) { + if ($vic.type(data) === "string") { + var regex = /(&|^)_method=[^&]*/; + var content = "&_method=" + actualMethod; + if (regex.test(data)) { + return data.replace(regex, content) + } else { + return data + content; + } + } else { + data.append("_method", actualMethod); + return data; + } + } + + /* + Is the provided text a valid JavaScript identifier path? + + We should also probably check if an identifier is a JavaScript keyword here. + */ + function isIdentifier(txt) { + return /^[$A-Z_][0-9A-Z_$]*$/i.test(txt); + } + + /* + Evaluate a script snippet provided by the user. + + script: A string. If this is an identifier, it is assumed to be a callable, retrieved from the + global namespace, and called. If it is a compound statement, it is evaluated using eval. + args: A list of [name, value] tuples. These will be injected into the namespace of evaluated + scripts, and be passed as arguments to safe evaluations. + */ + // It would be nice to use the spread operator here globalEval(script, ...args) - but it breaks + // uglify and isn't supported in some older browsers. + function globalEval(script, args) { + var names = []; + var values = []; + if (args) { + for (var i = 0; i < args.length; i++) { + names.push(args[i][0]); + values.push(args[i][1]); + } + } + if (isIdentifier(script)) { + return window[script].apply(this, values); + } else { + var outerfunc = window["eval"].call( + window, + '(function (' + names.join(", ") + ') {' + script + '})' + ); + return outerfunc.apply(this, values); + } + } + + function closestAttrValue(elt, attr) { + var closestElt = $vic(elt).closest(getICAttributeSelector(attr)); + if (closestElt.length > 0) { + return getICAttribute(closestElt, attr); + } else { + return null; + } + } + + function formatError(e) { + var msg = e.toString() + "\n"; + try { + msg += e.stack; + } catch (e) { + // ignore + } + return msg; + } + + function handleRemoteRequest(elt, type, url, data, success) { + + beforeRequest(elt); + + data = replaceOrAddMethod(data, type); + + // Spinner support + var indicator = findIndicator(elt); + if (indicator.length > 0) { + showIndicator(indicator); + } + + var requestId = uuid(); + var requestStart = new Date(); + var actualRequestType; + if(USE_ACTUAL_HTTP_METHOD) { + actualRequestType = type; + } else { + actualRequestType = type == 'GET' ? 'GET' : 'POST'; + } + + var ajaxSetup = { + type: actualRequestType, + url: url, + data: data, + dataType: 'text', + headers: { + "Accept": "text/html-partial, */*; q=0.9", + "X-VIC-Request": true, + "X-HTTP-Method-Override": type + }, + beforeSend: function(xhr, settings) { + triggerEvent(elt, "beforeSend.ic", [elt, data, settings, xhr, requestId]); + log(elt, "before AJAX request " + requestId + ": " + type + " to " + url, "DEBUG"); + var onBeforeSend = closestAttrValue(elt, 'v-ic-on-beforeSend'); + if (onBeforeSend) { + globalEval(onBeforeSend, [["elt", elt], ["data", data], ["settings", settings], ["xhr", xhr]]); + } + maybeInvokeLocalAction(elt, "-beforeSend"); + }, + success: function(data, textStatus, xhr) { + triggerEvent(elt, "success.ic", [elt, data, textStatus, xhr, requestId]); + triggerEvent($vic(document), "success.v-ic", [elt, data, textStatus, xhr, requestId]); + log(elt, "AJAX request " + requestId + " was successful.", "DEBUG"); + var onSuccess = closestAttrValue(elt, 'v-ic-on-success'); + if (onSuccess) { + if (globalEval(onSuccess, [["elt", elt], ["data", data], ["textStatus", textStatus], ["xhr", xhr]]) == false) { + return; + } + } + + var beforeHeaders = new Date(); + try { + if (processHeaders(elt, xhr)) { + log(elt, "Processed headers for request " + requestId + " in " + (new Date() - beforeHeaders) + "ms", "DEBUG"); + var beforeSuccess = new Date(); + + if (xhr.getResponseHeader("X-VIC-PushURL") || closestAttrValue(elt, 'v-ic-push-url') == "true") { + try { + requestCleanup(indicator, elt); // clean up before snap-shotting HTML + var newUrl = xhr.getResponseHeader("X-VIC-PushURL") || closestAttrValue(elt, 'v-ic-src'); + if(_history) { + _history.snapshotForHistory(newUrl); + } else { + throw "History support not enabled"; + } + } catch (e) { + log(elt, "Error during history snapshot for " + requestId + ": " + formatError(e), "ERROR"); + } + } + + success(data, textStatus, elt, xhr); + + log(elt, "Process content for request " + requestId + " in " + (new Date() - beforeSuccess) + "ms", "DEBUG"); + } + triggerEvent(elt, "after.success.ic", [elt, data, textStatus, xhr, requestId]); + maybeInvokeLocalAction(elt, "-success"); + } catch (e) { + log(elt, "Error processing successful request " + requestId + " : " + formatError(e), "ERROR"); + } + }, + error: function(xhr, status, str) { + triggerEvent(elt, "error.ic", [elt, status, str, xhr]); + var onError = closestAttrValue(elt, 'v-ic-on-error'); + if (onError) { + globalEval(onError, [["elt", elt], ["status", status], ["str", str], ["xhr", xhr]]); + } + processHeaders(elt, xhr); + maybeInvokeLocalAction(elt, "-error"); + log(elt, "AJAX request " + requestId + " to " + url + " experienced an error: " + str, "ERROR"); + }, + complete: function(xhr, status) { + log(elt, "AJAX request " + requestId + " completed in " + (new Date() - requestStart) + "ms", "DEBUG"); + requestCleanup(indicator, elt); + try { + if ($vic.contains(document, elt[0])) { + triggerEvent(elt, "complete.ic", [elt, data, status, xhr, requestId]); + } else { + triggerEvent($vic('body'), "complete.ic", [elt, data, status, xhr, requestId]); + } + } catch (e) { + log(elt, "Error during complete.ic event for " + requestId + " : " + formatError(e), "ERROR"); + } + var onComplete = closestAttrValue(elt, 'v-ic-on-complete'); + if (onComplete) { + globalEval(onComplete, [["elt", elt], ["xhr", xhr], ["status", status]]); + } + maybeInvokeLocalAction(elt, "-complete"); + } + }; + if ($vic.type(data) != "string") { + ajaxSetup.dataType = null; + ajaxSetup.processData = false; + ajaxSetup.contentType = false; + } + + triggerEvent($vic(document), "beforeAjaxSend.ic", [ajaxSetup, elt]); + + if(ajaxSetup.cancel) { + requestCleanup(indicator, elt); + } else { + $vic.ajax(ajaxSetup) + } + } + + function findIndicator(elt) { + var indicator = null; + elt = $vic(elt); + if (getICAttribute(elt, 'v-ic-indicator')) { + indicator = $vic(getICAttribute(elt, 'v-ic-indicator')).first(); + } else { + indicator = elt.find(".v-ic-indicator").first(); + if (indicator.length == 0) { + var parent = closestAttrValue(elt, 'v-ic-indicator'); + if (parent) { + indicator = $vic(parent).first(); + } else { + if (elt.next().is('.v-ic-indicator')) { + indicator = elt.next(); + } + } + } + } + return indicator; + } + + function processIncludes(data, str) { + if ($vic.trim(str).indexOf("{") == 0) { + var obj = $vic.parseJSON(str); + $vic.each(obj, function(name, value) { + data = appendData(data, name, value); + }); + } else { + $vic(str).each(function() { + var obj = $vic(this).serializeArray(); + $vic.each(obj, function(i, input) { + data = appendData(data, input.name, input.value); + }); + }); + } + return data; + } + + function processLocalVars(data, str) { + $vic(str.split(",")).each(function() { + var key = $vic.trim(this); + var item = localStorage.getItem(key); + if(item) { + data = appendData(data, key, item); + } + }); + return data; + } + + function appendData(data, string, value) { + if ($vic.type(data) === "string") { + if($vic.type(value) !== "string") { + value = JSON.stringify(value); + } + return data + "&" + string + "=" + encodeURIComponent(value); + } else { + data.append(string, value); + return data; + } + } + + function getParametersForElement(verb, elt, triggerOrigin) { + var target = getTarget(elt); + var data = null; + + if (elt.is('form') && elt.attr('enctype') == 'multipart/form-data') { + data = new FormData(elt[0]); + data = appendData(data, 'v-ic-request', true); + } else { + data = "v-ic-request=true"; + // if the element is in a form, include the entire form + var closestForm = elt.closest('form'); + if (elt.is('form') || (verb != "GET" && closestForm.length > 0)) { + data += "&" + closestForm.serialize(); + // include data from a focused button (to capture clicked button value) + var buttonData = elt.data('v-ic-last-clicked-button'); + if(buttonData) { + data = appendData(data, buttonData.name, buttonData.value); + } + } else { // otherwise include the element + data += "&" + elt.serialize(); + } + } + + var promptText = closestAttrValue(elt, 'v-ic-prompt'); + if (promptText) { + var promptVal = prompt(promptText); + if (promptVal) { + var promptParamName = closestAttrValue(elt, 'v-ic-prompt-name') || 'v-ic-prompt-value'; + data = appendData(data, promptParamName, promptVal); + } else { + return null; + } + } + + if (elt.attr('id')) { + data = appendData(data, 'v-ic-element-id', elt.attr('id')); + } + if (elt.attr('name')) { + data = appendData(data, 'v-ic-element-name', elt.attr('name')); + } + if (getICAttribute(target, 'v-ic-id')) { + data = appendData(data, 'v-ic-id', getICAttribute(target, 'v-ic-id')); + } + if (target.attr('id')) { + data = appendData(data, 'v-ic-target-id', target.attr('id')); + } + if (triggerOrigin && triggerOrigin.attr('id')) { + data = appendData(data, 'v-ic-trigger-id', triggerOrigin.attr('id')); + } + if (triggerOrigin && triggerOrigin.attr('name')) { + data = appendData(data, 'v-ic-trigger-name', triggerOrigin.attr('name')); + } + var includeAttr = closestAttrValue(elt, 'v-ic-include'); + if (includeAttr) { + data = processIncludes(data, includeAttr); + } + var localVars = closestAttrValue(elt, 'v-ic-local-vars'); + if (localVars) { + data = processLocalVars(data, localVars); + } + $vic(getICAttributeSelector('v-ic-global-include')).each(function() { + data = processIncludes(data, getICAttribute($vic(this), 'v-ic-global-include')); + }); + data = appendData(data, 'v-ic-current-url', currentUrl()); + + var selectFromResp = closestAttrValue(elt, 'v-ic-select-from-response'); + if(selectFromResp) { + data = appendData(data, 'v-ic-select-from-response', selectFromResp); + } + + log(elt, "request parameters " + data, "DEBUG"); + + return data; + } + + function maybeSetIntercoolerInfo(elt) { + var target = getTarget(elt); + getIntercoolerId(target); + if (elt.data('elementAdded.ic') != true) { + elt.data('elementAdded.ic', true); + triggerEvent(elt, "elementAdded.ic"); + } + } + + function getIntercoolerId(elt) { + if (!getICAttribute(elt, 'v-ic-id')) { + setICAttribute(elt, 'v-ic-id', uuid()); + } + return getICAttribute(elt, 'v-ic-id'); + } + + //============================================================ + // Tree Processing + //============================================================ + + function processNodes(elt) { + elt = $vic(elt); + if (elt.length > 1) { + elt.each(function() { + processNodes(this); + }); + } else { + processMacros(elt); + processSources(elt); + processPolling(elt); + processEventSources(elt); + processTriggerOn(elt); + processRemoveAfter(elt); + processAddClasses(elt); + processRemoveClasses(elt); + } + } + + function fireReadyStuff(elt) { + triggerEvent(elt, 'nodesProcessed.ic'); + $vic.each(_readyHandlers, function(i, handler) { + try { + handler(elt); + } catch (e) { + log(elt, formatError(e), "ERROR"); + } + }); + } + + function autoFocus(elt) { + elt.find('[autofocus]').last().focus(); + } + + function processMacros(elt) { + $vic.each(_MACROS, function(i, macro) { + if (elt.closest('.v-ic-ignore').length == 0) { + if (elt.is('[' + macro + ']')) { + processMacro(macro, elt); + } + elt.find('[' + macro + ']').each(function() { + var _this = $vic(this); + if (_this.closest('.v-ic-ignore').length == 0) { + processMacro(macro, _this); + } + }); + } + }); + } + + function processSources(elt) { + if (elt.closest('.v-ic-ignore').length == 0) { + if (elt.is(getICAttributeSelector("v-ic-src"))) { + maybeSetIntercoolerInfo(elt); + } + elt.find(getICAttributeSelector("v-ic-src")).each(function() { + var _this = $vic(this); + if (_this.closest('.v-ic-ignore').length == 0) { + maybeSetIntercoolerInfo(_this); + } + }); + } + } + + function processPolling(elt) { + if (elt.closest('.v-ic-ignore').length == 0) { + if (elt.is(getICAttributeSelector("v-ic-poll"))) { + maybeSetIntercoolerInfo(elt); + startPolling(elt); + } + elt.find(getICAttributeSelector("v-ic-poll")).each(function() { + var _this = $vic(this); + if (_this.closest('.v-ic-ignore').length == 0) { + maybeSetIntercoolerInfo(_this); + startPolling(_this); + } + }); + } + } + + function processTriggerOn(elt) { + if (elt.closest('.v-ic-ignore').length == 0) { + handleTriggerOn(elt); + elt.find(getICAttributeSelector('v-ic-trigger-on')).each(function() { + var _this = $vic(this); + if (_this.closest('.v-ic-ignore').length == 0) { + handleTriggerOn(_this); + } + }); + } + } + + function processRemoveAfter(elt) { + if (elt.closest('.v-ic-ignore').length == 0) { + handleRemoveAfter(elt); + elt.find(getICAttributeSelector('v-ic-remove-after')).each(function() { + var _this = $vic(this); + if (_this.closest('.v-ic-ignore').length == 0) { + handleRemoveAfter(_this); + } + }); + } + } + + function processAddClasses(elt) { + if (elt.closest('.v-ic-ignore').length == 0) { + handleAddClasses(elt); + elt.find(getICAttributeSelector('v-ic-add-class')).each(function() { + var _this = $vic(this); + if (_this.closest('.v-ic-ignore').length == 0) { + handleAddClasses(_this); + } + }); + } + } + + function processRemoveClasses(elt) { + if (elt.closest('.v-ic-ignore').length == 0) { + handleRemoveClasses(elt); + elt.find(getICAttributeSelector('v-ic-remove-class')).each(function() { + var _this = $vic(this); + if (_this.closest('.v-ic-ignore').length == 0) { + handleRemoveClasses(_this); + } + }); + } + } + + function processEventSources(elt) { + if (elt.closest('.v-ic-ignore').length == 0) { + handleEventSource(elt); + elt.find(getICAttributeSelector('v-ic-sse-src')).each(function() { + var _this = $vic(this); + if (_this.closest('.v-ic-ignore').length == 0) { + handleEventSource(_this); + } + }); + } + } + + //============================================================ + // Polling support + //============================================================ + + function startPolling(elt) { + if (elt.data('v-ic-poll-interval-id') == null && getICAttribute(elt, 'v-ic-pause-polling') != 'true') { + var interval = parseInterval(getICAttribute(elt, 'v-ic-poll')); + if (interval != null) { + var selector = icSelectorFor(elt); + var repeats = parseInt(getICAttribute(elt, 'v-ic-poll-repeats')) || -1; + var currentIteration = 0; + log(elt, "POLL: Starting poll for element " + selector, "DEBUG"); + var timerId = setInterval(function() { + var target = $vic(selector); + triggerEvent(elt, "onPoll.ic", target); + if ((target.length == 0) || (currentIteration == repeats) || elt.data('v-ic-poll-interval-id') != timerId) { + log(elt, "POLL: Clearing poll for element " + selector, "DEBUG"); + clearTimeout(timerId); + } else { + fireICRequest(target); + } + currentIteration++; + }, interval); + elt.data('v-ic-poll-interval-id', timerId); + } + } + } + + function cancelPolling(elt) { + if (elt.data('v-ic-poll-interval-id') != null) { + clearTimeout(elt.data('v-ic-poll-interval-id')); + elt.data('v-ic-poll-interval-id', null); + } + } + + //============================================================---- + // Dependency support + //============================================================---- + + function refreshDependencies(dest, src) { + log(src, "refreshing dependencies for path " + dest, "DEBUG"); + $vic(getICAttributeSelector('v-ic-src')).each(function() { + var fired = false; + var _this = $vic(this); + if (verbFor(_this) == "GET" && getICAttribute(_this, 'v-ic-deps') != 'ignore' ) { + if (isDependent(dest, getICAttribute(_this, 'v-ic-src'))) { + if (src == null || $vic(src)[0] != _this[0]) { + fireICRequest(_this); + fired = true; + } + } else if (isICDepsDependent(dest, getICAttribute(_this, 'v-ic-deps')) || getICAttribute(_this, 'v-ic-deps') == "*") { + if (src == null || $vic(src)[0] != _this[0]) { + fireICRequest(_this); + fired = true; + } + } + } + if (fired) { + log(_this, "depends on path " + dest + ", refreshing...", "DEBUG") + } + }); + } + + function isICDepsDependent(src, dest) { + if(dest) { + var paths = dest.split(","); + for (var i = 0; i < paths.length; i++) { + var str = paths[i].trim(); + if(isDependent(src, str)) { + return true; + } + } + } + return false; + } + + function isDependent(src, dest) { + return !!_isDependentFunction(src, dest); + } + + //============================================================---- + // Trigger-On support + //============================================================---- + + function verbFor(elt) { + elt = $vic(elt); + if (getICAttribute(elt, 'v-ic-verb')) { + return getICAttribute(elt, 'v-ic-verb').toUpperCase(); + } + return "GET"; + } + + function eventFor(attr, elt) { + if (attr == "default") { + elt = $vic(elt); + if (elt.is('button')) { + return 'click'; + } else if (elt.is('form')) { + return 'submit'; + } else if (elt.is('input, textarea, select, button')) { + return 'change'; + } else { + return 'click'; + } + } else { + return attr; + } + } + + function preventDefault(elt, evt) { + return elt.is('form') || + (elt.is('input[type="submit"], button') && elt.closest('form').length == 1) || + (elt.is('a') && elt.is('[href]') && elt.attr('href').indexOf('#') != 0); + } + + function handleRemoveAfter(elt) { + elt = $vic(elt); + if (getICAttribute(elt, 'v-ic-remove-after')) { + var interval = parseInterval(getICAttribute(elt, 'v-ic-remove-after')); + setTimeout(function() { + remove(elt); + }, interval); + } + } + + function parseAndApplyClass(classInfo, elt, operation) { + var cssClass = ""; + var delay = 50; + if (classInfo.indexOf(":") > 0) { + var split = classInfo.split(':'); + cssClass = split[0]; + delay = parseInterval(split[1]); + } else { + cssClass = classInfo; + } + setTimeout(function() { + elt[operation](cssClass) + }, delay); + } + + function handleAddClasses(elt) { + elt = $vic(elt); + if (getICAttribute(elt, 'v-ic-add-class')) { + var values = getICAttribute(elt, 'v-ic-add-class').split(","); + var arrayLength = values.length; + for (var i = 0; i < arrayLength; i++) { + parseAndApplyClass($vic.trim(values[i]), elt, 'addClass'); + } + } + } + + function handleRemoveClasses(elt) { + elt = $vic(elt); + if (getICAttribute(elt, 'v-ic-remove-class')) { + var values = getICAttribute(elt, 'v-ic-remove-class').split(","); + var arrayLength = values.length; + for (var i = 0; i < arrayLength; i++) { + parseAndApplyClass($vic.trim(values[i]), elt, 'removeClass'); + } + } + } + + function handleEventSource(elt) { + elt = $vic(elt); + if (getICAttribute(elt, 'v-ic-sse-src')) { + var evtSrcUrl = getICAttribute(elt, 'v-ic-sse-src'); + var eventSource = initEventSource(elt, evtSrcUrl); + elt.data('v-ic-event-sse-source', eventSource); + elt.data('v-ic-event-sse-map', {}); + } + } + + function initEventSource(elt, evtSrcUrl) { + var eventSource = Intercooler._internal.initEventSource(evtSrcUrl); + eventSource.onmessage = function(e) { + processICResponse(e.data, elt, false); + }; + return eventSource; + } + + function registerSSE(sourceElement, event) { + var source = sourceElement.data('v-ic-event-sse-source'); + var eventMap = sourceElement.data('v-ic-event-sse-map'); + if(source.addEventListener && eventMap[event] != true) { + source.addEventListener(event, function(){ + sourceElement.find(getICAttributeSelector('v-ic-trigger-on')).each(function(){ + var _that = $vic(this); + if(_that.attr('v-ic-trigger-on') == "sse:" + event) { + fireICRequest(_that); + } + }); + }) + } + } + + function getTriggeredElement(elt) { + var triggerFrom = getICAttribute(elt, 'v-ic-trigger-from'); + if(triggerFrom) { + if (triggerFrom == "document") { + return $vic(document); + } else if (triggerFrom == "window") { + return $vic(window); + } else { + return $vic(triggerFrom); + } + } else { + return elt; + } + } + + function handleTriggerOn(elt) { + if (getICAttribute(elt, 'v-ic-trigger-on')) { + // record button or submit input click info + if(elt.is('form')) { + elt.on('click focus', 'input, button, select, textarea', function(e){ + if($vic(this).is('input[type="submit"], button') && $vic(this).is("[name]")) { + elt.data('v-ic-last-clicked-button', {name:$vic(this).attr("name"), value:$vic(this).val()}) + } else { + elt.data('v-ic-last-clicked-button', null) + } + }); + } + if (getICAttribute(elt, 'v-ic-trigger-on') == 'load') { + fireICRequest(elt); + } else if (getICAttribute(elt, 'v-ic-trigger-on') == 'scrolled-into-view') { + initScrollHandler(); + setTimeout(function() { + triggerEvent($vic(window), 'scroll'); + }, 100); // Trigger a scroll in case element is already viewable + } else { + var triggerOn = getICAttribute(elt, 'v-ic-trigger-on').split(" "); + if(triggerOn[0].indexOf("sse:") == 0) { + //Server-sent event, find closest event source and register for it + var sourceElt = elt.closest(getICAttributeSelector('v-ic-sse-src')); + if(sourceElt) { + registerSSE(sourceElt, triggerOn[0].substr(4)) + } + } else { + var triggerOn = getICAttribute($vic(elt), 'v-ic-trigger-on').split(" "); + var event = eventFor(triggerOn[0], $vic(elt)); + $vic(getTriggeredElement(elt)).on(event, function(e) { + var onBeforeTrigger = closestAttrValue(elt, 'v-ic-on-beforeTrigger'); + if (onBeforeTrigger) { + if (globalEval(onError, [["elt", elt], ["evt", e], ["elt", elt]]) == false) { + log(elt, "v-ic-trigger cancelled by ic-on-beforeTrigger", "DEBUG"); + return false; + } + } + + if (triggerOn[1] == 'changed') { + var currentVal = elt.val(); + var previousVal = elt.data('v-ic-previous-val'); + elt.data('v-ic-previous-val', currentVal); + if (currentVal != previousVal) { + fireICRequest(elt); + } + } else { + fireICRequest(elt); + } + if (preventDefault(elt, e)) { + e.preventDefault(); + return false; + } + return true; + }); + if(event && (event.indexOf("timeout:") == 0)) { + setTimeout(function () { + $vic(getTriggeredElement(elt)).trigger(event); + }, parseInterval(event.split(":")[1])); + } + } + } + } + } + + //============================================================---- + // Macro support + //============================================================---- + + function macroIs(macro, constant) { + return macro == fixICAttributeName(constant); + } + + function processMacro(macro, elt) { + // action attributes + if (macroIs(macro, 'v-ic-post-to')) { + setIfAbsent(elt, 'v-ic-src', getICAttribute(elt, 'v-ic-post-to')); + setIfAbsent(elt, 'v-ic-verb', 'POST'); + setIfAbsent(elt, 'v-ic-trigger-on', 'default'); + setIfAbsent(elt, 'v-ic-deps', 'ignore'); + } + if (macroIs(macro, 'v-ic-put-to')) { + setIfAbsent(elt, 'v-ic-src', getICAttribute(elt, 'v-ic-put-to')); + setIfAbsent(elt, 'v-ic-verb', 'PUT'); + setIfAbsent(elt, 'v-ic-trigger-on', 'default'); + setIfAbsent(elt, 'v-ic-deps', 'ignore'); + } + if (macroIs(macro, 'v-ic-patch-to')) { + setIfAbsent(elt, 'v-ic-src', getICAttribute(elt, 'v-ic-patch-to')); + setIfAbsent(elt, 'v-ic-verb', 'PATCH'); + setIfAbsent(elt, 'v-ic-trigger-on', 'default'); + setIfAbsent(elt, 'v-ic-deps', 'ignore'); + } + if (macroIs(macro, 'v-ic-get-from')) { + setIfAbsent(elt, 'v-ic-src', getICAttribute(elt, 'v-ic-get-from')); + setIfAbsent(elt, 'v-ic-trigger-on', 'default'); + setIfAbsent(elt, 'v-ic-deps', 'ignore'); + } + if (macroIs(macro, 'v-ic-delete-from')) { + setIfAbsent(elt, 'v-ic-src', getICAttribute(elt, 'v-ic-delete-from')); + setIfAbsent(elt, 'v-ic-verb', 'DELETE'); + setIfAbsent(elt, 'v-ic-trigger-on', 'default'); + setIfAbsent(elt, 'v-ic-deps', 'ignore'); + } + if (macroIs(macro, 'v-ic-action')) { + setIfAbsent(elt, 'v-ic-trigger-on', 'default'); + } + + // non-action attributes + var value = null; + var url = null; + if (macroIs(macro, 'v-ic-style-src')) { + value = getICAttribute(elt, 'v-ic-style-src').split(":"); + var styleAttribute = value[0]; + url = value[1]; + setIfAbsent(elt, 'v-ic-src', url); + setIfAbsent(elt, 'v-ic-target', 'this.style.' + styleAttribute); + } + if (macroIs(macro, 'v-ic-attr-src')) { + value = getICAttribute(elt, 'v-ic-attr-src').split(":"); + var attribute = value[0]; + url = value[1]; + setIfAbsent(elt, 'v-ic-src', url); + setIfAbsent(elt, 'v-ic-target', 'this.' + attribute); + } + if (macroIs(macro, 'v-ic-prepend-from')) { + setIfAbsent(elt, 'v-ic-src', getICAttribute(elt, 'v-ic-prepend-from')); + setIfAbsent(elt, 'v-ic-swap-style', 'prepend'); + } + if (macroIs(macro, 'v-ic-append-from')) { + setIfAbsent(elt, 'v-ic-src', getICAttribute(elt, 'v-ic-append-from')); + setIfAbsent(elt, 'v-ic-swap-style', 'append'); + } + } + + function setIfAbsent(elt, attr, value) { + if (getICAttribute(elt, attr) == null) { + setICAttribute(elt, attr, value); + } + } + + //============================================================---- + // Utilities + //============================================================---- + + function isScrolledIntoView(elem) { + elem = $vic(elem); + if (elem.height() == 0 && elem.width() == 0) { + return false; + } + var docViewTop = $vic(window).scrollTop(); + var docViewBottom = docViewTop + $vic(window).height(); + + var elemTop = elem.offset().top; + var elemBottom = elemTop + elem.height(); + + return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) + && (elemBottom <= docViewBottom) && (elemTop >= docViewTop)); + } + + function maybeScrollToTarget(elt, target) { + if (closestAttrValue(elt, 'v-ic-scroll-to-target') != "false" && + (closestAttrValue(elt, 'v-ic-scroll-to-target') == 'true' || + closestAttrValue(target, 'v-ic-scroll-to-target') == 'true')) { + var offset = -50; // -50 px default offset padding + if (closestAttrValue(elt, 'v-ic-scroll-offset')) { + offset = parseInt(closestAttrValue(elt, 'v-ic-scroll-offset')); + } else if (closestAttrValue(target, 'v-ic-scroll-offset')) { + offset = parseInt(closestAttrValue(target, 'v-ic-scroll-offset')); + } + var currentPosition = target.offset().top; + var portalTop = $vic(window).scrollTop(); + var portalEnd = portalTop + window.innerHeight; + //if the current top of this element is not visible, scroll it to the top position + if (currentPosition < portalTop || currentPosition > portalEnd) { + offset += currentPosition; + $vic('html,body').animate({scrollTop: offset}, 400); + } + } + } + + function getTransitionDuration(elt, target) { + var transitionDuration = closestAttrValue(elt, 'v-ic-transition-duration'); + if (transitionDuration) { + return parseInterval(transitionDuration); + } + transitionDuration = closestAttrValue(target, 'v-ic-transition-duration'); + if (transitionDuration) { + return parseInterval(transitionDuration); + } + target = $vic(target); + var duration = 0; + var durationStr = target.css('transition-duration'); + if (durationStr) { + duration += parseInterval(durationStr); + } + var delayStr = target.css('transition-delay'); + if (delayStr) { + duration += parseInterval(delayStr); + } + return duration; + } + + function closeSSESource(elt) { + var src = elt.data('v-ic-event-sse-source'); + try { + if(src) { + src.close(); + } + } catch (e) { + log(elt, "Error closing ServerSentEvent source" + e, "ERROR"); + } + } + + function beforeSwapCleanup(target) { + target.find(getICAttributeSelector('v-ic-sse-src')).each(function() { + closeSSESource($vic(this)); + }); + triggerEvent(target, 'beforeSwap.ic'); + } + + function processICResponse(responseContent, elt, forHistory) { + if (responseContent && responseContent != "" && responseContent != " ") { + + log(elt, "response content: \n" + responseContent, "DEBUG"); + var target = getTarget(elt); + + var contentToSwap = maybeFilter(responseContent, closestAttrValue(elt, 'v-ic-select-from-response')); + + if (closestAttrValue(elt, 'v-ic-fix-ids') == "true") { + fixIDs(contentToSwap); + } + + var doSwap = function() { + if (closestAttrValue(elt, 'v-ic-replace-target') == "true") { + try { + beforeSwapCleanup(target); + closeSSESource(target); + target.replaceWith(contentToSwap); + target = contentToSwap; + } catch (e) { + log(elt, formatError(e), "ERROR"); + } + processNodes(contentToSwap); + fireReadyStuff(target); + autoFocus(target); + } else { + if (getICAttribute(elt, 'v-ic-swap-style') == "prepend") { + prepend(target, contentToSwap); + processNodes(contentToSwap); + fireReadyStuff(target); + autoFocus(target); + } else if (getICAttribute(elt, 'v-ic-swap-style') == "append") { + append(target, contentToSwap); + processNodes(contentToSwap); + fireReadyStuff(target); + autoFocus(target); + } else { + try { + beforeSwapCleanup(target); + target.empty().append(contentToSwap); + } catch (e) { + log(elt, formatError(e), "ERROR"); + } + target.children().each(function() { + processNodes(this); + }); + fireReadyStuff(target); + autoFocus(target); + } + if (forHistory != true) { + maybeScrollToTarget(elt, target); + } + } + }; + + if (target.length == 0) { + //TODO cgross - refactor getTarget to return printable string here + log(elt, "Invalid target for element: " + getICAttribute(elt.closest(getICAttributeSelector('v-ic-target')), 'v-ic-target'), "ERROR"); + return; + } + + var delay = getTransitionDuration(elt, target); + target.addClass('v-ic-transitioning'); + setTimeout(function() { + try { + doSwap(); + } catch (e) { + log(elt, "Error during content swap : " + formatError(e), "ERROR"); + } + setTimeout(function() { + try { + target.removeClass('v-ic-transitioning'); + if(_history) { + _history.updateHistory(); + } + triggerEvent(target, "complete_transition.ic", [target]); + } catch (e) { + log(elt, "Error during transition complete : " + formatError(e), "ERROR"); + } + }, 20); + }, delay); + } else { + log(elt, "Empty response, nothing to do here.", "DEBUG"); + } + } + + function maybeFilter(newContent, filter) { + var asQuery; + if ($vic.zepto) { + var newDoc = createDocument(newContent); + asQuery = $vic(newDoc).find('body').contents(); + } else { + asQuery = $vic($vic.parseHTML(newContent, null, true)); + } + if (filter) { + return walkTree(asQuery, filter).contents(); + } else { + return asQuery; + } + } + + function walkTree(elt, filter) { + return elt.filter(filter).add(elt.find(filter)); + } + + function fixIDs(contentToSwap) { + var fixedIDs = {}; + walkTree(contentToSwap, "[id]").each(function() { + var originalID = $vic(this).attr("id"); + var fixedID; + do { + fixedID = "v-ic-fixed-id-" + uuid(); + } while ($vic("#" + fixedID).length > 0); + fixedIDs[originalID] = fixedID; + $vic(this).attr("id", fixedID); + }); + walkTree(contentToSwap, "label[for]").each(function () { + var originalID = $vic(this).attr("for"); + $vic(this).attr("for", fixedIDs[originalID] || originalID); + }); + walkTree(contentToSwap, "*").each(function () { + $vic.each(this.attributes, function () { + if (this.value.indexOf("#") !== -1) { + this.value = this.value.replace(/#([-_A-Za-z0-9]+)/g, function(match, originalID) { + return "#" + (fixedIDs[originalID] || originalID); + }); + } + }) + }); + } + + function getStyleTarget(elt) { + var val = closestAttrValue(elt, 'v-ic-target'); + if (val && val.indexOf("this.style.") == 0) { + return val.substr(11) + } else { + return null; + } + } + + function getAttrTarget(elt) { + var val = closestAttrValue(elt, 'v-ic-target'); + if (val && val.indexOf("this.") == 0) { + return val.substr(5) + } else { + return null; + } + } + + function fireICRequest(elt, alternateHandler) { + elt = $vic(elt); + + var triggerOrigin = elt; + if (!elt.is(getICAttributeSelector('v-ic-src')) && getICAttribute(elt, 'v-ic-action') == undefined) { + elt = elt.closest(getICAttributeSelector('v-ic-src')); + } + + var confirmText = closestAttrValue(elt, 'v-ic-confirm'); + if (confirmText) { + if (!confirm(confirmText)) { + return; + } + } + + if("true" == closestAttrValue(elt, 'v-ic-disable-when-doc-hidden')) { + if(document['hidden']) { + return; + } + } + + if("true" == closestAttrValue(elt, 'v-ic-disable-when-doc-inactive')) { + if(!document.hasFocus()) { + return; + } + } + + if (elt.length > 0) { + var icEventId = uuid(); + elt.data('v-ic-event-id', icEventId); + var invokeRequest = function() { + + // if an existing request is in flight for this element, push this request as the next to be executed + if (elt.data('v-ic-request-in-flight') == true) { + elt.data('v-ic-next-request', {"req" : invokeRequest}); + return; + } + + if (elt.data('v-ic-event-id') == icEventId) { + var styleTarget = getStyleTarget(elt); + var attrTarget = styleTarget ? null : getAttrTarget(elt); + var verb = verbFor(elt); + var url = getICAttribute(elt, 'v-ic-src'); + if (url) { + var success = alternateHandler || function(data) { + if (styleTarget) { + elt.css(styleTarget, data); + } else if (attrTarget) { + elt.attr(attrTarget, data); + } else { + processICResponse(data, elt); + if (verb != 'GET') { + refreshDependencies(getICAttribute(elt, 'v-ic-src'), elt); + } + } + }; + var data = getParametersForElement(verb, elt, triggerOrigin); + if(data) { + handleRemoteRequest(elt, verb, url, data, success); + } + } + maybeInvokeLocalAction(elt, ""); + } + }; + + var triggerDelay = closestAttrValue(elt, 'v-ic-trigger-delay'); + if (triggerDelay) { + setTimeout(invokeRequest, parseInterval(triggerDelay)); + } else { + invokeRequest(); + } + } + } + + function maybeInvokeLocalAction(elt, modifier) { + var actions = getICAttribute(elt, 'ic' + modifier + '-action'); + if (actions) { + invokeLocalAction(elt, actions, modifier); + } + } + + function invokeLocalAction(elt, actions, modifier) { + var actionTargetVal = closestAttrValue(elt, 'ic' + modifier + '-action-target'); + if(actionTargetVal === null && modifier !== "") { + actionTargetVal = closestAttrValue(elt, 'v-ic-action-target'); + } + + var target = null; + if(actionTargetVal) { + target = getTargetImpl(elt, 'v-ic-action-target'); + } else { + target = getTarget(elt); + } + var actionArr = actions.split(";"); + + var actionsArr = []; + var delay = 0; + + $vic.each(actionArr, function(i, actionStr) { + var actionDef = $vic.trim(actionStr); + var action = actionDef; + var actionArgs = []; + if (actionDef.indexOf(":") > 0) { + action = actionDef.substr(0, actionDef.indexOf(":")); + actionArgs = computeArgs(actionDef.substr(actionDef.indexOf(":") + 1, actionDef.length)); + } + if (action == "") { + // ignore blanks + } else if (action == "delay") { + if (delay == null) { + delay = 0; + } + delay += parseInterval(actionArgs[0] + ""); // custom interval increase + } else { + if (delay == null) { + delay = 420; // 420ms default interval increase (400ms jQuery default + 20ms slop) + } + actionsArr.push([delay, makeApplyAction(target, action, actionArgs)]); + delay = null; + } + }); + + delay = 0; + $vic.each(actionsArr, function(i, action) { + delay += action[0]; + setTimeout(action[1], delay); + }); + } + + function computeArgs(args) { + try { + return eval("[" + args + "]") + } catch (e) { + return [$vic.trim(args)]; + } + } + + function makeApplyAction(target, action, args) { + return function() { + var func = target[action] || window[action]; + if (func) { + func.apply(target, args); + } else { + log(target, "Action " + action + " was not found", "ERROR"); + } + }; + } + + //============================================================ + // History Support + //============================================================ + + function newIntercoolerHistory(storage, history, slotLimit, historyVersion) { + + /* Constants */ + var HISTORY_SUPPORT_SLOT = 'v-ic-history-support'; + var HISTORY_SLOT_PREFIX = "v-ic-hist-elt-"; + + /* Instance Vars */ + var historySupportData = JSON.parse(storage.getItem(HISTORY_SUPPORT_SLOT)); + var _snapshot = null; + + // Reset history if the history config has changed + if (historyConfigHasChanged(historySupportData)) { + log(getTargetForHistory($vic('body')), "Intercooler History configuration changed, clearing history", "INFO"); + clearHistory(); + } + + if (historySupportData == null) { + historySupportData = { + slotLimit: slotLimit, + historyVersion: historyVersion, + lruList: [] + }; + } + + /* Instance Methods */ + function historyConfigHasChanged(historySupportData) { + return historySupportData == null || + historySupportData.slotLimit != slotLimit || + historySupportData.historyVersion != historyVersion || + historySupportData.lruList == null + } + + function clearHistory() { + var keys = []; + for (var i = 0; i < storage.length; i++) { + if (storage.key(i).indexOf(HISTORY_SLOT_PREFIX) == 0) { + keys.push(storage.key(i)); + } + } + for (var j = 0; j < keys.length; j++) { + storage.removeItem(keys[j]); + } + storage.removeItem(HISTORY_SUPPORT_SLOT); + historySupportData = { + slotLimit: slotLimit, + historyVersion: historyVersion, + lruList: [] + }; + } + + function updateLRUList(url) { + var lruList = historySupportData.lruList; + var currentIndex = lruList.indexOf(url); + var t = getTargetForHistory($vic('body')); + // found in current list, shift it to the end + if (currentIndex >= 0) { + log(t, "URL found in LRU list, moving to end", "INFO"); + lruList.splice(currentIndex, 1); + lruList.push(url); + } else { + // not found, add and shift if necessary + log(t, "URL not found in LRU list, adding", "INFO"); + lruList.push(url); + if (lruList.length > historySupportData.slotLimit) { + var urlToDelete = lruList.shift(); + log(t, "History overflow, removing local history for " + urlToDelete, "INFO"); + storage.removeItem(HISTORY_SLOT_PREFIX + urlToDelete); + } + } + + // save history metadata + storage.setItem(HISTORY_SUPPORT_SLOT, JSON.stringify(historySupportData)); + return lruList; + } + + function saveHistoryData(restorationData) { + var content = JSON.stringify(restorationData); + try { + storage.setItem(restorationData.id, content); + } catch (e) { + //quota error, nuke local cache + try { + clearHistory(); + storage.setItem(restorationData.id, content); + } catch (e) { + log(getTargetForHistory($vic('body')), "Unable to save intercooler history with entire history cleared, is something else eating " + + "local storage? History Limit:" + slotLimit, "ERROR"); + } + } + } + + function makeHistoryEntry(html, yOffset, url) { + var restorationData = { + "url": url, + "id": HISTORY_SLOT_PREFIX + url, + "content": html, + "yOffset": yOffset, + "timestamp": new Date().getTime() + }; + updateLRUList(url); + // save to the history slot + saveHistoryData(restorationData); + return restorationData; + } + + function addPopStateHandler(windowToAdd) { + if (windowToAdd.onpopstate == null || windowToAdd.onpopstate['v-ic-on-pop-state-handler'] != true) { + var currentOnPopState = windowToAdd.onpopstate; + windowToAdd.onpopstate = function(event) { + triggerEvent(getTargetForHistory($vic('body')), 'handle.onpopstate.ic'); + if (!handleHistoryNavigation(event)) { + if (currentOnPopState) { + currentOnPopState(event); + } + } + triggerEvent(getTargetForHistory($vic('body')), 'pageLoad.ic'); + }; + windowToAdd.onpopstate['v-ic-on-pop-state-handler'] = true; + } + } + + function updateHistory() { + if (_snapshot) { + pushUrl(_snapshot.newUrl, currentUrl(), _snapshot.oldHtml, _snapshot.yOffset); + _snapshot = null; + } + } + + function pushUrl(newUrl, originalUrl, originalHtml, yOffset) { + + var historyEntry = makeHistoryEntry(originalHtml, yOffset, originalUrl); + history.replaceState({"v-ic-id": historyEntry.id}, "", ""); + + var t = getTargetForHistory($vic('body')); + var restorationData = makeHistoryEntry(t.html(), window.pageYOffset, newUrl); + history.pushState({'v-ic-id': restorationData.id}, "", newUrl); + + triggerEvent(t, "pushUrl.ic", [t, restorationData]); + } + + function handleHistoryNavigation(event) { + var data = event.state; + if (data && data['v-ic-id']) { + var historyData = JSON.parse(storage.getItem(data['v-ic-id'])); + if (historyData) { + processICResponse(historyData["content"], getTargetForHistory($vic('body')), true); + if (historyData["yOffset"]) { + window.scrollTo(0, historyData["yOffset"]) + } + return true; + } else { + $vic.get(currentUrl(), {'v-ic-restore-history': true}, function(data, status) { + var newDoc = createDocument(data); + var replacementHtml = getTargetForHistory(newDoc).html(); + processICResponse(replacementHtml, getTargetForHistory($vic('body')), true); + }); + } + } + return false; + } + + function getTargetForHistory(elt) { + var explicitHistoryTarget = elt.find(getICAttributeSelector('v-ic-history-elt')); + if (explicitHistoryTarget.length > 0) { + return explicitHistoryTarget; + } else { + return elt; + } + } + + function snapshotForHistory(newUrl) { + var t = getTargetForHistory($vic('body')); + triggerEvent(t, "beforeHistorySnapshot.ic", [t]); + _snapshot = { + newUrl: newUrl, + oldHtml: t.html(), + yOffset: window.pageYOffset + }; + } + + function dumpLocalStorage() { + var str = ""; + var keys = []; + for (var x in storage) { + keys.push(x); + } + keys.sort(); + var total = 0; + for (var i in keys) { + var size = (storage[keys[i]].length * 2); + total += size; + str += keys[i] + "=" + (size / 1024 / 1024).toFixed(2) + " MB\n"; + } + return str + "\nTOTAL LOCAL STORAGE: " + (total / 1024 / 1024).toFixed(2) + " MB"; + } + + function supportData() { + return historySupportData; + } + + /* API */ + return { + clearHistory: clearHistory, + updateHistory: updateHistory, + addPopStateHandler: addPopStateHandler, + snapshotForHistory: snapshotForHistory, + _internal: { + addPopStateHandler: addPopStateHandler, + supportData: supportData, + dumpLocalStorage: dumpLocalStorage, + updateLRUList: updateLRUList + } + }; + } + + function getSlotLimit() { + return 20; + } + + function refresh(val) { + if (typeof val == 'string' || val instanceof String) { + refreshDependencies(val); + } else { + fireICRequest(val); + } + return VicIntercooler; + } + + var _history = null; + try { + _history = newIntercoolerHistory(localStorage, window.history, getSlotLimit(), .1); + } catch(e) { + log($vic('body'), "Could not initialize history", "WARN"); + } + + //============================================================ + // Local references transport + //============================================================ + + if($vic.ajaxTransport) { + $vic.ajaxTransport("text", function(options, origOptions) { + if (origOptions.url[0] == "#") { + var ltAttr = fixICAttributeName("v-ic-local-"); + var src = $vic(origOptions.url); + var rsphdr = []; + var status = 200; + var statusText = "OK"; + src.each(function(i, el) { + $vic.each(el.attributes, function(j, attr) { + if (attr.name.substr(0, ltAttr.length) == ltAttr) { + var lhName = attr.name.substring(ltAttr.length); + if (lhName == "status") { + var statusLine = attr.value.match(/(\d+)\s?(.*)/); + if (statusLine != null) { + status = statusLine[1]; + statusText = statusLine[2]; + } else { + status = "500"; + statusText = "Attribute Error"; + } + } else { + rsphdr.push(lhName + ": " + attr.value); + } + } + }); + }); + var rsp = src.length > 0 ? src.html() : ""; + return { + send: function(reqhdr, completeCallback) { + completeCallback(status, statusText, {html: rsp}, rsphdr.join("\n")); + }, + abort: function() { + } + }; + } else { + return null; + } + } + ); + + } + + //============================================================ + // Bootstrap + //============================================================ + + function init() { + var elt = $vic('body'); + processNodes(elt); + fireReadyStuff(elt); + if(_history) { + _history.addPopStateHandler(window); + } + if($vic.zepto) { + $vic('body').data('zeptoDataTest', {}); + if(typeof($vic('body').data('zeptoDataTest')) == "string") { + console.log("!!!! Please include the data module with Zepto! Intercooler requires full data support to function !!!!") + } + } + if (location.search && location.search.indexOf("v-ic-launch-debugger=true") >= 0) { + VicIntercooler.debug(); + } + } + + $vic(function() { + init(); + }); + + /* =================================================== + * API + * =================================================== */ + return { + refresh: refresh, + history: _history, + triggerRequest: fireICRequest, + processNodes: processNodes, + closestAttrValue: closestAttrValue, + verbFor: verbFor, + isDependent: isDependent, + getTarget: getTarget, + processHeaders: processHeaders, + setIsDependentFunction: function(func) { + _isDependentFunction = func; + }, + ready: function(readyHandler) { + _readyHandlers.push(readyHandler); + }, + debug: function() { + var debuggerUrl = closestAttrValue('body', 'v-ic-debugger-url') || + "https://intercoolerreleases-leaddynocom.netdna-ssl.com/intercooler-debugger.js"; + $vic.getScript(debuggerUrl) + .fail(function(jqxhr, settings, exception) { + log($vic('body'), formatError(exception), "ERROR"); + }); + }, + _internal: { + init: init, + replaceOrAddMethod: replaceOrAddMethod, + initEventSource: function(url) { + return new EventSource(url); + }, + globalEval: globalEval + } + }; +})(); \ No newline at end of file diff --git a/Bundle/CoreBundle/Resources/public/vendor/codrops-notification/css/ns-style-bar.css b/Bundle/CoreBundle/Resources/public/vendor/codrops-notification/css/ns-style-bar.css index f79462397..87526fe05 100644 --- a/Bundle/CoreBundle/Resources/public/vendor/codrops-notification/css/ns-style-bar.css +++ b/Bundle/CoreBundle/Resources/public/vendor/codrops-notification/css/ns-style-bar.css @@ -77,12 +77,12 @@ @-webkit-keyframes animScaleUp { 0% { opacity: 0; -webkit-transform: translate3d(0,-50%,0) scale3d(0,0,1); } - 100% { opacity 1; -webkit-transform: translate3d(0,-50%,0) scale3d(1,1,1); } + 100% { opacity: 1; -webkit-transform: translate3d(0,-50%,0) scale3d(1,1,1); } } @keyframes animScaleUp { 0% { opacity: 0; -webkit-transform: translate3d(0,-50%,0) scale3d(0,0,1); transform: translate3d(0,-50%,0) scale3d(0,0,1); } - 100% { opacity 1; -webkit-transform: translate3d(0,-50%,0) scale3d(1,1,1); transform: translate3d(0,-50%,0) scale3d(1,1,1); } + 100% { opacity: 1; -webkit-transform: translate3d(0,-50%,0) scale3d(1,1,1); transform: translate3d(0,-50%,0) scale3d(1,1,1); } } .vic-ns-effect-slidetop.vic-ns-show, diff --git a/Bundle/CoreBundle/Resources/public/vendor/codrops-notification/less/ns-default.less b/Bundle/CoreBundle/Resources/public/vendor/codrops-notification/less/ns-default.less index 656c02145..b5f2c1e31 100644 --- a/Bundle/CoreBundle/Resources/public/vendor/codrops-notification/less/ns-default.less +++ b/Bundle/CoreBundle/Resources/public/vendor/codrops-notification/less/ns-default.less @@ -5,7 +5,7 @@ background: rgba(42,45,50,0.85); padding: 22px; line-height: 1.4; - z-index: 1002; + z-index: 1102; pointer-events: none; color: rgba(250,251,255,0.95); font-size: 90%; diff --git a/Bundle/CoreBundle/Resources/public/vendor/codrops-notification/less/ns-style-other.less b/Bundle/CoreBundle/Resources/public/vendor/codrops-notification/less/ns-style-other.less index 65726ad62..9e9ed7289 100644 --- a/Bundle/CoreBundle/Resources/public/vendor/codrops-notification/less/ns-style-other.less +++ b/Bundle/CoreBundle/Resources/public/vendor/codrops-notification/less/ns-style-other.less @@ -1,6 +1,6 @@ .notification-shape { position: fixed; - z-index: 1000; + z-index: 1100; } .notification-shape svg { diff --git a/Bundle/CoreBundle/Resources/style/less/ugly.less b/Bundle/CoreBundle/Resources/style/less/ugly.less index 9ea79c667..a476e088e 100644 --- a/Bundle/CoreBundle/Resources/style/less/ugly.less +++ b/Bundle/CoreBundle/Resources/style/less/ugly.less @@ -1,6 +1,5 @@ @import 'parameters/parameters'; - .vic-checkbox { display: inline-block; label { @@ -36,4 +35,101 @@ bottom: 64px; left: 35px; right: 50px; -} \ No newline at end of file +} + +.vic-mt-0 { margin-top: 0; } +.vic-mt-1 { margin-top: 10px; } +.vic-mt-2 { margin-top: 20px; } +.vic-mt-3 { margin-top: 30px; } +.vic-mt-4 { margin-top: 40px; } +.vic-mt-5 { margin-top: 50px; } + +.vic-mr-0 { margin-right: 0; } +.vic-mr-1 { margin-right: 10px; } +.vic-mr-2 { margin-right: 20px; } +.vic-mr-3 { margin-right: 30px; } +.vic-mr-4 { margin-right: 40px; } +.vic-mr-5 { margin-right: 50px; } + +.vic-mb-0 { margin-bottom: 0; } +.vic-mb-1 { margin-bottom: 10px; } +.vic-mb-2 { margin-bottom: 20px; } +.vic-mb-3 { margin-bottom: 30px; } +.vic-mb-4 { margin-bottom: 40px; } +.vic-mb-5 { margin-bottom: 50px; } + +.vic-ml-0 { margin-left: 0; } +.vic-ml-1 { margin-left: 10px; } +.vic-ml-2 { margin-left: 20px; } +.vic-ml-3 { margin-left: 30px; } +.vic-ml-4 { margin-left: 40px; } +.vic-ml-5 { margin-left: 50px; } + +.vic-pt-0 { padding-top: 0; } +.vic-pt-1 { padding-top: 10px; } +.vic-pt-2 { padding-top: 20px; } +.vic-pt-3 { padding-top: 30px; } +.vic-pt-4 { padding-top: 40px; } +.vic-pt-5 { padding-top: 50px; } + +.vic-pr-0 { padding-right: 0; } +.vic-pr-1 { padding-right: 10px; } +.vic-pr-2 { padding-right: 20px; } +.vic-pr-3 { padding-right: 30px; } +.vic-pr-4 { padding-right: 40px; } +.vic-pr-5 { padding-right: 50px; } + +.vic-pb-0 { padding-bottom: 0; } +.vic-pb-1 { padding-bottom: 10px; } +.vic-pb-2 { padding-bottom: 20px; } +.vic-pb-3 { padding-bottom: 30px; } +.vic-pb-4 { padding-bottom: 40px; } +.vic-pb-5 { padding-bottom: 50px; } + +.vic-pl-0 { padding-left: 0; } +.vic-pl-1 { padding-left: 10px; } +.vic-pl-2 { padding-left: 20px; } +.vic-pl-3 { padding-left: 30px; } +.vic-pl-4 { padding-left: 40px; } +.vic-pl-5 { padding-left: 50px; } + +.vic-text-white { + color: white; +} + +.vic-float-left { + float: left; +} + +.vic-float-right { + float: right; +} + +.vic-dropdown-menu > li > a { + background-color: #333; + color: @white; +} + +@media (max-width: 992px) { + .col-sm-mt-1 { + margin-top: 10px; + } + .col-sm-mb-1 { + margin-top: 10px; + } + .col-sm-align-center { + text-align: center; + } +} + +.vic-dropdown-toggle:hover > span { + color: @green; +} + +.vic-dropdown-menu > li > a:hover, +.vic-dropdown-menu > li > a:focus, +.vic-dropdown-menu > li > a:focus > i { + color: @green; + text-decoration: none; + background-color: #333; +} diff --git a/Bundle/CoreBundle/Resources/views/Layout/layout.html.twig b/Bundle/CoreBundle/Resources/views/Layout/layout.html.twig index e5d43e1dd..f5408416c 100644 --- a/Bundle/CoreBundle/Resources/views/Layout/layout.html.twig +++ b/Bundle/CoreBundle/Resources/views/Layout/layout.html.twig @@ -25,8 +25,8 @@ {% endjavascripts %} - - + + {% endblock head_script %} {% block head_style %} @@ -60,6 +60,7 @@ {{ cms_slot_widgets('main_content') }} {% endblock body_content_main %} +
{% endblock body_content %} {% block foot_script %} diff --git a/Bundle/CoreBundle/Resources/views/Menu/admin_navbar.html.twig b/Bundle/CoreBundle/Resources/views/Menu/admin_navbar.html.twig index b0b07cf23..7e279d294 100644 --- a/Bundle/CoreBundle/Resources/views/Menu/admin_navbar.html.twig +++ b/Bundle/CoreBundle/Resources/views/Menu/admin_navbar.html.twig @@ -1,33 +1,29 @@